From patchwork Thu Feb 28 02:24:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159303 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp111266jad; Wed, 27 Feb 2019 18:26:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IZKOOgCc/1yEQHiXnoQrlM6sd22HN0684GNk4itz+upKQfU9DXI3jz3cm4dNX5A9otqXXZ1 X-Received: by 2002:a81:3988:: with SMTP id g130mr3942601ywa.470.1551320813505; Wed, 27 Feb 2019 18:26:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551320813; cv=none; d=google.com; s=arc-20160816; b=Sax2yK6r/LbFiytb+GDdkpNjPcHkviTOOtlOeSwrn+NQDhUrLyFjSD0DlTJq2LEMRv ICEbY3G97G50yV0m/oXL0xKXdgeZHhYpUmi0MKOX3879+c368kO9YRBR2sTJh3yTSg7F yRA4tHhnLkwY4ck5aNJgnnKepwY2sNoSpgXZ/WpxD37HiIF/OMNF7gAr58ddpi73ZOxQ yWjZXl4VcjdHCyBp7KzTJ9AH/NhQ/U+jm1Y9JmhEf6Kx7pRYIJMYrW0MNU5ftQkfFWQW a5Nha3ucH2fgjpyoyGiN98NCbqqkNMU78eJkg12elnnuQpEkJtDf0yq/uKxaqDDyaukV pXvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=KZzbWb8IhhUhb6EYWy5Z9lfBmv/g5o+I+lU770uGKJI=; b=BpOpvVL7sxpSvr2Ykk3Xio2fmKoaqA12uns0CLTL7CcqfsBwUAJrX+x1pY70Mt6v0S uwyNvf91dLTTvfNorLxqbHYuNsjiDNoHEwsTqKoh6y2maMiOZ9VnfkNxiR5vZOPpiojm 43Hc1SXalJmewdOaRGUym5fuO3yoWyZ3S32tuzpt/wW9+4rpShAx1atKvp9eJ5fIRRDX VpGtEiM85aVVogFs8lePvHJ0NjqBCyYriHRwA0v91bFuir2nD5zBG968JdYVBfS8oer6 aGBPmwwTcXxOi5sPxo/sH99UGHBi5U83j79mooSuFTdIk70PpHmG+RwI8W1GJz1QpISw x9yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bh9D8BCf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l12si9617635ybp.102.2019.02.27.18.26.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Feb 2019 18:26:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bh9D8BCf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:55320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzBPR-0004Jr-0S for patch@linaro.org; Wed, 27 Feb 2019 21:26:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzBN7-0003OJ-Ec for qemu-devel@nongnu.org; Wed, 27 Feb 2019 21:24:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzBN2-000574-19 for qemu-devel@nongnu.org; Wed, 27 Feb 2019 21:24:24 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:36157) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzBN1-00056E-Pe for qemu-devel@nongnu.org; Wed, 27 Feb 2019 21:24:23 -0500 Received: by mail-pl1-x643.google.com with SMTP id k2so8955939plt.3 for ; Wed, 27 Feb 2019 18:24: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; bh=KZzbWb8IhhUhb6EYWy5Z9lfBmv/g5o+I+lU770uGKJI=; b=Bh9D8BCfNoo83oQ9OVrnUsZ8R90zMasr6U8yQvUInOqVZnqyCXGzZ8UWjgiIhpfZBx N/y/wkoTORFOJNIgvdclLCGmtKsElUbmlQPZOUNPHRP9ICVds0THQl2ho91yZEOkyn9G BxfXIKvrCHkxyHPcX+sYlDULaLDoe4yBIaeGEWs1M1IeqWVxh9sz7p2eKKvNBrcntq0f P/73Xr7Qqo/Tr9L9EA0eg7IB6fLr17Eoj1dhhFKZR/0Gon6ZaW3GkuYqJ1ayhXguCoOn NWdZ9nU6KBTMpKiqeqJFCrIFsdc5iimxfZF1zBmv9ToQ/YlQCXEq9y20R6JndYYLz+6Z 7SEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KZzbWb8IhhUhb6EYWy5Z9lfBmv/g5o+I+lU770uGKJI=; b=GmRM9vBGsspIcg+U5TSGP+6td5fb+Ja7ZjaSXTyRSDNuemoz+w30qDTUY2e4GEarLX pUiOowZIT3LLfcse8292b/CyBPCk6DpmvtDpcoLyYRFziNqAY/2sfOn/hEQCdaCeDTsn CMybmJti3EW91RPfdWVVC009aY0sub1OB7bGp9qO3xgdgtOBl5GF/LKksw/q7j2VrmpL yRawWlnVDCHdm1eN7v8FZ0K5rHCqQ6uo8sIzPhnYE4rP/cljr6kN1ooVmMc4GaL/ccSr BDCih8qOsy0AjAtL46ofcrL+oZNuITBAF/bLF/iA6Tfoi2+kfbDL8T810khcG3ElFsII LfMg== X-Gm-Message-State: AHQUAua8oOp4unz6iyC5q3X75ElzhI4F9UFA2cPzNtB7pcjzcns6W2vh fsBInzIjf+icnhGNPV01muNfFcHnNSY= X-Received: by 2002:a17:902:1122:: with SMTP id d31mr5477367pla.246.1551320662318; Wed, 27 Feb 2019 18:24:22 -0800 (PST) Received: from cloudburst.dc.rr.com ([2605:e000:100e:478c:cfa2:eb27:db4f:e85]) by smtp.gmail.com with ESMTPSA id l28sm11928346pfi.186.2019.02.27.18.24.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 18:24:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 18:24:15 -0800 Message-Id: <20190228022415.27878-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190228022415.27878-1-richard.henderson@linaro.org> References: <20190228022415.27878-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH v2 3/3] target/arm: Implement ARMv8.0-PredRes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is named "Execution and Data prediction restriction instructions" within the ARMv8.5 manual, and given the name "PredRes" by binutils. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 13 ++++++++++- target/arm/cpu.c | 1 + target/arm/cpu64.c | 2 ++ target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1a6ca35ea7..e1acc711cf 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1060,7 +1060,8 @@ void pmu_init(ARMCPU *cpu); #define SCTLR_R (1U << 9) /* up to v6; RAZ in v7 */ #define SCTLR_UMA (1U << 9) /* v8 onward, AArch64 only */ #define SCTLR_F (1U << 10) /* up to v6 */ -#define SCTLR_SW (1U << 10) /* v7, RES0 in v8 */ +#define SCTLR_SW (1U << 10) /* v7 */ +#define SCTLR_EnRCTX (1U << 10) /* in v8.0-PredInv */ #define SCTLR_Z (1U << 11) /* in v7, RES1 in v8 */ #define SCTLR_EOS (1U << 11) /* v8.5-ExS */ #define SCTLR_I (1U << 12) @@ -3294,6 +3295,11 @@ static inline bool isar_feature_aa32_sb(const ARMISARegisters *id) return FIELD_EX32(id->id_isar6, ID_ISAR6, SB) != 0; } +static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id) +{ + return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0; +} + static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) { /* @@ -3397,6 +3403,11 @@ static inline bool isar_feature_aa64_sb(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SB) != 0; } +static inline bool isar_feature_aa64_predinv(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SPECRES) != 0; +} + static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) { /* We always set the AdvSIMD and FP fields identically wrt FP16. */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7940d49c1d..b78e1d610e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2004,6 +2004,7 @@ static void arm_max_initfn(Object *obj) t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); t = FIELD_DP32(t, ID_ISAR6, DP, 1); t = FIELD_DP32(t, ID_ISAR6, SB, 1); + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); cpu->isar.id_isar6 = t; t = cpu->id_mmfr4; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 168aa9e0f1..92c75cbfa6 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -318,6 +318,7 @@ static void aarch64_max_initfn(Object *obj) t = FIELD_DP64(t, ID_AA64ISAR1, GPA, 1); t = FIELD_DP64(t, ID_AA64ISAR1, GPI, 0); t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); + t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); cpu->isar.id_aa64isar1 = t; t = cpu->isar.id_aa64pfr0; @@ -349,6 +350,7 @@ static void aarch64_max_initfn(Object *obj) u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1); u = FIELD_DP32(u, ID_ISAR6, DP, 1); u = FIELD_DP32(u, ID_ISAR6, SB, 1); + u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1); cpu->isar.id_isar6 = u; /* diff --git a/target/arm/helper.c b/target/arm/helper.c index 8a71a80dfd..554f111ea8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5742,6 +5742,50 @@ static const ARMCPRegInfo pauth_reginfo[] = { }; #endif +static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + int el = arm_current_el(env); + + if (el == 0) { + uint64_t sctlr = arm_sctlr(env, el); + if (!(sctlr & SCTLR_EnRCTX)) { + return CP_ACCESS_TRAP; + } + } else if (el == 1) { + uint64_t hcr = arm_hcr_el2_eff(env); + if (hcr & HCR_NV) { + return CP_ACCESS_TRAP_EL2; + } + } + return CP_ACCESS_OK; +} + +static const ARMCPRegInfo predinv_reginfo[] = { + { .name = "CFP_RCTX", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 4, + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, + { .name = "DVP_RCTX", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 5, + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, + { .name = "CPP_RCTX", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 7, + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, + /* + * Note the AArch32 opcodes have a different OPC1. + */ + { .name = "CFPRCTX", .state = ARM_CP_STATE_AA32, + .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 4, + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, + { .name = "DVPRCTX", .state = ARM_CP_STATE_AA32, + .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 5, + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, + { .name = "CPPRCTX", .state = ARM_CP_STATE_AA32, + .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 7, + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, + REGINFO_SENTINEL +}; + void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ @@ -6641,6 +6685,17 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, pauth_reginfo); } #endif + + /* + * While all v8.0 cpus support aarch64, QEMU does have configurations + * that do not set ID_AA64ISAR1, e.g. user-only qemu-arm -cpu max, + * which will set ID_ISAR6. + */ + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) + ? cpu_isar_feature(aa64_predinv, cpu) + : cpu_isar_feature(aa32_predinv, cpu)) { + define_arm_cp_regs(cpu, predinv_reginfo); + } } void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)