diff mbox series

[PATCH-for-8.0,1/2] target/arm/gdbstub: Restrict aarch64_gdb_get_pauth_reg() to CONFIG_TCG

Message ID 20230322142902.69511-2-philmd@linaro.org
State New
Headers show
Series target/arm/gdbstub: Fix builds when TCG is disabled | expand

Commit Message

Philippe Mathieu-Daudé March 22, 2023, 2:29 p.m. UTC
aarch64_gdb_get_pauth_reg() -- although disabled since commit
5787d17a42 ("target/arm: Don't advertise aarch64-pauth.xml to
gdb") is still compiled in. It calls pauth_ptr_mask() which is
located in target/arm/tcg/pauth_helper.c, a TCG specific helper.

Restrict aarch64_gdb_get_pauth_reg() to TCG to avoid a linking
error when TCG is not enabled:

  Undefined symbols for architecture arm64:
    "_pauth_ptr_mask", referenced from:
        _aarch64_gdb_get_pauth_reg in target_arm_gdbstub64.c.o
  ld: symbol(s) not found for architecture arm64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

Fixes: e995d5cce4 ("target/arm: Implement gdbstub pauth extension")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/gdbstub.c   | 3 ++-
 target/arm/gdbstub64.c | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Richard Henderson March 22, 2023, 3:15 p.m. UTC | #1
On 3/22/23 07:29, Philippe Mathieu-Daudé wrote:
> aarch64_gdb_get_pauth_reg() -- although disabled since commit
> 5787d17a42 ("target/arm: Don't advertise aarch64-pauth.xml to
> gdb") is still compiled in. It calls pauth_ptr_mask() which is
> located in target/arm/tcg/pauth_helper.c, a TCG specific helper.
> 
> Restrict aarch64_gdb_get_pauth_reg() to TCG to avoid a linking
> error when TCG is not enabled:
> 
>    Undefined symbols for architecture arm64:
>      "_pauth_ptr_mask", referenced from:
>          _aarch64_gdb_get_pauth_reg in target_arm_gdbstub64.c.o
>    ld: symbol(s) not found for architecture arm64
>    clang: error: linker command failed with exit code 1 (use -v to see invocation)

I guess we should move this function somewhere else, because KVM can certainly use pauth, 
and we do want to be able to produce nice backtraces with gdb.


r~
Philippe Mathieu-Daudé March 28, 2023, 1:34 p.m. UTC | #2
On 22/3/23 16:15, Richard Henderson wrote:
> On 3/22/23 07:29, Philippe Mathieu-Daudé wrote:
>> aarch64_gdb_get_pauth_reg() -- although disabled since commit
>> 5787d17a42 ("target/arm: Don't advertise aarch64-pauth.xml to
>> gdb") is still compiled in. It calls pauth_ptr_mask() which is
>> located in target/arm/tcg/pauth_helper.c, a TCG specific helper.
>>
>> Restrict aarch64_gdb_get_pauth_reg() to TCG to avoid a linking
>> error when TCG is not enabled:
>>
>>    Undefined symbols for architecture arm64:
>>      "_pauth_ptr_mask", referenced from:
>>          _aarch64_gdb_get_pauth_reg in target_arm_gdbstub64.c.o
>>    ld: symbol(s) not found for architecture arm64
>>    clang: error: linker command failed with exit code 1 (use -v to see 
>> invocation)
> 
> I guess we should move this function somewhere else, because KVM can 
> certainly use pauth, and we do want to be able to produce nice 
> backtraces with gdb.

I ended inlining it (along with pauth_ptr_mask_internal,
renamed as pauth_param_mask):

https://lore.kernel.org/qemu-devel/20230328133054.6553-3-philmd@linaro.org/
diff mbox series

Patch

diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
index 3bd86cee97..655369dc74 100644
--- a/target/arm/gdbstub.c
+++ b/target/arm/gdbstub.c
@@ -21,6 +21,7 @@ 
 #include "cpu.h"
 #include "exec/gdbstub.h"
 #include "gdbstub/helpers.h"
+#include "sysemu/tcg.h"
 #include "internals.h"
 #include "cpregs.h"
 
@@ -526,7 +527,7 @@  void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
          * crash if they see this XML from QEMU; disable it for the 8.0
          * release, pending a better solution.
          */
-        if (isar_feature_aa64_pauth(&cpu->isar)) {
+        if (isar_feature_aa64_pauth(&cpu->isar) && tcg_enabled()) {
             gdb_register_coprocessor(cs, aarch64_gdb_get_pauth_reg,
                                      aarch64_gdb_set_pauth_reg,
                                      4, "aarch64-pauth.xml", 0);
diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c
index ec1e07f139..3bb0923cbf 100644
--- a/target/arm/gdbstub64.c
+++ b/target/arm/gdbstub64.c
@@ -210,6 +210,8 @@  int aarch64_gdb_set_sve_reg(CPUARMState *env, uint8_t *buf, int reg)
     return 0;
 }
 
+#ifdef CONFIG_TCG
+
 int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg)
 {
     switch (reg) {
@@ -244,6 +246,8 @@  int aarch64_gdb_set_pauth_reg(CPUARMState *env, uint8_t *buf, int reg)
     return 0;
 }
 
+#endif
+
 static void output_vector_union_type(GString *s, int reg_width,
                                      const char *name)
 {