Skip to contentSkip to conversation

Modifications to fix PowerPC on 64bit host, bug 1052857

PATCH Applied Samuel Seay 3 participants 5 messages Jan 2, 2013 – Jan 3, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Modifications to fix PowerPC on 64bit host, bug 1052857

Removed h2g() macro around the ka->_sa_handler due to the _sa_handler being a guest memory address
Changed the __put_user to put_user as it was attempting to put a value at the stack address but the new address is a guest memory address, __put_user is for host memory addresses. Patch v2 -> v3, removed unneeded casting in the put_user call left over from __put_user

---
 linux-user/signal.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/signal.c +2 -2
index 95e2ffa..c43b8ac 100644
@@ -4584,7 +4584,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
 
     signal = current_exec_domain_sig(sig);
 
-    err |= __put_user(h2g(ka->_sa_handler), &sc->handler);
+    err |= __put_user(ka->_sa_handler, &sc->handler);
     err |= __put_user(set->sig[0], &sc->oldmask);
 #if defined(TARGET_PPC64)
     err |= __put_user(set->sig[0] >> 32, &sc->_unused[3]);
@@ -4606,7 +4606,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
 
     /* Create a stack frame for the caller of the handler.  */
     newsp = frame_addr - SIGNAL_FRAMESIZE;
-    err |= __put_user(env->gpr[1], (target_ulong *)(uintptr_t) newsp);
+    err |= put_user(env->gpr[1], newsp, target_ulong);
 
     if (err)
         goto sigsegv;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 5 lines · Samuel Seay

Removed h2g() macro around the ka->_sa_handler due to the _sa_handler being a guest memory address
Changed the __put_user to put_user as it was attempting to put a value at the stack address but the new address is a guest memory address, __put_user is for host memory addresses. Patch v2 -> v3, removed unneeded casting in the put_user call left over from __put_user

Looks reasonable to me, but I'd like an ack from Peter.

Alex

Quoted 30 lines

---
linux-user/signal.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/signal.c +2 -2
index 95e2ffa..c43b8ac 100644
@@ -4584,7 +4584,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
 
    signal = current_exec_domain_sig(sig);
 
-    err |= __put_user(h2g(ka->_sa_handler), &sc->handler);
+    err |= __put_user(ka->_sa_handler, &sc->handler);
    err |= __put_user(set->sig[0], &sc->oldmask);
 #if defined(TARGET_PPC64)
    err |= __put_user(set->sig[0] >> 32, &sc->_unused[3]);
@@ -4606,7 +4606,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
 
    /* Create a stack frame for the caller of the handler.  */
    newsp = frame_addr - SIGNAL_FRAMESIZE;
-    err |= __put_user(env->gpr[1], (target_ulong *)(uintptr_t) newsp);
+    err |= put_user(env->gpr[1], newsp, target_ulong);
 
    if (err)
        goto sigsegv;
Signature · 1 line
1.7.9.5
Reviewed-by
#2 lore raw
Quoted 10 lines · Alexander Graf
Quoted 5 lines · Samuel Seay

Removed h2g() macro around the ka->_sa_handler due to the _sa_handler being a guest memory address
Changed the __put_user to put_user as it was attempting to put a value at the stack address but the new address is a guest memory address, __put_user is for host memory addresses. Patch v2 -> v3, removed unneeded casting in the put_user call left over from __put_user

Looks reasonable to me, but I'd like an ack from Peter.

Untested, and I haven't looked up the PPC ABI to check that the function is overall doing the right thing, but with those caveats:

-- PMM

#3 lore raw
Quoted 8 lines · Peter Maydell
Quoted 7 lines · Alexander Graf
Quoted 4 lines · Samuel Seay

Removed h2g() macro around the ka->_sa_handler due to the _sa_handler being a guest memory address
Changed the __put_user to put_user as it was attempting to put a value at the stack address but the new address is a guest memory address, __put_user is for host memory addresses. Patch v2 -> v3, removed unneeded casting in the put_user call left over from __put_user

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Looks reasonable to me, but I'd like an ack from Peter.

Untested, and I haven't looked up the PPC ABI to check that the function is overall doing the right thing, but with those caveats:

Considering the state it was in before, I'd say applying the patch is an improvement regardless on how broken any code around it might be :).

Applied to ppc-next.

Alex

#4 lore raw
Quoted 8 lines · Alexander Graf
Quoted 3 lines · Peter Maydell

Untested, and I haven't looked up the PPC ABI to check that the function is overall doing the right thing, but with those caveats:

Considering the state it was in before, I'd say applying the patch is an improvement regardless on how broken any code around it might be :).

Forgot, this patch doesn't address the other issue I mentioned, where

    env->gpr[4] = (target_ulong) h2g(sc);

is passing the guest a pointer to potentially about to be freed memory and should be doing something like
env->gpr[4] = frame_addr + offsetof(struct target_sigframe, sctx);
instead.

-- PMM