Skip to contentSkip to conversation

linux-user: Fix fault address truncation AArch64

PATCH In review [email protected] 3 participants 3 messages Oct 23, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Fix fault address truncation AArch64

From: Riku Voipio <[email protected]>

On AArch64 the si_addr field of siginfo_t is truncated to 32 bits because the fault address passes through an uint32_t variable. This is fixed by changing the variable to uint64_t.

v2 by Riku - follow Peters suggestion and drop the addr variable since its only used once in the Aarch64 loop.

---
 linux-user/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
linux-user/main.c +1 -3
index 5887022..5c14c1e 100644
@@ -1006,7 +1006,6 @@ void cpu_loop(CPUARMState *env)
     CPUState *cs = CPU(arm_env_get_cpu(env));
     int trapnr, sig;
     target_siginfo_t info;
-    uint32_t addr;
 
     for (;;) {
         cpu_exec_start(cs);
@@ -1042,12 +1041,11 @@ void cpu_loop(CPUARMState *env)
             /* fall through for segv */
         case EXCP_PREFETCH_ABORT:
         case EXCP_DATA_ABORT:
-            addr = env->exception.vaddress;
             info.si_signo = SIGSEGV;
             info.si_errno = 0;
             /* XXX: check env->error_code */
             info.si_code = TARGET_SEGV_MAPERR;
-            info._sifields._sigfault._addr = addr;
+            info._sifields._sigfault._addr = env->exception.vaddress;
             queue_signal(env, info.si_signo, &info);
             break;
         case EXCP_DEBUG:
Signature · 1 line
2.1.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On 23 October 2014 12:55, <[email protected]> wrote:

From: Riku Voipio <[email protected]>

On AArch64 the si_addr field of siginfo_t is truncated to 32 bits because the fault address passes through an uint32_t variable. This is fixed by changing the variable to uint64_t.

v2 by Riku - follow Peters suggestion and drop the addr variable since its only used once in the Aarch64 loop.

Ah, I was just wondering this morning whether I ought to do a version of this patch, so you've saved me the effort :-)

(You might want to put the notes about v2 below the '---'.)

thanks
-- PMM

#2 lore raw
Quoted 13 lines · Peter Maydell
Quoted 11 lines · On 23 October 2014 12:55, <[email protected]> wrote:

From: Riku Voipio <[email protected]>

On AArch64 the si_addr field of siginfo_t is truncated to 32 bits because the fault address passes through an uint32_t variable. This is fixed by changing the variable to uint64_t.

v2 by Riku - follow Peters suggestion and drop the addr variable since its only used once in the Aarch64 loop.

Quoted 6 lines

Ah, I was just wondering this morning whether I ought to do a version of this patch, so you've saved me the effort :-)

(You might want to put the notes about v2 below the '---'.)

If you do that, please just modify the entire patch description. I.e. don't talk about the type of a variable that doesn't exist.

r~