From patchwork Sun May 1 05:50:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 568581 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp7721759map; Sun, 1 May 2022 00:20:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWnM6eamc5Q3Lt76rGSMEBPF1fexhdqDia5v6ItzHyyN3D6zzuXaqe9rgJilCcdxK+gXs/ X-Received: by 2002:ac8:5893:0:b0:2e1:c7f6:9992 with SMTP id t19-20020ac85893000000b002e1c7f69992mr5835600qta.23.1651389632035; Sun, 01 May 2022 00:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651389632; cv=none; d=google.com; s=arc-20160816; b=A4GauRGyT58egGrDmbnmVRb07NXYApxt3Xv/rWeTadEGypNppwUpQzSuFEiUpn9qSb YjIU7BusaT/dnIkPp1q3tnrug9dOp6hFAXq6Cm1BgM5BTVp7JkWj6zWmrF6ui8OQFdAi +l3raqY6lyDk5Y4qqwvZagRkPDAZgx39qB4nhQh4oPkF0+8SOSRjebYJ8Ub9OjZV8Pxo XXeU6KZgOla80qUuQ2aumrRGK5EP4oBwcQhf9Hw1HpYTPidPPaDiWUCynROj5jkIj0o8 F3lvQXuKVa9q6N7eDls9CEpYuC8qB8e2G/JqDckiftCbsq7geNe0eP8hmgxq255SLGjF JWSA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=OgK/bg8qfHwwWTHPP3NZqw3YdheAlsDilvaD2LibWrI=; b=uLTxZvNbvIhXxVZ49IesK1FZ8yrKAEj1M7ro6Q/zaE66AsrozORhStIt3B/mRs3ydV VStVnFJpXkgB8nGJVhVh5UXLUeR9AikRCQWzRJC8V9tSdWOyFfUZMLJ/H+Ia9h7qKiRh iAfsWPj1BOOJaI8hFc6Rkd1h1UqZqoIhde5Z5Jx0D71ZKboIb43t9Q1j+uNWXgty2SKb KafxrPsJ7FCgWV6SuZelaGPTJEYD94Q81JuC0HSa4u5V/axLB0QekHiiESrylDgXD/Pi +uurn8X3nF2g8BKLqoKa+Eiva3e4UfHZam8DK/Z8pBTznS4nybH4FzpyvgKyfkLF94At D3ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U1Y6ZakE; 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 u8-20020ad45aa8000000b0045a853e62d4si729035qvg.123.2022.05.01.00.20.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 01 May 2022 00:20:32 -0700 (PDT) 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=U1Y6ZakE; 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]:40404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nl3sd-0000Vh-Ky for patch@linaro.org; Sun, 01 May 2022 03:20:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nl2UD-00077o-Aw for qemu-devel@nongnu.org; Sun, 01 May 2022 01:51:14 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:45763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nl2U8-0001Q6-Gu for qemu-devel@nongnu.org; Sun, 01 May 2022 01:51:12 -0400 Received: by mail-pf1-x42c.google.com with SMTP id h1so10049743pfv.12 for ; Sat, 30 Apr 2022 22:51:03 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=OgK/bg8qfHwwWTHPP3NZqw3YdheAlsDilvaD2LibWrI=; b=U1Y6ZakEi2LMpP+oP/YCAbXEpQ97pTuP2QGD8C3UeDqqeWqk6IwK76XqfSV8uZViKH GWPfY0bW4IEd4KdqDl+uvhWsDQ7D5Rr+/TWiPDJKh16788mcMczsjJkbuVO35KC1CWHX fQOHweNFWbctlp62jf01/mQIiIVkR1MQEM7nrTUbMmaW2HRoHtASd+fojhB4jpPRwwA3 d6hJ88BwkfFoyBjhQVdmhG6KOaHU5kgdWbYzYqwKcpejiTM47NwSB003PnpVHNkQKAuI +T0cyUBnKi9jc7so4Ij1v1Ey77K6JvF8dGTk6bnDak6glhOsqF5+ASvdG+3WCIxNL8cL HGaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OgK/bg8qfHwwWTHPP3NZqw3YdheAlsDilvaD2LibWrI=; b=ZYncZu1IPoe1DzHKvYIBgXiRwcNO6k0lbsXFjs2aRiI1lUkq0NZL+BUZzlOVy5zL18 TBGFW+/hJnMrn3JBXGzawEkkjec0iq/PiZOEu8dWrwtQWt1bMeflicHWKyFV9pkRKpIm ArhCJzGMFViS3lfXTE1Nsk/skU6p+2hlQR3aTwHDrPW9KZee8cE9wIv+zsTuiSUJjU+q P48kJXBfn56lwGtdorEQYSXl4Bj5sHyoCQscWWwQULEuotmsSFloKL9HaL4oum4QU7nN cb4Hn2PVty25fblYAe9tNc47g5sQG4SSItHaPIhzlqIZssxbeEXojCnHKWg1BnUITIWd vr6g== X-Gm-Message-State: AOAM530wlfNc4EKE/YGnlmXXNeB55PjmCTQexh9120htI7qwGmh05bYB h63vD3UXKPtVNBX9BwIVfDkxozwk47eaLQ== X-Received: by 2002:a05:6a00:98b:b0:50d:ac70:c39a with SMTP id u11-20020a056a00098b00b0050dac70c39amr6112590pfg.25.1651384262943; Sat, 30 Apr 2022 22:51:02 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id cm18-20020a17090afa1200b001cd8e9ea22asm17310342pjb.52.2022.04.30.22.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Apr 2022 22:51:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 34/45] target/arm: Add minimal RAS registers Date: Sat, 30 Apr 2022 22:50:16 -0700 Message-Id: <20220501055028.646596-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220501055028.646596-1-richard.henderson@linaro.org> References: <20220501055028.646596-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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: , Cc: qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add only the system registers required to implement zero error records. This means we need to save state for ERRSELR, but all values are out of range, so none of the indexed error record registers need be implemented. Add the EL2 registers required for injecting virtual SError. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- v2: Leave ERRSELR_EL1 undefined. v3: Rely on EL3-no-EL2 squashing during registration. --- target/arm/cpu.h | 5 +++ target/arm/helper.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index ca01f909a8..a55980d66d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -525,6 +525,11 @@ typedef struct CPUArchState { uint64_t tfsr_el[4]; /* tfsre0_el1 is index 0. */ uint64_t gcr_el1; uint64_t rgsr_el1; + + /* Minimal RAS registers */ + uint64_t disr_el1; + uint64_t vdisr_el2; + uint64_t vsesr_el2; } cp15; struct { diff --git a/target/arm/helper.c b/target/arm/helper.c index a5741e0ad7..b4bdd4a4a6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5980,6 +5980,87 @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, }; +/* + * Check for traps to RAS registers, which are controlled + * by HCR_EL2.TERR and SCR_EL3.TERR. + */ +static CPAccessResult access_terr(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + int el = arm_current_el(env); + + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_TERR)) { + return CP_ACCESS_TRAP_EL2; + } + if (el < 3 && (env->cp15.scr_el3 & SCR_TERR)) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +} + +static uint64_t disr_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + int el = arm_current_el(env); + + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) { + return env->cp15.vdisr_el2; + } + if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) { + return 0; /* RAZ/WI */ + } + return env->cp15.disr_el1; +} + +static void disr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t val) +{ + int el = arm_current_el(env); + + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) { + env->cp15.vdisr_el2 = val; + return; + } + if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) { + return; /* RAZ/WI */ + } + env->cp15.disr_el1 = val; +} + +/* + * Minimal RAS implementation with no Error Records. + * Which means that all of the Error Record registers: + * ERXADDR_EL1 + * ERXCTLR_EL1 + * ERXFR_EL1 + * ERXMISC0_EL1 + * ERXMISC1_EL1 + * ERXMISC2_EL1 + * ERXMISC3_EL1 + * ERXPFGCDN_EL1 (RASv1p1) + * ERXPFGCTL_EL1 (RASv1p1) + * ERXPFGF_EL1 (RASv1p1) + * ERXSTATUS_EL1 + * and + * ERRSELR_EL1 + * may generate UNDEFINED, which is the effect we get by not + * listing them at all. + */ +static const ARMCPRegInfo minimal_ras_reginfo[] = { + { .name = "DISR_EL1", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 1, .opc2 = 1, + .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.disr_el1), + .readfn = disr_read, .writefn = disr_write, .raw_writefn = raw_write }, + { .name = "ERRIDR_EL1", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 3, .opc2 = 0, + .access = PL1_R, .accessfn = access_terr, + .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "VDISR_EL2", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 1, .opc2 = 1, + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vdisr_el2) }, + { .name = "VSESR_EL2", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 3, + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vsesr_el2) }, +}; + /* Return the exception level to which exceptions should be taken * via SVEAccessTrap. If an exception should be routed through * AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should @@ -8214,6 +8295,9 @@ void register_cp_regs_for_features(ARMCPU *cpu) if (cpu_isar_feature(aa64_ssbs, cpu)) { define_one_arm_cp_reg(cpu, &ssbs_reginfo); } + if (cpu_isar_feature(any_ras, cpu)) { + define_arm_cp_regs(cpu, minimal_ras_reginfo); + } if (cpu_isar_feature(aa64_vh, cpu) || cpu_isar_feature(aa64_debugv8p2, cpu)) {