From patchwork Mon Dec 18 11:32:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 755493 Delivered-To: patch@linaro.org Received: by 2002:adf:b181:0:b0:336:6142:bf13 with SMTP id q1csp828833wra; Mon, 18 Dec 2023 03:38:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5RAqugje7u45q3ql/fNd5pXDZDAhtwXKXGXXgjsmd69d84yHw8HqvwemqZz7MFr4fVMf+ X-Received: by 2002:a05:622a:194:b0:425:99fd:fd16 with SMTP id s20-20020a05622a019400b0042599fdfd16mr26328070qtw.70.1702899513456; Mon, 18 Dec 2023 03:38:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702899513; cv=none; d=google.com; s=arc-20160816; b=XuVZ42/Knw8NaRWQYWNEhv9YcZP0RzNca+DAUp7wIZtc3rUfLmkbpTbI+EQHavydrc 9+S0D7ss4KBZ7h6kw8E+UMz0yIOZjDRhbqZkJto6alUWJg1Lldb/PxWj2XMsHLpjQ0uQ OozebmzpW2izXnV3905vg3enkMcRft7hJXJwcuhP1W/O7RTc8R7edSfsLqSAGukqEvmA OmsIrr6KKAaWDtOX026zX/Fu0fmlzStmx7exVnXx4kiZcr1foBKgf6S0fZm+zHboQRLq s2LOwghvvE9+GZVNDAHRDWze/rSzmMYx7M0aMTncEdsimQcXFluxAktwUuKNKLGSxJRC Padw== 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:to:from :dkim-signature; bh=cnaAgGELiStMiiqiZ/WGnlE6jWaXkDE/fig9LQyAGcg=; fh=H2AmuqulvQE+T5zu97MCEUC3z9wF9NssS7895NhR/+c=; b=SMYoLaFm/zHkmoiRFWsXCqfzA3Gr4Jq9oq1hYaK8a+kR8On7vHaJut57vWXm2a3grt 2jYcNsdzRqYCzdD0Vw1X+RJy8ptq8kQS3PU7uVbqxYA3nBzntzk8bChP/Kc79gWi1sdm vl1Y2MDDlU09vWi9k56zBVIKYvwOVzyRZY7AKWWCZhhq2KJ1eFMbSQ4hqaKbtx+6JWlW sYTQMHYI4XilSyfPpph8VWCHR9SijB5mmjSA1WCV12dUGlEUNJAUqVdvFJLZ6vkIpz9K NZBe7A6f+qvWdEOt8p5h6o//DazjwT1uxLJmK6kDREBNzr1db9IzQ6yEIr0ie88/SdkK 0D9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="svZF/0nL"; 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 t12-20020ac8588c000000b00425e75fa13csi14533573qta.90.2023.12.18.03.38.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Dec 2023 03:38:33 -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="svZF/0nL"; 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 1rFBsG-000726-IO; Mon, 18 Dec 2023 06:33:28 -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 1rFBsE-0006zC-Ps for qemu-devel@nongnu.org; Mon, 18 Dec 2023 06:33:26 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFBs7-0003MH-2I for qemu-devel@nongnu.org; Mon, 18 Dec 2023 06:33:26 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40c68c1990dso32892575e9.0 for ; Mon, 18 Dec 2023 03:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702899197; x=1703503997; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cnaAgGELiStMiiqiZ/WGnlE6jWaXkDE/fig9LQyAGcg=; b=svZF/0nLA3Lgvz5LNmtl4+J632zMGgFFqZH4JLAiExhu6bPJh4ILQDrNCbstBjwpjT r2v2OjS1735IgrDi95f3gkK6ZgypKlkdsDy+g8NgPYEBzitmNHtpgLOmSnLRO7zztRry sgwsf5zBuku8Iw0ePGpJwckYjBYhlhvpLI618nKoAPVYpnHlG6BKkjf+0WG8YvTQtOW7 aB0Z8Sfh461VugjDEiT9Lwxlf0Z4cZfoGVo7d4OLc47aFrLwV1S8sPg1thPJEd2KUp8O /g6ojFjRcKYGGvyyKKdjPE6ZBaS9v/qEqOzXK+5bs8797hsJvEncpBD5Vyd5BaADu75m fWkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702899197; x=1703503997; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cnaAgGELiStMiiqiZ/WGnlE6jWaXkDE/fig9LQyAGcg=; b=TzbRq5tB3/XWr0QB/fbQ+hyFGZr+6saDaJ5VejPnTCs3GYIzzrNUbnhPtWFkZhl11Q qE1JBk3OOpElYfMVUb0cYFeu7ffwwMtOZwW1uHGwsPcy52GAe0sbJclpObqo4gpTLY4M 3qslucYy7PCfdRIwjHEXG1/GkXfMXsAhyM27TgpunRfMPDiDGJPIm/2Vt0L0hAGVr3dd RpvNRhfZ6QRDKQoLxnxjKAYpIsqR3BVHiRaa9zLv1nldCLBIXAKnvYpoIGbP691WyAof XjC9WL36dZC36T18X6A910AJDytmcxy+AkV1DO+r52XwjF4EtjgeGXNXEHsDlkAktLwd 2Tbw== X-Gm-Message-State: AOJu0Yzs2Ic1ouGlcpMXkEa7wHKvsfNZf8Zn1pT7JPP6SibdxYiCUAiJ MS/YME39VdXLkiksTKx9Mc3nu6BjwH09Cd51LP4= X-Received: by 2002:a7b:cd0c:0:b0:40c:359c:47fd with SMTP id f12-20020a7bcd0c000000b0040c359c47fdmr5590379wmj.178.1702899197767; Mon, 18 Dec 2023 03:33:17 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id j18-20020adff012000000b003366da509ecsm671193wro.85.2023.12.18.03.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 03:33:17 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 23/35] target/arm: Implement VNCR_EL2 register Date: Mon, 18 Dec 2023 11:32:53 +0000 Message-Id: <20231218113305.2511480-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218113305.2511480-1-peter.maydell@linaro.org> References: <20231218113305.2511480-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 For FEAT_NV2, a new system register VNCR_EL2 holds the base address of the memory which nested-guest system register accesses are redirected to. Implement this register. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/cpu.h | 3 +++ target/arm/helper.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0ec67847181..9df8fc08d79 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -547,6 +547,9 @@ typedef struct CPUArchState { uint64_t gpccr_el3; uint64_t gptbr_el3; uint64_t mfar_el3; + + /* NV2 register */ + uint64_t vncr_el2; } cp15; struct { diff --git a/target/arm/helper.c b/target/arm/helper.c index afed58b6f7f..45444360f95 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8107,6 +8107,28 @@ static const ARMCPRegInfo fgt_reginfo[] = { .access = PL2_RW, .accessfn = access_fgt, .fieldoffset = offsetof(CPUARMState, cp15.fgt_exec[FGTREG_HFGITR]) }, }; + +static void vncr_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* + * Clear the RES0 bottom 12 bits; this means at runtime we can guarantee + * that VNCR_EL2 + offset is 64-bit aligned. We don't need to do anything + * about the RESS bits at the top -- we choose the "generate an EL2 + * translation abort on use" CONSTRAINED UNPREDICTABLE option (i.e. let + * the ptw.c code detect the resulting invalid address). + */ + env->cp15.vncr_el2 = value & ~0xfffULL; +} + +static const ARMCPRegInfo nv2_reginfo[] = { + { .name = "VNCR_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 2, .opc2 = 0, + .access = PL2_RW, + .writefn = vncr_write, + .fieldoffset = offsetof(CPUARMState, cp15.vncr_el2) }, +}; + #endif /* TARGET_AARCH64 */ static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, @@ -9590,6 +9612,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, rme_mte_reginfo); } } + + if (cpu_isar_feature(aa64_nv2, cpu)) { + define_arm_cp_regs(cpu, nv2_reginfo); + } #endif if (cpu_isar_feature(any_predinv, cpu)) {