summaryrefslogtreecommitdiffstats
path: root/linux-user/ppc/signal.c
diff options
context:
space:
mode:
authorPeter Maydell2018-07-23 15:03:14 +0200
committerPeter Maydell2018-07-23 15:03:14 +0200
commit55b1f14cefcb19ce6d5e28c4c83404230888aa7e (patch)
treec4e9b01139251216e9918db89453831b38e9c1cf /linux-user/ppc/signal.c
parentpo: Don't include comments with location (diff)
parentlinux-user/ppc: Implement swapcontext syscall (diff)
downloadqemu-55b1f14cefcb19ce6d5e28c4c83404230888aa7e.tar.gz
qemu-55b1f14cefcb19ce6d5e28c4c83404230888aa7e.tar.xz
qemu-55b1f14cefcb19ce6d5e28c4c83404230888aa7e.zip
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.0-pull-request' into staging
Some ppc/ppc64 fixes: - we can run now most of the targets on a ppc64 host with 64kB pages - add swapcontext syscall to run tests/test-coroutine in debian-powerpc-user-cross # gpg: Signature made Mon 23 Jul 2018 13:55:57 BST # gpg: using RSA key F30C38BD3F2FBE3C # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" # gpg: aka "Laurent Vivier <laurent@vivier.eu>" # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * remotes/vivier2/tags/linux-user-for-3.0-pull-request: linux-user/ppc: Implement swapcontext syscall linux-user: fix ELF load alignment error Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'linux-user/ppc/signal.c')
-rw-r--r--linux-user/ppc/signal.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c
index ef4c518f11..2ae120a2bc 100644
--- a/linux-user/ppc/signal.c
+++ b/linux-user/ppc/signal.c
@@ -675,3 +675,59 @@ sigsegv:
force_sig(TARGET_SIGSEGV);
return -TARGET_QEMU_ESIGRETURN;
}
+
+/* This syscall implements {get,set,swap}context for userland. */
+abi_long do_swapcontext(CPUArchState *env, abi_ulong uold_ctx,
+ abi_ulong unew_ctx, abi_long ctx_size)
+{
+ struct target_ucontext *uctx;
+ struct target_mcontext *mctx;
+
+ /* For ppc32, ctx_size is "reserved for future use".
+ * For ppc64, we do not yet support the VSX extension.
+ */
+ if (ctx_size < sizeof(struct target_ucontext)) {
+ return -TARGET_EINVAL;
+ }
+
+ if (uold_ctx) {
+ TaskState *ts = (TaskState *)thread_cpu->opaque;
+
+ if (!lock_user_struct(VERIFY_WRITE, uctx, uold_ctx, 1)) {
+ return -TARGET_EFAULT;
+ }
+
+#ifdef TARGET_PPC64
+ mctx = &uctx->tuc_sigcontext.mcontext;
+#else
+ /* ??? The kernel aligns the pointer down here into padding, but
+ * in setup_rt_frame we don't. Be self-compatible for now.
+ */
+ mctx = &uctx->tuc_mcontext;
+ __put_user(h2g(mctx), &uctx->tuc_regs);
+#endif
+
+ save_user_regs(env, mctx);
+ host_to_target_sigset(&uctx->tuc_sigmask, &ts->signal_mask);
+
+ unlock_user_struct(uctx, uold_ctx, 1);
+ }
+
+ if (unew_ctx) {
+ int err;
+
+ if (!lock_user_struct(VERIFY_READ, uctx, unew_ctx, 1)) {
+ return -TARGET_EFAULT;
+ }
+ err = do_setcontext(uctx, env, 0);
+ unlock_user_struct(uctx, unew_ctx, 1);
+
+ if (err) {
+ /* We cannot return to a partially updated context. */
+ force_sig(TARGET_SIGSEGV);
+ }
+ return -TARGET_QEMU_ESIGRETURN;
+ }
+
+ return 0;
+}