From 5769c4d5652e295bbcbeb72e76b370985aaab18b Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 7 May 2025 16:35:20 +0200 Subject: [PATCH] xtensa: gdbstub: fix compilation Building gdbstub for xtensa is failing currently with multiple failures like arch/xtensa/core/gdbstub.c:432:24: error: invalid operands to \ binary - (have 'int *' and 'const struct arch_esf *') 432 | if ((int *)bsa - stack > 4) { Fix them by using appropriate pointer types. Signed-off-by: Guennadi Liakhovetski --- arch/xtensa/core/gdbstub.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/arch/xtensa/core/gdbstub.c b/arch/xtensa/core/gdbstub.c index 0ebc9cc68cc..51b00ff9589 100644 --- a/arch/xtensa/core/gdbstub.c +++ b/arch/xtensa/core/gdbstub.c @@ -427,13 +427,13 @@ static void copy_to_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack) struct xtensa_register *reg; int idx, num_laddr_regs; - uint32_t *bsa = *(int **)stack; + uint32_t *bsa = *(const int **)stack; - if ((int *)bsa - stack > 4) { + if (bsa - (const uint32_t *)stack > 4) { num_laddr_regs = 8; - } else if ((int *)bsa - stack > 8) { + } else if (bsa - (const uint32_t *)stack > 8) { num_laddr_regs = 12; - } else if ((int *)bsa - stack > 12) { + } else if (bsa - (const uint32_t *)stack > 12) { num_laddr_regs = 16; } else { num_laddr_regs = 4; @@ -445,8 +445,7 @@ static void copy_to_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack) if (reg->regno == SOC_GDB_REGNO_A1) { /* A1 is calculated */ - reg->val = POINTER_TO_UINT( - ((char *)bsa) + BASE_SAVE_AREA_SIZE); + reg->val = POINTER_TO_UINT(((char *)bsa) + sizeof(_xtensa_irq_bsa_t)); reg->seqno = ctx->seqno; } else { reg->val = bsa[reg->stack_offset / 4]; @@ -518,13 +517,13 @@ static void restore_from_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack) struct xtensa_register *reg; int idx, num_laddr_regs; - _xtensa_irq_bsa_t *bsa = (void *)*(int **)stack; + _xtensa_irq_bsa_t *bsa = (void *)*(const int **)stack; - if ((int *)bsa - stack > 4) { + if ((uint32_t *)bsa - (const uint32_t *)stack > 4) { num_laddr_regs = 8; - } else if ((int *)bsa - stack > 8) { + } else if ((uint32_t *)bsa - (const uint32_t *)stack > 8) { num_laddr_regs = 12; - } else if ((int *)bsa - stack > 12) { + } else if ((uint32_t *)bsa - (const uint32_t *)stack > 12) { num_laddr_regs = 16; } else { num_laddr_regs = 4; @@ -547,7 +546,7 @@ static void restore_from_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack) /* Shouldn't be changing stack pointer */ continue; } else { - bsa[reg->stack_offset / 4] = reg->val; + ((uint32_t *)bsa)[reg->stack_offset / 4] = reg->val; } } @@ -559,7 +558,7 @@ static void restore_from_ctx(struct gdb_ctx *ctx, const struct arch_esf *stack) continue; } else if (reg->stack_offset != 0) { /* For those registers stashed in stack */ - bsa[reg->stack_offset / 4] = reg->val; + ((uint32_t *)bsa)[reg->stack_offset / 4] = reg->val; } else if (gdb_xtensa_is_special_reg(reg)) { /* * Currently not writing back any special