From patchwork Tue Dec 3 22:53:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 180771 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2177412ile; Tue, 3 Dec 2019 15:10:44 -0800 (PST) X-Google-Smtp-Source: APXvYqz/YZQrAgeO0BLyRwQnt0DeUNvSqaFXdW2ZVL6csX1lHKyK0RgwgLDXX9+bSvCkf11OACz/ X-Received: by 2002:a50:b6f2:: with SMTP id f47mr729210ede.138.1575414644583; Tue, 03 Dec 2019 15:10:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575414644; cv=none; d=google.com; s=arc-20160816; b=JnydCGUvUbFX/qNYzitJdNj6R3POh8C9+IRC8Dm+vgzh2a3ZnHCp1NOk0kvnAOczja +s8WY4A/1JfcxG5QG/BjhPGfW1HK6t8TbEhRETI+SJ/gr3dkjc6QCeR+2C1UNawtEYOF 6QsyrXZUHxnCIctgR5hkrCAAWr+zyZhhWP+5kOzm+RXmmW0ysGnwdNJQOjnwsZH2Gjai jatd7lwoFfZFsukavkHOLqHW4HqIADeh+voJk4bQdkC2q4iH/PhLSIhu5ykPnvRzOfbL uBQY8nOoITV32z6n2bO4S/K6zeKp4RdaXnSGgfk6P90wQbVNZuvZTIuJ4OUAttfx6xRx xW9A== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=zIHslnUoGfikMY/tOISXoUEjJ6B+SC/aIId9fLfQVxs=; b=TcvjHJyems3EoeBRQ0f4zRuMqMXw9pik93/cqTtsnfW3YgnDL7pwBk3joF0xayqnOz vNW0wZsU5ciQjIawJvXM/f8Xxx6pviwR1HKgit953eeBy/oE2j7QwzrBbn6K6Vij0azo J9lNL9Z38STm+ozeShb2wsz7Jltju503JNwqhyu6Nzwazk1RfCHbvJjnFHy0QPegm4ZK cubWg+X3ZeLf+jHunTaE2UY8snJezBf7I2uAj90b8RHP+uCE1N5nMtW62lGKpZlaHN0u tk+EKtCPnd/7+fBL64by9J5rmUy1zQszXs1NQu8d8zRCS/jFTKIGY0tc9X/CgHmIm8rd ck7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CnJtkF8Z; 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 h5si2131811ejj.164.2019.12.03.15.10.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2019 15:10:44 -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=CnJtkF8Z; 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]:60218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icHJb-0003E0-4j for patch@linaro.org; Tue, 03 Dec 2019 18:10:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58613) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icH3e-0002wm-Ru for qemu-devel@nongnu.org; Tue, 03 Dec 2019 17:54:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icH3Z-0006ue-5R for qemu-devel@nongnu.org; Tue, 03 Dec 2019 17:54:11 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:36581) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icH3V-0006Zp-Tg for qemu-devel@nongnu.org; Tue, 03 Dec 2019 17:54:07 -0500 Received: by mail-pj1-x102c.google.com with SMTP id n96so2120386pjc.3 for ; Tue, 03 Dec 2019 14:53:46 -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; bh=zIHslnUoGfikMY/tOISXoUEjJ6B+SC/aIId9fLfQVxs=; b=CnJtkF8ZTefan5dRJ/FlnlnsN9Bl085KXHD9S5KUxhOY3kcVUZUr+mjfmIqvdDG8Fx Yrcg5wVcSTYVV60HTxBczy6HtmryhUMJXN+YEHiaHQMnVkgil2Zx/v40INj2ASwyttsg aFj8KH/r/LPwZAJ4O+IwkMvsDJE29RYsPAZU1yVtkvEcIReLQkRa9UngxFjp7Bb31gQC vz8d+U9mUdDLc3HXrJTTlS7fG/XKHpyZDZgZQQe5K1s2YyW6LYOxv2EczLRXivGgFGQ+ Gr7EhiJNwZHpN8KKWLvv7DG6K0CNjzeJmGkaiOs0NT5/h68HS4Rj2xklSJgz+Xt3h8kK 76Lw== 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; bh=zIHslnUoGfikMY/tOISXoUEjJ6B+SC/aIId9fLfQVxs=; b=JoRTPdOYhSoyzzfje8G99xoWbtztc5j5QzuzMkYz1xVwKJgd43xGZZcVHs3tSguQae pw2F+oBeaETxM9cvt3Ui8CHUztD98cBoRQdNiJSeWY+ukDCkfQakIbz3ranbReKGSvhO U8O8k4dSgRr9J9OfMB+aQHNAwkx7RD0b3bJWh1QU9Xbz4PpkxMT25Obk9fWmi9+x+aX6 mQMDrb3JoBvAsFnqIOrRiVthMKpvi4KBbMd7QIoFdEW3hjcscKdhyhmLMdWvwkUGSOga 4c/o6TlUEZzuiYcKPGo+NPxnQBustWQajR5Kmz3CjacrXC6HIPsZKagFo0ihahr5UlZD asZg== X-Gm-Message-State: APjAAAUwHiRsvc0HDDVIOVgkWDJo9UhCleDYZJK0UnLXrKTWVNboAysK 8i++yj5Azfh3YEKbplGerXwsiGceWM0= X-Received: by 2002:a17:902:9a8d:: with SMTP id w13mr355806plp.330.1575413625366; Tue, 03 Dec 2019 14:53:45 -0800 (PST) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id d22sm3789713pjd.2.2019.12.03.14.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 14:53:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 08/11] target/arm: Enforce PAN semantics in get_S1prot Date: Tue, 3 Dec 2019 14:53:30 -0800 Message-Id: <20191203225333.17055-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203225333.17055-1-richard.henderson@linaro.org> References: <20191203225333.17055-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::102c 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 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. Signed-off-by: Richard Henderson --- target/arm/internals.h | 13 +++++++++++++ target/arm/helper.c | 3 +++ 2 files changed, 16 insertions(+) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/arm/internals.h b/target/arm/internals.h index 2408953031..ab3b436379 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_EL10_1_PAN: + case ARMMMUIdx_EL20_2_PAN: + case ARMMMUIdx_SE1_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 6c65dd799e..a1dbafb9b2 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9444,6 +9444,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); }