From patchwork Mon Feb 20 23:26:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655142 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661735wrc; Mon, 20 Feb 2023 15:28:44 -0800 (PST) X-Google-Smtp-Source: AK7set/HJRwpjGPAowooO4CI+uhZ9c0wwOFtdgILdgHUxRsLcmv3or9+rNVQ52kdSvkdLwJO/FgH X-Received: by 2002:ad4:5c84:0:b0:56e:f9a2:3eba with SMTP id o4-20020ad45c84000000b0056ef9a23ebamr5221204qvh.41.1676935723959; Mon, 20 Feb 2023 15:28:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935723; cv=none; d=google.com; s=arc-20160816; b=QUA5C0Mj0DRas0F0BRqjjY6fwWUHVwZwMf1y7bDsGjg3AFYZb+dsliwcpxsJZWjOyo oEutW39ukCyeqX9NVshDxam1sCa9q6j/6rbOb+G/h0WRl4is8rGAtzn+psVfwZEdKqia x2CBMzVVpOLkDO4BGuki8zbeOY9Fp8dAoTSKoid7tJijU7+XyWfmjzAFbbrVvfPH8xwm fstBpEhh2UDhw6dPKY8bL00myGmHZsXUtvUdtc7+XzyrBW74Ityu+fKyuORSa9/FRSm8 l1iT7TCpujI0EzwiUVymDbcZ5MXdnU0vtP5CauEkRTH6EQMdCQ5an9HWbde7GV32/tzS VGbw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kl7nsc9p6BIDSk+FSIUoP/kFXINcnp5gsZ8dnkbWdwU=; b=hZdSI325N5lz/fjMr4kN8fpO4OZBvdnmTB4Sy0R7cMHTXE84+jisbsxlsw2UMiSHnp EQEda/xGGt6HdZLN5ZRSBasGePz/QxDesELz+kvIMqfrd0Fy/Os8lNBH0AFuVmFwsIY2 UJNZ+IFW6Ju2oza6x4Yoe0scRsUUuQ5tibX7dNwpCr2nMat/m21DozR0KnSnHzL9K4iH MSHFDf3HXwcIddDGugOX9+MqP7+BYoLd3YUDRYg6ZMeS6szfzUtqorEaYUyOVCbjlb8P xEO/zNzQlxWt7UdxnhJQyDvCvHtXx9TGdSg+tREZDWtkYcgjP052+lMvCIP2GKks8uo9 APdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Px0cV/J3"; 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=pass (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 az11-20020a05620a170b00b0071c5429ce79si10796509qkb.743.2023.02.20.15.28.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:28:43 -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=pass header.i=@linaro.org header.s=google header.b="Px0cV/J3"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUFYR-0003lv-8S; Mon, 20 Feb 2023 18:26:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUFYQ-0003k7-Dd for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:42 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYO-0000Jl-Jo for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:42 -0500 Received: by mail-pj1-x102c.google.com with SMTP id g14so2820879pjb.2 for ; Mon, 20 Feb 2023 15:26:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kl7nsc9p6BIDSk+FSIUoP/kFXINcnp5gsZ8dnkbWdwU=; b=Px0cV/J3cA5nxUSIyPH4WmDlrGXHRfWGHBHPLb9gDVPzqc5DzcQKJSyzqE9QlLI+KI MP0WilTKdLe3pXXIH00HYQMyLsx62Pkqwk6Y/a1VB8bKZpfoW7Bizazr8jZyFSj1hq6E ASiaiGbPrGXVTacms4f97QAVgpX0FOiK7uTEzf/O7O6hgzlAo4w3JO1TwflpHZIYew6h yICHGIc4nhDV/KSmGXZXjCaqbpkBKNmpArxqGPrBv4FQy+j/U1cr+O25W87Znir7OezD 6WLLXy02d05orj0R+erfCvNimihBA7U8BBPh4y3xIYrv5aXNr7uAJtTLWTEX1Ok7JS/i 1+uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kl7nsc9p6BIDSk+FSIUoP/kFXINcnp5gsZ8dnkbWdwU=; b=PC5wWMlxetl122Buf3Vbf72iPYj+p0/4b7bMnJ5s9q9mIXBwy1wexqAAasoSvc9LH6 gRe5Md8G+rAZAWO07lMd9fmLzVa07dc+PcqYx2ZnClBqs0F16lPsDHIIcmcXyHIErLwn xSSoO/RSgShkll1Lbr9FpQnJssGkEZsXYFtVrvmHzzkHObLZ39yo9oTe/w9IQ6759tkC B8wxozJiY2woENNmMX36Ne9JGYz+qDLYf5tqqZj0eRm5Ez3aMmKWoM+pOMWwWtu/T4l5 j4ZtQ15y1pPyILxgmEB7JTNnhMifMZOb8WeqoDd0/lVBWmWaKSN0ga/le7/DRmF13R4r EcGg== X-Gm-Message-State: AO0yUKX6UfbgJnXUpOzFlIA0CBpRMF75VtnTQu7lkqzAOlYCvQlzFdIw DvB8MuR7yS8bZ3iaYCuHV9t6IFramAcHU+EaUT4= X-Received: by 2002:a17:902:d4cc:b0:19b:dc8:c67b with SMTP id o12-20020a170902d4cc00b0019b0dc8c67bmr2462597plg.50.1676935598836; Mon, 20 Feb 2023 15:26:38 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 05/21] target/arm: Add RME cpregs Date: Mon, 20 Feb 2023 13:26:10 -1000 Message-Id: <20230220232626.429947-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org This includes GPCCR, GPTBR, MFAR, the TLB flush insns PAALL, PAALLOS, RPALOS, RPAOS, and the cache flush insns CIPAPA and CIGDPAPA. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 19 +++++++++++ target/arm/helper.c | 83 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 486baf3924..6a97c727d1 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -541,6 +541,11 @@ typedef struct CPUArchState { uint64_t fgt_read[2]; /* HFGRTR, HDFGRTR */ uint64_t fgt_write[2]; /* HFGWTR, HDFGWTR */ uint64_t fgt_exec[1]; /* HFGITR */ + + /* RME registers */ + uint64_t gpccr_el3; + uint64_t gptbr_el3; + uint64_t mfar_el3; } cp15; struct { @@ -1043,6 +1048,7 @@ struct ArchCPU { uint64_t reset_cbar; uint32_t reset_auxcr; bool reset_hivecs; + uint8_t reset_l0gptsz; /* * Intermediate values used during property parsing. @@ -2336,6 +2342,19 @@ FIELD(MVFR1, SIMDFMAC, 28, 4) FIELD(MVFR2, SIMDMISC, 0, 4) FIELD(MVFR2, FPMISC, 4, 4) +FIELD(GPCCR, PPS, 0, 3) +FIELD(GPCCR, IRGN, 8, 2) +FIELD(GPCCR, ORGN, 10, 2) +FIELD(GPCCR, SH, 12, 2) +FIELD(GPCCR, PGS, 14, 2) +FIELD(GPCCR, GPC, 16, 1) +FIELD(GPCCR, GPCP, 17, 1) +FIELD(GPCCR, L0GPTSZ, 20, 4) + +FIELD(MFAR, FPA, 12, 40) +FIELD(MFAR, NSE, 62, 1) +FIELD(MFAR, NS, 63, 1) + QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK); /* If adding a feature bit which corresponds to a Linux ELF diff --git a/target/arm/helper.c b/target/arm/helper.c index 2ebca3e2b6..c769218763 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6932,6 +6932,83 @@ static const ARMCPRegInfo sme_reginfo[] = { .access = PL2_RW, .accessfn = access_esm, .type = ARM_CP_CONST, .resetvalue = 0 }, }; + +static void tlbi_aa64_paall_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + CPUState *cs = env_cpu(env); + + tlb_flush(cs); +} + +static void gpccr_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* L0GPTSZ is RO; other bits not mentioned are RES0. */ + uint64_t rw_mask = R_GPCCR_PPS_MASK | R_GPCCR_IRGN_MASK | + R_GPCCR_ORGN_MASK | R_GPCCR_SH_MASK | R_GPCCR_PGS_MASK | + R_GPCCR_GPC_MASK | R_GPCCR_GPCP_MASK; + + env->cp15.gpccr_el3 = (value & rw_mask) | (env->cp15.gpccr_el3 & ~rw_mask); +} + +static void gpccr_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + env->cp15.gpccr_el3 = FIELD_DP64(0, GPCCR, L0GPTSZ, + env_archcpu(env)->reset_l0gptsz); +} + +static void tlbi_aa64_paallos_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + CPUState *cs = env_cpu(env); + + tlb_flush_all_cpus_synced(cs); +} + +static const ARMCPRegInfo rme_reginfo[] = { + { .name = "GPCCR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 2, .crm = 1, .opc2 = 6, + .access = PL3_RW, .writefn = gpccr_write, .resetfn = gpccr_reset, + .fieldoffset = offsetof(CPUARMState, cp15.gpccr_el3) }, + { .name = "GPTBR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 2, .crm = 1, .opc2 = 4, + .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.gptbr_el3) }, + { .name = "MFAR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 6, .crm = 0, .opc2 = 5, + .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.mfar_el3) }, + { .name = "TLBI_PAALL", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 7, .opc2 = 4, + .access = PL3_W, .type = ARM_CP_NO_RAW, + .writefn = tlbi_aa64_paall_write }, + { .name = "TLBI_PAALLOS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 4, + .access = PL3_W, .type = ARM_CP_NO_RAW, + .writefn = tlbi_aa64_paallos_write }, + /* + * QEMU does not have a way to invalidate by physical address, thus + * invalidating a range of physical addresses is accomplished by + * flushing all tlb entries in the outer sharable domain, + * just like PAALLOS. + */ + { .name = "TLBI_RPALOS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 4, .opc2 = 7, + .access = PL3_W, .type = ARM_CP_NO_RAW, + .writefn = tlbi_aa64_paallos_write }, + { .name = "TLBI_RPAOS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 4, .opc2 = 3, + .access = PL3_W, .type = ARM_CP_NO_RAW, + .writefn = tlbi_aa64_paallos_write }, + { .name = "DC_CIPAPA", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 1, + .access = PL3_W, .type = ARM_CP_NOP }, +}; + +static const ARMCPRegInfo rme_mte_reginfo[] = { + { .name = "DC_CIGDPAPA", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 5, + .access = PL3_W, .type = ARM_CP_NOP }, +}; #endif /* TARGET_AARCH64 */ static void define_pmu_regs(ARMCPU *cpu) @@ -9123,6 +9200,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) if (cpu_isar_feature(aa64_tlbios, cpu)) { define_arm_cp_regs(cpu, tlbios_reginfo); } + if (cpu_isar_feature(aa64_rme, cpu)) { + define_arm_cp_regs(cpu, rme_reginfo); + if (cpu_isar_feature(aa64_mte, cpu)) { + define_arm_cp_regs(cpu, rme_mte_reginfo); + } + } #ifndef CONFIG_USER_ONLY /* Data Cache clean instructions up to PoP */ if (cpu_isar_feature(aa64_dcpop, cpu)) {