From patchwork Tue Jan 24 00:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 645982 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp2471253pvb; Mon, 23 Jan 2023 16:05:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXviRdmsG4YgMz2Hz1Z/Wri/nTE6Fhlo7fLxV7maCwEBjf+TnCq+0vXywqp3AjMYJoeG3v1E X-Received: by 2002:ad4:48c4:0:b0:532:c11:c390 with SMTP id v4-20020ad448c4000000b005320c11c390mr36703915qvx.14.1674518729369; Mon, 23 Jan 2023 16:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674518729; cv=none; d=google.com; s=arc-20160816; b=zcW7h/Ze5go5GMtSMVyd8bBOGfXw2tBXW5sQihyN/KOqVetsLNzbmrzTr6LsfrXqtU cMxN6Hiq/0qp6gJNhkUe/uccLOABYc1QrIKROuu3DCu+g86pASpDvc2wfHKyxIgIs2Cc PlEtSHx9sOW+r2hv2EhB77PIVjDLdOMBz8Yw96mJ/jYMJ4zqXgxOVV4yjT3McOt+X0eo TR9gi6RWUO4Xogk2dwFgwzvs8i5HVsaJ7+ztnntOFFuB8YhIjPIfdXu2+8KlpRpb98du yoj+i5y2SUWn1hKdXevq0+bnNR/KQEAbnrRxMCvBYyJGJp94cpDmmo1mKr2aZR5KbkPi KPbA== 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=F6JnjYYyfWuQ76nLJMJggCd96mltrDtBeLHdFG+/fn0=; b=t36nWZeuMz0fvPSJvcN7ejdHxOjB/Xdz5SqN9WV1//YZGtHyjGOOLWf6lJJcgJF58j gEZer91bE/+HRmj70X8y6dh3U/lArGnaZjLF0LxMqLv32+fu4KAUX2QdEvI3TODGmRCQ t7mdvWTzyoyVlPqj/p8G4n4VoaOy0WLzqFDoF1AsmGkM1uXM52fsM4rjEO4V41XmDXPH BGv/RcXg84lBA+oiNZ8j9Vf2fyhhTk7Lp1DyayD94Rm6rvPZw6nQs+qomhiTfYEbTfpv 6TGRi0URumMo6yMiAuEdFonW4xI2vK0tj+Oz3lfZXI7cPIsZnX88GfLp137TxzLygfyy kcNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZH8SXape; 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 kr30-20020a0562142b9e00b005346c78e62fsi238927qvb.584.2023.01.23.16.05.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jan 2023 16:05:29 -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=ZH8SXape; 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 1pK6kK-0008UX-Km; Mon, 23 Jan 2023 19:01:04 -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 1pK6kG-0008BZ-T0 for qemu-devel@nongnu.org; Mon, 23 Jan 2023 19:01:01 -0500 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pK6kD-0001qX-Um for qemu-devel@nongnu.org; Mon, 23 Jan 2023 19:01:00 -0500 Received: by mail-pg1-x52e.google.com with SMTP id b12so10242130pgj.6 for ; Mon, 23 Jan 2023 16:00:57 -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=F6JnjYYyfWuQ76nLJMJggCd96mltrDtBeLHdFG+/fn0=; b=ZH8SXapeW/ubErkQQ/SgQzs5hDrtcJWJfftxwX/CkHCCVYrX5vQB0t8gC/wBtMPHHf SNBoSM0YMU7KABdhHyd4XQiIEhhQYRuW+489A5RVdeSSU8N8MC0GOYiXIva9AeR5wvMr HmL3EveaJzWy01eomOF3Q5kRftrPUFkHJYukrZQV7j9G8YsqKg7aHWR329/Xo6hvMY7X Dp9PTRAIDfz3G0su1RNQGyaa4UtU0SnLm7XOtoHx5m/nxte+qIcY/FG/NW1a3kc7dIAv gTio2B9N9hpf4wAb1Q47xfXAeInwKzQRWn5mYYrnOHXV4y83HSC0cf2OyOPR3RpMdDNf 1Hig== 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=F6JnjYYyfWuQ76nLJMJggCd96mltrDtBeLHdFG+/fn0=; b=jvUR/jfmfrMjzfLt2wal633npgWwVoKyHbEcQtaOvbc/C7qQ2ridF1YgwEG0VGhOtI HTxsZYWLfcejxDWef7E/PlJ0kYPpNsXlifgA+e8846xr0z63fYTKLpUb7tk2pYXCbTuv MtQcSwfvIVBBemAtCQL03IElGIwkbfj76heN1tbHfyXeFGhsiCEkKkh+wmizJNIJyIuN CUJLX1f0vzoAMwNxZ3/vNt973ydAim6XoQ1DS4WlXsTOjpsCNph+w4xBC+o7DCi/18tT 3r/Ym7mzhMCXCAix1UxmpLYR0KLAh53E9m6MEQfM38yHy2XMNjTFOkOOKM0VtYEFWdEg 8KEA== X-Gm-Message-State: AFqh2kopa8KVWInHNVYtrYmw4Io3PcBzhcXz9Jmj2A9tBl8nOa9Jc8cD tIX0st197Tq9FhfNJHd0bPpb9ny9+5CSdg1X X-Received: by 2002:a05:6a00:190e:b0:58b:c1a1:4006 with SMTP id y14-20020a056a00190e00b0058bc1a14006mr32861709pfi.18.1674518457191; Mon, 23 Jan 2023 16:00:57 -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 x21-20020a056a00189500b0058bc37f3d13sm174104pfh.43.2023.01.23.16.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 16:00:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, yier.jin@huawei.com, jonathan.cameron@huawei.com, leonardo.garcia@linaro.org Subject: [PATCH 06/22] target/arm: Add RME cpregs Date: Mon, 23 Jan 2023 14:00:11 -1000 Message-Id: <20230124000027.3565716-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230124000027.3565716-1-richard.henderson@linaro.org> References: <20230124000027.3565716-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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=ham 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 insn CIPAPA. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/cpu.h | 19 ++++++++++++ target/arm/helper.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9d1a6b346d..26bdd6e465 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -529,6 +529,11 @@ typedef struct CPUArchState { uint64_t disr_el1; uint64_t vdisr_el2; uint64_t vsesr_el2; + + /* RME registers */ + uint64_t gpccr_el3; + uint64_t gptbr_el3; + uint64_t mfar_el3; } cp15; struct { @@ -1031,6 +1036,7 @@ struct ArchCPU { uint64_t reset_cbar; uint32_t reset_auxcr; bool reset_hivecs; + uint8_t reset_l0gptsz; /* * Intermediate values used during property parsing. @@ -2324,6 +2330,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 783b675bd1..7bd15e9d17 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6848,6 +6848,77 @@ 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 }, +}; #endif /* TARGET_AARCH64 */ static void define_pmu_regs(ARMCPU *cpu) @@ -8915,6 +8986,9 @@ 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); + } #ifndef CONFIG_USER_ONLY /* Data Cache clean instructions up to PoP */ if (cpu_isar_feature(aa64_dcpop, cpu)) {