From patchwork Fri May 27 13:00:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9138413 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 2639160467 for ; Fri, 27 May 2016 13:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 181CD27CCD for ; Fri, 27 May 2016 13:49:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D02428159; Fri, 27 May 2016 13:49:35 +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 16D1F27CCD for ; Fri, 27 May 2016 13:49:32 +0000 (UTC) Received: from localhost ([::1]:45953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6I8p-0003yN-G5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 09:49:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HOH-00080Y-W4 for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HOD-0001OE-6k for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:25 -0400 Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]:33390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HOC-0001O7-Up for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:21 -0400 Received: by mail-lf0-x230.google.com with SMTP id s64so21627128lfe.0 for ; Fri, 27 May 2016 06:01:20 -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=Qy9yeqOR+bw8l3t7/5rJGHy3+mvD4iqQjKsmTVGlpgIxAoYMBnNkmefAI+zQhVk8V1 Hl/Zc6/EzSZJiPB3MnYsIJpkiUPKU12FpkHK0Z7AlaZQzulVeMCp0qx/KtyP5gc9aK0t lSMuAQU8Ns1UjU1Q3+I2s2kq5UHA5V0RFE+5w= 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=goFkeeRm9cCsZhBWmQVLn47YpjRw+Lh0awq+oUhEv3xbl64RTv7DPyn2MtRztzINO2 thgrPHVIFzUK6ftYghruHysGMyMGCwgwlgXuUqrUK/B6bKuWY9a31d1QtSJx88o0Jtbl zrdAnmkSOjWt0JGF4fHqYu9H/7mBk9q6UC9czknJFcjrw6IrLYv/O9HsfoCdUsrQXxA0 Znn8xZZSf6CpQ2FaAYlwB01JkG+nDsFAe5PeHfebwbR5uUCus72ots0rEiYkCTanZtz9 Z6FrLaOF5fzKUevYakV9vPaqyEfqoupQddBnMbn0RrfPBS4fNHsaIuJCNOI8O7PDO7jm 2xig== X-Gm-Message-State: ALyK8tJc7bev/O3fcNuFu0bL88tuQXk7nF9bYuO6St/xmbu891i1X/y5NSs9u9USEkf1Ofj/ X-Received: by 10.25.144.70 with SMTP id s67mr4544714lfd.163.1464354080111; Fri, 27 May 2016 06:01:20 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id n16sm2281066lfg.31.2016.05.27.06.01.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:01:19 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:29 +0300 Message-Id: <49e55cbacf4ad08f831b9f3f9cb0f3082883a3a1.1464353863.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::230 Subject: [Qemu-devel] [PULL v2 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;