From patchwork Mon Dec 10 15:05:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 153273 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3662683ljp; Mon, 10 Dec 2018 07:07:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/X7mPgpEeGxIVw+ECD+i8Yq1d99i73VL8KGkcEU1R4bt3t7YFf06Y5I0UODMCk30CzylmQt X-Received: by 2002:a0c:e5c1:: with SMTP id u1mr11929674qvm.113.1544454471273; Mon, 10 Dec 2018 07:07:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544454471; cv=none; d=google.com; s=arc-20160816; b=w0djHzyCcxbjsXYVrZa/beefVMkmxNWjVqERmBN3mte0llj3IqA2ItrK2hyMhoYneS 8ilFM3XnlKQyuxgWKzPs5PAQ+DXvNiJr6B0QaMOwvDoguLDxNBBgl45c86nAUwjQ+gRc 8ArJ8yAmDO70SSWj+/cukL2JDN85/o5EGXIJj+hGHyp+4OecQFJiT6uhRQ3hd5Y6s820 QOSCa5fP2daKD2GKItSdcn2PhKeISquiuIWT+dMyhgxWJMLyVdyRv+StHAjpA+4lEgG0 1enbA2CGynUJZwye1UhKDQvEoeOlCSU+v0Zig45GIvg7me4J+p9tEff1H9o/c0ifVmSp mJ9g== 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=xir+xQnKUxj9WKRQcojx3q0A4djL7id8IxY2T1i5d/U=; b=AZJewzPhs12LwVqzIHX8UkN5ReQzE6/K1+X+cS5E/3dli39gxJBSMFuSFXZzvXGj3X tYNWcdWyLTdVALmXjKx0S1BeEVkPEP9e7pcdXlh23H0yAbqXoe6RLBOgkDsJY1ZAPiqm +QT5k0WI2JQC6k5BVG2K+Ni7cn7w+4VecSEymQhFRcHPsBVIADaI9AiBbcKW5YumrrZD SYM5AnPShjlzMDC93pXV9Vm4nq+zmD/DoXl1v+UTrzUYtyj13pjutW66zrcUQ/yDgpKe WsZP9rRjey+0AREyt4qLMEZ3t44P8YkGSsnCYqOD4H8GjGxNp2E/XSEVAJTwxR2f6Niy 1Khg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a1vosRGX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r18si1360100qtc.338.2018.12.10.07.07.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Dec 2018 07:07:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a1vosRGX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:33219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWN9y-0003j4-D8 for patch@linaro.org; Mon, 10 Dec 2018 10:07:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWN7T-0002jk-WE for qemu-devel@nongnu.org; Mon, 10 Dec 2018 10:05:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWN7N-0003kk-G9 for qemu-devel@nongnu.org; Mon, 10 Dec 2018 10:05:15 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:41805) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gWN7N-0003k7-7o for qemu-devel@nongnu.org; Mon, 10 Dec 2018 10:05:09 -0500 Received: by mail-ot1-x344.google.com with SMTP id u16so10643099otk.8 for ; Mon, 10 Dec 2018 07: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=xir+xQnKUxj9WKRQcojx3q0A4djL7id8IxY2T1i5d/U=; b=a1vosRGXg8v4nKClFgGvsMBzGocPd4klBY/QNNzVauslswF8ItAKW/IRpz+BnQlHp3 bPAhEQU5Q7icQrKxGcRG0I/wSdKdQ7aThMAP8sQLtGAdhJvDHdTcMoblr6BmRK1eDhDM rpYwBY1TOsz25xOd33K+yAbEKeP4+d4hUBgmE= 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=xir+xQnKUxj9WKRQcojx3q0A4djL7id8IxY2T1i5d/U=; b=bxf1EprtZfMoij+BU/t8MZPJOU4GbdnvV1sDExvgT1E2M6scdYrbcvrQ8ZBrxVqJln CteGwnE4Mzi3uFrJluo05y2A1u8QvEXHFKmI/FCaaMjVCTSy+E/Xu4kz2SEAFdh+kJDL UAM/TKyG+10OWb+di+VgztR26A8bSa+5gDWRAoYXdJVKWCLQaos37mvLIXsJZHDJ0e32 zwVQzoiblheoCxoAwPSZfhdCzAaKH+ZqSolkP0M1dXOWZvYnFFR8pNQW8W6xgdJpyQnb SGzxE7qWfKRfUN/6wSRz0+ik1LFwydH+0Kcmjrdh1OsQUDOON4q/UGhcoazZS6tHWCKJ 6SZA== X-Gm-Message-State: AA+aEWa6+jdzIenSPwlKkLsqsd1b6LbeyGMWw+56jSU5U7KwItHadvWq t8wTCK77+m9HMjqlUCinmejTq6Hxhh7zdw== X-Received: by 2002:a05:6830:1584:: with SMTP id i4mr8189486otr.116.1544454308242; Mon, 10 Dec 2018 07:05:08 -0800 (PST) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id b18sm5694734oii.51.2018.12.10.07.05.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Dec 2018 07:05:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 10 Dec 2018 09:05:01 -0600 Message-Id: <20181210150501.7990-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181210150501.7990-1-richard.henderson@linaro.org> References: <20181210150501.7990-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::344 Subject: [Qemu-devel] [PATCH v4 3/3] target/arm: Implement the ARMv8.1-LOR extension 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" Provide a trivial implementation with zero limited ordering regions, which causes the LDLAR and STLLR instructions to devolve into the LDAR and STLR instructions from the base ARMv8.0 instruction set. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v2: Mark LORID_EL1 read-only. Add TLOR access checks. Conditionally unmask TLOR in hcr/scr_write. v3: Fix isar_feature_aa64_lor. Split out access_lor_ns. Defer all {E2H,TGE} vs TLOR testing to arm_hcr_el2_eff. --- target/arm/cpu.h | 5 +++ target/arm/cpu64.c | 1 + target/arm/helper.c | 75 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 12 ++++++ 4 files changed, 93 insertions(+) -- 2.17.2 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 05ac883b6b..c943f35dd9 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3340,6 +3340,11 @@ static inline bool isar_feature_aa64_sve(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0; } +static inline bool isar_feature_aa64_lor(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, LO) != 0; +} + /* * Forward to the above feature tests given an ARMCPU pointer. */ diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 1a4289c9dd..1d57be0c91 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -326,6 +326,7 @@ static void aarch64_max_initfn(Object *obj) t = cpu->isar.id_aa64mmfr1; t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ + t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); cpu->isar.id_aa64mmfr1 = t; /* Replicate the same data to the 32-bit id registers. */ diff --git a/target/arm/helper.c b/target/arm/helper.c index d6f8be9f4e..644599b29d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1281,6 +1281,7 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { /* Begin with base v8.0 state. */ uint32_t valid_mask = 0x3fff; + ARMCPU *cpu = arm_env_get_cpu(env); if (arm_el_is_aa64(env, 3)) { value |= SCR_FW | SCR_AW; /* these two bits are RES1. */ @@ -1303,6 +1304,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) valid_mask &= ~SCR_SMD; } } + if (cpu_isar_feature(aa64_lor, cpu)) { + valid_mask |= SCR_TLOR; + } /* Clear all-context RES0 bits. */ value &= valid_mask; @@ -3963,6 +3967,9 @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) */ valid_mask &= ~HCR_TSC; } + if (cpu_isar_feature(aa64_lor, cpu)) { + valid_mask |= HCR_TLOR; + } /* Clear RES0 bits. */ value &= valid_mask; @@ -5018,6 +5025,42 @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) return pfr0; } +/* Shared logic between LORID and the rest of the LOR* registers. + * Secure state has already been delt with. + */ +static CPAccessResult access_lor_ns(CPUARMState *env) +{ + int el = arm_current_el(env); + + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_TLOR)) { + return CP_ACCESS_TRAP_EL2; + } + if (el < 3 && (env->cp15.scr_el3 & SCR_TLOR)) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +} + +static CPAccessResult access_lorid(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_is_secure_below_el3(env)) { + /* Access ok in secure mode. */ + return CP_ACCESS_OK; + } + return access_lor_ns(env); +} + +static CPAccessResult access_lor_other(CPUARMState *env, + const ARMCPRegInfo *ri, bool isread) +{ + if (arm_is_secure_below_el3(env)) { + /* Access denied in secure mode. */ + return CP_ACCESS_TRAP; + } + return access_lor_ns(env); +} + void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ @@ -5759,6 +5802,38 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_one_arm_cp_reg(cpu, &sctlr); } + 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); + } + if (cpu_isar_feature(aa64_sve, cpu)) { define_one_arm_cp_reg(cpu, &zcr_el1_reginfo); if (arm_feature(env, ARM_FEATURE_EL2)) { diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index fd36425f1a..e1da1e4d6f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -2290,6 +2290,12 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) } return; + case 0x8: /* STLLR */ + if (!dc_isar_feature(aa64_lor, s)) { + break; + } + /* StoreLORelease is the same as Store-Release for QEMU. */ + /* fall through */ case 0x9: /* STLR */ /* Generate ISS for non-exclusive accesses including LASR. */ if (rn == 31) { @@ -2301,6 +2307,12 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) disas_ldst_compute_iss_sf(size, false, 0), is_lasr); return; + case 0xc: /* LDLAR */ + if (!dc_isar_feature(aa64_lor, s)) { + break; + } + /* LoadLOAcquire is the same as Load-Acquire for QEMU. */ + /* fall through */ case 0xd: /* LDAR */ /* Generate ISS for non-exclusive accesses including LASR. */ if (rn == 31) {