From d00095c4a6b5c0c139c9b76878f181918db4d1c1 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Fri, 16 May 2025 10:08:06 -0700 Subject: [PATCH] xtensa: fix num_high_regs calculation when dumping stack The calculation of number of high registers is not entirely correct. We need to get past the pointer to BSA in the stack frame before reaching the high registers. The location address difference between the BSA and start of high registers then can be used to calculate how many high registers in the stack frame. So correct the start location of high registers in the calculation as it was incorrect before. Though the result would be the same as further divisions would mask this error. However, it is better to correct this for readability. Signed-off-by: Daniel Leung --- arch/xtensa/core/vector_handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/xtensa/core/vector_handlers.c b/arch/xtensa/core/vector_handlers.c index fa58b9c2133..520b1cd0d50 100644 --- a/arch/xtensa/core/vector_handlers.c +++ b/arch/xtensa/core/vector_handlers.c @@ -153,7 +153,7 @@ void xtensa_dump_stack(const void *stack) bsa = frame->ptr_to_bsa; /* Calculate number of high registers. */ - num_high_regs = (uint8_t *)bsa - (uint8_t *)frame + sizeof(void *); + num_high_regs = (uint8_t *)bsa - ((uint8_t *)frame + sizeof(void *)); num_high_regs /= sizeof(uintptr_t); /* And high registers are always comes in 4 in a block. */