From patchwork Wed May 25 10:32:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9135147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EBC866075C for ; Wed, 25 May 2016 10:57:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF8A728110 for ; Wed, 25 May 2016 10:57:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4892282A2; Wed, 25 May 2016 10:57:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 1642928164 for ; Wed, 25 May 2016 10:57:59 +0000 (UTC) Received: from localhost ([::1]:58919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WVi-0007SV-6K for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 06:57:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7W-0001cc-TW for qemu-devel@nongnu.org; Wed, 25 May 2016 06:33:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W7O-0003Wt-8C for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:58 -0400 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]:33015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7N-0003WS-Ve for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:50 -0400 Received: by mail-lf0-x232.google.com with SMTP id e131so16314687lfb.0 for ; Wed, 25 May 2016 03:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j30J5dGnL4ch0X+ATOE+ZxOU9oCteuBwW8WZNCSbhVU=; b=FeNskHcRDXxRe6MQGqITx0F49p8AxeaGXXMZxnPjsouQ2JdUDo66WbB7pcYNjXi5GS GQ5T2q27JyoF9QSzKAWwk0elLQwq/2UbUMrso8s9QZVuafw9mlwQBIgPoxcCdszzrBg8 UDJlD41J+uqa6u02eKV5YA/tlJgvAkR6vX1LY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j30J5dGnL4ch0X+ATOE+ZxOU9oCteuBwW8WZNCSbhVU=; b=FPemfkO0w11e3rn+Z8XgsbjhCoBThmTVWWXgRXc2o/PR/La8vGHzwyDA2ukAfw6erF YckRc69bOjN2h+Fmve/7s3v1jfI98RCgm6+Xy5g9j+0YFkYDDk6XZXDKFDZn4Womkp0f zu3oypfuEc/ixoFmtGJouWXG0NWmfpNQb8DdiDiBIvKk7ip3I1LrbjDnsnMELtFINQ1J 22f9rJ9GQuD1Fj9C+57xkWIBiv5WxCHZjXf5dinq0G2e2PmPW8+OuxWuaoOSdcOa5u8I J+ipgQ/yMCwT1+vm84kCr/1k/ZXSsQcmsyyFNDJ0IkSwtBadg6DfZAKJJcMBIAnYIOzh xzuA== X-Gm-Message-State: ALyK8tL01cWoAbrGpkiimnwXi83CvH23/N+PB4BIqYaMJ2EIvvvDcs4NszGYaXdo83sxM3Cs X-Received: by 10.25.146.6 with SMTP id u6mr743702lfd.60.1464172369255; Wed, 25 May 2016 03:32:49 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id o75sm1379610lfi.9.2016.05.25.03.32.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:48 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:32:10 +0300 Message-Id: <210a7201d1bd9e25eec01d23edb713f181eabb23.1464153942.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::232 Subject: [Qemu-devel] [PULL 38/38] linux-user, target-ppc: fix use of MSR_LE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Vivier 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 Reviewed-by: Thomas Huth Signed-off-by: Laurent Vivier Signed-off-by: Riku Voipio --- 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 28ce921..8090b4d 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -4632,7 +4632,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) { @@ -4747,7 +4747,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; @@ -4842,7 +4842,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;