From: Thomas Huth <huth@tuxfamily.org>
To: Laurent Vivier <laurent@vivier.eu>, Riku Voipio <riku.voipio@iki.fi>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH] linux-user,target-ppc: fix use of MSR_LE
Date: Thu, 31 Mar 2016 11:48:09 +0200 [thread overview]
Message-ID: <56FCF259.5000301@tuxfamily.org> (raw)
In-Reply-To: <1459355811-31155-1-git-send-email-laurent@vivier.eu>
On 30.03.2016 18:36, Laurent Vivier wrote:
> setup_frame()/setup_rt_frame()/restore_user_regs() are using
> MSR_LE as the similar kernel functions do: as a bitmask.
>
> But in QEMU, MSR_LE is a bit position, so change this
> accordingly.
>
> The previous code was doing nothing as MSR_LE is 0,
> and "env->msr &= ~MSR_LE" doesn't change the value of msr.
>
> And yes, a user process can change its endianness,
> see linux kernel commit:
>
> fab5db9 [PATCH] powerpc: Implement support for setting little-endian mode via prctl
>
> and prctl(2): PR_SET_ENDIAN, PR_GET_ENDIAN
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> linux-user/signal.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/linux-user/signal.c b/linux-user/signal.c
> index a233bab..f1b597b 100644
> --- a/linux-user/signal.c
> +++ b/linux-user/signal.c
> @@ -4588,7 +4588,7 @@ static void restore_user_regs(CPUPPCState *env,
>
> /* If doing signal return, restore the previous little-endian mode. */
> if (sig)
> - env->msr = (env->msr & ~MSR_LE) | (msr & MSR_LE);
> + env->msr = (env->msr & ~(1ull << MSR_LE)) | (msr & (1ull << MSR_LE));
>
> /* Restore Altivec registers if necessary. */
> if (env->insns_flags & PPC_ALTIVEC) {
> @@ -4703,7 +4703,7 @@ static void setup_frame(int sig, struct target_sigaction *ka,
> #endif
>
> /* Signal handlers are entered in big-endian mode. */
> - env->msr &= ~MSR_LE;
> + env->msr &= ~(1ull << MSR_LE);
>
> unlock_user_struct(frame, frame_addr, 1);
> return;
> @@ -4798,7 +4798,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka,
> #endif
>
> /* Signal handlers are entered in big-endian mode. */
> - env->msr &= ~MSR_LE;
> + env->msr &= ~(1ull << MSR_LE);
>
> unlock_user_struct(rt_sf, rt_sf_addr, 1);
> return;
>
Reviewed-by: Thomas Huth <huth@tuxfamily.org>
prev parent reply other threads:[~2016-03-31 9:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 16:36 [Qemu-devel] [PATCH] linux-user,target-ppc: fix use of MSR_LE Laurent Vivier
2016-03-31 9:48 ` Thomas Huth [this message]
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=56FCF259.5000301@tuxfamily.org \
--to=huth@tuxfamily.org \
--cc=agraf@suse.de \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).