Modifications to fix PowerPC on 64bit host, bug 1052857
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
@@ -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
Quoted 5 lines · Samuel Seay
Removed
h2g()macro around theka->_sa_handlerdue to the_sa_handlerbeing a guest memory address
Changed the__put_usertoput_useras it was attempting to put a value at the stack address but the new address is a guest memory address,__put_useris for host memory addresses. Patch v2 -> v3, removed unneeded casting in theput_usercall left over from__put_userSigned-off-by Samuel Seay <[email protected]>
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@@ -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
Peter Maydell
Reviewed-byQuoted 10 lines · Alexander Graf
Quoted 5 lines · Samuel Seay
Removed
h2g()macro around theka->_sa_handlerdue to the_sa_handlerbeing a guest memory address
Changed the__put_usertoput_useras it was attempting to put a value at the stack address but the new address is a guest memory address,__put_useris for host memory addresses. Patch v2 -> v3, removed unneeded casting in theput_usercall left over from__put_userSigned-off-by Samuel Seay <[email protected]>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
Alexander Graf
AppliedQuoted 8 lines · Peter Maydell
Quoted 7 lines · Alexander Graf
Quoted 4 lines · Samuel Seay
Removed
h2g()macro around theka->_sa_handlerdue to the_sa_handlerbeing a guest memory address
Changed the__put_usertoput_useras it was attempting to put a value at the stack address but the new address is a guest memory address,__put_useris for host memory addresses. Patch v2 -> v3, removed unneeded casting in theput_usercall left over from__put_user
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Samuel Seay <[email protected]>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:
Reviewed-by Peter Maydell <[email protected]>
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
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:
Reviewed-by Peter Maydell <[email protected]>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