From patchwork Fri Mar 1 20:04:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159517 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp1149446jad; Fri, 1 Mar 2019 12:14:15 -0800 (PST) X-Google-Smtp-Source: APXvYqxu/SpM5RcEfMnn9iFFhGMETdavCNne18CV8k3wEVXqNyLBZ1BpvL04Fjco/5pgJqRi2gLH X-Received: by 2002:a0d:cb15:: with SMTP id n21mr4957659ywd.209.1551471254998; Fri, 01 Mar 2019 12:14:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551471254; cv=none; d=google.com; s=arc-20160816; b=bVIK7peXLvnRV2Oup9dHwvsUlfIFzrNywhhnXIN9/4hKg8BbcdPu/2EiMM/QLavbHg Jd9r9WvzKpl/L4uU8ev4+dkpdilI9VR8ZGn9yYM6tSdZfEtALn2vBbVUIEDBCJ2kDRN9 nP5nOsZhQe2XxeRpLApUZn+0wk123E4ernXbHzwGPF5cpkXaqGK0X9NdlcSSqQhP56JF yqQcBBIdg6i2yaJalLAM3PhDCqtbVZHXO1bi0bKDZwacDktW0DyQctPT9WhlwaX5jxmJ 2ocP/FjuSS1Ii+1EQVFsaQ04DbTmTAXDFxHEiz055sQleAKO8oOJqUv9yW++RgIjIxl1 6Dgg== 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=e5S+wkc/GorK1btTXbXOPpamD5OJCnpi6JpWnmoa3L8=; b=SP5fa6gRw+rk7sy17+rq292Z1eSvFBLtRmSgiIMA62ZJJNfjfOWYO5XM2xOoIL62UO 9471I5VWnzD62xkMl2Gw/t5TrLR7kPHnTNujwX/QIW1aZU2FlaXFA6brmu/0kMHsuV5t VZ1u5Bp4mlZu8Dr25hkXlTZD1dGRU95EKVvsrniyYiglQ1LSi5EaZ4Srp5WdhN+pSpfz yp1SZiX8RAvrN17zNrYKs+KjVPDquhYb4xj32HkV8CTrylJaBEIkWKzzuJJR4ziCsKDR ofyUgYG76+w1Z0HnZbp7YGgD8QDsCaa0zE+/xYBx/yQ/62kCk6WtXINbArUeK9GCGm1t EjTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=y1u8B99N; 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 o81si13321306ywc.424.2019.03.01.12.14.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Mar 2019 12:14:14 -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=y1u8B99N; 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]:43566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzoXu-0006VY-Hv for patch@linaro.org; Fri, 01 Mar 2019 15:14:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzoPd-0004kR-JN for qemu-devel@nongnu.org; Fri, 01 Mar 2019 15:05:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzoPM-0001qe-2t for qemu-devel@nongnu.org; Fri, 01 Mar 2019 15:05:29 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:36773) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzoPH-0001eP-Vb for qemu-devel@nongnu.org; Fri, 01 Mar 2019 15:05:22 -0500 Received: by mail-pf1-x441.google.com with SMTP id n22so11916212pfa.3 for ; Fri, 01 Mar 2019 12:05:09 -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=e5S+wkc/GorK1btTXbXOPpamD5OJCnpi6JpWnmoa3L8=; b=y1u8B99N6ugESVQViJP/shOR4NIGwvuQHF4L+uEOZ479/H1LKM0wIFicJHahLW2MSY ka0O0FIK4SrCjUo8sbi++Mp6WHuZbyaY/0wGLvWobSwXyxq8t76mJYkcUmV7G0a+MyU2 zOF9iEcYtFXqDMwh+nixFNQk80KzI5TV0gheKc5wr8G02BH0vIllZ5822DRoEWXbS75u 14ZRFp6k9YBry66inb7veDWxjpCySwoGxuHW5e118nUUfAfjHI+k59JDibOWLhDKQpB6 7aAeCKTWnSd+YFnleOXaF0egUVIbVp/fZhIGzmbaYnPMcdslcs4i4BkeDpd9CKv/JJoA LVUQ== 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=e5S+wkc/GorK1btTXbXOPpamD5OJCnpi6JpWnmoa3L8=; b=Ychzj0shio/sUIpUH3lZCa3D8krTB10IWmLAvnybqQtpexcOgd35fHIcYDK9dxRiyI Vrvd54uEaMBBuyqp5rRsd73qUs3lIA9idU1RclUt3JdDuO7lRbXx4xSwzjj2BURCDDAi yKozfuhsInJa61YfZ7Y28bxHI18kWQ0lvH7HBe79AQZrHu3LCIBiyqNh3uK7JiN+eWHf ttaXgQy1GMWmcBRI6MGsM+cU4VwvUw3Z0bIS2uMwS75mC6ZarPR0XqJMGp0J2iOYxbvb VbjuTeG+WTAUcMVkzUl7ZiNRBQhL1wv3ExSBl5sRVbJvT65RIZhgTB13wlVFnOI9YoDy ta3w== X-Gm-Message-State: APjAAAVtWr0HHdjI5o7mnycCgAq6iLto4AInEP3m0k/CJ/21b2Jzfh8j HoTlUhU5i2c4g+DB3U0g2M7eebmkGL0= X-Received: by 2002:a65:4844:: with SMTP id i4mr6314062pgs.347.1551470708259; Fri, 01 Mar 2019 12:05:08 -0800 (PST) Received: from cloudburst.twiddle.net (cpe-72-132-238-51.dc.res.rr.com. [72.132.238.51]) by smtp.gmail.com with ESMTPSA id x8sm31869206pfn.137.2019.03.01.12.05.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2019 12:05:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Mar 2019 12:04:54 -0800 Message-Id: <20190301200501.16533-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190301200501.16533-1-richard.henderson@linaro.org> References: <20190301200501.16533-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::441 Subject: [Qemu-devel] [PATCH v3 03/10] target/arm: Implement ARMv8.0-PredInv 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" 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 361e51143c..c822f94236 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) @@ -3312,6 +3313,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) { /* @@ -3455,6 +3461,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 ef069c268d..96f0ff0ec7 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2022,6 +2022,7 @@ static void arm_max_initfn(Object *obj) t = FIELD_DP32(t, ID_ISAR6, DP, 1); t = FIELD_DP32(t, ID_ISAR6, FHM, 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 6788c0f6ff..87337b6385 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -319,6 +319,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; @@ -351,6 +352,7 @@ static void aarch64_max_initfn(Object *obj) u = FIELD_DP32(u, ID_ISAR6, DP, 1); u = FIELD_DP32(u, ID_ISAR6, FHM, 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 49ff79a146..2607d39ad1 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5719,6 +5719,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 */ @@ -6618,6 +6662,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)