From patchwork Tue Mar 5 16:50:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 159683 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp5189164jad; Tue, 5 Mar 2019 08:57:21 -0800 (PST) X-Google-Smtp-Source: APXvYqwbrX5Co/CybGWqNRbPT2ZJum/6zFbI8xqVkMWOX51/iEADcJdN9CRL5nXWArq6VjzNaMaC X-Received: by 2002:a81:4c04:: with SMTP id z4mr1791873ywa.38.1551805040951; Tue, 05 Mar 2019 08:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551805040; cv=none; d=google.com; s=arc-20160816; b=dlLojyQ2PaAUuue1DsUZ+Uir0S/XnPV6rIydowamwYKbs9foxEKLJuZ8GZNWPbGRFr Gu9GjEEIHdnWY16EtGENsR6Z2s+N5oz45EAxkKiHnuJx2nc2YrWkwSQQqQVli2d4iy4U CVox7PlEEWi7UAs4Aiyzc9A+wC/SGl1mVuJaA09pZLSerK04VNBenkSVIx9avlYNElOs 17Ry1/2oOrSFL2EAQu25onMkEsyJDUboucTPQTi+1JA6YvQgM0HOXREBPgA6Av8+TbZL DsCGcJRel72xyoGv6GWPHwBGjtExEW5AxyOJ5Xt+zdgOLdDh85Aq9qwXriYVZohaGE6m 0XxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=MhK0rVzLjKODPV7m/7aRrkaiKGeVb3/JwMjqVR8x4p8=; b=t6vyzaLVSOKBYKi1croHy3BGe725sA0JcV7zNxdw+I5d7a03tFqojpStUBOLvFSlZw FUwRKj+0DbwChAMon3Y3Dekwx3V2xHxkpYJY/Y3WB2T0LHJN5Jnank9xZ/MKWZbZWu1N xeJtcnlfCmRd/lkvNBcB07BljpdoL18GCckIQ1rJr0NKJpOtrZTrAn/MnYSa+zIwCOoM euO2uW/sGgr2v26dIBWhyr/p99d09GnILPJidQj4oiTG+pxVlGR8kDH91RPvshabze4n /DGNS1yHH78fLbVER4cHKBIAptYmqhUl+FqDNQAfQiT8dn+VCnpWbh68xW6qlej0HXDs IHKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OQSIggrH; 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 21si4974404ywd.413.2019.03.05.08.57.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 05 Mar 2019 08:57:20 -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=OQSIggrH; 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]:45811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DNY-0006X5-E7 for patch@linaro.org; Tue, 05 Mar 2019 11:57:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1DHX-0001a5-0k for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:51:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1DHQ-0000ko-Sd for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:51:06 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:33897) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1DHQ-0000jO-I8 for qemu-devel@nongnu.org; Tue, 05 Mar 2019 11:51:00 -0500 Received: by mail-wr1-x42d.google.com with SMTP id f14so10258692wrg.1 for ; Tue, 05 Mar 2019 08:51:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MhK0rVzLjKODPV7m/7aRrkaiKGeVb3/JwMjqVR8x4p8=; b=OQSIggrHvgX85cXqPv3WIH78a4yo+SWPKOh2qHJE6rfLXOXfryiO4Qf/NQ9Q9NE45/ A+VYriR5BZ/Y+0EmUWSw4Eax+MFtyKgznSF44NIrKr5WxScTWLBtrhUub+Gv7sQLc6gi 9O9koKJ9EXWwshv3AH+mezbm5XCkDxCtX9ciRqJFxkn/GUB5NO37Zg3KXq7zjnqlWz8s IhMFUrC5i436IIpAwIBZid5VDrZv5FyOJ6LLiW5PtoTdB2haY72ExXo8vtoK0ADIL2Vy Jg6k2aVJhFyvldweFd4HPdaB8RxF2DMwUpBQ9GHDNdK5EFrHiktxkV5ghfzJxbFMKbGR Qqmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MhK0rVzLjKODPV7m/7aRrkaiKGeVb3/JwMjqVR8x4p8=; b=hWmhN/aRTQVcLwERpg3nBXZReUQdP6+msXieC8lUK0KgbMy7qRH+ePnMYxAOQLk1Fd 78V3afDKyCXGd2FxlBcDBlTEvB1aM5djxzZsJLVkcKKoSAjdlD4aXkOgBFhrwq5oFo6J vUMUhjw/Fwl1ySyY1+jKRUOpCDRiYM+mMu5C2IMW0F6+idbWgucJ1UVC9L+qhjE7XvQI J0fbyviV87Cp7KBh9fgRp2/WGvrk11dxbcBRijtCX+CaAfJyphaePrqIctaQOBfGYrqm RuAFy/m4a+sMXPvy0hWFTYLhJuwEfMl/2M25ULy1zXIBLfhP1dqM4NU7x+vTnKJYBNcv ukBw== X-Gm-Message-State: APjAAAWqygc+fISNExRpHHnymX0nmdXOx0gBY1ptgo7axuoSMBSUogcH wAnYUMYZhrbAwBBIj/8QspkJvOXk4zo= X-Received: by 2002:a5d:4d12:: with SMTP id z18mr17503137wrt.115.1551804659147; Tue, 05 Mar 2019 08:50:59 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 2sm10071495wrg.89.2019.03.05.08.50.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 08:50:58 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 5 Mar 2019 16:50:33 +0000 Message-Id: <20190305165051.26860-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305165051.26860-1-peter.maydell@linaro.org> References: <20190305165051.26860-1-peter.maydell@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::42d Subject: [Qemu-devel] [PULL 04/22] 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20190301200501.16533-4-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- 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.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 361e51143c7..c822f94236c 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 ef069c268df..96f0ff0ec72 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 6788c0f6ff7..87337b63855 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 49ff79a146b..2607d39ad1c 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)