From nobody Sat May 30 18:37:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1779204843; cv=none; d=zohomail.com; s=zohoarc; b=KAhKZ+rZz5r5OJZClJjAnw8DEPqEI6EzI1LzcteLlFvsxvH81ASb7Nyts/QOVJq8vNl306/IMkwfvxx7pftMH55yf3Oy6e/JaDfyG1eeKySJCI75vRg+R8niWXI1TrS6IHdUUBR6zE5c53gQwvbK3S3sXe790/UeLjPK/bjrABE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779204843; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pYmKjFuS4S1UdxusOVX29Ta5fki6ZMd1A5v9kjl/tsM=; b=M2nEdPOS+vm20b0W1YyhfV0gfo+XxFSqTkqmBBVXhCLTbpaZsxdHMOuETRN5XS1Bi+Q9kJ5hRsz8nFK63x2IZTjCgYRQUym1LpiQlE7GgAt87L/rLs14Ft8imqamjKEINOVzeqfmXU+e6ATg0lPQl57g2V6i716x+X9wPDuozC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779204843452701.5093768580065; Tue, 19 May 2026 08:34:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPMRq-0008TS-P0; Tue, 19 May 2026 11:33:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPMRc-0008O9-Gs for qemu-devel@nongnu.org; Tue, 19 May 2026 11:33:25 -0400 Received: from mail-06.mail-europe.com ([85.9.210.45]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPMRY-0002eg-B7 for qemu-devel@nongnu.org; Tue, 19 May 2026 11:33:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1779204788; x=1779463988; bh=pYmKjFuS4S1UdxusOVX29Ta5fki6ZMd1A5v9kjl/tsM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Kxn25ESnH4/B+F2PwoK4I/w/C+NPIUnaRZzgqyBfpUcx5wE4p2Y+sPLAXLHovZW8L 1GzdFZLFFDNO2L5OYDfPx1naULxivxj9Ie6K58YTLgpaxxtt4QFclZL/1xh8Ckw5QU wcsi+5Ui+fVJBWmS9a2/mOwdNr5Z5snSFyw+x6tcxbpHiPlFKIUcDV/RK0NyNtw/OI 2xjz6cErbnzvfzzkzZ2ne8j7OfwnJgfIc80SL0q+0Q3CnVaJfXnLrceURcxoyL2GeD wYaNp/7ByQXy373vHN9LL5U4Hgr+fYHFVu/L9GUjT1HOu7xep7MvdNH13K0pM9Fqh1 Wyn1h+RGDE9gA== Date: Tue, 19 May 2026 15:33:03 +0000 To: Peter Maydell From: Jason Wright Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 1/2] target/arm: implement FEAT_RNG_TRAP for RNDR/RNDRRS Message-ID: <20260519153249.31100-2-wrigjl@proton.me> In-Reply-To: <20260519153249.31100-1-wrigjl@proton.me> References: <20260519153249.31100-1-wrigjl@proton.me> Feedback-ID: 198029889:user:proton X-Pm-Message-ID: 9667e4f3dd1008b647acc16e6aa19be4b6ca9db2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=85.9.210.45; envelope-from=wrigjl@proton.me; helo=mail-06.mail-europe.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, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1779204846321158500 Content-Type: text/plain; charset="utf-8" Add an .accessfn to the RNDR and RNDRRS system registers that traps reads to EL3 when SCR_EL3.TRNDR is set, as required by FEAT_RNG_TRAP. Mark SCR_EL3.TRNDR (bit 40) as a writable field in scr_write() when the CPU advertises the feature. The pseudocode in DDI04387 revision M.b shows the trap firing from El0, EL1, EL2, and EL3, so there is no check of arm_current_el(). Signed-off-by: Jason Wright --- target/arm/cpu-features.h | 5 +++++ target/arm/helper.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 4e44245a8b..a3f1406f69 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -890,6 +890,11 @@ static inline bool isar_feature_aa64_rndr(const ARMISA= Registers *id) return FIELD_EX64_IDREG(id, ID_AA64ISAR0, RNDR) !=3D 0; } =20 +static inline bool isar_feature_aa64_rng_trap(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64PFR1, RNDR_TRAP) !=3D 0; +} + static inline bool isar_feature_aa64_tlbirange(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64ISAR0, TLB) =3D=3D 2; diff --git a/target/arm/helper.c b/target/arm/helper.c index 8240f1b384..e293cc3836 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -787,6 +787,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegI= nfo *ri, uint64_t value) if (cpu_isar_feature(aa64_mec, cpu)) { valid_mask |=3D SCR_MECEN; } + if (cpu_isar_feature(aa64_rng_trap, cpu)) { + valid_mask |=3D SCR_TRNDR; + } } else { valid_mask &=3D ~(SCR_RW | SCR_ST); if (cpu_isar_feature(aa32_ras, cpu)) { @@ -5294,6 +5297,15 @@ static const ARMCPRegInfo pauth_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, keys.apib.hi) }, }; =20 +static CPAccessResult access_rndr(CPUARMState *env, const ARMCPRegInfo *ri, + bool isread) +{ + if (env->cp15.scr_el3 & SCR_TRNDR) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +} + static uint64_t rndr_readfn(CPUARMState *env, const ARMCPRegInfo *ri) { Error *err =3D NULL; @@ -5325,11 +5337,11 @@ static const ARMCPRegInfo rndr_reginfo[] =3D { { .name =3D "RNDR", .state =3D ARM_CP_STATE_AA64, .type =3D ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END | ARM_CP_IO, .opc0 =3D 3, .opc1 =3D 3, .crn =3D 2, .crm =3D 4, .opc2 =3D 0, - .access =3D PL0_R, .readfn =3D rndr_readfn }, + .access =3D PL0_R, .accessfn =3D access_rndr, .readfn =3D rndr_readf= n }, { .name =3D "RNDRRS", .state =3D ARM_CP_STATE_AA64, .type =3D ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END | ARM_CP_IO, .opc0 =3D 3, .opc1 =3D 3, .crn =3D 2, .crm =3D 4, .opc2 =3D 1, - .access =3D PL0_R, .readfn =3D rndr_readfn }, + .access =3D PL0_R, .accessfn =3D access_rndr, .readfn =3D rndr_readf= n }, }; =20 static void dccvap_writefn(CPUARMState *env, const ARMCPRegInfo *ri, --=20 2.50.1 (Apple Git-155) From nobody Sat May 30 18:37:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1779204834; cv=none; d=zohomail.com; s=zohoarc; b=DAkSDXxSVBRT0q1BxhLubJMiiVN7xwoeirLBh2L80Y+Rpf1FH2m5dt7++3xFK70gKDzbk/19zk8RiWaiRU/MgbaPQDXa6qmvgqX/zgONOB5U9DHoiAu+gIT2b7ZHcEU+et2mFCFl0FBKnTf02m5iS9C+mdfKYe12XsAPEe8oeI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779204834; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W+BGqpzXNd9QawnVgBG/CnE2Yr1j4Ig9F9/QpkEif4g=; b=XFR9/OnEw8PtvNP+3KzpBCFQ2uNw/ahqPw4HTwNU6GkydMul9et3xb9pkZE98wSMs0qf0H++xs8yfBAGb8ftteq24DkA9Kz4Moc3fzze10qGkYjk3HZqlm4zB954FjfFfF8mcMKW5CgyIeo1JZLDz68UJ30aB0tp5RecsNdAiGk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779204834133981.292696450067; Tue, 19 May 2026 08:33:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wPMRs-0008U2-AG; Tue, 19 May 2026 11:33:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPMRc-0008OA-Gv for qemu-devel@nongnu.org; Tue, 19 May 2026 11:33:25 -0400 Received: from mail-07.mail-europe.com ([188.165.51.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wPMRY-0002ft-BG for qemu-devel@nongnu.org; Tue, 19 May 2026 11:33:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1779204791; x=1779463991; bh=W+BGqpzXNd9QawnVgBG/CnE2Yr1j4Ig9F9/QpkEif4g=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=dJU/6pxGWp+BKMUdcuOnHq4/iC4hKLa/1wvdtyiYklA0cgCma5XwBayhatBoIeCnR YK9toYw7iPG1bEpvOoQfWn2HKoA7mQUcuTNtCGPcE7QkC/n3cEkbZoxeY2pubACZCT ZS7on4epxJae5cTR5/LfhQpV8EbXgFT3wYFjsrojtRsoT4sVl1hBLsv6hqWP/pAyhZ vIjGbn7tqJv5RACqjHDcakeW+7qcUoYGHkGr2qM7+hzSLrytZmtUGRRvG59kay0W9R EymGLYQBhE9wvcFoUXsnCi90D0gZ1eMX3Aj6iE4jRULkzy3UxAfY8KZVzRqkRgl+BA SWvX3oGMkhMRg== Date: Tue, 19 May 2026 15:33:09 +0000 To: Peter Maydell From: Jason Wright Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 2/2] target/arm: advertise FEAT_RNG_TRAP on cortex-max Message-ID: <20260519153249.31100-3-wrigjl@proton.me> In-Reply-To: <20260519153249.31100-1-wrigjl@proton.me> References: <20260519153249.31100-1-wrigjl@proton.me> Feedback-ID: 198029889:user:proton X-Pm-Message-ID: 2c4eb3eadc1cd6e18bda07b73588ceb45150b5c5 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=188.165.51.139; envelope-from=wrigjl@proton.me; helo=mail-07.mail-europe.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @proton.me) X-ZM-MESSAGEID: 1779204836591158500 Content-Type: text/plain; charset="utf-8" Set ID_AA64PFR1.RNDR_TRAP=3D1 on the max CPU model so guests and firmware detect FEAT_RNG_TRAP, per the Arm Architecture Reference Manual for A-profile architecture (DDI 0487). Signed-off-by: Jason Wright --- target/arm/tcg/cpu64.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index 649d854a65..8caa06ecb7 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1291,6 +1291,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_3 */ t =3D FIELD_DP64(t, ID_AA64PFR1, NMI, 1); /* FEAT_NMI */ t =3D FIELD_DP64(t, ID_AA64PFR1, GCS, 1); /* FEAT_GCS */ + t =3D FIELD_DP64(t, ID_AA64PFR1, RNDR_TRAP, 1); /* FEAT_RNG_TRAP */ SET_IDREG(isar, ID_AA64PFR1, t); =20 t =3D GET_IDREG(isar, ID_AA64MMFR0); --=20 2.50.1 (Apple Git-155)