From patchwork Wed Mar 30 16:36:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 8700601 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 17081C0553 for ; Wed, 30 Mar 2016 16:37:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 76CD820225 for ; Wed, 30 Mar 2016 16:37:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B162D20220 for ; Wed, 30 Mar 2016 16:37:19 +0000 (UTC) Received: from localhost ([::1]:55757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alJ7O-0000nk-Rj for patchwork-qemu-devel@patchwork.kernel.org; Wed, 30 Mar 2016 12:37:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alJ7H-0000nf-CD for qemu-devel@nongnu.org; Wed, 30 Mar 2016 12:37:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alJ7G-0002Xc-HA for qemu-devel@nongnu.org; Wed, 30 Mar 2016 12:37:11 -0400 Received: from smtp1-g21.free.fr ([2a01:e0c:1:1599::10]:44544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alJ7G-0002XQ-BV; Wed, 30 Mar 2016 12:37:10 -0400 Received: from Quad.localdomain (unknown [IPv6:2a01:e34:eeee:5240:12c3:7bff:fe6b:9a76]) by smtp1-g21.free.fr (Postfix) with ESMTPS id 2286A9401CF; Wed, 30 Mar 2016 18:33:02 +0200 (CEST) From: Laurent Vivier To: Riku Voipio Date: Wed, 30 Mar 2016 18:36:51 +0200 Message-Id: <1459355811-31155-1-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.5.0 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 2a01:e0c:1:1599::10 Cc: Laurent Vivier , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Alexander Graf Subject: [Qemu-devel] [PATCH] linux-user,target-ppc: fix use of MSR_LE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Thomas Huth --- 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;