From patchwork Thu Jul 5 22:26:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev\" via" X-Patchwork-Id: 10510399 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 62F096028F for ; Thu, 5 Jul 2018 22:27:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA08120748 for ; Thu, 5 Jul 2018 22:27:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBA8D20856; Thu, 5 Jul 2018 22:27:18 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 7A5E620748 for ; Thu, 5 Jul 2018 22:27:18 +0000 (UTC) Received: from localhost ([::1]:55038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbCib-00022G-BP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Jul 2018 18:27:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbChz-0001j8-7A for qemu-devel@nongnu.org; Thu, 05 Jul 2018 18:26:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbChv-0001fa-Sh for qemu-devel@nongnu.org; Thu, 05 Jul 2018 18:26:39 -0400 Received: from smtp57.i.mail.ru ([217.69.128.37]:54132) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fbChv-0001ax-KX for qemu-devel@nongnu.org; Thu, 05 Jul 2018 18:26:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=RpfKInGG7i5DppSOncCn+s2OssNVfbb+degcZv2OuP0=; b=YZnaGfhI6plL/AmxALlvV8OgOnSsRsefaGErYxs8WzOhhYOfFWneiXtdPAGJc4uLJrxlUmN0APXKZhD/2B94xBhAOzerpj1YUbsjTn0VmHRWz9rbG9Io9jyc1TRJ9xGCn2wYMDhkwMbR80PBN+b/KuHchiXGsGn3Eo9BjAzMJ6Y=; Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1fbChs-0006RJ-1h; Fri, 06 Jul 2018 01:26:32 +0300 To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 01:26:22 +0300 Message-Id: <20180705222622.17139-1-jusual@mail.ru> X-Mailer: git-send-email 2.17.1 Authentication-Results: smtp57.i.mail.ru; auth=pass smtp.auth=jusual@mail.ru smtp.mailfrom=jusual@mail.ru X-7FA49CB5: 0D63561A33F958A5A15DAAFB3829AC31B66762F6C3410D93DDF24A0ACFE5168B0A6AB1C7CE11FEE35EF3C447179F0106BA3038C0950A5D36B5C8C57E37DE458B4C7702A67D5C33162DBA43225CD8A89F9FFED5BD9FB41755B287D9020BFCF125043C0C66DECA6D5443847C11F186F3C5E7DDDDC251EA7DABCC89B49CDF41148FFC2B27DE93B9EBF03B503F486389A921A5CC5B56E945C8DA X-Mailru-Sender: 7766D515518070DE138AAC7428EA760D8449059D152FE2744049CD14C760FCF5A8D17387A81429A57C4160E8B47E48163DDE9B364B0DF2898CB68AF7A628805D594FB4C9F0DBF412AE208404248635DF X-Mras: OK X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 217.69.128.37 Subject: [Qemu-devel] [PATCH v2] target/arm: Forbid unprivileged mode for M Baseline 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: , X-Patchwork-Original-From: Julia Suvorova via Qemu-devel From: "Denis V. Lunev\" via" Reply-To: Julia Suvorova Cc: Peter Maydell , Jim Mussared , =?UTF-8?q?Steffen=20G=C3=B6rtz?= , Joel Stanley , Stefan Hajnoczi , Julia Suvorova Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP MSR handling is the only place where CONTROL.nPRIV is modified. Signed-off-by: Julia Suvorova Reviewed-by: Peter Maydell --- v2: * Add the check in the CONTROL_NS case target/arm/helper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 5ee229eb35..2343aa5069 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10686,8 +10686,10 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) write_v7m_control_spsel_for_secstate(env, val & R_V7M_CONTROL_SPSEL_MASK, M_REG_NS); - env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK; - env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK; + if (arm_feature(env, ARM_FEATURE_M_MAIN)) { + env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK; + env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK; + } return; case 0x98: /* SP_NS */ { @@ -10781,8 +10783,10 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) !arm_v7m_is_handler_mode(env)) { write_v7m_control_spsel(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0); } - env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK; - env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK; + if (arm_feature(env, ARM_FEATURE_M_MAIN)) { + env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK; + env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK; + } break; default: bad_reg: