From patchwork Mon Feb 3 14:46:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362831 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61BEC1395 for ; Mon, 3 Feb 2020 14:48:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 384E92080C for ; Mon, 3 Feb 2020 14:48:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MttvHJ2x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 384E92080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd1N-0008LU-BJ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:48:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44478) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0T-0006ZP-CK for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0S-000327-Aj for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:21 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:38186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0S-00031S-4P for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:20 -0500 Received: by mail-wm1-x342.google.com with SMTP id a9so17456790wmj.3 for ; Mon, 03 Feb 2020 06:47:20 -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=Xi6aqLCGsPeAJ9MPcbLlXNLY3ZKVruAB+cLB8Mn+tIk=; b=MttvHJ2xCMZHuTGoMqa90tqvmau2Jmp8Q4nQtntH9cvhZ1/VNUt/abjrgnTY+ayn+Z yAsklnLTWIRxZe7ua9qZYlL8MLz6fz7xhuRX1YAIRMl/APfSA2yZ3TvpwyDpyj49ajIy 3nuKZgezNCqc2+owNYMV6MrvWHpeq1HXHhpCV1WHtbUN5QwTSStRf/rVIN/WZ/lS+425 dEtkw4P20v/cq0tkI3tJBb+E20YbpOSCHpPbPQfayl2jQt88vf9fGkQI1dIQaSzHGpeU hQflvBSSvx7e8GTs5UCwnF2cILva6zCdY55AhbwtK4q4xr76aeVyoXWeXkUGIJdchfgE jfKA== 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=Xi6aqLCGsPeAJ9MPcbLlXNLY3ZKVruAB+cLB8Mn+tIk=; b=VjnlxrKFSgyLBGFa+favbQjeWTCu2T/21A2qcaSAPltQVIlMaUQrQb7YL9YOi0BBJi 5Do8EYutLY38YkZdjhucqIAdCoGqL6WBMp7dQLJeAlaL6f/Pzi1S1oF3VXKVSCqvOXFB M1ercNk6+dGchsixybDytbB7wDYK8/0N+NfPWza7KU5c9W5QMr5DjvEQQLzVXH20g83b 3zyPrY3YUdPW9D2w+QWAF0NdEdLBIMloKBDK6+EIwAgyrABm2BqEhLKwQPt5UmRO/GyZ gV/EMh2I13hB/mqjpUe2+eF4mRZR1P11aLH24x0Ilbpq8wzOa+xfXEiym2zkZBK9L4BY r2eg== X-Gm-Message-State: APjAAAXanCyq1qg3qKz0lZclJ2eOz1B0lW+kj2lOZ7hv5hmtddD0woXC 9ClGeY0KUEGLRn6lyiM6hETKgoa4jJcUvQ== X-Google-Smtp-Source: APXvYqwDZPi239Ub9VfO7AzLDa1tqZvZis5Qctar/4+nn2opTZTQQnB0YNuwG0A5QRaJRh6yyZyoJQ== X-Received: by 2002:a1c:5445:: with SMTP id p5mr29292787wmi.75.1580741238750; Mon, 03 Feb 2020 06:47:18 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/20] target/arm: Add arm_mmu_idx_is_stage1_of_2 Date: Mon, 3 Feb 2020 14:46:57 +0000 Message-Id: <20200203144716.32204-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::342 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, =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Use a common predicate for querying stage1-ness. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- v2: Rename from arm_mmu_idx_is_stage1 to arm_mmu_idx_is_stage1_of_2 --- target/arm/internals.h | 18 ++++++++++++++++++ target/arm/helper.c | 8 +++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 6d4a942bde..1f8ee5f573 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1034,6 +1034,24 @@ static inline ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env); #endif +/** + * arm_mmu_idx_is_stage1_of_2: + * @mmu_idx: The ARMMMUIdx to test + * + * Return true if @mmu_idx is a NOTLB mmu_idx that is the + * first stage of a two stage regime. + */ +static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx) +{ + switch (mmu_idx) { + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E1: + return true; + default: + return false; + } +} + /* * Parameters of a given virtual address, as extracted from the * translation control register (TCR) for a given regime. diff --git a/target/arm/helper.c b/target/arm/helper.c index 70b10428c5..852fd71dcc 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3261,8 +3261,7 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, bool take_exc = false; if (fi.s1ptw && current_el == 1 && !arm_is_secure(env) - && (mmu_idx == ARMMMUIdx_Stage1_E1 || - mmu_idx == ARMMMUIdx_Stage1_E0)) { + && arm_mmu_idx_is_stage1_of_2(mmu_idx)) { /* * Synchronous stage 2 fault on an access made as part of the * translation table walk for AT S1E0* or AT S1E1* insn @@ -9294,8 +9293,7 @@ static inline bool regime_translation_disabled(CPUARMState *env, } } - if ((env->cp15.hcr_el2 & HCR_DC) && - (mmu_idx == ARMMMUIdx_Stage1_E0 || mmu_idx == ARMMMUIdx_Stage1_E1)) { + if ((env->cp15.hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) { /* HCR.DC means SCTLR_EL1.M behaves as 0 */ return true; } @@ -9604,7 +9602,7 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, hwaddr addr, MemTxAttrs txattrs, ARMMMUFaultInfo *fi) { - if ((mmu_idx == ARMMMUIdx_Stage1_E0 || mmu_idx == ARMMMUIdx_Stage1_E1) && + if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && !regime_translation_disabled(env, ARMMMUIdx_Stage2)) { target_ulong s2size; hwaddr s2pa; From patchwork Mon Feb 3 14:46:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3BEA61395 for ; Mon, 3 Feb 2020 14:50:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 01FC42080C for ; Mon, 3 Feb 2020 14:50:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="f4K94r2u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01FC42080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd3b-0003cc-6J for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:50:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44523) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0V-0006al-Oz for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0T-00034s-IF for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:23 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0T-00032e-AN for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:21 -0500 Received: by mail-wr1-x442.google.com with SMTP id z3so18568757wru.3 for ; Mon, 03 Feb 2020 06:47:21 -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=8r+HTQiaz0B+9GBGLlyu4AdBjlkmGcwLI10SNr8Qdfk=; b=f4K94r2u99Lt9ufV9Pi8Hwf/reIRLqrA0gHSXISmZmVirERW8Del9vY4FTB2lr7KSb 3y2D1kdpRl5BDcwepocpmybfoDjfcrF1DMjDg1Gbg0fzyMwPSm8kKIkzHMQ0hJMtJRuj RhavSE1j62FvjuaJiv2HXrbZm47tURmyY3xusTFd+4lI64q31fTbK+nK91CQx9E/KwZV eDXVmoEn2mYqO5TNnbdoezaq1C5mbPzKMKSAmOGq1XWlRRNiyPS+XcHHqFvZEDP2PjZ6 fo/YcqBg1xzkdCHzB9d2E7Hb8R0VY0aLCpUqNlz2D+/0l9rJ7NPqXSzslvTv2B8uUjRa R76A== 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=8r+HTQiaz0B+9GBGLlyu4AdBjlkmGcwLI10SNr8Qdfk=; b=Ue5hfVEJnTZt1NdrLUhgDla6Wn3F5BFelpmCBm5vpT0Ek3If9rScfEpHlsrIbL8RJI sDBFPJtsOioymxxfDNqTjNRGe4J27G0NJ/QDVRDJSnqcYjnCPScWtZ3SbEFOtphJaqzC Ph/TaNkl4erHR1c5ba7+hP7s4Q8INYDIO3HlyjfAxyCKJWb6jV8LI43n8/4yAMZ6t8xu 1mYArNVZaDnujyc7FIcusjoTEOnWzNj8Pj5jwnGUXfTVDh3TjXaaj0E5e6Sa06JUOz8O Wg3bxYa+oCUUlBDkHlOn1Us9K8nEyQIdYXoKvuQUWenbhjsYz14ibOnDcEH2ebbrT971 MP3Q== X-Gm-Message-State: APjAAAVLm537Ql9+5vYsGsSFJdqYOrJBEFr7q4/gdfB7tP+y9/lj2OEJ 3Wkb3MZ7rG4P4Br/D0ttJY7NqsA/7kKWYA== X-Google-Smtp-Source: APXvYqxIQ11WXF8HypIGHR1wj2/mp+gM0EakuqMhr00KHMcbjyVnkX1YEPMifhaDG7K8qpJfOrGbYg== X-Received: by 2002:adf:ec4c:: with SMTP id w12mr17002103wrn.124.1580741239725; Mon, 03 Feb 2020 06:47:19 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/20] target/arm: Add mmu_idx for EL1 and EL2 w/ PAN enabled Date: Mon, 3 Feb 2020 14:46:58 +0000 Message-Id: <20200203144716.32204-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::442 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" To implement PAN, we will want to swap, for short periods of time, to a different privileged mmu_idx. In addition, we cannot do this with flushing alone, because the AT* instructions have both PAN and PAN-less versions. Add the ARMMMUIdx*_PAN constants where necessary next to the corresponding ARMMMUIdx* constant. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu-param.h | 2 +- target/arm/cpu.h | 33 ++++++++++++++------- target/arm/internals.h | 9 ++++++ target/arm/helper.c | 60 +++++++++++++++++++++++++++++++------- target/arm/translate-a64.c | 3 ++ target/arm/translate.c | 2 ++ 6 files changed, 87 insertions(+), 22 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index 18ac562346..d593b60b28 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -29,6 +29,6 @@ # define TARGET_PAGE_BITS_MIN 10 #endif -#define NB_MMU_MODES 9 +#define NB_MMU_MODES 12 #endif diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0b3036c484..c63bceaaa5 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2751,20 +2751,24 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync); * 5. we want to be able to use the TLB for accesses done as part of a * stage1 page table walk, rather than having to walk the stage2 page * table over and over. + * 6. we need separate EL1/EL2 mmu_idx for handling the Privileged Access + * Never (PAN) bit within PSTATE. * * This gives us the following list of cases: * * NS EL0 EL1&0 stage 1+2 (aka NS PL0) * NS EL1 EL1&0 stage 1+2 (aka NS PL1) + * NS EL1 EL1&0 stage 1+2 +PAN * NS EL0 EL2&0 - * NS EL2 EL2&0 + * NS EL2 EL2&0 +PAN * NS EL2 (aka NS PL2) * S EL0 EL1&0 (aka S PL0) * S EL1 EL1&0 (not used if EL3 is 32 bit) + * S EL1 EL1&0 +PAN * S EL3 (aka S PL1) * NS EL1&0 stage 2 * - * for a total of 9 different mmu_idx. + * for a total of 12 different mmu_idx. * * R profile CPUs have an MPU, but can use the same set of MMU indexes * as A profile. They only need to distinguish NS EL0 and NS EL1 (and @@ -2819,19 +2823,22 @@ typedef enum ARMMMUIdx { /* * A-profile. */ - ARMMMUIdx_E10_0 = 0 | ARM_MMU_IDX_A, - ARMMMUIdx_E20_0 = 1 | ARM_MMU_IDX_A, + ARMMMUIdx_E10_0 = 0 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_0 = 1 | ARM_MMU_IDX_A, - ARMMMUIdx_E10_1 = 2 | ARM_MMU_IDX_A, + ARMMMUIdx_E10_1 = 2 | ARM_MMU_IDX_A, + ARMMMUIdx_E10_1_PAN = 3 | ARM_MMU_IDX_A, - ARMMMUIdx_E2 = 3 | ARM_MMU_IDX_A, - ARMMMUIdx_E20_2 = 4 | ARM_MMU_IDX_A, + ARMMMUIdx_E2 = 4 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_2 = 5 | ARM_MMU_IDX_A, + ARMMMUIdx_E20_2_PAN = 6 | ARM_MMU_IDX_A, - ARMMMUIdx_SE10_0 = 5 | ARM_MMU_IDX_A, - ARMMMUIdx_SE10_1 = 6 | ARM_MMU_IDX_A, - ARMMMUIdx_SE3 = 7 | ARM_MMU_IDX_A, + ARMMMUIdx_SE10_0 = 7 | ARM_MMU_IDX_A, + ARMMMUIdx_SE10_1 = 8 | ARM_MMU_IDX_A, + ARMMMUIdx_SE10_1_PAN = 9 | ARM_MMU_IDX_A, + ARMMMUIdx_SE3 = 10 | ARM_MMU_IDX_A, - ARMMMUIdx_Stage2 = 8 | ARM_MMU_IDX_A, + ARMMMUIdx_Stage2 = 11 | ARM_MMU_IDX_A, /* * These are not allocated TLBs and are used only for AT system @@ -2839,6 +2846,7 @@ typedef enum ARMMMUIdx { */ ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB, ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB, + ARMMMUIdx_Stage1_E1_PAN = 2 | ARM_MMU_IDX_NOTLB, /* * M-profile. @@ -2864,10 +2872,13 @@ typedef enum ARMMMUIdxBit { TO_CORE_BIT(E10_0), TO_CORE_BIT(E20_0), TO_CORE_BIT(E10_1), + TO_CORE_BIT(E10_1_PAN), TO_CORE_BIT(E2), TO_CORE_BIT(E20_2), + TO_CORE_BIT(E20_2_PAN), TO_CORE_BIT(SE10_0), TO_CORE_BIT(SE10_1), + TO_CORE_BIT(SE10_1_PAN), TO_CORE_BIT(SE3), TO_CORE_BIT(Stage2), diff --git a/target/arm/internals.h b/target/arm/internals.h index 1f8ee5f573..6be8b2d1a9 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -843,12 +843,16 @@ static inline bool regime_has_2_ranges(ARMMMUIdx mmu_idx) switch (mmu_idx) { case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_Stage1_E1_PAN: case ARMMMUIdx_E10_0: case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: case ARMMMUIdx_E20_0: case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: case ARMMMUIdx_SE10_0: case ARMMMUIdx_SE10_1: + case ARMMMUIdx_SE10_1_PAN: return true; default: return false; @@ -861,10 +865,13 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) switch (mmu_idx) { case ARMMMUIdx_E10_0: case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: case ARMMMUIdx_E20_0: case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_Stage1_E1_PAN: case ARMMMUIdx_E2: case ARMMMUIdx_Stage2: case ARMMMUIdx_MPrivNegPri: @@ -875,6 +882,7 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_SE3: case ARMMMUIdx_SE10_0: case ARMMMUIdx_SE10_1: + case ARMMMUIdx_SE10_1_PAN: case ARMMMUIdx_MSPrivNegPri: case ARMMMUIdx_MSUserNegPri: case ARMMMUIdx_MSPriv: @@ -1046,6 +1054,7 @@ static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx) switch (mmu_idx) { case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_Stage1_E1_PAN: return true; default: return false; diff --git a/target/arm/helper.c b/target/arm/helper.c index 852fd71dcc..739d2d4cc5 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -671,6 +671,7 @@ static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri, tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E10_1 | + ARMMMUIdxBit_E10_1_PAN | ARMMMUIdxBit_E10_0 | ARMMMUIdxBit_Stage2); } @@ -682,6 +683,7 @@ static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri, tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E10_1 | + ARMMMUIdxBit_E10_1_PAN | ARMMMUIdxBit_E10_0 | ARMMMUIdxBit_Stage2); } @@ -2700,6 +2702,7 @@ static int gt_phys_redir_timeridx(CPUARMState *env) switch (arm_mmu_idx(env)) { case ARMMMUIdx_E20_0: case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: return GTIMER_HYP; default: return GTIMER_PHYS; @@ -2711,6 +2714,7 @@ static int gt_virt_redir_timeridx(CPUARMState *env) switch (arm_mmu_idx(env)) { case ARMMMUIdx_E20_0: case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: return GTIMER_HYPVIRT; default: return GTIMER_VIRT; @@ -3337,7 +3341,9 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, format64 = arm_s1_regime_using_lpae_format(env, mmu_idx); if (arm_feature(env, ARM_FEATURE_EL2)) { - if (mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_E10_1) { + if (mmu_idx == ARMMMUIdx_E10_0 || + mmu_idx == ARMMMUIdx_E10_1 || + mmu_idx == ARMMMUIdx_E10_1_PAN) { format64 |= env->cp15.hcr_el2 & (HCR_VM | HCR_DC); } else { format64 |= arm_current_el(env) == 2; @@ -3797,7 +3803,9 @@ static void vmsa_tcr_ttbr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, if (extract64(raw_read(env, ri) ^ value, 48, 16) && (arm_hcr_el2_eff(env) & HCR_E2H)) { tlb_flush_by_mmuidx(env_cpu(env), - ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E20_0); + ARMMMUIdxBit_E20_2 | + ARMMMUIdxBit_E20_2_PAN | + ARMMMUIdxBit_E20_0); } raw_write(env, ri, value); } @@ -3815,6 +3823,7 @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, if (raw_read(env, ri) != value) { tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E10_1 | + ARMMMUIdxBit_E10_1_PAN | ARMMMUIdxBit_E10_0 | ARMMMUIdxBit_Stage2); raw_write(env, ri, value); @@ -4175,12 +4184,18 @@ static int vae1_tlbmask(CPUARMState *env) { /* Since we exclude secure first, we may read HCR_EL2 directly. */ if (arm_is_secure_below_el3(env)) { - return ARMMMUIdxBit_SE10_1 | ARMMMUIdxBit_SE10_0; + return ARMMMUIdxBit_SE10_1 | + ARMMMUIdxBit_SE10_1_PAN | + ARMMMUIdxBit_SE10_0; } else if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) { - return ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E20_0; + return ARMMMUIdxBit_E20_2 | + ARMMMUIdxBit_E20_2_PAN | + ARMMMUIdxBit_E20_0; } else { - return ARMMMUIdxBit_E10_1 | ARMMMUIdxBit_E10_0; + return ARMMMUIdxBit_E10_1 | + ARMMMUIdxBit_E10_1_PAN | + ARMMMUIdxBit_E10_0; } } @@ -4214,18 +4229,28 @@ static int alle1_tlbmask(CPUARMState *env) * stage 1 translations. */ if (arm_is_secure_below_el3(env)) { - return ARMMMUIdxBit_SE10_1 | ARMMMUIdxBit_SE10_0; + return ARMMMUIdxBit_SE10_1 | + ARMMMUIdxBit_SE10_1_PAN | + ARMMMUIdxBit_SE10_0; } else if (arm_feature(env, ARM_FEATURE_EL2)) { - return ARMMMUIdxBit_E10_1 | ARMMMUIdxBit_E10_0 | ARMMMUIdxBit_Stage2; + return ARMMMUIdxBit_E10_1 | + ARMMMUIdxBit_E10_1_PAN | + ARMMMUIdxBit_E10_0 | + ARMMMUIdxBit_Stage2; } else { - return ARMMMUIdxBit_E10_1 | ARMMMUIdxBit_E10_0; + return ARMMMUIdxBit_E10_1 | + ARMMMUIdxBit_E10_1_PAN | + ARMMMUIdxBit_E10_0; } } static int alle2_tlbmask(CPUARMState *env) { /* TODO: ARMv8.4-SecEL2 */ - return ARMMMUIdxBit_E20_0 | ARMMMUIdxBit_E20_2 | ARMMMUIdxBit_E2; + return ARMMMUIdxBit_E20_0 | + ARMMMUIdxBit_E20_2 | + ARMMMUIdxBit_E20_2_PAN | + ARMMMUIdxBit_E2; } static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -9215,6 +9240,7 @@ static uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) switch (mmu_idx) { case ARMMMUIdx_E20_0: case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: case ARMMMUIdx_Stage2: case ARMMMUIdx_E2: return 2; @@ -9223,10 +9249,13 @@ static uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_SE10_0: return arm_el_is_aa64(env, 3) ? 1 : 3; case ARMMMUIdx_SE10_1: + case ARMMMUIdx_SE10_1_PAN: case ARMMMUIdx_Stage1_E0: case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_Stage1_E1_PAN: case ARMMMUIdx_E10_0: case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: case ARMMMUIdx_MPrivNegPri: case ARMMMUIdx_MUserNegPri: case ARMMMUIdx_MPriv: @@ -9342,6 +9371,8 @@ static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) return ARMMMUIdx_Stage1_E0; case ARMMMUIdx_E10_1: return ARMMMUIdx_Stage1_E1; + case ARMMMUIdx_E10_1_PAN: + return ARMMMUIdx_Stage1_E1_PAN; default: return mmu_idx; } @@ -9388,6 +9419,7 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) return false; case ARMMMUIdx_E10_0: case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: g_assert_not_reached(); } } @@ -11280,7 +11312,9 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, target_ulong *page_size, ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) { - if (mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_E10_1) { + if (mmu_idx == ARMMMUIdx_E10_0 || + mmu_idx == ARMMMUIdx_E10_1 || + mmu_idx == ARMMMUIdx_E10_1_PAN) { /* Call ourselves recursively to do the stage 1 and then stage 2 * translations. */ @@ -11807,10 +11841,13 @@ int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) case ARMMMUIdx_SE10_0: return 0; case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: case ARMMMUIdx_SE10_1: + case ARMMMUIdx_SE10_1_PAN: return 1; case ARMMMUIdx_E2: case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: return 2; case ARMMMUIdx_SE3: return 3; @@ -12027,11 +12064,14 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, /* TODO: ARMv8.2-UAO */ switch (mmu_idx) { case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: case ARMMMUIdx_SE10_1: + case ARMMMUIdx_SE10_1_PAN: /* TODO: ARMv8.3-NV */ flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); break; case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: /* TODO: ARMv8.4-SecEL2 */ /* * Note that E20_2 is gated by HCR_EL2.E2H == 1, but E20_0 is diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 6e82486884..49631c2340 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -124,12 +124,15 @@ static int get_a64_user_mem_index(DisasContext *s) */ switch (useridx) { case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: useridx = ARMMMUIdx_E10_0; break; case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: useridx = ARMMMUIdx_E20_0; break; case ARMMMUIdx_SE10_1: + case ARMMMUIdx_SE10_1_PAN: useridx = ARMMMUIdx_SE10_0; break; default: diff --git a/target/arm/translate.c b/target/arm/translate.c index e11a5871d0..d58c328e08 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -155,10 +155,12 @@ static inline int get_a32_user_mem_index(DisasContext *s) case ARMMMUIdx_E2: /* this one is UNPREDICTABLE */ case ARMMMUIdx_E10_0: case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: return arm_to_core_mmu_idx(ARMMMUIdx_E10_0); case ARMMMUIdx_SE3: case ARMMMUIdx_SE10_0: case ARMMMUIdx_SE10_1: + case ARMMMUIdx_SE10_1_PAN: return arm_to_core_mmu_idx(ARMMMUIdx_SE10_0); case ARMMMUIdx_MUser: case ARMMMUIdx_MPriv: From patchwork Mon Feb 3 14:46:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF2891395 for ; Mon, 3 Feb 2020 14:48:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 869502080C for ; Mon, 3 Feb 2020 14:48:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pYAWXrk2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 869502080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd1P-0008Or-P3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:48:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44509) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0V-0006Zw-1x for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0U-00035h-1T for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:22 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:33033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0T-00034G-Rr for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:21 -0500 Received: by mail-wm1-x344.google.com with SMTP id m10so68312wmc.0 for ; Mon, 03 Feb 2020 06:47:21 -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=xtW+FSSefxatLNrrEmn+GvZA5uNXwjZFYEeWUyFoKGE=; b=pYAWXrk2KaditU/d70ufbRDBxFmocZ0IyAosh+BQ5QRhwbmifU4tsZhWj0kyneL1r7 tUQQktCCNpcG/Y8DRpYhoehZ1Rvf8dNMd0zdO+DXYbJrjzoGWs9pXhqnSggPh6hrQuuC b3ikGPmCagEegNH1PI+AP/nAnALq+OVsWxiYyUFNwJRVgs3TgoB88z1NK5JlJ746y47c 5wJkgMvta15IWIMNjedeBslCada1NedQSEJyBsenzk50jDSe6Fq56uqWrGNA2JB52T1X 6p7g9mxSH66a+BRSn3I2gOBVMRWeeZINwG4Bj3Xm4iJ0aDtziYi4h2zm/q0+3KTp/S94 T1wg== 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=xtW+FSSefxatLNrrEmn+GvZA5uNXwjZFYEeWUyFoKGE=; b=hU97+sNnH6SEqR3p777eXCG2Uiz4hTZsgR7Qvngio4Z5N9W7eenOtQjhzOmDeU7e/E dSnHQOLZU4XsefhgP64lMwKqagvKlR8R6/0/TvpDHLVUOlIGT57aaA6ICik9mdIvULen GyBj9SZKJiRQeJzRh9RTolRKqaYxvErbGJI5QCDrFTF724L+4xONt2qOlsH9PwxcEvR3 Cvhgm5ojXgSilIddOZwsbA0bh+LAhDxgT2bG+H3quBKRq0HQ7iF1dlJDbXRZvwObJHWP sjqqCprrkcdnT/xFTFNTzUpBZgL3BQZBiz9gVRxOT9K7MdzGCedJCdwTDAZ6K/peGHmY OArQ== X-Gm-Message-State: APjAAAWaCXLXR4+DB3decBbYVtlac8kYAHslSikxal4o5KyCDJ6J9H8C YxjaMajzYhTPFByIb8bJ+GBKwcYAl54qKw== X-Google-Smtp-Source: APXvYqyxwsU5/Vf3HmMEoob40uvxNdbO/14/tdJUhmVmbH9U9iFAYaFKOqlL2aek9KBfssL1D/He2g== X-Received: by 2002:a05:600c:2218:: with SMTP id z24mr29295363wml.50.1580741240505; Mon, 03 Feb 2020 06:47:20 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/20] target/arm: Add isar_feature tests for PAN + ATS1E1 Date: Mon, 3 Feb 2020 14:46:59 +0000 Message-Id: <20200203144716.32204-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::344 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Include definitions for all of the bits in ID_MMFR3. We already have a definition for ID_AA64MMFR1.PAN. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c63bceaaa5..08b2f5d73e 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1727,6 +1727,15 @@ FIELD(ID_ISAR6, FHM, 8, 4) FIELD(ID_ISAR6, SB, 12, 4) FIELD(ID_ISAR6, SPECRES, 16, 4) +FIELD(ID_MMFR3, CMAINTVA, 0, 4) +FIELD(ID_MMFR3, CMAINTSW, 4, 4) +FIELD(ID_MMFR3, BPMAINT, 8, 4) +FIELD(ID_MMFR3, MAINTBCST, 12, 4) +FIELD(ID_MMFR3, PAN, 16, 4) +FIELD(ID_MMFR3, COHWALK, 20, 4) +FIELD(ID_MMFR3, CMEMSZ, 24, 4) +FIELD(ID_MMFR3, SUPERSEC, 28, 4) + FIELD(ID_MMFR4, SPECSEI, 0, 4) FIELD(ID_MMFR4, AC2, 4, 4) FIELD(ID_MMFR4, XNX, 8, 4) @@ -3443,6 +3452,16 @@ static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id) return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 4; } +static inline bool isar_feature_aa32_pan(const ARMISARegisters *id) +{ + return FIELD_EX64(id->mvfr0, ID_MMFR3, PAN) != 0; +} + +static inline bool isar_feature_aa32_ats1e1(const ARMISARegisters *id) +{ + return FIELD_EX64(id->mvfr0, ID_MMFR3, PAN) >= 2; +} + /* * 64-bit feature tests via id registers. */ @@ -3602,6 +3621,16 @@ static inline bool isar_feature_aa64_lor(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, LO) != 0; } +static inline bool isar_feature_aa64_pan(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) != 0; +} + +static inline bool isar_feature_aa64_ats1e1(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 2; +} + static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; From patchwork Mon Feb 3 14:47:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24F0A1395 for ; Mon, 3 Feb 2020 14:48:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF1A22080C for ; Mon, 3 Feb 2020 14:48:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cIUPm46r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF1A22080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd1R-0008W5-VQ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:48:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44533) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0W-0006bf-DF for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0V-00036o-5F for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:24 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:40912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0U-000362-VY for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:23 -0500 Received: by mail-wm1-x343.google.com with SMTP id t14so17462462wmi.5 for ; Mon, 03 Feb 2020 06:47:22 -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=2RHX+9VAaI14LH2Ijti0R37fLYBPx3ELl/51B+kqxLE=; b=cIUPm46rPwr1I2vTyH53gapoGurLqsjkZf01uMi+qP3jbXo851VSVwMIuA1zXtKENk OiyA3e6ZIYbSA1Bzi+BD4i2viejbv4XVgMDnhThQtbVQiScPQ6uid0LUt5dnMYPZXzGA tiBKbnmn+X176XgmSMyNmMaKwS0tEDEHbNDbwswKaxRtfFYAmH3pnX720lrlVdzJsrz9 L0ltE/KnTV/FoMte2heRWvgsgbqQTzQMTal3Miz0oRMkAtQErH6MN9zbZy5DHT56Byo4 3jQMFvUE8vt9alwOfCx0Ako1mG1GTBkdEfOn23e12OBgINtxqpuCb1y3Uyn8H7tpM8Ym RQSg== 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=2RHX+9VAaI14LH2Ijti0R37fLYBPx3ELl/51B+kqxLE=; b=e9Jah7JOCghFkxFMGzxSl0BuDrpd8vqcHTnO84VkA8lj2Z/ZR45oKydzHUZFwCcnq4 6gpIOIGnoWSRkiZbc+t329qH8OcVCBk+cRLVXNYR/ltb+RofP7nISKAAd9bgsqHxzbrd tX22beE1DKsLJzOpVAwOyXwWwrMPPinsF9IYDLjpfTlLt4RJw/3fVftq1YSj1nzLc5Bx OGLhnhjXFYNAr9rRrPLiLb50D3ZDE4qumw+P1fS3rHb0wZPDAOTYx71XDirvXxjCqcf/ xmzgkMW8Vd0wb0K4kOcJTWDeYYZmtjBO5K/5f6lwt/hZIpnInqr4UTC/X7+EsYpOOQN4 vx3Q== X-Gm-Message-State: APjAAAUjwDRPjLEv22YnlQzVtO64VF9tfVuSdM/tqzFB9qnRlEDuM7FN HGwdr/ynFCTuqdusxD64AQbRJC8NcS99Pg== X-Google-Smtp-Source: APXvYqyOvMQ+ffoeAHDFEZZ3/wYB6JcYlNYIzO3tik8dShR+rv2kh0TAuFfgfwk3ei1VGHdLPOUzyA== X-Received: by 2002:a1c:cc11:: with SMTP id h17mr28766142wmb.19.1580741241613; Mon, 03 Feb 2020 06:47:21 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/20] target/arm: Move LOR regdefs to file scope Date: Mon, 3 Feb 2020 14:47:00 +0000 Message-Id: <20200203144716.32204-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::343 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" For static const regdefs, file scope is preferred. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 57 +++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 739d2d4cc5..795ef727d0 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6343,6 +6343,35 @@ static CPAccessResult access_lor_other(CPUARMState *env, return access_lor_ns(env); } +/* + * A trivial implementation of ARMv8.1-LOR leaves all of these + * registers fixed at 0, which indicates that there are zero + * supported Limited Ordering regions. + */ +static const ARMCPRegInfo lor_reginfo[] = { + { .name = "LORSA_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 0, + .access = PL1_RW, .accessfn = access_lor_other, + .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "LOREA_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 1, + .access = PL1_RW, .accessfn = access_lor_other, + .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "LORN_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 2, + .access = PL1_RW, .accessfn = access_lor_other, + .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "LORC_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 3, + .access = PL1_RW, .accessfn = access_lor_other, + .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "LORID_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, + .access = PL1_R, .accessfn = access_lorid, + .type = ARM_CP_CONST, .resetvalue = 0 }, + REGINFO_SENTINEL +}; + #ifdef TARGET_AARCH64 static CPAccessResult access_pauth(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) @@ -7577,34 +7606,6 @@ void register_cp_regs_for_features(ARMCPU *cpu) } if (cpu_isar_feature(aa64_lor, cpu)) { - /* - * A trivial implementation of ARMv8.1-LOR leaves all of these - * registers fixed at 0, which indicates that there are zero - * supported Limited Ordering regions. - */ - static const ARMCPRegInfo lor_reginfo[] = { - { .name = "LORSA_EL1", .state = ARM_CP_STATE_AA64, - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 0, - .access = PL1_RW, .accessfn = access_lor_other, - .type = ARM_CP_CONST, .resetvalue = 0 }, - { .name = "LOREA_EL1", .state = ARM_CP_STATE_AA64, - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 1, - .access = PL1_RW, .accessfn = access_lor_other, - .type = ARM_CP_CONST, .resetvalue = 0 }, - { .name = "LORN_EL1", .state = ARM_CP_STATE_AA64, - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 2, - .access = PL1_RW, .accessfn = access_lor_other, - .type = ARM_CP_CONST, .resetvalue = 0 }, - { .name = "LORC_EL1", .state = ARM_CP_STATE_AA64, - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 3, - .access = PL1_RW, .accessfn = access_lor_other, - .type = ARM_CP_CONST, .resetvalue = 0 }, - { .name = "LORID_EL1", .state = ARM_CP_STATE_AA64, - .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, - .access = PL1_R, .accessfn = access_lorid, - .type = ARM_CP_CONST, .resetvalue = 0 }, - REGINFO_SENTINEL - }; define_arm_cp_regs(cpu, lor_reginfo); } From patchwork Mon Feb 3 14:47:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362851 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1115A1395 for ; Mon, 3 Feb 2020 14:52:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DBE8E2082E for ; Mon, 3 Feb 2020 14:52:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="amx+EMl5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBE8E2082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd5D-00076E-2h for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:52:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44553) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0X-0006dM-A5 for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0W-00038Q-3d for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:25 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:33583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0V-00036z-Tc for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:24 -0500 Received: by mail-wr1-x444.google.com with SMTP id u6so5256987wrt.0 for ; Mon, 03 Feb 2020 06:47:23 -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=rcege1rdFln5muDzfVSDtjPu75r3ILD97R1ciS/AOgA=; b=amx+EMl5MXhSrDDM1ZFSxPxcO0+OkPK0A2scXiRGdXU3AVHs4ZBU9cWfSkR1jHsELM um+A1zkrcVRHPvbc2jAn+jYc59/v8PZSfPt0wQf3aTGpxOPyApdI9nRCWPv9bvsgEH7b FmYOyzhMhNNkgoJ9mBY1ctnq9oBBy2yDMITTF4kWXkr/Nyg8VPE7XPZBDZxkMiLmlSxB cqxJvnTvx70rIPrgWQLvSoSxgpgaK6OCJ1J7Ld8rtIJxfUz2y/P3TW748JFKJaXVEI/8 8tRooDY8KpOGGrwQObxSVzHN3NdreyGu8wf1Yi2ajufvEA9qNzlj6pdIbth0tDrDkWs7 NpOQ== 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=rcege1rdFln5muDzfVSDtjPu75r3ILD97R1ciS/AOgA=; b=nJ3Kfj6mS0RVYk9hqz+EdlfAe7UdIUn/hBFx8p/nivrS62Z4BEIQIhE2sIKVyvADE1 sZPYh0h7LOb/8NhqNiRlogCNgIxq+1gk38qwtST8O4n+wiLlleZ3DzaT7koxzcSwJmsS pfUowIOfPS7cR9CbIsdGVgNzy2gQNG+raR8RDxKBLWHba44fkNkYFcrKxLqArr2Pn137 YQn/dGKwZDoJpOhqhRC+lFia5U64+ZV/EV0k+zw5K9C4YdVrXX1/UALOBBJSyzy0J59P xQ4jLy5TD04HYBpNbW+0BUeSAp1q8ph8M5JAGDcF60q6v7Yh/pIWamPoH4xpsrqREXPx RzUw== X-Gm-Message-State: APjAAAVvGxuZBw4XfTEQqjQ8px2L9+vWNTAAToM10F4+6N/z77KMoeYo kWQTZ9xoOOnn9It4N+KxiE2VUdj6431SKw== X-Google-Smtp-Source: APXvYqzZrSn59xpf0uxJ72KCLFL1NvLd9x8bUMo8eRVFuT6gwtwwL/Wqad4zHkNqjq/3f6ZARGHvfQ== X-Received: by 2002:a5d:438c:: with SMTP id i12mr15580983wrq.51.1580741242760; Mon, 03 Feb 2020 06:47:22 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/20] target/arm: Split out aarch32_cpsr_valid_mask Date: Mon, 3 Feb 2020 14:47:01 +0000 Message-Id: <20200203144716.32204-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::444 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Split this helper out of msr_mask in translate.c. At the same time, transform the negative reductive logic to positive accumulative logic. It will be usable along the exception paths. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/internals.h | 24 ++++++++++++++++++++++++ target/arm/translate.c | 17 +++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 6be8b2d1a9..0569c96fd9 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1061,6 +1061,30 @@ static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx) } } +static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, + const ARMISARegisters *id) +{ + uint32_t valid = CPSR_M | CPSR_AIF | CPSR_IL | CPSR_NZCV; + + if ((features >> ARM_FEATURE_V4T) & 1) { + valid |= CPSR_T; + } + if ((features >> ARM_FEATURE_V5) & 1) { + valid |= CPSR_Q; /* V5TE in reality*/ + } + if ((features >> ARM_FEATURE_V6) & 1) { + valid |= CPSR_E | CPSR_GE; + } + if ((features >> ARM_FEATURE_THUMB2) & 1) { + valid |= CPSR_IT; + } + if (isar_feature_jazelle(id)) { + valid |= CPSR_J; + } + + return valid; +} + /* * Parameters of a given virtual address, as extracted from the * translation control register (TCR) for a given regime. diff --git a/target/arm/translate.c b/target/arm/translate.c index d58c328e08..032f7074cb 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -2747,22 +2747,11 @@ static uint32_t msr_mask(DisasContext *s, int flags, int spsr) mask |= 0xff000000; /* Mask out undefined bits. */ - mask &= ~CPSR_RESERVED; - if (!arm_dc_feature(s, ARM_FEATURE_V4T)) { - mask &= ~CPSR_T; - } - if (!arm_dc_feature(s, ARM_FEATURE_V5)) { - mask &= ~CPSR_Q; /* V5TE in reality*/ - } - if (!arm_dc_feature(s, ARM_FEATURE_V6)) { - mask &= ~(CPSR_E | CPSR_GE); - } - if (!arm_dc_feature(s, ARM_FEATURE_THUMB2)) { - mask &= ~CPSR_IT; - } + mask &= aarch32_cpsr_valid_mask(s->features, s->isar); + /* Mask out execution state and reserved bits. */ if (!spsr) { - mask &= ~(CPSR_EXEC | CPSR_RESERVED); + mask &= ~CPSR_EXEC; } /* Mask out privileged bits. */ if (IS_USER(s)) From patchwork Mon Feb 3 14:47:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362857 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACDEE139A for ; Mon, 3 Feb 2020 14:53:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83CC22082E for ; Mon, 3 Feb 2020 14:53:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zgZtczPI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83CC22082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd6O-0001xV-Ov for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:53:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44583) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0Y-0006gP-Cl for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0X-0003A2-7j for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:26 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:39864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0X-00039A-18 for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:25 -0500 Received: by mail-wm1-x343.google.com with SMTP id c84so17460286wme.4 for ; Mon, 03 Feb 2020 06:47:24 -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=XUwRqb79kS8kGVWucDBWbJCOx+r2N7qBqeKITwaONR0=; b=zgZtczPIN+/hrjYqx8CgswcleCDQ44VBwl4AIca2dMGd0NK+ncAgMkK0qqosLjURLQ YJSgvVHNvG7AW5AntyuP7Ci6hmeNUXW26cQpRFI6/e9tdfUYChcKHQBRCNyJWP1Mb2gf 508JDwbRk+v8FMRiHd2PDUl0p0GRSjWE171v/sebMkAcJcPzpZAcOmcZ/ck9X7D1vKJb WgYFo/4Sf/oXKikA8z5bxC2Ror8WjcDnitV8fTgXKvOK2wRpconRww8QhvyrfWLOFbcm eDLg1ZHPn4ANnzWX9rup0+4Wj+FiZ4iem+GdVV7ZOiceIO6wNLy8Wa61BWUSMYUZn+xE w/+Q== 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=XUwRqb79kS8kGVWucDBWbJCOx+r2N7qBqeKITwaONR0=; b=B4x03CHy4/X2iFaVzbDywtK8j6Ct63o5yDfREE7VbMYaL4D7fi8V4I1gJ8sLdttwb8 j4XXJeDl3wzQnmbNZg5xBLoTqyNBFoyis5uPDMpmiUV/3z0UEoOo2EONpPIgW5wFR43O qhghOc85WzOmTmWV5yPnYo80ny23IGNwNZr3MaS1ReV8aLPC1JAIlf9256EeqcmB9HO8 8AcCVUTiqbuqC9kopytCOtRaCaeKIrztiSGPH8i6XOKN8Dk9opB6tI8NgfiG5AU7HI4d OOOI5O2no0Ne3HJJ+e6JT0u15EDalryla9AAMbHz5yDTLmtmNh8HvbXKVjjCoferuplp HFKQ== X-Gm-Message-State: APjAAAUFWde4gpQ6sjs3q3mcKH8ZxY7nU5tLANXcEf0IMZg5ujT6gdt3 YuoOcFaNygXnSIjL5mpFzQ8Z/7WOvFd+Jg== X-Google-Smtp-Source: APXvYqxSUU9SPHvZ6E7kPxVtsSvDlWqYQ3kxXgulklYti+ZnHIqGE3BnMZEtBuMWZobk9o+/tzZfsw== X-Received: by 2002:a05:600c:118a:: with SMTP id i10mr30361140wmf.142.1580741243790; Mon, 03 Feb 2020 06:47:23 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/20] target/arm: Replace CPSR_ERET_MASK with aarch32_cpsr_valid_mask Date: Mon, 3 Feb 2020 14:47:02 +0000 Message-Id: <20200203144716.32204-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::343 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" CPSR_ERET_MASK was a useless renaming of CPSR_RESERVED. The function also takes into account bits that the cpu does not support. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/cpu.h | 2 -- target/arm/op_helper.c | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 08b2f5d73e..694b074298 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1209,8 +1209,6 @@ void pmu_init(ARMCPU *cpu); #define CPSR_USER (CPSR_NZCV | CPSR_Q | CPSR_GE) /* Execution state bits. MRS read as zero, MSR writes ignored. */ #define CPSR_EXEC (CPSR_T | CPSR_IT | CPSR_J | CPSR_IL) -/* Mask of bits which may be set by exception return copying them from SPSR */ -#define CPSR_ERET_MASK (~CPSR_RESERVED) /* Bit definitions for M profile XPSR. Most are the same as CPSR. */ #define XPSR_EXCP 0x1ffU diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 27d16ad9ad..acf1815ea3 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -400,11 +400,14 @@ void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask) /* Write the CPSR for a 32-bit exception return */ void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t val) { + uint32_t mask; + qemu_mutex_lock_iothread(); arm_call_pre_el_change_hook(env_archcpu(env)); qemu_mutex_unlock_iothread(); - cpsr_write(env, val, CPSR_ERET_MASK, CPSRWriteExceptionReturn); + mask = aarch32_cpsr_valid_mask(env->features, &env_archcpu(env)->isar); + cpsr_write(env, val, mask, CPSRWriteExceptionReturn); /* Generated code has already stored the new PC value, but * without masking out its low bits, because which bits need From patchwork Mon Feb 3 14:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3082139A for ; Mon, 3 Feb 2020 14:50:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C80462080C for ; Mon, 3 Feb 2020 14:50:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HklwrR9Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C80462080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd3W-0003TB-Vc for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:50:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44602) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0Z-0006jA-6U for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0Y-0003By-6J for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:27 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:36696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0Y-0003B0-02 for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:26 -0500 Received: by mail-wm1-x343.google.com with SMTP id p17so17477676wma.1 for ; Mon, 03 Feb 2020 06:47:25 -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=HxFn/LN4dplxFN3c05IVUCGmUl6pKY2lLmTfpEZdCB0=; b=HklwrR9Q9Ev2LIPPJB0ioVBBHjHdEQMGP43Nk9WoIKlrDV7vPvpxGauzzmYHg/hnHM s9aXTJ/MKSmYjA/UG8GA4F1ltt1ZxuOP2alwqe+aszrSwofiNGhwwZoGo4mmYBR3L+15 2JI1KBz7Yi+q2TM5+xcpyFTcAsXQocTxCqh13LsAfa/v7oUgqypmT/VW7YO6K1awN4qd QlxZjIBktDlMxRr5o5qyt0Ea5aFOKWWtXMsB5P6LdycPcM5Jb9fL6fMTiFxhPOF1lKj5 W0degXKMZjHmyVdY8EszAE72cPRuH1HLEMgay8KhA/enx3Ok6w36/PY2JDcuLFO03Hb5 43UQ== 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=HxFn/LN4dplxFN3c05IVUCGmUl6pKY2lLmTfpEZdCB0=; b=bLf20vBSQ6+qbShGOc+LvhYZGp3858nz037qy/gSu420zd41aMT65+nEUW/i+Sbrl+ 7GXsqf81r0JepLNSUKowIcsYLDTqdqi1bRH9ZkuYeJld8MFe4KgQ34R/iF/lwxmP9P3U DmPvoHV+aNUP7U6s6xmNQMxTkmWA7Be28XDFSUgZbazDpefK7RW5jtWQI2XrywPf8pch lZvxns0zZzDEyrrOb1X0p5hDQmyfTYB9IzVR5nVuXVIyh3HrMipQs9KTn+nWgjo4f66X u31UnZWBCmq70xOnXmIgRjKPT2sKgh+08uRr3I2mWOC4O9sN6LUI5nw4TEG3G7fKQvvi 4Ygw== X-Gm-Message-State: APjAAAUIAPD0ugmKD6hctd0n7YwwA7EYS4agyjiLsjottN5H3cHPxjLa pfcM3JCuuz8K/UnQnzKbdLgwVXXMUw2SWw== X-Google-Smtp-Source: APXvYqwCLdDnBfrB7XHL6H6DsGq9fRMWcOYohlZuh85MJiSAstGKIb4KvwXJOSmA4EMXci1suRkJtw== X-Received: by 2002:a1c:6246:: with SMTP id w67mr28984376wmb.141.1580741244874; Mon, 03 Feb 2020 06:47:24 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/20] target/arm: Use aarch32_cpsr_valid_mask in helper_exception_return Date: Mon, 3 Feb 2020 14:47:03 +0000 Message-Id: <20200203144716.32204-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::343 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Using ~0 as the mask on the aarch64->aarch32 exception return was not even as correct as the CPSR_ERET_MASK that we had used on the aarch32->aarch32 exception return. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper-a64.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index bf45f8a785..0c9feba392 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -959,7 +959,7 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) { int cur_el = arm_current_el(env); unsigned int spsr_idx = aarch64_banked_spsr_index(cur_el); - uint32_t spsr = env->banked_spsr[spsr_idx]; + uint32_t mask, spsr = env->banked_spsr[spsr_idx]; int new_el; bool return_to_aa64 = (spsr & PSTATE_nRW) == 0; @@ -1014,7 +1014,8 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) * will sort the register banks out for us, and we've already * caught all the bad-mode cases in el_from_spsr(). */ - cpsr_write(env, spsr, ~0, CPSRWriteRaw); + mask = aarch32_cpsr_valid_mask(env->features, &env_archcpu(env)->isar); + cpsr_write(env, spsr, mask, CPSRWriteRaw); if (!arm_singlestep_active(env)) { env->uncached_cpsr &= ~PSTATE_SS; } From patchwork Mon Feb 3 14:47:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB408139A for ; Mon, 3 Feb 2020 14:52:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B22AA2082E for ; Mon, 3 Feb 2020 14:52:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="auU1JfQw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B22AA2082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd58-0006uA-Rt for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:52:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44619) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0a-0006me-3q for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0Z-0003De-1M for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:27 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:37780) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0Y-0003CI-RT for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:26 -0500 Received: by mail-wm1-x343.google.com with SMTP id f129so17476863wmf.2 for ; Mon, 03 Feb 2020 06:47:26 -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=Ovq6zgHOTulKMgq/xQFAYxCo50RIglYC4qMYC5kDj6w=; b=auU1JfQwFWFbSUdQSiEFjkA4aOa1gGSpGsPZWvy7UkWbApt8hct8aS0C2/+Ue5mRdn gpRNX9L/4dTUTUGP3ry3vGw/j9pC5U6cgamZMaN7nmcZJgnYS0ZStyz8vMqNgW+dQkIm dZ0EfrYf8R/EC+7xxFjiIr6x4iW26SEdp/mM5UxaLEu8H9763pYJu3YcxxQ6H57hrIey uRSKax1b+ci9FL78j5xjON8ctRT0v2B40+QIXhYpXqNmHS7Wf4tBT8T/pJ7p956nbNKD OZW6QnNHg8Mh+o+UCWgOeG9b7sf07qGFdv7UnBQk8OaFjDFSchkxqfNmqqqmHhoQ/EOv vw8g== 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=Ovq6zgHOTulKMgq/xQFAYxCo50RIglYC4qMYC5kDj6w=; b=aJzmady6C4X00TFEz6MeH9/+tnCJgmz9LTzZb8KlOs6WbMuaxova+uicXwA7OeeARW t/vRYX82ezzUxcHItZxOxlpCYgzvQn2NmdpIlz3rXM8nEH9qFs0vfbM2z7yRJBtK9aQj FUp5G9tVrV2dBWCFbk5iKBpRQIvwmpNvZL9HBO57ujHqRBAkBnqJKEKukWcdrumZEmXu CtDHxl7nEsAmTxTut3ykCv5E1fW9Hhcn5fg4qC6xldWOSQLoklV8NQ7VIFQrFpPYTAK2 Hp8GXJiqDHCxkWM/0tslAUuj+8zATKmEHlSdelAEBHFu231R4MMdwsE1g/Rdr5XadLvS AjsA== X-Gm-Message-State: APjAAAUvrPUpL6q0MX+8/EjsKh0ko59FY99/q6n0skGdspKsmX3nHB49 4sVtsrwNi7tIKBTzZM862lM8jdkbzAQexg== X-Google-Smtp-Source: APXvYqzjqwFe5eY4Kok2wFA0JxeiBF6n9T4/gvVZTnLA3zJ0g8EazZI3ThJT0mtBcSsPoANNNKuXXg== X-Received: by 2002:a7b:cbc9:: with SMTP id n9mr30109328wmi.89.1580741245709; Mon, 03 Feb 2020 06:47:25 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/20] target/arm: Remove CPSR_RESERVED Date: Mon, 3 Feb 2020 14:47:04 +0000 Message-Id: <20200203144716.32204-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::343 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The only remaining use was in op_helper.c. Use PSTATE_SS directly, and move the commentary so that it is more obvious what is going on. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 6 ------ target/arm/op_helper.c | 9 ++++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 694b074298..c6dff1d55b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1186,12 +1186,6 @@ void pmu_init(ARMCPU *cpu); #define CPSR_IT_2_7 (0xfc00U) #define CPSR_GE (0xfU << 16) #define CPSR_IL (1U << 20) -/* Note that the RESERVED bits include bit 21, which is PSTATE_SS in - * an AArch64 SPSR but RES0 in AArch32 SPSR and CPSR. In QEMU we use - * env->uncached_cpsr bit 21 to store PSTATE.SS when executing in AArch32, - * where it is live state but not accessible to the AArch32 code. - */ -#define CPSR_RESERVED (0x7U << 21) #define CPSR_J (1U << 24) #define CPSR_IT_0_1 (3U << 25) #define CPSR_Q (1U << 27) diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index acf1815ea3..af3020b78f 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -387,7 +387,14 @@ void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome) uint32_t HELPER(cpsr_read)(CPUARMState *env) { - return cpsr_read(env) & ~(CPSR_EXEC | CPSR_RESERVED); + /* + * We store the ARMv8 PSTATE.SS bit in env->uncached_cpsr. + * This is convenient for populating SPSR_ELx, but must be + * hidden from aarch32 mode, where it is not visible. + * + * TODO: ARMv8.4-DIT -- need to move SS somewhere else. + */ + return cpsr_read(env) & ~(CPSR_EXEC | PSTATE_SS); } void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask) From patchwork Mon Feb 3 14:47:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362837 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6789213A4 for ; Mon, 3 Feb 2020 14:50:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2616A2080C for ; Mon, 3 Feb 2020 14:50:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="blArgvmA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2616A2080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd3R-0003OY-52 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:50:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44641) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0b-0006qP-6f for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0a-0003Fb-56 for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:29 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:52393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0Z-0003EX-VJ for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:28 -0500 Received: by mail-wm1-x342.google.com with SMTP id p9so16235633wmc.2 for ; Mon, 03 Feb 2020 06:47:27 -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=C0PdOrMCFpbNK82WNUW0H1iqrpAaqeLX3nijX9wXiI0=; b=blArgvmAvO/Dvnfmg9Ej5qvcGd3b2fg7n3cAkZ4oJnEwjP4QPH3YqLR2xALFzwFjy4 OcA3FFA9loP5rTfVlmEDT5fzwjr2xw62EvWCpDEYuwKOZMjuXnp08ETJOuznLQF7VZbg Fjwvn8ALcoDzURyxaxvt5qgixkrl66lTjhRuspLoBW+ry5OtrtdjbZ5h12aovHtHZ3eR MVEqo6TH5uIwtHSSalzIcNH4uJ4jSPtngLPo1GWcjEHeyoY7NSgE9KV3LQgUwtYV5E24 vt5r2pMibeF7AnabDE23vpV5sNv027GwkrvtlAMeC0ToCbPK6NtafWGb4ACKGICLaC9Z PJ+g== 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=C0PdOrMCFpbNK82WNUW0H1iqrpAaqeLX3nijX9wXiI0=; b=YM41hE5v7xekaCyTi6nJ9bSPAJOjDaHXKmr8pOIBo9ZWfCMm1SU2IjNyr18wx71Vl+ PBqbyu+V+phFV3t6s0GgfRQMlPVcwmV9qSke0byxNZhf2n2TP2qbVXTtJVSNulA7MR9i rdSDV2chJj9hZYo27FCzlBTcLZzMFG319rAfpbIydliuPe9H+sEoouS8Vz8arJJ/YBAY l+vwLECnzkM+2KHLKhgDBreD83yOH/oiK4+yKfmnVww6gyRa88QfPc/mahdqLqQC+e2Z TUVs4pOCXSmY5nsXFHyF8Vq2u58y3vWlsPDzx5weGG30UIXy0tEcqeR6ZkZIW/oSSl7F Xsag== X-Gm-Message-State: APjAAAU/fgYf90qyIfO1bPCh/sXpR1zoYWe6kaYMGqttQfg2RfJ7OMAm mjFw4Tn0jyTneRvt1jT85hMUg+PSRzppKw== X-Google-Smtp-Source: APXvYqyg2ir4YWeay+SJ3FKeZ0G7iqSvMf15ajkdR43gn8G1uNLYc8QPYJVyvGxK7mxIzCyyX4gHSA== X-Received: by 2002:a05:600c:2150:: with SMTP id v16mr29005049wml.156.1580741246586; Mon, 03 Feb 2020 06:47:26 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/20] target/arm: Tidy msr_mask Date: Mon, 3 Feb 2020 14:47:05 +0000 Message-Id: <20200203144716.32204-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::342 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The CPSR_USER mask for IS_USER already avoids all of the RES0 bits as per aarch32_cpsr_valid_mask. Fix up the formatting. Signed-off-by: Richard Henderson --- target/arm/translate.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 032f7074cb..2b3bfcf7ca 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -2734,28 +2734,34 @@ static inline void gen_mulxy(TCGv_i32 t0, TCGv_i32 t1, int x, int y) /* Return the mask of PSR bits set by a MSR instruction. */ static uint32_t msr_mask(DisasContext *s, int flags, int spsr) { - uint32_t mask; + uint32_t mask = 0; - mask = 0; - if (flags & (1 << 0)) + if (flags & (1 << 0)) { mask |= 0xff; - if (flags & (1 << 1)) - mask |= 0xff00; - if (flags & (1 << 2)) - mask |= 0xff0000; - if (flags & (1 << 3)) - mask |= 0xff000000; - - /* Mask out undefined bits. */ - mask &= aarch32_cpsr_valid_mask(s->features, s->isar); - - /* Mask out execution state and reserved bits. */ - if (!spsr) { - mask &= ~CPSR_EXEC; } - /* Mask out privileged bits. */ - if (IS_USER(s)) + if (flags & (1 << 1)) { + mask |= 0xff00; + } + if (flags & (1 << 2)) { + mask |= 0xff0000; + } + if (flags & (1 << 3)) { + mask |= 0xff000000; + } + + if (IS_USER(s)) { + /* Mask out privileged bits. */ mask &= CPSR_USER; + } else { + /* Mask out undefined bits. */ + mask &= aarch32_cpsr_valid_mask(s->features, s->isar); + + /* Mask out execution state and reserved bits. */ + if (!spsr) { + mask &= ~CPSR_EXEC; + } + } + return mask; } From patchwork Mon Feb 3 14:47:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362843 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B700139A for ; Mon, 3 Feb 2020 14:50:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E55962080C for ; Mon, 3 Feb 2020 14:50:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wsH4G3Ow" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E55962080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd3h-0003ow-5G for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:50:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44647) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0b-0006rp-KU for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0a-0003Fv-Kw for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:29 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:40914) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0a-0003F6-Ct for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:28 -0500 Received: by mail-wm1-x344.google.com with SMTP id t14so17462977wmi.5 for ; Mon, 03 Feb 2020 06:47: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=DU+uDtDiqQV/fll1Aq36wX3lYUGSGI8gTP30+WnYS14=; b=wsH4G3OwCSDUN6ebKJC1Y7Gzoajq5jSYMXo0ghtb7Vbdhc7m3NEPg9VRtK2zYHy/tU 1c4c2i2an2vVPJYrGMVt4JUOk4D42AHlOVQasr5iw36GIF7KXEEFbhxaY/SIGissJMwR eEqbUtAsoQW+7SIHzYcIt+C5NpD1c0uyhF7pIBSG/eVJ+/thzJDLwUbzNxGk8jpaRix6 pTZeShOiUqvu9FK+F84E5UF3slNLPBAMFnaJ38K8pCaXLAo36WWP9Gs2Qvth5jP1iD3L huV88kpnwa78zTeslx6dwNMGv0e+OSbQtJPQcGw+6lIp/TIhhAK6wieUqdX1CeLFryjk FE9Q== 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=DU+uDtDiqQV/fll1Aq36wX3lYUGSGI8gTP30+WnYS14=; b=huwkQ8i7pR44RbacgtA9P67m1chve9IralqlsErKCs+2DxMf5HB2SEvJZ1TOgru16u xkDJYEQyyuc6CWUYqJxSD44k24VjSE+gNUtKinF0J4KAo8KEwuZITkyn5j+Bxt+4zolv MjzUQD3ooB86+TsMncGeDDM0Uz4kxwWlY5F2F1ge2IjsqaYxnAsQBssQ2xxeZJnOrrgi ARGLA6cID00L1zZreKaoViC6/pD01GDeisoWrtHcmeHBgXIdJL6qqZHS1fazEP/Her6N +tg8y/iF7SoWzwT4uHWb2yNCJI6n6VG3AOjaGlnRASH+Io5IRgCIEQKOFPzKvlMsE31Q s5NA== X-Gm-Message-State: APjAAAWbtkwfc5/alEerBkjMdP4nQ9LxVOhTOGZJL2nFc+YdvgNeuQwh nUb4NldhAjr10dOS/x20R2FAsvEI2FkHgw== X-Google-Smtp-Source: APXvYqzj0xyxHgsdwt63q2BB6qqxU7PMI12kPN+56ysafeMqRh4fKi+u7AXXO0/sQxtha/Fb2OQ3kw== X-Received: by 2002:a05:600c:2c13:: with SMTP id q19mr30318265wmg.144.1580741247250; Mon, 03 Feb 2020 06:47:27 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/20] target/arm: Introduce aarch64_pstate_valid_mask Date: Mon, 3 Feb 2020 14:47:06 +0000 Message-Id: <20200203144716.32204-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::344 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Use this along the exception return path, where we previously accepted any values. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/internals.h | 12 ++++++++++++ target/arm/helper-a64.c | 1 + 2 files changed, 13 insertions(+) diff --git a/target/arm/internals.h b/target/arm/internals.h index 0569c96fd9..034d98ad53 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1085,6 +1085,18 @@ static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, return valid; } +static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id) +{ + uint32_t valid; + + valid = PSTATE_M | PSTATE_DAIF | PSTATE_IL | PSTATE_SS | PSTATE_NZCV; + if (isar_feature_aa64_bti(id)) { + valid |= PSTATE_BTYPE; + } + + return valid; +} + /* * Parameters of a given virtual address, as extracted from the * translation control register (TCR) for a given regime. diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 0c9feba392..509ae93069 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -1032,6 +1032,7 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) cur_el, new_el, env->regs[15]); } else { env->aarch64 = 1; + spsr &= aarch64_pstate_valid_mask(&env_archcpu(env)->isar); pstate_write(env, spsr); if (!arm_singlestep_active(env)) { env->pstate &= ~PSTATE_SS; From patchwork Mon Feb 3 14:47:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362855 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 697911395 for ; Mon, 3 Feb 2020 14:53:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4035B20838 for ; Mon, 3 Feb 2020 14:53:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="r177u88x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4035B20838 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd6L-0001kt-Fy for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:53:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44674) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0d-0006wN-1R for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0b-0003Gt-NW for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:30 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0b-0003GH-Gy for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:29 -0500 Received: by mail-wm1-x343.google.com with SMTP id s10so16217338wmh.3 for ; Mon, 03 Feb 2020 06:47:29 -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=nUOaAe5msZQVUzw7VQcCZtKtZ1DmxqUChU+tqPOWLLg=; b=r177u88xyyUst+RS2vi+GtG/gMWs+ikpfXmekZKgX3PPXgKCmQl17MOymL/ajJAjF3 0ZyXu/1WUzGXH9w5KDva96wRcplboOEFSvh+wHS+YW5hj7nyf3EP1AiMwzYugm0UsxMX dnK6ut8F3pgDSwHCezZKZAag05XRc/AIcCxAKdAzvpALbWVRXuNcb+4wlnBypfiOy/Uy VWOGXrFnH5MWa8cb1hnRIahIxczrRrsLQiCIMg8XszI2zQTwj4f2eFxCrT8flLxJmjMI uCxgosSIrAOXvOOqTPDDFD0IkLfHITRUKJsSvwfQQKF0VZBgbNe4lIddQK8j31q9uIe7 2B6g== 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=nUOaAe5msZQVUzw7VQcCZtKtZ1DmxqUChU+tqPOWLLg=; b=fUnABCvueQthdx5g0aCCbZGbMbkogZknYzTh/hcSm1uVOrfLPnbXKxMDZS2G2H9Ibg RBPNsz2stuoyauLcK42PwGYq0RaHcDGlfoWE4K3EFMvUSRkEaqQ9G7RHZ1hCkfO7aflC BnIK2c5aLr7PrGVtzEAI3K/vpuoCIBDUp/v0umfD9q8Bitg7KubHba+buODfqsLbojjv VwIKhMe0k3X5CeN6MyYF9HKRG04rYq8jGTtpHCy+Prmm2AM8X7ZuSJzaZU/M3KlJ8Y16 0nTaVGvJLHZUTYUItbNo9Hvpin8+BHZ+2vH2F0QHWJ+2xl3iquBqX9j/u4EH8RJz82ed GtCg== X-Gm-Message-State: APjAAAUo+OOVCxS++rl81l4Vd7CfwUUDjYiLtrEA29G0DHCKap0YlChc eRuAuLZ+2RFwo0NR0b10olNxcp8ld/R/Pg== X-Google-Smtp-Source: APXvYqz7no7TZS5bstypyqzx7fB4UVdkAR+X53hmw1M10IU/DkdFtmcvgXP86Z+b76IkycQVTYhL9g== X-Received: by 2002:a05:600c:2109:: with SMTP id u9mr30905584wml.183.1580741248306; Mon, 03 Feb 2020 06:47:28 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/20] target/arm: Update MSR access for PAN Date: Mon, 3 Feb 2020 14:47:07 +0000 Message-Id: <20200203144716.32204-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::343 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" For aarch64, there's a dedicated msr (imm, reg) insn. For aarch32, this is done via msr to cpsr; and writes from el0 are ignored. Since v8.0, the CPSR_RESERVED bits have been allocated. We are not yet implementing ARMv8.0-SSBS or ARMv8.4-DIT, so retain CPSR_RESERVED for now, so that the bits remain RES0. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- v2: Move regdef to file scope; merge patch for CPSR_RESERVED: do not remove CPSR_SSBS from CPSR_RESERVED yet, mask PAN from CPSR if feature not enabled (pmm). v3: Update for cpsr_valid_mask etc. --- target/arm/cpu.h | 2 ++ target/arm/internals.h | 6 ++++++ target/arm/helper.c | 21 +++++++++++++++++++++ target/arm/translate-a64.c | 14 ++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c6dff1d55b..65a0ef8cd6 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1186,6 +1186,7 @@ void pmu_init(ARMCPU *cpu); #define CPSR_IT_2_7 (0xfc00U) #define CPSR_GE (0xfU << 16) #define CPSR_IL (1U << 20) +#define CPSR_PAN (1U << 22) #define CPSR_J (1U << 24) #define CPSR_IT_0_1 (3U << 25) #define CPSR_Q (1U << 27) @@ -1250,6 +1251,7 @@ void pmu_init(ARMCPU *cpu); #define PSTATE_BTYPE (3U << 10) #define PSTATE_IL (1U << 20) #define PSTATE_SS (1U << 21) +#define PSTATE_PAN (1U << 22) #define PSTATE_V (1U << 28) #define PSTATE_C (1U << 29) #define PSTATE_Z (1U << 30) diff --git a/target/arm/internals.h b/target/arm/internals.h index 034d98ad53..f6709a2b08 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1081,6 +1081,9 @@ static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features, if (isar_feature_jazelle(id)) { valid |= CPSR_J; } + if (isar_feature_aa32_pan(id)) { + valid |= CPSR_PAN; + } return valid; } @@ -1093,6 +1096,9 @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id) if (isar_feature_aa64_bti(id)) { valid |= PSTATE_BTYPE; } + if (isar_feature_aa64_pan(id)) { + valid |= PSTATE_PAN; + } return valid; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 795ef727d0..90a22921dc 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4163,6 +4163,24 @@ static void aa64_daif_write(CPUARMState *env, const ARMCPRegInfo *ri, env->daif = value & PSTATE_DAIF; } +static uint64_t aa64_pan_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + return env->pstate & PSTATE_PAN; +} + +static void aa64_pan_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + env->pstate = (env->pstate & ~PSTATE_PAN) | (value & PSTATE_PAN); +} + +static const ARMCPRegInfo pan_reginfo = { + .name = "PAN", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 2, .opc2 = 3, + .type = ARM_CP_NO_RAW, .access = PL1_RW, + .readfn = aa64_pan_read, .writefn = aa64_pan_write +}; + static CPAccessResult aa64_cacheop_access(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) @@ -7608,6 +7626,9 @@ void register_cp_regs_for_features(ARMCPU *cpu) if (cpu_isar_feature(aa64_lor, cpu)) { define_arm_cp_regs(cpu, lor_reginfo); } + if (cpu_isar_feature(aa64_pan, cpu)) { + define_one_arm_cp_reg(cpu, &pan_reginfo); + } if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { define_arm_cp_regs(cpu, vhe_reginfo); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 49631c2340..d8ba240a15 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1602,6 +1602,20 @@ static void handle_msr_i(DisasContext *s, uint32_t insn, s->base.is_jmp = DISAS_NEXT; break; + case 0x04: /* PAN */ + if (!dc_isar_feature(aa64_pan, s) || s->current_el == 0) { + goto do_unallocated; + } + if (crm & 1) { + set_pstate_bits(PSTATE_PAN); + } else { + clear_pstate_bits(PSTATE_PAN); + } + t1 = tcg_const_i32(s->current_el); + gen_helper_rebuild_hflags_a64(cpu_env, t1); + tcg_temp_free_i32(t1); + break; + case 0x05: /* SPSel */ if (s->current_el == 0) { goto do_unallocated; From patchwork Mon Feb 3 14:47:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEBF11395 for ; Mon, 3 Feb 2020 14:54:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74CB62082E for ; Mon, 3 Feb 2020 14:54:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="unf8cXmi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74CB62082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd7W-0004RV-Ja for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:54:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44686) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0d-0006yK-JR for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0c-0003Hg-Kk for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:31 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:40136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0c-0003Gy-DX for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:30 -0500 Received: by mail-wr1-x441.google.com with SMTP id j104so18529846wrj.7 for ; Mon, 03 Feb 2020 06:47:30 -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=6oZGlz7Genf3xLLU7zOHALEHpqBlGtMbmuDPmda8R6w=; b=unf8cXmi/oAz6FJzFInSy8M6FDjUrrLW1BkuSpjab1Aq0p6WHQtLXcY4gJbrz4Tlh3 /HtsQgo7shBWyV7ZMvdBIuFCJo+Tnu643yZo8FG1J0vl32r3uyaP9T0YdOOZdR7hqIqk t1uvkvzauouUF6/MPux3czRMFNiEqNqPb6KoL08QQ8GB0bLC1dQJPDnbPdpnTvCHTrF/ vE6HTIjTfnrT9RsC9lYZgXbN4Po4FMzYwMcxZSbNBrarnNwaq5bR5DeJLwq12jJJn8W1 Ci5G6lWZIlrYKHJ0z4uFf5HyC5xetr6HbMTpIRNzLuco3xo3IEELh6Nv2Vi1Fmx2maO/ 4RqA== 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=6oZGlz7Genf3xLLU7zOHALEHpqBlGtMbmuDPmda8R6w=; b=Zy7STHRkIweBlV9YLsNlBHVglEP7rAJd/BnN4nMulYzP1uk7E5gaMDx9GAGKdT9vUE nhyedI0RhDW/0GoWFM1Ow8rGFKYDCnmD6Qa01xiz6VdkBDQxV0O5hiQ8gkZO8Cu2ZS7l NEU32b06u9I26/lRLtxPNNUpERYSroxjg/eXxC9OXuTZeCDKzCT0UboKIHMsw4WxhJLS JRFGdvPdhA+p2muSwQbZHKQFEvG+shd7mlgQyWQbWfdeJAhNStcOhXp0dHTGU447AeWg L1GTTOlTCWNdT4WWqgmn3C4AHOinFjCXkqj56sCAeZCRK9erqLZo+f9D2JIyvrwT1Gc9 XxgQ== X-Gm-Message-State: APjAAAUVr0jhfTnkDC/xQ93BF82sn+bmNYzlqfkX1G+auDLJRL9aUh06 16gCzuh8VirdqGOgAyrYmLZtRaGBh1df/g== X-Google-Smtp-Source: APXvYqx03SR44SPyD0TjGphSPo8KlYPLoADcfL7zaXPTE5QRlQ5paayknTkm5BB1XrvEr+UQE+FChQ== X-Received: by 2002:adf:ff8c:: with SMTP id j12mr15846902wrr.354.1580741249231; Mon, 03 Feb 2020 06:47:29 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/20] target/arm: Update arm_mmu_idx_el for PAN Date: Mon, 3 Feb 2020 14:47:08 +0000 Message-Id: <20200203144716.32204-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Examine the PAN bit for EL1, EL2, and Secure EL1 to determine if it applies. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 90a22921dc..638abe6af0 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11904,13 +11904,22 @@ ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el) return ARMMMUIdx_E10_0; case 1: if (arm_is_secure_below_el3(env)) { + if (env->pstate & PSTATE_PAN) { + return ARMMMUIdx_SE10_1_PAN; + } return ARMMMUIdx_SE10_1; } + if (env->pstate & PSTATE_PAN) { + return ARMMMUIdx_E10_1_PAN; + } return ARMMMUIdx_E10_1; case 2: /* TODO: ARMv8.4-SecEL2 */ /* Note that TGE does not apply at EL2. */ if ((env->cp15.hcr_el2 & HCR_E2H) && arm_el_is_aa64(env, 2)) { + if (env->pstate & PSTATE_PAN) { + return ARMMMUIdx_E20_2_PAN; + } return ARMMMUIdx_E20_2; } return ARMMMUIdx_E2; From patchwork Mon Feb 3 14:47: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: 11362867 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B8921395 for ; Mon, 3 Feb 2020 14:56:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 41BDC2082E for ; Mon, 3 Feb 2020 14:56:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PEvOkN9E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41BDC2082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd90-0007BK-Bf for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:56:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44706) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0f-00071S-3a for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0d-0003Ib-Fb for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:33 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:46009) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0d-0003Hm-9Y for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:31 -0500 Received: by mail-wr1-x442.google.com with SMTP id a6so18494509wrx.12 for ; Mon, 03 Feb 2020 06:47: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=4YEwUgXqMm4/ex3vX/ecAj+lmJE3iRPAxqCBL/YGcWE=; b=PEvOkN9EB66cctkdi8BaRf1PrzLNOaa4iXeV2OheGE7R78rHNQ0VgvpUvqjJyHSfZw kPR29tbOK9ccoF4mOI5RTs9rZeZrkAU2Oh46mMca1oy6fHYcM7Pm5bpadUvlTGVoVZbW 3OhPdhGlHCLI8YKNEQfBe6/c9Ovp3O87KDgzAwjhA5tNjPkyADmR+Rzmi7BIFW5NmHG5 nDVunaaQxGPkF1/sFnY2uyO3KrVDBzKNZA0l87KDvTkAKLirov6W/R1jA7DQI97SetYj cKKYssM4Dde6LAZaHcegJ5A5G5KRTxwYQdfO4PvtgvtTvInwVWMY6iHb8tmRQPsUXCxm auxg== 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=4YEwUgXqMm4/ex3vX/ecAj+lmJE3iRPAxqCBL/YGcWE=; b=aWTAn31uKR8KadDYhsBMMO5Eg7qOe6L2LYk1WsD5UT4sTR3IZG7R9pPcbNXWhZWf89 W/38whqsVEWswf4TkHX6VLS+zdJWm+CGSQXhpl/7AtlwlN+alfESaaVb1K1FLv3t8jdg SOm/kygaettYHzLCNnny/XCFMeF5jz1IASnH4VWX/z0kDyG6HtKwOVAHhbfqyB/DI3PF Qh4ahaWtY/518KYuMnzrLSqun6xCSUMO5nady5iaUDaP3GMqkPc2sjZj/XXBsX2hlWb1 c2LJNxoVvmMM+ilPzcCiF+NyH4MJwwPxnGH5ChX5mzypbqy0gUA8agZTk9PIyOYzxqrB dt7w== X-Gm-Message-State: APjAAAXVpNCd7VUw2xR2CZ5SVC0errZE6o0mG/PQsmm01IYwJTg7T71t EWYXaTIENjzRDJ2h2bNLeEu6KmFGdxfAxw== X-Google-Smtp-Source: APXvYqyCJm+SMzPv8vyhjLW9IX4Uos0fpAOIkuAigrnfnDar8Ofq3wMca/QX25162vXbvFn6l6AGbg== X-Received: by 2002:adf:f986:: with SMTP id f6mr12272124wrr.182.1580741250129; Mon, 03 Feb 2020 06:47:30 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 13/20] target/arm: Enforce PAN semantics in get_S1prot Date: Mon, 3 Feb 2020 14:47:09 +0000 Message-Id: <20200203144716.32204-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::442 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+patchwork-qemu-devel=patchwork.kernel.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(+) 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 638abe6af0..18e4cbb63c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9578,6 +9578,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); } From patchwork Mon Feb 3 14:47:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362847 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24F64139A for ; Mon, 3 Feb 2020 14:52:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF8E72082E for ; Mon, 3 Feb 2020 14:52:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="K/jTU8I/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF8E72082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd57-0006qF-5h for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:52:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44729) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0g-000735-CB for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0f-0003K8-31 for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:34 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:39866) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0e-0003Io-9I for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:33 -0500 Received: by mail-wm1-x344.google.com with SMTP id c84so17460914wme.4 for ; Mon, 03 Feb 2020 06:47:32 -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=LdEIwR4tXW88OebyAe9sT02I9h4JxavRP0Kmc9yS4sc=; b=K/jTU8I/+Mtqu3Hpko6DMMrKVbygJbXNlwjj48HH/fj7r+F3Yv/Xs5cAYV6w0HErb7 PVTMGa/Sn9wObfxpI/JvtfwxGxl7z+DPx5CZHAmglE9nOy24DlXueri1IA5lqUqGKvjT gTOHfO9H3JNnBoHd/Ir5fFbcRS5RuAOsY7818Eyt/WE+xkrOQWpkKSw/Yg05ib6RpPQu Ij4Zz5hCiDqmaPFsPPYXyfTGMZpwY9JVz3H8ToQNi7xTWZ5sgb7kAYiUsr9d7NodNTVm BHgxDnGFiUzFD81ExiBQrXdXPfdjOT3SluU/AY5cCRuuRMU3qGne1KGG/BISfRsAp+gE /lJA== 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=LdEIwR4tXW88OebyAe9sT02I9h4JxavRP0Kmc9yS4sc=; b=QVU5KxtbDk1vP47FnbS4OEY8R2nX+hs1K+DSrmwyqkiKMNQaLiA9tkzXrpj9f7rvF2 RdERLYtGCmYa65e9+rmAzJvFWbmqLWhowHinsxseYKa20DZ3FMa+KpTElg4lUQLDfpYt H8ZB0smvvvVjhIKRV6J7NW2hpFEu327xoowHzDgEIBCnvizdmHvhUGZFPbYyIxiZPECM 0KsF0cLC5p440DjcNruEWY9ZEaPa2Jg01SRPwXTepbhlLCB2zLFEVGx7SNTWhU4sxmLl bAxJ6jj1mLBqN2c+h5eGsBjAaKrcqUoldADjxIp3cIgZ0+QQoxaAOyjIzyXr1mHnqBvi 3+Vg== X-Gm-Message-State: APjAAAVkLWD99wbthmw4EXuZR2nAUrgoEHET4LD1Yva/WdhyE8TB4Jkp sYuYdYqEsq1klfFSBkhYwX1qSIxo7MIV3A== X-Google-Smtp-Source: APXvYqyXaPYeeTnpk7b2l6yL3WScnDn+N1aChU2GGMfAk+JZopSAbSoDzFS0NhkRQc0eDFEuuzIrWQ== X-Received: by 2002:a7b:cbc9:: with SMTP id n9mr30109691wmi.89.1580741251096; Mon, 03 Feb 2020 06:47:31 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/20] target/arm: Set PAN bit as required on exception entry Date: Mon, 3 Feb 2020 14:47:10 +0000 Message-Id: <20200203144716.32204-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::344 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The PAN bit is preserved, or set as per SCTLR_ELx.SPAN, plus several other conditions listed in the ARM ARM. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- v2: Tidy preservation of CPSR_PAN in take_aarch32_exception (pmm). --- target/arm/helper.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 18e4cbb63c..4c0eb7e7d9 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8772,8 +8772,12 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, uint32_t mask, uint32_t offset, uint32_t newpc) { + int new_el; + /* Change the CPU state so as to actually take the exception. */ switch_mode(env, new_mode); + new_el = arm_current_el(env); + /* * For exceptions taken to AArch32 we must clear the SS bit in both * PSTATE and in the old-state value we save to SPSR_, so zero it now. @@ -8786,7 +8790,7 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode; /* Set new mode endianness */ env->uncached_cpsr &= ~CPSR_E; - if (env->cp15.sctlr_el[arm_current_el(env)] & SCTLR_EE) { + if (env->cp15.sctlr_el[new_el] & SCTLR_EE) { env->uncached_cpsr |= CPSR_E; } /* J and IL must always be cleared for exception entry */ @@ -8797,6 +8801,12 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, env->thumb = (env->cp15.sctlr_el[2] & SCTLR_TE) != 0; env->elr_el[2] = env->regs[15]; } else { + /* CPSR.PAN is preserved unless target is EL1 and SCTLR.SPAN == 0. */ + if (cpu_isar_feature(aa64_pan, env_archcpu(env)) + && new_el == 1 + && !(env->cp15.sctlr_el[1] & SCTLR_SPAN)) { + env->uncached_cpsr |= CPSR_PAN; + } /* * this is a lie, as there was no c1_sys on V4T/V5, but who cares * and we should just guard the thumb mode on V4 @@ -9059,6 +9069,7 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) unsigned int new_el = env->exception.target_el; target_ulong addr = env->cp15.vbar_el[new_el]; unsigned int new_mode = aarch64_pstate_mode(new_el, true); + unsigned int old_mode; unsigned int cur_el = arm_current_el(env); /* @@ -9138,20 +9149,43 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) } if (is_a64(env)) { - env->banked_spsr[aarch64_banked_spsr_index(new_el)] = pstate_read(env); + old_mode = pstate_read(env); aarch64_save_sp(env, arm_current_el(env)); env->elr_el[new_el] = env->pc; } else { - env->banked_spsr[aarch64_banked_spsr_index(new_el)] = cpsr_read(env); + old_mode = cpsr_read(env); env->elr_el[new_el] = env->regs[15]; aarch64_sync_32_to_64(env); env->condexec_bits = 0; } + env->banked_spsr[aarch64_banked_spsr_index(new_el)] = old_mode; + qemu_log_mask(CPU_LOG_INT, "...with ELR 0x%" PRIx64 "\n", env->elr_el[new_el]); + if (cpu_isar_feature(aa64_pan, cpu)) { + /* The value of PSTATE.PAN is normally preserved, except when ... */ + new_mode |= old_mode & PSTATE_PAN; + switch (new_el) { + case 2: + /* ... the target is EL2 with HCR_EL2.{E2H,TGE} == '11' ... */ + if ((arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) + != (HCR_E2H | HCR_TGE)) { + break; + } + /* fall through */ + case 1: + /* ... the target is EL1 ... */ + /* ... and SCTLR_ELx.SPAN == 0, then set to 1. */ + if ((env->cp15.sctlr_el[new_el] & SCTLR_SPAN) == 0) { + new_mode |= PSTATE_PAN; + } + break; + } + } + pstate_write(env, PSTATE_DAIF | new_mode); env->aarch64 = 1; aarch64_restore_sp(env, new_el); From patchwork Mon Feb 3 14:47:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DF2E1395 for ; Mon, 3 Feb 2020 14:52:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4542F2082E for ; Mon, 3 Feb 2020 14:52:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NRMGruGr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4542F2082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd5F-0007Cm-CL for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:52:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44737) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0h-00073o-9U for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0f-0003Ka-HZ for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:35 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:43390) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0f-0003Jl-BX for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:33 -0500 Received: by mail-wr1-x444.google.com with SMTP id z9so6315190wrs.10 for ; Mon, 03 Feb 2020 06:47:33 -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=ABlKw+Ee4niadP/JeYKLANZAwZirqXwkkASseIFrEXM=; b=NRMGruGroHf7AClzZs+T+myM+48vTTnzH8EKIDhAJ0hhN6mdEn3XgR0N2xWfouDVyw +HA4O4eoF91xAPBn4q33CoXgQ2KJnGQ5MkcEyLNquNNXvknLyaCnO9SlHsCVLv7tCpTH EyqeZy9/E7OdqW5qyRKQBVckQL6rt1y4xZAGSB2wXrxs4f0EoBI2J1aeJiPeFMQhLuSM 0N9Lw3SYgeIT1lGEjdYcjqxdsj0NJ85TBzN35ol6RfsiiAD+z5XotnO10LvHZSsjEfUz SdRb8Oz5sjbtE5H9zwi0izxDuRSn9yCwZgTnjozwRh4dC5K4MYRwI8Il6CItluU9LBNw RjSg== 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=ABlKw+Ee4niadP/JeYKLANZAwZirqXwkkASseIFrEXM=; b=hKQso2eefT4SPuxaKowVhrBeHQrHd4o2Hj/DOheDvnRU5b6S9Znat0f7No0VwEOSiA MjEEWzkhXo+jzh9jZLL1ZBCOGCg9n1i+UdLpUBRbbBJODJ8EvdIRp8mXSSG8D5Gmy09n KW1B2nnuk1LgWM2epff+LfM5G/0i7PUHqhfMvJsXsyTWqmDAYuXf+lDz1OAhgRiFu5kV HneYonoAKXxjGAXj0jJp9IO3SEYzAGnqyIIRb8dL8OcS1+GIUveKhGYyGneB6fJPG2Xh pQgXU/u4ot4vd0y5+67RYmfG9beJNm88A/883pErngaiRVXFX2UPpROZKeRPs8W6HJst MMSw== X-Gm-Message-State: APjAAAWdzpuinYBDi8cUF4lyRrbndIJ3IleWM/vLm5doVI6uZusCJZ6V zqPZyDXinrCWtzwJLni2qkf/+TUO2l4jaQ== X-Google-Smtp-Source: APXvYqxRuehRWyOBqfCo0Cd2eNaFY8UuVVZ8pHUhVRBa3nxnNb0ozjUJvQi3pP7KnQ685WbTMPaJiA== X-Received: by 2002:adf:f18e:: with SMTP id h14mr14627191wro.265.1580741252117; Mon, 03 Feb 2020 06:47:32 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/20] target/arm: Implement ATS1E1 system registers Date: Mon, 3 Feb 2020 14:47:11 +0000 Message-Id: <20200203144716.32204-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::444 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This is a minor enhancement over ARMv8.1-PAN. The *_PAN mmu_idx are used with the existing do_ats_write. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v2: Move regdefs to file scope (pmm). --- target/arm/helper.c | 56 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 4c0eb7e7d9..e69cde801f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3409,16 +3409,21 @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) switch (ri->opc2 & 6) { case 0: - /* stage 1 current state PL1: ATS1CPR, ATS1CPW */ + /* stage 1 current state PL1: ATS1CPR, ATS1CPW, ATS1CPRP, ATS1CPWP */ switch (el) { case 3: mmu_idx = ARMMMUIdx_SE3; break; case 2: - mmu_idx = ARMMMUIdx_Stage1_E1; - break; + g_assert(!secure); /* TODO: ARMv8.4-SecEL2 */ + /* fall through */ case 1: - mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1; + if (ri->crm == 9 && (env->uncached_cpsr & CPSR_PAN)) { + mmu_idx = (secure ? ARMMMUIdx_SE10_1_PAN + : ARMMMUIdx_Stage1_E1_PAN); + } else { + mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1; + } break; default: g_assert_not_reached(); @@ -3487,8 +3492,13 @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, switch (ri->opc2 & 6) { case 0: switch (ri->opc1) { - case 0: /* AT S1E1R, AT S1E1W */ - mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1; + case 0: /* AT S1E1R, AT S1E1W, AT S1E1RP, AT S1E1WP */ + if (ri->crm == 9 && (env->pstate & PSTATE_PAN)) { + mmu_idx = (secure ? ARMMMUIdx_SE10_1_PAN + : ARMMMUIdx_Stage1_E1_PAN); + } else { + mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1; + } break; case 4: /* AT S1E2R, AT S1E2W */ mmu_idx = ARMMMUIdx_E2; @@ -6692,6 +6702,32 @@ static const ARMCPRegInfo vhe_reginfo[] = { REGINFO_SENTINEL }; +#ifndef CONFIG_USER_ONLY +static const ARMCPRegInfo ats1e1_reginfo[] = { + { .name = "AT_S1E1R", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 0, + .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .writefn = ats_write64 }, + { .name = "AT_S1E1W", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, + .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .writefn = ats_write64 }, + REGINFO_SENTINEL +}; + +static const ARMCPRegInfo ats1cp_reginfo[] = { + { .name = "ATS1CPRP", + .cp = 15, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 0, + .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .writefn = ats_write }, + { .name = "ATS1CPWP", + .cp = 15, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1, + .access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, + .writefn = ats_write }, + REGINFO_SENTINEL +}; +#endif + void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ @@ -7629,6 +7665,14 @@ void register_cp_regs_for_features(ARMCPU *cpu) if (cpu_isar_feature(aa64_pan, cpu)) { define_one_arm_cp_reg(cpu, &pan_reginfo); } +#ifndef CONFIG_USER_ONLY + if (cpu_isar_feature(aa64_ats1e1, cpu)) { + define_arm_cp_regs(cpu, ats1e1_reginfo); + } + if (cpu_isar_feature(aa32_ats1e1, cpu)) { + define_arm_cp_regs(cpu, ats1cp_reginfo); + } +#endif if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { define_arm_cp_regs(cpu, vhe_reginfo); From patchwork Mon Feb 3 14:47:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362871 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2FCB13A4 for ; Mon, 3 Feb 2020 14:57:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A96142082E for ; Mon, 3 Feb 2020 14:57:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RzAX5rZP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A96142082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iydAG-0001pK-TV for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:57:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44755) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0i-000761-AA for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0h-0003Lj-9i for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:36 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:37182) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0g-0003L8-Jp for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:35 -0500 Received: by mail-wr1-x444.google.com with SMTP id w15so18557027wru.4 for ; Mon, 03 Feb 2020 06:47:34 -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=pbTFZCO7ADOXNmgFtzr7ygDnLBWMHSNndfGhWIzZQwI=; b=RzAX5rZP5/FBD+yNLHkwMSd679Kwq78O9fLcdmxWoX84EZT6LgKiqA+BqzMJ4v6yXv b4n7SPSFpeFUXYIF9Bn1Yxb7oL7FcNWfXgA39wPGPyhp2MR3nOcAc8HX0tkoMcGKy7d3 Jw+/0xkPHTvbACleBLlk0m/dbNBC64+RBuwlYm6cAnPpR6eeKNp4d6axI9dSb5ramOf0 bLRZUnUMJEZDF/GWGFH1iCDLsWILjHramcxVCvnE40vtrMI3N1poh3Tu4YmKWtFbX+53 LycjB8ux8nVQO4zT7AHgzeLhlafnIgKW0A+SMqqLx0bCXrnBndbDHoEhyrEnuztORM4M OuHw== 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=pbTFZCO7ADOXNmgFtzr7ygDnLBWMHSNndfGhWIzZQwI=; b=qCL63cgrNdhHl3bx18dTXeqMeXUY1dvOZMRQoFqv3bYCafzl+aRA6eyqZVclJQKEpA MOnkE4+td50geh2CTu7ZU8ZB4IHxCMKisti9wqoO8X1CkX73r/+yfq/D+OYqVMey8TNF f9gCbApxBQbOo7JTegAD7mmrnwpyjQY6ig7a2RioPQ9wZZME8sg3zsvfkXK//5y85gOl qEIQttWCRfRplTv7Mwt7PBFlLY6ol0EmUHZ/RdnWpuF6JdI09qPjTI7Ss/qb120JqBYq cpsVO9B33V1M6EX5FILzcDorLNfW5n8/ZpWdgzil6kgtusgOnWASt1oUjIGlEBqJ4Lm5 6OKg== X-Gm-Message-State: APjAAAVmYc2dmrfKIBJZ2BjwuLh6VXhFu3jfpUW2lNcnszn0ySrolq1r 5WL3mW//mDtAFTloe7MIfY2/K4vljZUQ5g== X-Google-Smtp-Source: APXvYqzG+CCELV5hLIIj8g4ne/4b7VD24A+RUsT87T/yAId+tY2iBh/KHpmO3qCjbX+Q9CX/TUHTaw== X-Received: by 2002:adf:de0b:: with SMTP id b11mr13585826wrm.89.1580741253484; Mon, 03 Feb 2020 06:47:33 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 16/20] target/arm: Enable ARMv8.2-ATS1E1 in -cpu max Date: Mon, 3 Feb 2020 14:47:12 +0000 Message-Id: <20200203144716.32204-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::444 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This includes enablement of ARMv8.1-PAN. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.c | 4 ++++ target/arm/cpu64.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b0762a76c4..de733aceeb 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2709,6 +2709,10 @@ static void arm_max_initfn(Object *obj) t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ cpu->isar.mvfr2 = t; + t = cpu->id_mmfr3; + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ + cpu->id_mmfr3 = t; + t = cpu->id_mmfr4; t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ cpu->id_mmfr4 = t; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index c80fb5fd43..57fbc5eade 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -673,6 +673,7 @@ static void aarch64_max_initfn(Object *obj) t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); + t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */ cpu->isar.id_aa64mmfr1 = t; /* Replicate the same data to the 32-bit id registers. */ @@ -693,6 +694,10 @@ static void aarch64_max_initfn(Object *obj) u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1); cpu->isar.id_isar6 = u; + u = cpu->id_mmfr3; + u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */ + cpu->id_mmfr3 = u; + /* * FIXME: We do not yet support ARMv8.2-fp16 for AArch32 yet, * so do not set MVFR1.FPHP. Strictly speaking this is not legal, From patchwork Mon Feb 3 14:47:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362865 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26AAC139A for ; Mon, 3 Feb 2020 14:55:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F1C742082E for ; Mon, 3 Feb 2020 14:55:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jgremrvH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1C742082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd80-0005Wa-5i for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:55:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44771) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0j-00079n-KQ for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0i-0003NN-FM for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:37 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:55601) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0i-0003Lr-7z for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:36 -0500 Received: by mail-wm1-x341.google.com with SMTP id q9so16197249wmj.5 for ; Mon, 03 Feb 2020 06:47:36 -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=wrkzS6FRdoEngMPC4+Uz0wTjeXPKrRoSSZpCbAQkd2I=; b=jgremrvH46XWHnkFF9TFiUtcMcONvE0F2XV8SUqEwKWzcDDgPWD7Z3duoxnST+vaJk bbFmpaCrdtikrFMCnJItFCFU2ES3CVOgivs/kRm4tP+bQM6V/OhxXlkte9W4gOfd01lU XgiMZ2JsnDlvFUP56atlBqjzrvjFPNgErOyycgIF9olKsNI2jYLyV/0s23BuL8oy8/uY KBNdKWrYIQNluk9OQSlo/EmNUD7hZZvxRtQ7uju4jbJwpWyTlKwW6EX8RRoErCLuULb5 KFzQcWJurO0SZXQ8YveWRbmZCITjuTl3x6VUOx4/V8jtIxlXBcKykryEekOuUKnVUI8O 0+Zw== 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=wrkzS6FRdoEngMPC4+Uz0wTjeXPKrRoSSZpCbAQkd2I=; b=FR4waD/ZDEKqnnKaOG5kZJz7WpSOBfTuqYu9KJSJJL4CzF7CvqRS5e00UX7NaA19v+ zwOdoOG/f9ovHMd11phTDc+ZZpeN5jEDQOA88z+hE2dXoISENX9z0hbs5x6trNrRAQGv RpfVsYfFajE/Q8CEtHNJzK1LEhdkmFrFKlQmag8NMHMgBHgK/jIwVKyiOo2p9ErX4RJw tRyNeYq8CxolJDx0d6Bqq0EXt2K4iAhIuMj+MXNTd4Z3RwyxFUTjNLh5ai1MjvY0LQ2q xFpwLMJnG3J0JtnuMbFRuqLAOvRv/MNbgNB7WZJ9xeGZIMiRwtFi6Zn7HS5ICf5MYQVM 2Mhw== X-Gm-Message-State: APjAAAUlGjogU3rG2BI40j5gKtOvl6/4vOItliRVjL5VYgw/qWwOvqzD 8lXcxcgpxbds+lPeJhvTP2D6bY5v45OjGQ== X-Google-Smtp-Source: APXvYqxQfdoq4ol+peGQwPnJ0QtyheU7OJgee53HQrJ7Z4Vr+7MSEpG2gg3WVyu6qS5awcSv93qs8A== X-Received: by 2002:a05:600c:2c13:: with SMTP id q19mr30318792wmg.144.1580741255001; Mon, 03 Feb 2020 06:47:35 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 17/20] target/arm: Add ID_AA64MMFR2_EL1 Date: Mon, 3 Feb 2020 14:47:13 +0000 Message-Id: <20200203144716.32204-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::341 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Add definitions for all of the fields, up to ARMv8.5. Convert the existing RESERVED register to a full register. Query KVM for the value of the register for the host. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 17 +++++++++++++++++ target/arm/helper.c | 4 ++-- target/arm/kvm64.c | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 65a0ef8cd6..71879393c2 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -871,6 +871,7 @@ struct ARMCPU { uint64_t id_aa64pfr1; uint64_t id_aa64mmfr0; uint64_t id_aa64mmfr1; + uint64_t id_aa64mmfr2; } isar; uint32_t midr; uint32_t revidr; @@ -1803,6 +1804,22 @@ FIELD(ID_AA64MMFR1, PAN, 20, 4) FIELD(ID_AA64MMFR1, SPECSEI, 24, 4) FIELD(ID_AA64MMFR1, XNX, 28, 4) +FIELD(ID_AA64MMFR2, CNP, 0, 4) +FIELD(ID_AA64MMFR2, UAO, 4, 4) +FIELD(ID_AA64MMFR2, LSM, 8, 4) +FIELD(ID_AA64MMFR2, IESB, 12, 4) +FIELD(ID_AA64MMFR2, VARANGE, 16, 4) +FIELD(ID_AA64MMFR2, CCIDX, 20, 4) +FIELD(ID_AA64MMFR2, NV, 24, 4) +FIELD(ID_AA64MMFR2, ST, 28, 4) +FIELD(ID_AA64MMFR2, AT, 32, 4) +FIELD(ID_AA64MMFR2, IDS, 36, 4) +FIELD(ID_AA64MMFR2, FWB, 40, 4) +FIELD(ID_AA64MMFR2, TTL, 48, 4) +FIELD(ID_AA64MMFR2, BBM, 52, 4) +FIELD(ID_AA64MMFR2, EVT, 56, 4) +FIELD(ID_AA64MMFR2, E0PD, 60, 4) + FIELD(ID_DFR0, COPDBG, 0, 4) FIELD(ID_DFR0, COPSDBG, 4, 4) FIELD(ID_DFR0, MMAPDBG, 8, 4) diff --git a/target/arm/helper.c b/target/arm/helper.c index e69cde801f..a48f37dc05 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7082,11 +7082,11 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, .resetvalue = cpu->isar.id_aa64mmfr1 }, - { .name = "ID_AA64MMFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, + { .name = "ID_AA64MMFR2_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = 0 }, + .resetvalue = cpu->isar.id_aa64mmfr2 }, { .name = "ID_AA64MMFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index fb21ab9e73..3bae9e4a66 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -549,6 +549,8 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ARM64_SYS_REG(3, 0, 0, 7, 0)); err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, ARM64_SYS_REG(3, 0, 0, 7, 1)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, + ARM64_SYS_REG(3, 0, 0, 7, 2)); /* * Note that if AArch32 support is not present in the host, From patchwork Mon Feb 3 14:47:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362869 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FE3613A4 for ; Mon, 3 Feb 2020 14:56:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9FB42082E for ; Mon, 3 Feb 2020 14:56:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JXVWnqxv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9FB42082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd9a-00007a-2C for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:56:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44794) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0l-0007Du-1l for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0j-0003QA-PL for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:38 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:36604) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0j-0003O3-In for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:37 -0500 Received: by mail-wr1-x443.google.com with SMTP id z3so18570030wru.3 for ; Mon, 03 Feb 2020 06:47:37 -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=IuKBvOWRLR1mygq3KRUQA3yOE5ySqkxN0SbADQ9Z81s=; b=JXVWnqxvQ/7nxy9Ez1gIwCk2ia//eXTZ/x/UP0+CnEhTTC9HpBQmDZgxnl1iHbwAhs fs2f0591pbxCiLNkF3vMSBztizLf4zvYbik5PpSsPbuXr+7EEYJja2/GpjSOuJC2e3Z5 yKwq4MQH50Vhaz9pOXBxeG9cXQWD2UGfOnlUqpdz0XBQq1/NgxkEsYnCwPMd5dnDt/XD bPfifjmBmoKiJonTvP31i3uZgUToTadZPrEoTp1CBXG1MrXisUtsVwMgGnioPgmJB7fQ kscOu1e7Zl+47YJ3+r029qsEgSRwJdUJxlhrRcGVZaf12iSPDimzfy2e744ya7KHVW0A pBxQ== 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=IuKBvOWRLR1mygq3KRUQA3yOE5ySqkxN0SbADQ9Z81s=; b=fl5bLwhyqq3glcQKU7XnJWlULWeQ2P20IwpJvoVNVGdYvKLICre8mbucG9MUPD4aWB tdC1WcZQKztWTJNJwmUXgwcMqTY5hnzwZ0NTWKFFZZbCc0C8pYh/iPSFE1mhaT19nUd2 owzhhfnvetP3tCt9oPUAvZc37IlMqCNLGsQ4+3GdVjP7vyqlB31umhZLdkDHFnMDpijk faPSvZh5n4sNhrcMyIwLChAlBB30E/Fm+paUyATi8s3//8PHBKvR8m6Zt65daLl9qqDB ujnBYotcjs3iA126iT79w2EzxCMAhiw0BhBNn5o+Ea44oG3THnfSxM0htsCK0pn6KEJ/ MTnw== X-Gm-Message-State: APjAAAWN5wrGJZoz7lQaO7wA7SpjRbyHHPS/tmUg04FXODKR5eUd1n5F T76x6kmSQKYWv3zOXE3N6PlGrMu04OsoaA== X-Google-Smtp-Source: APXvYqx5FSbCRrKyFEegipKJwbEhTNX2lM2w+k5F/iTWNeejW7Hm20zGdjS1beKUideMuTZn1RpziA== X-Received: by 2002:adf:ffc7:: with SMTP id x7mr15753461wrs.159.1580741256340; Mon, 03 Feb 2020 06:47:36 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/20] target/arm: Update MSR access to UAO Date: Mon, 3 Feb 2020 14:47:14 +0000 Message-Id: <20200203144716.32204-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::443 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- v2: Move reginfo to file scope; avoid setting uao from spsr when the feature is not enabled (pmm). v3: Update for aarch64_pstate_valid_mask --- target/arm/cpu.h | 6 ++++++ target/arm/internals.h | 3 +++ target/arm/helper.c | 21 +++++++++++++++++++++ target/arm/translate-a64.c | 14 ++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 71879393c2..e943ffe8a9 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1253,6 +1253,7 @@ void pmu_init(ARMCPU *cpu); #define PSTATE_IL (1U << 20) #define PSTATE_SS (1U << 21) #define PSTATE_PAN (1U << 22) +#define PSTATE_UAO (1U << 23) #define PSTATE_V (1U << 28) #define PSTATE_C (1U << 29) #define PSTATE_Z (1U << 30) @@ -3642,6 +3643,11 @@ static inline bool isar_feature_aa64_ats1e1(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, PAN) >= 2; } +static inline bool isar_feature_aa64_uao(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, UAO) != 0; +} + static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; diff --git a/target/arm/internals.h b/target/arm/internals.h index 4a139644b5..58c4d707c5 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1112,6 +1112,9 @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id) if (isar_feature_aa64_pan(id)) { valid |= PSTATE_PAN; } + if (isar_feature_aa64_uao(id)) { + valid |= PSTATE_UAO; + } return valid; } diff --git a/target/arm/helper.c b/target/arm/helper.c index a48f37dc05..d847b0f40b 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4191,6 +4191,24 @@ static const ARMCPRegInfo pan_reginfo = { .readfn = aa64_pan_read, .writefn = aa64_pan_write }; +static uint64_t aa64_uao_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + return env->pstate & PSTATE_UAO; +} + +static void aa64_uao_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + env->pstate = (env->pstate & ~PSTATE_UAO) | (value & PSTATE_UAO); +} + +static const ARMCPRegInfo uao_reginfo = { + .name = "UAO", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 2, .opc2 = 4, + .type = ARM_CP_NO_RAW, .access = PL1_RW, + .readfn = aa64_uao_read, .writefn = aa64_uao_write +}; + static CPAccessResult aa64_cacheop_access(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) @@ -7673,6 +7691,9 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, ats1cp_reginfo); } #endif + if (cpu_isar_feature(aa64_uao, cpu)) { + define_one_arm_cp_reg(cpu, &uao_reginfo); + } if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { define_arm_cp_regs(cpu, vhe_reginfo); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index d8ba240a15..7c26c3bfeb 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1602,6 +1602,20 @@ static void handle_msr_i(DisasContext *s, uint32_t insn, s->base.is_jmp = DISAS_NEXT; break; + case 0x03: /* UAO */ + if (!dc_isar_feature(aa64_uao, s) || s->current_el == 0) { + goto do_unallocated; + } + if (crm & 1) { + set_pstate_bits(PSTATE_UAO); + } else { + clear_pstate_bits(PSTATE_UAO); + } + t1 = tcg_const_i32(s->current_el); + gen_helper_rebuild_hflags_a64(cpu_env, t1); + tcg_temp_free_i32(t1); + break; + case 0x04: /* PAN */ if (!dc_isar_feature(aa64_pan, s) || s->current_el == 0) { goto do_unallocated; From patchwork Mon Feb 3 14:47:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362859 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD9D1139A for ; Mon, 3 Feb 2020 14:53:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 946F82082E for ; Mon, 3 Feb 2020 14:53:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LhDXlIAY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 946F82082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd6S-00023A-Qf for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:53:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44815) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0m-0007Hv-I4 for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0l-0003VD-D3 for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:40 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:38267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0l-0003Sh-6g for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:39 -0500 Received: by mail-wr1-x441.google.com with SMTP id y17so18550482wrh.5 for ; Mon, 03 Feb 2020 06:47:39 -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=JSoxWa3cljnlHVlVCNXL6Dtt3Ft2EaSM4NkE+KvUy1o=; b=LhDXlIAYlGQoxULJ1aL2M2PuCCsffiUtg3+tzKF/REVKWhflCJhFA8uOeXArqL0m3F qhosnnxFxUxc2i5Csu6n0lIMKGN7rooh5G1V37CbjwIALt1kXUtcxNXBS09CfKarYUj4 c3/CwQZIq3isofwbq+YbjXHixlrX44bJ/5Gh+pT2DdGB4LCpoikYNUeLB8MxyXlGRiHx 4Y+KQW6S7HPJJhzTup/4t0FvdQE0n8iWv+YJkpehay5CfPTwwuhamRFfOmKxgs7h1tw0 9z0POq6DN6VVOHbqq376TKDUZJYsfmi9/v+mTDQdOP39at0hj/nIA9dsLAaIQZOIJkif lcYg== 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=JSoxWa3cljnlHVlVCNXL6Dtt3Ft2EaSM4NkE+KvUy1o=; b=AyykF46YKUA9HdIpmGAbF82TIXpmrlK1L2iUjor0B07AFZiOLmTiBnO6HXA6VEr2Dc y+Eghuv8ueAVPcablHvPinZNABI0xdCZKb6puSVgYBNWfO+5KC1f6TAZZ+ABl7ZIQtZM Hj17h6+8ZOBR3KjLjbVtINYxIRRQ5iRzG6FukUPtVyeOgwI6hMbDyne62rzIFhjij7rA Bg7EMfSp/WxdOYqce+mHe7JfDozNJYZbKfRM0SqRuZ15aEqULnk9/qONoLrYtcIBJ/RD ny7ZaE1mWlpBL/je4KKL9k3lSso9s4m2KZqbrMNkTebI4peFCNym5t2AJGmXZ3iCoMVp 4wlw== X-Gm-Message-State: APjAAAW28svzVpTdiZLuDhfX0Wfoc/UI3LNFDKIOfVr2A3Io5Ek440X5 2HMz75fVyjZ2vOTMmHasz6+QcteLfEVh+g== X-Google-Smtp-Source: APXvYqymT3gTO7OvOfzWpHn38gu8neTIBMaLCKiu1j+kZJrbo+DRvskBncCgjDynG3VgCBr3qanxGQ== X-Received: by 2002:adf:f28c:: with SMTP id k12mr16876820wro.360.1580741257423; Mon, 03 Feb 2020 06:47:37 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 19/20] target/arm: Implement UAO semantics Date: Mon, 3 Feb 2020 14:47:15 +0000 Message-Id: <20200203144716.32204-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We need only override the current condition under which TBFLAG_A64.UNPRIV is set. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index d847b0f40b..b24a6a6526 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12194,28 +12194,29 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, } /* Compute the condition for using AccType_UNPRIV for LDTR et al. */ - /* TODO: ARMv8.2-UAO */ - switch (mmu_idx) { - case ARMMMUIdx_E10_1: - case ARMMMUIdx_E10_1_PAN: - case ARMMMUIdx_SE10_1: - case ARMMMUIdx_SE10_1_PAN: - /* TODO: ARMv8.3-NV */ - flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); - break; - case ARMMMUIdx_E20_2: - case ARMMMUIdx_E20_2_PAN: - /* TODO: ARMv8.4-SecEL2 */ - /* - * Note that E20_2 is gated by HCR_EL2.E2H == 1, but E20_0 is - * gated by HCR_EL2. == '11', and so is LDTR. - */ - if (env->cp15.hcr_el2 & HCR_TGE) { + if (!(env->pstate & PSTATE_UAO)) { + switch (mmu_idx) { + case ARMMMUIdx_E10_1: + case ARMMMUIdx_E10_1_PAN: + case ARMMMUIdx_SE10_1: + case ARMMMUIdx_SE10_1_PAN: + /* TODO: ARMv8.3-NV */ flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); + break; + case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: + /* TODO: ARMv8.4-SecEL2 */ + /* + * Note that EL20_2 is gated by HCR_EL2.E2H == 1, but EL20_0 is + * gated by HCR_EL2. == '11', and so is LDTR. + */ + if (env->cp15.hcr_el2 & HCR_TGE) { + flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1); + } + break; + default: + break; } - break; - default: - break; } return rebuild_hflags_common(env, fp_el, mmu_idx, flags); From patchwork Mon Feb 3 14:47:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 11362863 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 226381395 for ; Mon, 3 Feb 2020 14:54:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDECF2082E for ; Mon, 3 Feb 2020 14:54:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wIH351M8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDECF2082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd7d-0004g2-66 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 09:54:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44836) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyd0o-0007Lo-1k for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyd0m-0003Zd-Pk for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:41 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34884) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyd0m-0003XP-Hn for qemu-devel@nongnu.org; Mon, 03 Feb 2020 09:47:40 -0500 Received: by mail-wr1-x442.google.com with SMTP id w12so7618269wrt.2 for ; Mon, 03 Feb 2020 06:47:40 -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=n25wa1lNKzA3qMHXUq9DJlF06TNEvhgokWarr1Y211Q=; b=wIH351M8p77wzGZYb8BBlxl8blks686bS3l1ybHB2FE8tDOW5vsmorCA8/5x05cA5J WGekc67qznSDHxKocX4c4C6T2WsQfHCG77HlqkUG5WJCkjpPAFwa7LiqvQ9943Y4gHxl CwfBhue34L0xuCP0iucwMrYMm50uY9xQQwZhGjYSYHeoGTvoI/o4gmd9piKjkIKElBN0 klpaF64VXvX1SqNIaDAE94RJSHay2FLvDXXyhHLYe/CeAJA2aBBtRdOmttvuKxOxzCvV An8miXYO2KKJxelVu+S1a8/kbuisNzZ8QIdV2/hVckArNgh8kJdoY7sqKIUerNwlgimT Nvpw== 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=n25wa1lNKzA3qMHXUq9DJlF06TNEvhgokWarr1Y211Q=; b=QQrc8wruAVJCBxhphHyaXb7vBdXfH9HVvUUyYSX0PfQWcSbb+p2ThD/w8/m5BZLtsb 6SXG5C3uzBJkCSCYQ1CRjTYXCFfgXnYjeYFM2pz91z/QL1jXYvjowhx2z73YfxVn9yoF 2N8IXaHZZFDy36lF+eatHHoZzBwWGPnjCsqE0qq/nYCqeXrDEATW7uMqKWqSnIE7uoRI AOeIx9JE+ErPZH7SSuR+FXrR6/bElI5kw3rRfkz7A09rkStB4Ndz3szcbmpmDH4VYXG7 yvf11ynwjfijivQ2B45WpctKjzXxW79aDKCBn6/m9ELHJLf3BafFe05O2APTNP0EwtF6 Qw8Q== X-Gm-Message-State: APjAAAWizqlK1WIUA8tYj4xiti++0nP2bOFOrMT++jILcowbg2wRuuPN J5R4UWLB7gHvuDsVKdqOpyqHrgjygajeqQ== X-Google-Smtp-Source: APXvYqzJPKJxRO2gmpQSJv/hQ0ANcrBvCzSXl9ffZB1vaZriz7e3Hjl8rHdiACe/lOoCJ9ZWmDF5Iw== X-Received: by 2002:adf:fac8:: with SMTP id a8mr15988719wrs.81.1580741259354; Mon, 03 Feb 2020 06:47:39 -0800 (PST) Received: from cloudburst.c.hoisthospitality.com ([135.196.99.211]) by smtp.gmail.com with ESMTPSA id h2sm26429739wrt.45.2020.02.03.06.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 06:47:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/20] target/arm: Enable ARMv8.2-UAO in -cpu max Date: Mon, 3 Feb 2020 14:47:16 +0000 Message-Id: <20200203144716.32204-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203144716.32204-1-richard.henderson@linaro.org> References: <20200203144716.32204-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::442 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu64.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 57fbc5eade..1359564c55 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -676,6 +676,10 @@ static void aarch64_max_initfn(Object *obj) t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */ cpu->isar.id_aa64mmfr1 = t; + t = cpu->isar.id_aa64mmfr2; + t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); + cpu->isar.id_aa64mmfr2 = t; + /* Replicate the same data to the 32-bit id registers. */ u = cpu->isar.id_isar5; u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */