[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 06/52] linux-user: Properly Dereference PPC64 ELFv1 Sig
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PULL 06/52] linux-user: Properly Dereference PPC64 ELFv1 Signal Handler Pointer |
Date: |
Thu, 4 Sep 2014 19:19:54 +0200 |
From: Tom Musta <address@hidden>
Properly dereference 64-bit PPC ELF V1 ABIT function pointers to signal
handlers.
On this platform, function pointers are pointers to structures and the first 64
bits of such a structure contains the function's entry point. The second 64
bits
contains the TOC pointer, which must be placed into GPR 2.
Signed-off-by: Tom Musta <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
linux-user/signal.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 6f77d4d..48c5f1c 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -4483,6 +4483,15 @@ struct target_rt_sigframe {
#endif
+#if defined(TARGET_PPC64)
+
+struct target_func_ptr {
+ target_ulong entry;
+ target_ulong toc;
+};
+
+#endif
+
/* We use the mc_pad field for the signal return trampoline. */
#define tramp mc_pad
@@ -4714,7 +4723,17 @@ static void setup_frame(int sig, struct target_sigaction
*ka,
env->gpr[1] = newsp;
env->gpr[3] = signal;
env->gpr[4] = frame_addr + offsetof(struct target_sigframe, sctx);
+
+#if defined(TARGET_PPC64)
+ /* PPC64 function pointers are pointers to OPD entries. */
+ struct target_func_ptr *handler =
+ (struct target_func_ptr *)g2h(ka->_sa_handler);
+ env->nip = tswapl(handler->entry);
+ env->gpr[2] = tswapl(handler->toc);
+#else
env->nip = (target_ulong) ka->_sa_handler;
+#endif
+
/* Signal handlers are entered in big-endian mode. */
env->msr &= ~MSR_LE;
@@ -4793,7 +4812,17 @@ static void setup_rt_frame(int sig, struct
target_sigaction *ka,
env->gpr[4] = (target_ulong) h2g(&rt_sf->info);
env->gpr[5] = (target_ulong) h2g(&rt_sf->uc);
env->gpr[6] = (target_ulong) h2g(rt_sf);
+
+#if defined(TARGET_PPC64)
+ /* PPC64 function pointers are pointers to OPD entries. */
+ struct target_func_ptr *handler =
+ (struct target_func_ptr *)g2h(ka->_sa_handler);
+ env->nip = tswapl(handler->entry);
+ env->gpr[2] = tswapl(handler->toc);
+#else
env->nip = (target_ulong) ka->_sa_handler;
+#endif
+
/* Signal handlers are entered in big-endian mode. */
env->msr &= ~MSR_LE;
--
1.8.1.4
- [Qemu-ppc] [PULL 16/52] spapr: Split memory nodes to power-of-two blocks, (continued)
- [Qemu-ppc] [PULL 16/52] spapr: Split memory nodes to power-of-two blocks, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 01/52] PPC: KVM: Fix g3beige and mac99 when HV is loaded, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 18/52] spapr: Fix ibm, associativity for memory nodes, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 10/52] spapr: add uuid/host details to device tree, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 14/52] spapr: Use DT memory node rendering helper for other nodes, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 02/52] ppc: spapr-rtas - implement os-term rtas call, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 19/52] loader: Add load_image_size() to replace load_image(), Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 21/52] ppc: debug stub: Get trap instruction opcode from KVM, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 23/52] ppc: Add software breakpoint support, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 05/52] linux-user: Enable Signal Handlers on PPC64, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 06/52] linux-user: Properly Dereference PPC64 ELFv1 Signal Handler Pointer,
Alexander Graf <=
- [Qemu-ppc] [PULL 20/52] spapr: Locate RTAS and device-tree based on real RMA, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 22/52] ppc: synchronize excp_vectors for injecting exception, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 11/52] PPC: mac99: Move NVRAM to page boundary when necessary, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 27/52] target-ppc: Bug Fix: rlwnm, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 24/52] ppc: Add hw breakpoint watchpoint support, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 26/52] target-ppc: Bug Fix: rlwinm, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 33/52] target-ppc: Bug Fix: srad, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 25/52] ppc/spapr: Fix MAX_CPUS to 255, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 30/52] target-ppc: Bug Fix: mullw, Alexander Graf, 2014/09/04
- [Qemu-ppc] [PULL 37/52] PPC: mac_nvram: Remove unused functions, Alexander Graf, 2014/09/04