From patchwork Tue Feb 5 19:02:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 157523 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5563561jaa; Tue, 5 Feb 2019 11:42:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IaZ6QAxZs4yaygUkhLnIqOExEFRVlt08xB8fOC4V/I8eLqaBT0vTclkJkPSbV5518ERBIh9 X-Received: by 2002:a25:6149:: with SMTP id v70mr5451662ybb.404.1549395749210; Tue, 05 Feb 2019 11:42:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549395749; cv=none; d=google.com; s=arc-20160816; b=eb3GHNrJaKQip7qMQUoJ39kM/ARzXZ75WKg27k4oaGARjUsUREcbLQ+pYbegC6ltaj oUPpa/eraFo/DuI3k87KRs3mCOHU6PPif/yI/YfssOmFxFN0OSvQCzuU56F4yYKKZXJi iTtd6yl4DOgpfT6tA4Y3HpjVgZOgmreV3ZovUmp/RH9vx6++s+7RhjkBFSS5V+YhZ8Hb 0q5M9DiK6KIe+U2ovUwbEMPj/wd0LZYjHhRh0HjK3nJLypRfCLbS2TdWCt5bEj3bDvDG 5Bdn60AXb5uImWcsz+W9TH9vKs2Z0n/M5rqaPrc4mzJAuYTogGh4sH+CLMTx/shpGK/j 6hCQ== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=he1QWpSzeqIC+bRSMpRaTOp6xpr+dy0RWS2usRX99EY=; b=NB0SLkukRo/z4btpKFjUeEW6N0QjP96xvBclJrsJriO6Ett6dxLWyGR+ZPlaozt/lx LQJZXeM3i14bplZMi+yParvafPOTQDo7nsCgPCECpPOH0eP9hNxv5P+vnG12YFivheYq Tb7h6Lo2GfkriUbgyFDEkqIPItegiNL1a8SK79PGZreC46zLmsle78iww8djiNmiMCUu 4Zp03rMwDiM4QWojkhZ/UO2BoudxkJcFCE402mvkmu3XF7APtLRNGCIHfLxGJu1zSU9D Ugo6SIdBoIHG6sUAKYq3eCzTycdVq8CgWUybpyE4LWWVTh3qtNa+4YBrPs15stCQ3cs0 vKYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="aa3/nmV2"; 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=fail (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 r62si2509891ywf.326.2019.02.05.11.42.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Feb 2019 11:42:29 -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=fail header.i=@linaro.org header.s=google header.b="aa3/nmV2"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:39055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr6c0-0005oL-JH for patch@linaro.org; Tue, 05 Feb 2019 14:42:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gr5zc-0007p6-8i for qemu-devel@nongnu.org; Tue, 05 Feb 2019 14:02:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gr5zZ-0004Hc-Nd for qemu-devel@nongnu.org; Tue, 05 Feb 2019 14:02:47 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:45085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gr5zZ-00042q-F7 for qemu-devel@nongnu.org; Tue, 05 Feb 2019 14:02:45 -0500 Received: by mail-wr1-x442.google.com with SMTP id q15so4818203wro.12 for ; Tue, 05 Feb 2019 11:02:28 -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=he1QWpSzeqIC+bRSMpRaTOp6xpr+dy0RWS2usRX99EY=; b=aa3/nmV2Y0bZUSJntez4HQyep2rTcbR2yA2fBtuR2DXFkU5wqREYgEHDjss3Q8rLCE fhmXuNqXvWOecnHUQbj1Spxnt59g/0PLQV1DIF4JEuZncGwzvaOLd2FNES3V+gbznLWS gzsoTZBlpCFkfn9QARvQdKRTaSZ9/eCZel1JVK4GZQlVN5jy4khc+PcGN5xNOZA0se08 aZkV6qYsXXpgQ14RxfqxMlf9lzOfjMeZDWHbSThkO6anQr7Nm1DKTJrWBFXq8th+H+PB Hdf+f5gmjX01+viec2sdQs6cB3FfciHOciWXntHVOBpDL8x0bbvF0Hnz9tgqZgM3YzSC 9WIA== 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=he1QWpSzeqIC+bRSMpRaTOp6xpr+dy0RWS2usRX99EY=; b=uckkkpJRRtDgq+TXKs8rRb+/uTP7u0w2uoa27yjKD5NDBE8q11IPAfa5Y10YHKrPXa LgQnOqGauPwsRjRiqBDQ56wDYSLgYmesUy5iKttZYO8MtGHN8hhDCnUClEBxC15AJdCr hpGWMVGhuYlcfMyiF3sqGwUnEGFIj8Ph5YA/INiWzNMRR5ZYlvxpi2LN/hhoVzFvWNHQ YyC8iYrR1O60K+9N6EQvevb4yvuD/C7LDjj3RcZ927hruQ5xRdOkwFK3L22cuJ/ah4X4 mbT79LD19K79cg1GrCIKRVUfCtB8ZnXkAv3XfgQHiL/Uw5uNFktSiqEModeOPOACekYT qZfg== X-Gm-Message-State: AHQUAua+rjZVIJMOZa3D4UXHPk5sa+umoiJtkIRcDel7rYjvM+UyTbFN xxetDAOdXB/gwF7BijK/YTk9iw== X-Received: by 2002:a5d:49cd:: with SMTP id t13mr4918476wrs.144.1549393345754; Tue, 05 Feb 2019 11:02:25 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s132sm12470668wmf.28.2019.02.05.11.02.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Feb 2019 11:02:25 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8A7031FF81; Tue, 5 Feb 2019 19:02:24 +0000 (UTC) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 19:02:19 +0000 Message-Id: <20190205190224.2198-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190205190224.2198-1-alex.bennee@linaro.org> References: <20190205190224.2198-1-alex.bennee@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::442 Subject: [Qemu-devel] [PATCH v2 1/6] target/arm: relax permission checks for HWCAP_CPUID registers 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: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Although technically not visible to userspace the kernel does make them visible via a trap and emulate ABI. We provide a new permission mask (PL0U_R) which maps to PL0_R for CONFIG_USER builds and adjust the minimum permission check accordingly. Signed-off-by: Alex Bennée --- target/arm/cpu.h | 12 ++++++++++++ target/arm/helper.c | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a68bcc9fed..1616632dcb 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2211,6 +2211,18 @@ static inline bool cptype_valid(int cptype) #define PL0_R (0x02 | PL1_R) #define PL0_W (0x01 | PL1_W) +/* + * For user-mode some registers are accessible to EL0 via a kernel + * trap-and-emulate ABI. In this case we define the read permissions + * as actually being PL0_R. However some bits of any given register + * may still be masked. + */ +#ifdef CONFIG_USER_ONLY +#define PL0U_R PL0_R +#else +#define PL0U_R PL1_R +#endif + #define PL3_RW (PL3_R | PL3_W) #define PL2_RW (PL2_R | PL2_W) #define PL1_RW (PL1_R | PL1_W) diff --git a/target/arm/helper.c b/target/arm/helper.c index d070879894..5857c0ba96 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6851,7 +6851,11 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, if (r->state != ARM_CP_STATE_AA32) { int mask = 0; switch (r->opc1) { - case 0: case 1: case 2: + case 0: + /* min_EL EL1, but some accessible to EL0 via kernel ABI */ + mask = PL0U_R | PL1_RW; + break; + case 1: case 2: /* min_EL EL1 */ mask = PL1_RW; break;