From patchwork Sat Feb 8 12:58:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 183225 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp1948773ile; Sat, 8 Feb 2020 05:03:48 -0800 (PST) X-Google-Smtp-Source: APXvYqwN9Dn1DVVqg8Ugl/0q9GjWVj25Bgba1IkMWGbIfuM3mey9uiMnYMjSNbt6baJNth0UeIcw X-Received: by 2002:ad4:40cb:: with SMTP id x11mr2728521qvp.167.1581167028525; Sat, 08 Feb 2020 05:03:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581167028; cv=none; d=google.com; s=arc-20160816; b=pd/CVFpnOlyerCsjFwKeCmh+cMhbDbQk39jkkr9bkFnEpD6FAsHlHvKh5O+gtraSsc gUHjrZtSlW4WUmJVY0sPiR7vI5oQ4BkWYsk9oMLgNjMT0pLkeKgLA8ZnT+B+67LjqvQw 1xFxx2y7CYKbFp5Rwy9ExQU7uFL4Nr5tL9qFjAT0MPg9ARyUQ4Pu2DzXU/9I2a5I/Ywo HiZS1jL7riV3Au+qVMOtAjNbAdOOyml/b5S+ir/6wkfl5FSlhsZdrjSheCkk3GZSosss jFA4N/e9siJrHu0udlznfo7Ec1tIxFzf8upiVUlkUQDNcZJs09S9qU5OwSO5hS3dibo7 M1Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ENQgvGHJlgOvyNIKuMG2rnxdNRZFYiYT8ZYfYWz3WUI=; b=lQF2n6pBe3be89zGI2uADiRXoZcQIY25ZDI1yy1PFNrAI0nCn2HDjuvF7ALcQ73ONF 28cRMtalOIbD2a6XSZOFJXePONEOcc5mOjCiFSqMOMgT2L0yebytUdgDANZdGE+6vzuF GCGb03qUty7kwO34+TtkCBei/DsMGCT1k2kgpsBPWhj+PvMzdDg/bgWfvU1rT/dquwPx LdRXOEcEWXuVFmBAog1Yc4HW/7YbLXBnlJUfo+flsZxbyrqhaobyvTSYbvYi3jz8WJm4 Hi63mbNRoNenZqla/lT7jvHbrAAVtp/JgeJGy5sYIamgev+LGDVnWMK40TgbFtJRRsuQ 3m/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WYEPhxPx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r187si1435942qkb.359.2020.02.08.05.03.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 08 Feb 2020 05:03:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WYEPhxPx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0Pm0-0002S6-0V for patch@linaro.org; Sat, 08 Feb 2020 08:03:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41485) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j0Pgv-0000kc-6l for qemu-devel@nongnu.org; Sat, 08 Feb 2020 07:58:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j0Pgu-00056p-6t for qemu-devel@nongnu.org; Sat, 08 Feb 2020 07:58:33 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:35365) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j0Pgu-00052a-0g for qemu-devel@nongnu.org; Sat, 08 Feb 2020 07:58:32 -0500 Received: by mail-wr1-x441.google.com with SMTP id w12so2064816wrt.2 for ; Sat, 08 Feb 2020 04:58:31 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=ENQgvGHJlgOvyNIKuMG2rnxdNRZFYiYT8ZYfYWz3WUI=; b=WYEPhxPx5xLyyzO+9sogxoawsKbGdaU29SDxiv8YD/0yNxy7tcy7888GBhbxBbyXH9 6Df3SX3WSjocUDZILpCWM5K4Pn5lWL4TuX+nWeM45Pkt7vwW5NkmQoUIHg7dzFvjWRju lKYN6MzaT82FlMdeWuklLSXwZxYXKmLy/bbQ/Xkdu6qNZKjXMTy2Dj50CrfqLUdx25Ho EzcS8RGfNbbQrIO6U4jEPSMuYPluJRiJW35svSzx8vyWWFeJIdAhA5+5UKfPYXBu4AGQ tvanrEnVI8RXpyElleywz0cicQr/IchA6Mys1n2CtspBDf3LSI9036guP2LMDucUcovf 25lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ENQgvGHJlgOvyNIKuMG2rnxdNRZFYiYT8ZYfYWz3WUI=; b=ON03Orq3P+n6e09sEx0NYtbVELcwvzAXA4V1Mbu9ExGbgyNYQ797rN+T1BlG/Oh876 lOEZVFb16mpgyby10nn1Pc7Wu49Bm2EU1QwVDPGF0z91EUXr+wH2TDZK1RPhgmzdgXEF vL5wscP5PuCyANQJ1Iv7k6HFwPLjTaiODp0B3WGkymFbi6sRxZmvM9UGqXnfi2yPvbyx 54F5RHpDGtZACXA/Me9os/DZfYw7OtznunbaUtDntrOPp8ok/eL9dSST2mCFvZ853OHO DXzjFmc8eL4TEGbhKdD19eepk9EpdwhY5bwsoLBejAvo2Gxs3Q7nHJE74MymhejHFbK2 nxeg== X-Gm-Message-State: APjAAAUbkbHQjuAAunI1ndmFIhxAD1W8UF95xtfB3VAkafa7ySkZO2QS PSY+xJ3GONBnRZ/vjYOGR+FhlNtnX2651Q== X-Received: by 2002:a5d:538e:: with SMTP id d14mr5581291wrv.358.1581166710819; Sat, 08 Feb 2020 04:58:30 -0800 (PST) Received: from localhost.localdomain ([82.3.55.76]) by smtp.gmail.com with ESMTPSA id p5sm7490534wrt.79.2020.02.08.04.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2020 04:58:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 13/20] target/arm: Enforce PAN semantics in get_S1prot Date: Sat, 8 Feb 2020 12:58:09 +0000 Message-Id: <20200208125816.14954-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200208125816.14954-1-richard.henderson@linaro.org> References: <20200208125816.14954-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If we have a PAN-enforcing mmu_idx, set prot == 0 if user_rw != 0. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/internals.h | 13 +++++++++++++ target/arm/helper.c | 3 +++ 2 files changed, 16 insertions(+) -- 2.20.1 diff --git a/target/arm/internals.h b/target/arm/internals.h index f6709a2b08..4a139644b5 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -893,6 +893,19 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) } } +static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx) +{ + switch (mmu_idx) { + case ARMMMUIdx_Stage1_E1_PAN: + case ARMMMUIdx_E10_1_PAN: + case ARMMMUIdx_E20_2_PAN: + case ARMMMUIdx_SE10_1_PAN: + return true; + default: + return false; + } +} + /* Return the FSR value for a debug exception (watchpoint, hardware * breakpoint or BKPT insn) targeting the specified exception level. */ diff --git a/target/arm/helper.c b/target/arm/helper.c index f6a600aa00..178757d271 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9569,6 +9569,9 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, if (is_user) { prot_rw = user_rw; } else { + if (user_rw && regime_is_pan(env, mmu_idx)) { + return 0; + } prot_rw = simple_ap_to_rw_prot_is_user(ap, false); }