All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Weiser <michael.weiser@gmx.de>
To: qemu-devel@nongnu.org
Cc: Michael Weiser <michael.weiser@gmx.de>,
	Riku Voipio <riku.voipio@iki.fi>,
	Laurent Vivier <laurent@vivier.eu>
Subject: [Qemu-devel] [PATCH v2 3/5] linux-user: Fix endianess of aarch64 signal trampoline
Date: Tue, 19 Dec 2017 21:16:11 +0100	[thread overview]
Message-ID: <20171219201613.7399-4-michael.weiser@gmx.de> (raw)
In-Reply-To: <20171219201613.7399-1-michael.weiser@gmx.de>

Since for aarch64 the signal trampoline is synthesized directly into the
signal frame we need to make sure the instructions end up little-endian.
Otherwise the wrong endianness will cause a SIGILL upon return from the
signal handler on big-endian targets.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
---
 linux-user/signal.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index dae14d4a89..81b7fbeb1e 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -1599,9 +1599,13 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
     if (ka->sa_flags & TARGET_SA_RESTORER) {
         return_addr = ka->sa_restorer;
     } else {
-        /* mov x8,#__NR_rt_sigreturn; svc #0 */
-        __put_user(0xd2801168, &frame->tramp[0]);
-        __put_user(0xd4000001, &frame->tramp[1]);
+        /*
+         * mov x8,#__NR_rt_sigreturn; svc #0
+         * Since these are instructions they need to be put as little-endian
+         * regardless of target default or current CPU endianness.
+         */
+        __put_user_e(0xd2801168, &frame->tramp[0], le);
+        __put_user_e(0xd4000001, &frame->tramp[1], le);
         return_addr = frame_addr + offsetof(struct target_rt_sigframe, tramp);
     }
     env->xregs[0] = usig;
-- 
2.15.1

  parent reply	other threads:[~2017-12-19 20:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-19 20:16 [Qemu-devel] [PATCH v2 0/5] Add aarch64_be-linux-user target Michael Weiser
2017-12-19 20:16 ` [Qemu-devel] [PATCH v2 1/5] linux-user: Add support for big-endian aarch64 Michael Weiser
2017-12-19 20:16 ` [Qemu-devel] [PATCH v2 2/5] linux-user: Add separate aarch64_be uname Michael Weiser
2017-12-20 15:20   ` Laurent Vivier
2017-12-20 15:36     ` Peter Maydell
2017-12-20 15:51       ` Laurent Vivier
2017-12-20 16:01       ` Michael Weiser
2017-12-19 20:16 ` Michael Weiser [this message]
2017-12-19 20:16 ` [Qemu-devel] [PATCH v2 4/5] configure: Add aarch64_be-linux-user target Michael Weiser
2017-12-20 14:55   ` Laurent Vivier
2017-12-20 15:51     ` Michael Weiser
2017-12-19 20:16 ` [Qemu-devel] [PATCH v2 5/5] linux-user: Add aarch64_be magic numbers to qemu-binfmt-conf.sh Michael Weiser
2017-12-20 14:18   ` Laurent Vivier
2017-12-20 15:37     ` Michael Weiser
2017-12-20 15:56       ` Laurent Vivier
2017-12-20 16:15         ` Michael Weiser
2017-12-20 16:43           ` Laurent Vivier
2017-12-20 20:29             ` Michael Weiser
2017-12-19 20:45 ` [Qemu-devel] [PATCH v2 0/5] Add aarch64_be-linux-user target no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171219201613.7399-4-michael.weiser@gmx.de \
    --to=michael.weiser@gmx.de \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.