From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813770; cv=none; d=zohomail.com; s=zohoarc; b=Clt/ww8HNapvXHhOhGKNGiyBgYZSXmpCpRnJuTE3NKW2fcE6Ky47Lpb7yLmXGd99SKwLCGHFOqz8RTCFNCMObXy7AoqS8Dg1+VvIdhUysnd4sCMQ3suvQ2dKNEG7qrFJ8GiBue88JDmOBSoZ6fZEAW0RDTeDOIr3Wty04LsL9jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813770; h=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=8cYPzfT79hzawhax/U0Dq4YWRUe35ck31xEEzB7qIbI=; b=KGj/OIX1IiyshdEQuVFAuOc7ew9HD0/m2GJCwifltQAsusvTycQ9al24Em5oq9K5X7NNLzOQgJ9N177ujar30JJnecflnmsP/Uw6sRgwFku2+xW2Qd3akhTdNm3RZj/Fo7plv+iKu4Utve/1J2bmqsPLlrKReI9cjR/7V3ScvMQ= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813770623299.72559133610116; Fri, 6 Mar 2026 08:16:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXpq-00044f-8Y; Fri, 06 Mar 2026 11:15:35 -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 1vyXpm-00042b-8g for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:26 -0500 Received: from p-west3-cluster1-host1-snip4-5.eps.apple.com ([57.103.73.136] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXpi-000744-9L for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:24 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id E317918007AA; Fri, 6 Mar 2026 16:15:17 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 20CA818007A1; Fri, 6 Mar 2026 16:15:14 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813720; x=1775405720; bh=8cYPzfT79hzawhax/U0Dq4YWRUe35ck31xEEzB7qIbI=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=LC/7LAydiWLq1d/v9RBzpYXZly846TQaD88WSnaeoRmbhwZ0aplSe34SmCNcUEfO/Z9bKvX6dCemGqSgmDs9TjZUDWtg9gKYkh6p9ifpj5Sc4ZkOQHDCbDiK8ubEE95oCa1e48JyXguDqR2IezcNcv/ThAjpSDurQYOnwQiiD8t2RPF6eNyS3rZwyB5PPtYmm3WWrtcVyIvoCAqoDyhGH9Ahbm8D/PFrAy945wVgKbmvaQeSaRKFndr5EocuZBSW4LReSRNAqn+phPU+yeoE26HSirci7gqmD3Hcba5AJ54RXGaZqkbooJhTd3/12AxLEtUtXerFQ0uw+fqhkCvoYg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 01/17] hvf/arm: handle FEAT_SME2 migration Date: Fri, 6 Mar 2026 17:14:53 +0100 Message-ID: <20260306161509.79712-2-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: fABST7ofA2SqHggr-w214vnQE84mJyC- X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX4SSEaUK6D73U Usu2Cn+/Ka3EF4HlnxOMiOhvQgsQ62avlOyIlX7JU6AlfOLaou/wmvVUSYjiGA37lhxQpvCbbnn R1doUEJShBztiRKO+HFqFWo+u1Afm5GoXRMrTGTYWB3ZM/JUnl7ybuZa+73NQgxFp7g8LgyJwnK zS01nnHCrIvzZL/d8DmsFb+fyyZfd6X6ck1k4koKh6Nv0vQ115A2OYTFuJkN/rTcKLaVvHlssBf SNMOEz0/NORHocQeLntB0lY5XOfEG0Z9DdBhV3Kt2IG4XDVurZJ4v621Ct3dONWLxUvVaUYNkC5 ns1+vFyDzLQD2zLgId/fVZUNOzykn9ldYtQ7HE+A0BLGWX+SGwqSx4OLcZahBU= X-Authority-Info-Out: v=2.4 cv=DrpbOW/+ c=1 sm=1 tr=0 ts=69aafd96 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=FwCt1zJGaJMg4q4ZpKQA:9 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: fABST7ofA2SqHggr-w214vnQE84mJyC- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 bulkscore=0 clxscore=1030 malwarescore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABfDPucK8Bw+TDfDg2ztKb/KSypq2pmZoPhh+Zr/34Ln29r9cWFXa9n2EZPitSn3aqQAly/HHoXHvqUqG8cXqV1QzUuQ1bq0fMqyh9vrIS0mSbvq2DRGLJhi5mZ5lxp/gsLXm0Qx9r/aYzAXtG995J3wrk53Yh0ufn228PK0S0BhiU7m2R2kZ97WgiMpRgvnASzwy+XXg+OHu6vethUxgnT99vo6kpFmzttMIkOVBJoihzCldF4QUsrmE3E9Yl3f1cWmpjvRNyYhvQIUzF6IH/aa8sKMIkaDJJ+IHxtJPDH9m4kE/vKnxhRJbCYncQrUr//+oFjTntAsNoYupF8dlZhpBMAeJCCoTqNRH1jeviTdbM42kDLgJajJngUdO/DMYtRnbnZ3YIkwdNJeZDGAAdKrHX9f2/5UYs2WRTIuvVq5BiCDrSYhVKI1QPr4B2dzImw1XNY1Ge8e78xNdk9NSOxW9LQnMxBpzmeDDMDUgevy5euN14vidX57Px7RpY3RQlUfmceKjjEiQT7VKESyBLzmBNT60GxcdpHqMkVMSui5GaZ+BUNlYjUUTq0RoBvu4ewC1zbcWyh3bkevHzeCvxwC/HsE5NjU6XqaNM0J45Txa4wJ5aiiXCRwWUpXsBdlrFUB5ezT21XL5i5bHSt1lnHyNfbC5/KzzUGadsTU1kdbPH4fIZdIja0bZ7Y0t8bHsLm+10yW/JRVs8aRdVHzBmXv3s5l73/luwdtD0LmC+oO6L/h9ajzHQ4sbaXQ== 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.73.136; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813773636154100 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis SME2 support adds the following state for HVF guests: - Vector registers Z0, ... , Z31 (introduced by FEAT_SVE but HVF does not support it) - Predicate registers P0, .., P15 (also FEAT_SVE) - ZA register - ZT0 register - PSTATE.{SM,ZA} bits (SVCR pseudo-register) - SMPRI_EL1 which handles the PE's priority in the SMCU - TPIDR2_EL0 the thread local ID register for SME Signed-off-by: Manos Pitsidianakis Message-Id: <20260306-sme2-hvf-v7-1-e72eeda41ed3@linaro.org> Reviewed-by: Mohamed Mediouni --- target/arm/hvf/hvf.c | 298 ++++++++++++++++++++++++++++++++- target/arm/hvf/hvf_sme_stubs.h | 172 +++++++++++++++++++ target/arm/hvf/sysreg.c.inc | 8 + target/arm/hvf_arm.h | 41 +++++ target/arm/machine.c | 2 +- 5 files changed, 518 insertions(+), 3 deletions(-) create mode 100644 target/arm/hvf/hvf_sme_stubs.h diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index d79469ca27..21b16dfe42 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -395,6 +395,60 @@ static const struct hvf_reg_match hvf_fpreg_match[] = =3D { { HV_SIMD_FP_REG_Q31, offsetof(CPUARMState, vfp.zregs[31]) }, }; =20 +static const struct hvf_reg_match hvf_sme2_zreg_match[] =3D { + { HV_SME_Z_REG_0, offsetof(CPUARMState, vfp.zregs[0]) }, + { HV_SME_Z_REG_1, offsetof(CPUARMState, vfp.zregs[1]) }, + { HV_SME_Z_REG_2, offsetof(CPUARMState, vfp.zregs[2]) }, + { HV_SME_Z_REG_3, offsetof(CPUARMState, vfp.zregs[3]) }, + { HV_SME_Z_REG_4, offsetof(CPUARMState, vfp.zregs[4]) }, + { HV_SME_Z_REG_5, offsetof(CPUARMState, vfp.zregs[5]) }, + { HV_SME_Z_REG_6, offsetof(CPUARMState, vfp.zregs[6]) }, + { HV_SME_Z_REG_7, offsetof(CPUARMState, vfp.zregs[7]) }, + { HV_SME_Z_REG_8, offsetof(CPUARMState, vfp.zregs[8]) }, + { HV_SME_Z_REG_9, offsetof(CPUARMState, vfp.zregs[9]) }, + { HV_SME_Z_REG_10, offsetof(CPUARMState, vfp.zregs[10]) }, + { HV_SME_Z_REG_11, offsetof(CPUARMState, vfp.zregs[11]) }, + { HV_SME_Z_REG_12, offsetof(CPUARMState, vfp.zregs[12]) }, + { HV_SME_Z_REG_13, offsetof(CPUARMState, vfp.zregs[13]) }, + { HV_SME_Z_REG_14, offsetof(CPUARMState, vfp.zregs[14]) }, + { HV_SME_Z_REG_15, offsetof(CPUARMState, vfp.zregs[15]) }, + { HV_SME_Z_REG_16, offsetof(CPUARMState, vfp.zregs[16]) }, + { HV_SME_Z_REG_17, offsetof(CPUARMState, vfp.zregs[17]) }, + { HV_SME_Z_REG_18, offsetof(CPUARMState, vfp.zregs[18]) }, + { HV_SME_Z_REG_19, offsetof(CPUARMState, vfp.zregs[19]) }, + { HV_SME_Z_REG_20, offsetof(CPUARMState, vfp.zregs[20]) }, + { HV_SME_Z_REG_21, offsetof(CPUARMState, vfp.zregs[21]) }, + { HV_SME_Z_REG_22, offsetof(CPUARMState, vfp.zregs[22]) }, + { HV_SME_Z_REG_23, offsetof(CPUARMState, vfp.zregs[23]) }, + { HV_SME_Z_REG_24, offsetof(CPUARMState, vfp.zregs[24]) }, + { HV_SME_Z_REG_25, offsetof(CPUARMState, vfp.zregs[25]) }, + { HV_SME_Z_REG_26, offsetof(CPUARMState, vfp.zregs[26]) }, + { HV_SME_Z_REG_27, offsetof(CPUARMState, vfp.zregs[27]) }, + { HV_SME_Z_REG_28, offsetof(CPUARMState, vfp.zregs[28]) }, + { HV_SME_Z_REG_29, offsetof(CPUARMState, vfp.zregs[29]) }, + { HV_SME_Z_REG_30, offsetof(CPUARMState, vfp.zregs[30]) }, + { HV_SME_Z_REG_31, offsetof(CPUARMState, vfp.zregs[31]) }, +}; + +static const struct hvf_reg_match hvf_sme2_preg_match[] =3D { + { HV_SME_P_REG_0, offsetof(CPUARMState, vfp.pregs[0]) }, + { HV_SME_P_REG_1, offsetof(CPUARMState, vfp.pregs[1]) }, + { HV_SME_P_REG_2, offsetof(CPUARMState, vfp.pregs[2]) }, + { HV_SME_P_REG_3, offsetof(CPUARMState, vfp.pregs[3]) }, + { HV_SME_P_REG_4, offsetof(CPUARMState, vfp.pregs[4]) }, + { HV_SME_P_REG_5, offsetof(CPUARMState, vfp.pregs[5]) }, + { HV_SME_P_REG_6, offsetof(CPUARMState, vfp.pregs[6]) }, + { HV_SME_P_REG_7, offsetof(CPUARMState, vfp.pregs[7]) }, + { HV_SME_P_REG_8, offsetof(CPUARMState, vfp.pregs[8]) }, + { HV_SME_P_REG_9, offsetof(CPUARMState, vfp.pregs[9]) }, + { HV_SME_P_REG_10, offsetof(CPUARMState, vfp.pregs[10]) }, + { HV_SME_P_REG_11, offsetof(CPUARMState, vfp.pregs[11]) }, + { HV_SME_P_REG_12, offsetof(CPUARMState, vfp.pregs[12]) }, + { HV_SME_P_REG_13, offsetof(CPUARMState, vfp.pregs[13]) }, + { HV_SME_P_REG_14, offsetof(CPUARMState, vfp.pregs[14]) }, + { HV_SME_P_REG_15, offsetof(CPUARMState, vfp.pregs[15]) }, +}; + /* * QEMU uses KVM system register ids in the migration format. * Conveniently, HVF uses the same encoding of the op* and cr* parameters @@ -406,22 +460,201 @@ static const struct hvf_reg_match hvf_fpreg_match[] = =3D { #define HVF_TO_KVMID(HVF) \ (CP_REG_ARM64 | CP_REG_SIZE_U64 | CP_REG_ARM64_SYSREG | (HVF)) =20 -/* Verify this at compile-time. */ +/* + * Verify this at compile-time. + * + * SME2 registers are guarded by a runtime availability attribute instead = of a + * compile-time def, so verify those at runtime in hvf_arch_init_vcpu() be= low. + */ =20 #define DEF_SYSREG(HVF_ID, ...) \ QEMU_BUILD_BUG_ON(HVF_ID !=3D KVMID_TO_HVF(KVMID_AA64_SYS_REG64(__VA_ARG= S__))); +#define DEF_SYSREG_15_02(...) =20 #include "sysreg.c.inc" =20 #undef DEF_SYSREG +#undef DEF_SYSREG_15_02 =20 #define DEF_SYSREG(HVF_ID, op0, op1, crn, crm, op2) HVF_ID, +#define DEF_SYSREG_15_02(...) =20 static const hv_sys_reg_t hvf_sreg_list[] =3D { #include "sysreg.c.inc" }; =20 #undef DEF_SYSREG +#undef DEF_SYSREG_15_02 + +#define DEF_SYSREG(...) +#define DEF_SYSREG_15_02(HVF_ID, op0, op1, crn, crm, op2) HVF_ID, + +API_AVAILABLE(macos(15.2)) +static const hv_sys_reg_t hvf_sreg_list_sme2[] =3D { +#include "sysreg.c.inc" +}; + +#undef DEF_SYSREG +#undef DEF_SYSREG_15_02 + +/* + * For FEAT_SME2 migration, we need to store PSTATE.{SM,ZA} bits which are + * accessible with the SVCR pseudo-register. However, in the HVF API this = is + * not exposed as a system-register (i.e. HVF_SYS_REG_SVCR) but a custom + * struct, hv_vcpu_sme_state_t. So we need to define our own KVMID in orde= r to + * store it in cpreg_values and make it migrateable. + */ +#define SVCR KVMID_AA64_SYS_REG64(3, 3, 4, 2, 2) + +API_AVAILABLE(macos(15.2)) +static void hvf_arch_put_sme(CPUState *cpu) +{ + ARMCPU *arm_cpu =3D ARM_CPU(cpu); + CPUARMState *env =3D &arm_cpu->env; + const size_t svl_bytes =3D hvf_arm_sme2_get_svl(); + const size_t z_size =3D svl_bytes; + const size_t preg_size =3D DIV_ROUND_UP(z_size, 8); + const size_t za_size =3D svl_bytes * svl_bytes; + hv_vcpu_sme_state_t sme_state =3D { 0 }; + hv_return_t ret; + uint64_t svcr; + int n; + + /* + * Set PSTATE.{SM,ZA} bits + */ + svcr =3D arm_cpu->cpreg_values[arm_cpu->cpreg_array_len - 1]; + env->svcr =3D svcr; + + /* + * Construct SVCR (PSTATE.{SM,ZA}) state to pass to HVF: + */ + sme_state.streaming_sve_mode_enabled =3D FIELD_EX64(env->svcr, SVCR, S= M) > 0; + sme_state.za_storage_enabled =3D FIELD_EX64(env->svcr, SVCR, ZA) > 0; + ret =3D hv_vcpu_set_sme_state(cpu->accel->fd, &sme_state); + assert_hvf_ok(ret); + + /* + * We only care about Z/P registers if we're in streaming SVE mode, i.= e. + * PSTATE.SM is set, because only then can instructions that access th= em be + * used. We don't care about the register values otherwise. This is be= cause + * when the processing unit exits/enters this mode, it zeroes out those + * registers. + */ + if (sme_state.streaming_sve_mode_enabled) { + for (n =3D 0; n < ARRAY_SIZE(hvf_sme2_zreg_match); ++n) { + ret =3D hv_vcpu_set_sme_z_reg(cpu->accel->fd, + hvf_sme2_zreg_match[n].reg, + (uint8_t *)&env->vfp.zregs[n].d[0], + z_size); + assert_hvf_ok(ret); + } + + for (n =3D 0; n < ARRAY_SIZE(hvf_sme2_preg_match); ++n) { + ret =3D hv_vcpu_set_sme_p_reg(cpu->accel->fd, + hvf_sme2_preg_match[n].reg, + (uint8_t *)&env->vfp.pregs[n].p[0], + preg_size); + assert_hvf_ok(ret); + } + } + + /* + * If PSTATE.ZA bit is set then ZA and ZT0 are valid, otherwise they a= re + * zeroed out. + */ + if (sme_state.za_storage_enabled) { + hv_sme_zt0_uchar64_t tmp =3D { 0 }; + + memcpy(&tmp, &env->za_state.zt0, 64); + ret =3D hv_vcpu_set_sme_zt0_reg(cpu->accel->fd, &tmp); + assert_hvf_ok(ret); + + ret =3D hv_vcpu_set_sme_za_reg(cpu->accel->fd, + (uint8_t *)&env->za_state.za, + za_size); + assert_hvf_ok(ret); + } + + return; +} + +API_AVAILABLE(macos(15.2)) +static void hvf_arch_get_sme(CPUState *cpu) +{ + ARMCPU *arm_cpu =3D ARM_CPU(cpu); + CPUARMState *env =3D &arm_cpu->env; + const size_t svl_bytes =3D hvf_arm_sme2_get_svl(); + const size_t z_size =3D svl_bytes; + const size_t preg_size =3D DIV_ROUND_UP(z_size, 8); + const size_t za_size =3D svl_bytes * svl_bytes; + hv_vcpu_sme_state_t sme_state =3D { 0 }; + hv_return_t ret; + uint64_t svcr; + int n; + + /* + * Get SVCR (PSTATE.{SM,ZA}) state from HVF: + */ + ret =3D hv_vcpu_get_sme_state(cpu->accel->fd, &sme_state); + assert_hvf_ok(ret); + + /* + * Set SVCR first because changing it will zero out Z/P regs + */ + svcr =3D + (sme_state.za_storage_enabled ? R_SVCR_ZA_MASK : 0) + | (sme_state.streaming_sve_mode_enabled ? R_SVCR_SM_MASK : 0); + + aarch64_set_svcr(env, svcr, R_SVCR_ZA_MASK | R_SVCR_SM_MASK); + arm_cpu->cpreg_values[arm_cpu->cpreg_array_len - 1] =3D svcr; + + /* + * We only care about Z/P registers if we're in streaming SVE mode, i.= e. + * PSTATE.SM is set, because only then can instructions that access th= em be + * used. We don't care about the register values otherwise. This is be= cause + * when the processing unit exits/enters this mode, it zeroes out those + * registers. + */ + if (sme_state.streaming_sve_mode_enabled) { + for (n =3D 0; n < ARRAY_SIZE(hvf_sme2_zreg_match); ++n) { + ret =3D hv_vcpu_get_sme_z_reg(cpu->accel->fd, + hvf_sme2_zreg_match[n].reg, + (uint8_t *)&env->vfp.zregs[n].d[0], + z_size); + assert_hvf_ok(ret); + } + + for (n =3D 0; n < ARRAY_SIZE(hvf_sme2_preg_match); ++n) { + ret =3D hv_vcpu_get_sme_p_reg(cpu->accel->fd, + hvf_sme2_preg_match[n].reg, + (uint8_t *)&env->vfp.pregs[n].p[0], + preg_size); + assert_hvf_ok(ret); + } + } + + /* + * If PSTATE.ZA bit is set then ZA and ZT0 are valid, otherwise they a= re + * zeroed out. + */ + if (sme_state.za_storage_enabled) { + hv_sme_zt0_uchar64_t tmp =3D { 0 }; + + /* Get ZT0 in a tmp vector, and then copy it to env.za_state.zt0 */ + ret =3D hv_vcpu_get_sme_zt0_reg(cpu->accel->fd, &tmp); + assert_hvf_ok(ret); + + memcpy(&env->za_state.zt0, &tmp, 64); + ret =3D hv_vcpu_get_sme_za_reg(cpu->accel->fd, + (uint8_t *)&env->za_state.za, + za_size); + assert_hvf_ok(ret); + + } + + return; +} =20 static uint32_t hvf_reg2cp_reg(uint32_t reg) { @@ -534,6 +767,10 @@ int hvf_arch_get_registers(CPUState *cpu) uint64_t kvm_id =3D arm_cpu->cpreg_indexes[i]; int hvf_id =3D KVMID_TO_HVF(kvm_id); =20 + if (kvm_id =3D=3D HVF_TO_KVMID(SVCR)) { + continue; + } + if (cpu->accel->guest_debug_enabled) { /* Handle debug registers */ switch (hvf_id) { @@ -627,6 +864,13 @@ int hvf_arch_get_registers(CPUState *cpu) =20 arm_cpu->cpreg_values[i] =3D val; } + if (cpu_isar_feature(aa64_sme, arm_cpu)) { + if (__builtin_available(macOS 15.2, *)) { + hvf_arch_get_sme(cpu); + } else { + g_assert_not_reached(); + } + } assert(write_list_to_cpustate(arm_cpu)); =20 aarch64_restore_sp(env, arm_current_el(env)); @@ -643,6 +887,18 @@ int hvf_arch_put_registers(CPUState *cpu) hv_simd_fp_uchar16_t fpval; int i, n; =20 + /* + * Set SVCR first because changing it will zero out Z/P (including NEO= N) + * regs + */ + if (cpu_isar_feature(aa64_sme, arm_cpu)) { + if (__builtin_available(macOS 15.2, *)) { + hvf_arch_put_sme(cpu); + } else { + g_assert_not_reached(); + } + } + for (i =3D 0; i < ARRAY_SIZE(hvf_reg_match); i++) { val =3D *(uint64_t *)((void *)env + hvf_reg_match[i].offset); ret =3D hv_vcpu_set_reg(cpu->accel->fd, hvf_reg_match[i].reg, val); @@ -672,6 +928,10 @@ int hvf_arch_put_registers(CPUState *cpu) uint64_t kvm_id =3D arm_cpu->cpreg_indexes[i]; int hvf_id =3D KVMID_TO_HVF(kvm_id); =20 + if (kvm_id =3D=3D HVF_TO_KVMID(SVCR)) { + continue; + } + if (cpu->accel->guest_debug_enabled) { /* Handle debug registers */ switch (hvf_id) { @@ -985,6 +1245,20 @@ int hvf_arch_init_vcpu(CPUState *cpu) hv_return_t ret; int i; =20 + if (__builtin_available(macOS 15.2, *)) { + if (hvf_arm_sme2_supported()) { + sregs_match_len +=3D ARRAY_SIZE(hvf_sreg_list_sme2) + 1; + } + +#define DEF_SYSREG_15_02(HVF_ID, ...) \ + g_assert(HVF_ID =3D=3D KVMID_TO_HVF(KVMID_AA64_SYS_REG64(__VA_ARGS= __))); +#define DEF_SYSREG(...) + +#include "sysreg.c.inc" + +#undef DEF_SYSREG +#undef DEF_SYSREG_15_02 + } env->aarch64 =3D true; =20 /* system count frequency sanity check */ @@ -1005,7 +1279,7 @@ int hvf_arch_init_vcpu(CPUState *cpu) memset(arm_cpu->cpreg_values, 0, sregs_match_len * sizeof(uint64_t)); =20 /* Populate cp list for all known sysregs */ - for (i =3D 0; i < sregs_match_len; i++) { + for (i =3D 0; i < ARRAY_SIZE(hvf_sreg_list); i++) { hv_sys_reg_t hvf_id =3D hvf_sreg_list[i]; uint64_t kvm_id =3D HVF_TO_KVMID(hvf_id); uint32_t key =3D kvm_to_cpreg_id(kvm_id); @@ -1016,6 +1290,26 @@ int hvf_arch_init_vcpu(CPUState *cpu) arm_cpu->cpreg_indexes[sregs_cnt++] =3D kvm_id; } } + if (__builtin_available(macOS 15.2, *)) { + if (hvf_arm_sme2_supported()) { + for (i =3D 0; i < ARRAY_SIZE(hvf_sreg_list_sme2); i++) { + hv_sys_reg_t hvf_id =3D hvf_sreg_list_sme2[i]; + uint64_t kvm_id =3D HVF_TO_KVMID(hvf_id); + uint32_t key =3D kvm_to_cpreg_id(kvm_id); + const ARMCPRegInfo *ri =3D get_arm_cp_reginfo(arm_cpu->cp_= regs, key); + + if (ri) { + assert(!(ri->type & ARM_CP_NO_RAW)); + arm_cpu->cpreg_indexes[sregs_cnt++] =3D kvm_id; + } + } + /* + * Add SVCR last. It is elsewhere assumed its index is after + * hvf_sreg_list and hvf_sreg_list_sme2. + */ + arm_cpu->cpreg_indexes[sregs_cnt++] =3D HVF_TO_KVMID(SVCR); + } + } arm_cpu->cpreg_array_len =3D sregs_cnt; arm_cpu->cpreg_vmstate_array_len =3D sregs_cnt; =20 diff --git a/target/arm/hvf/hvf_sme_stubs.h b/target/arm/hvf/hvf_sme_stubs.h new file mode 100644 index 0000000000..43686f7824 --- /dev/null +++ b/target/arm/hvf/hvf_sme_stubs.h @@ -0,0 +1,172 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +typedef int32_t hv_return_t; +typedef uint64_t hv_vcpu_t; + +static inline bool hvf_arm_sme2_supported(void) +{ + return false; +} + +static inline uint32_t hvf_arm_sme2_get_svl(void) +{ + g_assert_not_reached(); +} + +typedef enum hv_sme_p_reg_t { + HV_SME_P_REG_0, + HV_SME_P_REG_1, + HV_SME_P_REG_2, + HV_SME_P_REG_3, + HV_SME_P_REG_4, + HV_SME_P_REG_5, + HV_SME_P_REG_6, + HV_SME_P_REG_7, + HV_SME_P_REG_8, + HV_SME_P_REG_9, + HV_SME_P_REG_10, + HV_SME_P_REG_11, + HV_SME_P_REG_12, + HV_SME_P_REG_13, + HV_SME_P_REG_14, + HV_SME_P_REG_15, +} hv_sme_p_reg_t; + +/* + * The system version of this type declares it with + * __attribute__((ext_vector_type(64))) + * However, that is clang specific and not supported by GCC. + * Since these headers are only here for the case where the system + * headers do not provide these types (including both older macos + * and non-macos hosts), we don't need to make the type match + * exactly, so we declare it as a uint8_t array. + */ +typedef uint8_t hv_sme_zt0_uchar64_t[64]; + +typedef enum hv_sme_z_reg_t { + HV_SME_Z_REG_0, + HV_SME_Z_REG_1, + HV_SME_Z_REG_2, + HV_SME_Z_REG_3, + HV_SME_Z_REG_4, + HV_SME_Z_REG_5, + HV_SME_Z_REG_6, + HV_SME_Z_REG_7, + HV_SME_Z_REG_8, + HV_SME_Z_REG_9, + HV_SME_Z_REG_10, + HV_SME_Z_REG_11, + HV_SME_Z_REG_12, + HV_SME_Z_REG_13, + HV_SME_Z_REG_14, + HV_SME_Z_REG_15, + HV_SME_Z_REG_16, + HV_SME_Z_REG_17, + HV_SME_Z_REG_18, + HV_SME_Z_REG_19, + HV_SME_Z_REG_20, + HV_SME_Z_REG_21, + HV_SME_Z_REG_22, + HV_SME_Z_REG_23, + HV_SME_Z_REG_24, + HV_SME_Z_REG_25, + HV_SME_Z_REG_26, + HV_SME_Z_REG_27, + HV_SME_Z_REG_28, + HV_SME_Z_REG_29, + HV_SME_Z_REG_30, + HV_SME_Z_REG_31, +} hv_sme_z_reg_t; + +enum { + HV_SYS_REG_SMCR_EL1, + HV_SYS_REG_SMPRI_EL1, + HV_SYS_REG_TPIDR2_EL0, + HV_SYS_REG_ID_AA64ZFR0_EL1, + HV_SYS_REG_ID_AA64SMFR0_EL1, +}; + +enum { + HV_FEATURE_REG_ID_AA64SMFR0_EL1, + HV_FEATURE_REG_ID_AA64ZFR0_EL1, +}; + +typedef struct { + bool streaming_sve_mode_enabled; + bool za_storage_enabled; +} hv_vcpu_sme_state_t; + +static inline hv_return_t hv_sme_config_get_max_svl_bytes(size_t *value) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_get_sme_state(hv_vcpu_t vcpu, + hv_vcpu_sme_state_t *sme_s= tate) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_set_sme_state(hv_vcpu_t vcpu, + const hv_vcpu_sme_state_t = *sme_state) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_get_sme_z_reg(hv_vcpu_t vcpu, + hv_sme_z_reg_t reg, + uint8_t *value, + size_t length) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_set_sme_z_reg(hv_vcpu_t vcpu, + hv_sme_z_reg_t reg, + const uint8_t *value, + size_t length) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_get_sme_p_reg(hv_vcpu_t vcpu, + hv_sme_p_reg_t reg, + uint8_t *value, + size_t length) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_set_sme_p_reg(hv_vcpu_t vcpu, + hv_sme_p_reg_t reg, + const uint8_t *value, + size_t length) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_get_sme_za_reg(hv_vcpu_t vcpu, + uint8_t *value, + size_t length) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_set_sme_za_reg(hv_vcpu_t vcpu, + const uint8_t *value, + size_t length) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_get_sme_zt0_reg(hv_vcpu_t vcpu, + hv_sme_zt0_uchar64_t *va= lue) +{ + g_assert_not_reached(); +} + +static inline hv_return_t hv_vcpu_set_sme_zt0_reg(hv_vcpu_t vcpu, + const hv_sme_zt0_uchar64= _t *value) +{ + g_assert_not_reached(); +} diff --git a/target/arm/hvf/sysreg.c.inc b/target/arm/hvf/sysreg.c.inc index 067a8603fa..7a2f880f78 100644 --- a/target/arm/hvf/sysreg.c.inc +++ b/target/arm/hvf/sysreg.c.inc @@ -145,3 +145,11 @@ DEF_SYSREG(HV_SYS_REG_TPIDRRO_EL0, 3, 3, 13, 0, 3) DEF_SYSREG(HV_SYS_REG_CNTV_CTL_EL0, 3, 3, 14, 3, 1) DEF_SYSREG(HV_SYS_REG_CNTV_CVAL_EL0, 3, 3, 14, 3, 2) DEF_SYSREG(HV_SYS_REG_SP_EL1, 3, 4, 4, 1, 0) + +DEF_SYSREG_15_02(HV_SYS_REG_SMCR_EL1, 3, 0, 1, 2, 6) +DEF_SYSREG_15_02(HV_SYS_REG_SMPRI_EL1, 3, 0, 1, 2, 4) +DEF_SYSREG_15_02(HV_SYS_REG_TPIDR2_EL0, 3, 3, 13, 0, 5) +DEF_SYSREG_15_02(HV_SYS_REG_ID_AA64ZFR0_EL1, 3, 0, 0, 4, 4) +DEF_SYSREG_15_02(HV_SYS_REG_ID_AA64SMFR0_EL1, 3, 0, 0, 4, 5) +DEF_SYSREG_15_02(HV_SYS_REG_SMPRI_EL1, 3, 0, 1, 2, 4) +DEF_SYSREG_15_02(HV_SYS_REG_SMCR_EL1, 3, 0, 1, 2, 6) diff --git a/target/arm/hvf_arm.h b/target/arm/hvf_arm.h index 5d19d82e5d..6b1c3b9792 100644 --- a/target/arm/hvf_arm.h +++ b/target/arm/hvf_arm.h @@ -22,4 +22,45 @@ void hvf_arm_init_debug(void); =20 void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu); =20 +/* + * We need access to types from macOS SDK >=3D15.2, so expose stubs if the + * headers are not available until we raise our minimum macOS version. + */ +#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED + #if (__MAC_OS_X_VERSION_MAX_ALLOWED >=3D 150200) + #include "system/hvf_int.h" + + static inline bool hvf_arm_sme2_supported(void) + { + if (__builtin_available(macOS 15.2, *)) { + size_t svl_bytes; + hv_return_t result =3D hv_sme_config_get_max_svl_bytes(&svl_by= tes); + if (result =3D=3D HV_UNSUPPORTED) { + return false; + } + assert_hvf_ok(result); + return svl_bytes > 0; + } else { + return false; + } + } + + static inline uint32_t hvf_arm_sme2_get_svl(void) + { + if (__builtin_available(macOS 15.2, *)) { + size_t svl_bytes; + hv_return_t result =3D hv_sme_config_get_max_svl_bytes(&svl_by= tes); + assert_hvf_ok(result); + return svl_bytes; + } else { + abort(); + } + } + #else /* (__MAC_OS_X_VERSION_MAX_ALLOWED >=3D 150200) */ + #include "hvf/hvf_sme_stubs.h" + #endif /* (__MAC_OS_X_VERSION_MAX_ALLOWED >=3D 150200) */ +#else /* ifdef __MAC_OS_X_VERSION_MAX_ALLOWED */ + #include "hvf/hvf_sme_stubs.h" +#endif /* ifdef __MAC_OS_X_VERSION_MAX_ALLOWED */ + #endif diff --git a/target/arm/machine.c b/target/arm/machine.c index bbaae34449..81a506ce4c 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -231,7 +231,7 @@ static bool sve_needed(void *opaque) { ARMCPU *cpu =3D opaque; =20 - return cpu_isar_feature(aa64_sve, cpu); + return cpu_isar_feature(aa64_sve, cpu) || cpu_isar_feature(aa64_sme, c= pu); } =20 /* The first two words of each Zreg is stored in VFP state. */ --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813782; cv=none; d=zohomail.com; s=zohoarc; b=RQpCj9wuOt93DTftmKetAWpdq5Ubd5qr/exe8orZCCvg6F+4Up9w3SLtciyQ3DVrb2n2pQOqf+8M/8lugaPmeM/XyI7yqtOwsoaRsohNdEcYjSCRswN7PEpevfIbj66B2LKujsVfkjLjLpHkHJMM8aU8mfrCGzDWrhHWxVsTx54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813782; h=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=Bv7t7Vy+N3Dr+xwTtt4qH/q/trULmWUOvcHWfy7me0o=; b=bBKu2ml2+7HrmfgeFxjHB68/fTbK6Lxi87U3brUpYoiuGlbdVRr6hWk+qaJAEt7pX66R8/XvBsMvaDXukO6KMk+zVPwzHRLfiUMi+bwqGY9NaY3s4tQhgMyopVBHMevV13nBBw6f+lYnYrYmzwaskrLKzX1GDpddYR8tRssTI6A= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813781543612.4815238228238; Fri, 6 Mar 2026 08:16:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXpw-000470-LK; Fri, 06 Mar 2026 11:15:36 -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 1vyXpm-00042e-Ao for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:26 -0500 Received: from p-west3-cluster1-host2-snip4-10.eps.apple.com ([57.103.73.151] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXpk-00074i-HZ for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:26 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 7E3BA180012D; Fri, 6 Mar 2026 16:15:20 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id B2EBA1800119; Fri, 6 Mar 2026 16:15:17 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813723; x=1775405723; bh=Bv7t7Vy+N3Dr+xwTtt4qH/q/trULmWUOvcHWfy7me0o=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=evMBneXS+U/8Bo2oT14by89mAYbOa18h2XTnOQ8gz8QnhAJ7/or4GOa8gqC+XpUcIks/HscuZ+/T0Uh7/wVHQrY7Jf7pX7sBhUdeVdAHdHpQ93nSr1N8o23cq4RmXBLCx5uHoAASXPnvPnj4iw1dJuA6eShJ9XrKlmaLm5T9TExUUMy/z/HEjUtQeVsxNN9brvzTi6hxG6r0m+VgZ0sI0tds5avrzdlaSq3kGJoeAD+3JDAQZfpo+UrxEl0NqMTh5ZclPX5z8bGIROlJxaFKRJH/OLvBDS8EaYuvq/aGP9RNeTMkTkkU6XJfSSi9TGZKXhnB0CnS5dLWA3ISpIkmzw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 02/17] hvf/arm: expose FEAT_SME2 to guest if available Date: Fri, 6 Mar 2026 17:14:54 +0100 Message-ID: <20260306161509.79712-3-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=CcYFJbrl c=1 sm=1 tr=0 ts=69aafd99 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=cKmG3w1NXntEKhAjIXMA:9 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: d6att8EZ9eEiAk-o1aFH7PpNYL0bjNK3 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX/g5O176wo8pi 7ustFW2EG8Q8IO92Hc149w6oBt4p2RUk1MexVL7BaeZVKxzCm13FCi9M47mycMhU5luHr3SriRf a9DX7gS63kKw0oAcUHn4wxXFb2W4Ewv41SvbPzDwHvyd4Z5XjXxqK1aCJrqp5Avjkm85uaFqxJr Ur/BW+tevSAcVvCFlwumr27AtQoi0+0tbKtK/V//5atTyi9f7j40Tz4xzQUm4eZalk+171KN3b7 Fi4j9hwGlSWcmlLT8ddshLD+uNJmbyQm12oiRJrDCYl3Ug7/44WA93CtWeg37YRUax/wML/2rXa AdJO7UPv4deijmYIVJ1fNHWngc4SqXBK9X9z083bCcZqp2Z731BKisPYy2s/4s= X-Proofpoint-ORIG-GUID: d6att8EZ9eEiAk-o1aFH7PpNYL0bjNK3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 clxscore=1030 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABm6Bnuo0lWMJeDS7w9AWTxhKczQtA2NPtPTvtZdsZSW0h1rm37c7+uH17PQFuk2Jb7MmGjCCSsmq43ENKM/u1bHFURGgPOkx8bfjpy3Hk2PDKi8x0Oq9jtHX01V3i0U8qbPvSEhQTzxtVUt5E25IxX0rRKDLclJ4lO+rffpmh5ywCsfQC13CwEKbfTSemfeGF3iA4Zav2iMl6dvJU8kkAqot2WrQbinTUq+Gfo2uZWUVuEy7vx4VWKxJykOqwzxfbfnioTnz0nO5VFqxOldLm7JW0bSQjr/R5cmNtihOu/uoLXPTN3iG94Obor3J2reP0cbWpEFCQfyMwsi7b5tn26V4MHPMen9a5+yiA/3hXcw27e9LoPm4EFf3iZdpQJYZlM/ZclXEPGFWNI8cNpgEXBuWyYKe/0zHCsi06LryBu1TkWYzuXx/ULGxDqWhjfWbda7/JnnWzF1SBMg9bNPMYP/ZIB8oxS5QwI/A75onRVlpNsaUIOPinzV1VKQ4CxOwoE129rLAWkcWpSlylOBSlLPp+9enr5OmpNmcjZV+HhTtkGo576FNXBqx1yeXHi4NbfTGGNHkFqOwZgqEhNlkOHoxFd2AvbM9FUFTUKIDw5GwzahM1cYALUm+vTr9b21+2/dNKl2nOBP0kGNqEm+EJwDHaOFtXHIWiF99dCk4y3wOcmpI2vuO3u6PGMk6P0DgJwZW9r6kXGys8UmlFjv/z6nqjyBLzHzmzRqVetakoz7PpEzEyT5sV416FznwRU4vsI/SVSWNMCdI= 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.73.151; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813784782158500 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis Starting from M4 cores and MacOS 15.2 SDK, HVF can virtualise FEAT_SME2. Signed-off-by: Manos Pitsidianakis Message-Id: <20260306-sme2-hvf-v7-2-e72eeda41ed3@linaro.org> Reviewed-by: Mohamed Mediouni --- target/arm/hvf/hvf.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 21b16dfe42..5fc8f6bbbd 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -315,6 +315,7 @@ typedef struct ARMHostCPUFeatures { uint64_t features; uint64_t midr; uint32_t reset_sctlr; + uint32_t sme_vq_supported; const char *dtb_compatible; } ARMHostCPUFeatures; =20 @@ -1106,6 +1107,24 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPU= Features *ahcf) r |=3D hv_vcpu_config_get_feature_reg(config, regs[i].reg, &host_isar.idregs[regs[i].inde= x]); } + + if (__builtin_available(macOS 15.2, *)) { + static const struct sme_isar_regs { + hv_feature_reg_t reg; + ARMIDRegisterIdx index; + } sme_regs[] =3D { + { HV_FEATURE_REG_ID_AA64SMFR0_EL1, ID_AA64SMFR0_EL1_IDX }, + { HV_FEATURE_REG_ID_AA64ZFR0_EL1, ID_AA64ZFR0_EL1_IDX }, + }; + + if (hvf_arm_sme2_supported()) { + for (i =3D 0; i < ARRAY_SIZE(sme_regs); i++) { + r |=3D hv_vcpu_config_get_feature_reg(config, sme_regs[i].= reg, + &host_isar.idregs[sme_= regs[i].index]); + } + } + } + os_release(config); =20 /* @@ -1121,19 +1140,6 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPU= Features *ahcf) =20 clamp_id_aa64mmfr0_parange_to_ipa_size(&host_isar); =20 - /* - * Disable SME, which is not properly handled by QEMU hvf yet. - * To allow this through we would need to: - * - make sure that the SME state is correctly handled in the - * get_registers/put_registers functions - * - get the SME-specific CPU properties to work with accelerators - * other than TCG - * - fix any assumptions we made that SME implies SVE (since - * on the M4 there is SME but not SVE) - */ - SET_IDREG(&host_isar, ID_AA64PFR1, - GET_IDREG(&host_isar, ID_AA64PFR1) & ~R_ID_AA64PFR1_SME_MASK= ); - ahcf->isar =3D host_isar; =20 /* @@ -1148,6 +1154,8 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUF= eatures *ahcf) */ ahcf->reset_sctlr |=3D 0x00800000; =20 + ahcf->sme_vq_supported =3D hvf_arm_sme2_supported() ? hvf_arm_sme2_get= _svl() : 0; + /* Make sure we don't advertise AArch32 support for EL0/EL1 */ if ((GET_IDREG(&host_isar, ID_AA64PFR0) & 0xff) !=3D 0x11) { return false; @@ -1199,6 +1207,7 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu) cpu->env.features =3D arm_host_cpu_features.features; cpu->midr =3D arm_host_cpu_features.midr; cpu->reset_sctlr =3D arm_host_cpu_features.reset_sctlr; + cpu->sme_vq.supported =3D arm_host_cpu_features.sme_vq_supported; } =20 void hvf_arch_vcpu_destroy(CPUState *cpu) @@ -1343,6 +1352,7 @@ int hvf_arch_init_vcpu(CPUState *cpu) arm_cpu->isar.idregs[ID_AA64MMFR0_EL1_IDX]); assert_hvf_ok(ret); =20 + aarch64_add_sme_properties(OBJECT(cpu)); return 0; } =20 --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813923; cv=none; d=zohomail.com; s=zohoarc; b=EL0+jM0QWOeKCCJV4LQd7K2oKlu5YJneC/YnfPeOUqA9t4o2BAQt/kzybY2vYrObOWr7UFcqDpE/xjuP/1mwlpMt8934n20iCMm1AcdCDgSZLTHMnvLnhro7D4V9JYcsO4yoO/jV+VuWTUxZj2whzY7gMl49A4JGP1wx9Zz0JBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813923; h=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=uN8lJoU61mvTYRaLVzoXbtKJ70njqQPJMrPpFOc3RPE=; b=nFqnv8HhrKoiE2OMey+gt375fBJWW8zPqYXrG/+f5u77MoWSriaWWoC0cMn27jKkjUucJORrrxPIFHdkdTLOdvzbbmG+FsvNqdlsJei5W4d/pheHchtcJ+VWgbYI7yAW/QTuOkIuONMqtj8sTr2oKzpDv+7MGZMkPKsiL9UfOgY= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813923071361.0501311488114; Fri, 6 Mar 2026 08:18:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXpy-00047U-JC; Fri, 06 Mar 2026 11:15:38 -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 1vyXpn-00043f-Tx for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:28 -0500 Received: from p-west3-cluster3-host8-snip4-10.eps.apple.com ([57.103.72.211] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXpm-00075D-BA for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:27 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 36CF118000AE; Fri, 6 Mar 2026 16:15:23 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 5135518007A6; Fri, 6 Mar 2026 16:15:20 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813725; x=1775405725; bh=uN8lJoU61mvTYRaLVzoXbtKJ70njqQPJMrPpFOc3RPE=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=KBBqWpxMt9gIbK6MOLDM7bVEUWzwZNFBHajAKhRg1uxk8yTmrNg8j9JMghbMNrHPLHHw5BTzfQ6BE42UCncC05A/awmKnamCTdfnAOzJ8GCLhAlk5sLUvtWyCGXaSOe8sICTzauDmfAUTegveU1Hf1LuVdWmTtRC4uAMfhXy3pKOwvUsVfuS0ZPQJfbMj4K+hYOlsilGWZ+v3QaI9IgSVvRYa3z8o6re8eDVMdXFWWQkwkJhV8jdGZX+RwUpHqdbu3fK6nzLNxiuW9AmXKvjAaGrPZ5Jm1KDScTIbF0YnOALEsO6cl17TfR38Ml2kuFRdsJd/KVEOXpqpS+Ori6BOg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 03/17] hw/arm: virt: remove hvf_arm.h include Date: Fri, 6 Mar 2026 17:14:55 +0100 Message-ID: <20260306161509.79712-4-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: Fnc_oZLBm7PUPUGj4rketjFob-IIaBRm X-Authority-Info-Out: v=2.4 cv=Qblrf8bv c=1 sm=1 tr=0 ts=69aafd9c cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=lDyTXvYnw_i6wWSIVMAA:9 a=NqO74GWdXPXpGKcKHaDJD/ajO6k=:19 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: Fnc_oZLBm7PUPUGj4rketjFob-IIaBRm X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX8rXOvFA81pyO BIJhk4yXFQf8UMZr9UpPQKLkZCvj2ZK0zWp40Nh9DfemOecJ7Vs8+VJ0JucUpa1ew+UYPDLzxdy mxghU1a45e4zoNS1fYN3DkytahcRnpy2uPJe1b4gykdsU90eJAbb9m6Ec+FFLUCScb0zu3muBL+ f1Xjvxol75pJRtrsoQOmSJhtjvHHfKrlw3slyGJPgs5SPyz0EnwOfEX/fydesY+2wrPtKfE9lZn l1+TEH9MfSs7yPjny8m6eS1ATVTSaGLLBxxBrcunPJZQB5kowY/mNBiNvRea0I5/h7w4aftBGpC hA2ZLz2wutmRTpE6zLeNpmZ63at0ja2MzrOkQso7mIkZSUOQkg9xMXd1qPle8U= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 clxscore=1030 mlxlogscore=715 phishscore=0 spamscore=0 bulkscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABVh9orUISu8Us/uSUbdc2KHjkrxy5L2k/BMoKPBaGj+PVnWl3AAe0+LZ6RwzfDmrfT+oLukPhgsEtXRmAQ+vV9s4ib1i+bwB7xTw4B03JQAa7FVGUcX04q0dnnDNW0aVtj37tnmNjWqNIrtnK+dF0x2RZ3wd/PbyrPGnkzrkOVONFhuwq32+S0I/MqrRpvJudVfaeoaKjoT1/8vdNSu1lmQ1yHktDgdGs3QnRt6HDmkw9/jGFTx319tcfbwp9f8FEmDnE1NsIIXLACzTuQFbc1n6k0QZPIBMgvDxoxtjg3ixWmL7jH03NnO1SBriZXFyQS0w3zf0RZhr7Z9+T/87rUflZ9vRotPikQ0acroZVepEtQYOjFKGLpbjoQo72cBjrpbfOHXW7EzsvDMsafmtWZAcattZQAQ5eVZ05ZyM9EWkwHU6EZGV85wc6PrP3wemHCEoRNor5tn3ZImHsQAlZTP0M+cbx9Q4Y8AhZI2crzLRTWwz5T8VEqHvs9XqaKYhS5GSg1vtwOOald1CI3SBDCGV9IgSmc/gBBgKHC3IAZRMKQJqtVU89z0f7eAMPuNVGUmz/Ctwt1n0lwYngmL+DFV85B+UjLmR3tdW7I9mZx4j3VJZQyAkBeRsqzuovuiMl0C8vOgqzM13qofe8A3/hA/7qH4Bo7ZEBNL65GjlMXbEjuOOcs+pF3kaUoa5w9it0+ma70jc2OTj49izyER17kjTaZhif7OT8CDpIehN/LcuAlCMz4uftxz0UqM7bIl9vkfz+Ut7TxUA= 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.211; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813924955154100 Content-Type: text/plain; charset="utf-8" Having that include breaks the build for Linux after inclusion of SME suppo= rt. Signed-off-by: Mohamed Mediouni Reviewed-by: Peter Maydell --- hw/arm/virt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index cab2e21e8a..7456614d05 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -71,7 +71,6 @@ #include "hw/intc/arm_gicv3_its_common.h" #include "hw/core/irq.h" #include "kvm_arm.h" -#include "hvf_arm.h" #include "whpx_arm.h" #include "hw/firmware/smbios.h" #include "qapi/visitor.h" --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813944; cv=none; d=zohomail.com; s=zohoarc; b=mvAWQdvzXCw0LNjWAU727iJw8uKNKh+8vCL+MtAz1t+WfcKSRBNfLfmJkGOTgJQx1dgOx3EAMrQxCUwihF9nrVsHQ0uXB8O09gi+SvppPIIZNgycl85yl4mh1EGNPqR64ziX0V8zhWJmMtarvoDx9Wo9pSapVvTh7pHcqEuyIDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813944; h=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=IzVSt1aVpyTkgRI+sV6HgtQSQ/A0iOy/FaOFV8C9G40=; b=LPJYhA8PZO5o3akeSDaZSZtfXyMLGPwINE/b4zq54YcjAkTKJDS08g6W/o57hJEr/ZEl3m06Lyo/eipXKjddTCSE2DSaS+nQoSIDBYNnXko0OfvWllQopwL/Nmp+ntORONIq2OBe7YqL1b+YkRIhUHk32beXzHe6ZYXDi4wYV84= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813944802829.8200047561535; Fri, 6 Mar 2026 08:19:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXpy-00047L-Dq; Fri, 06 Mar 2026 11:15:38 -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 1vyXpp-00044K-E2 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:29 -0500 Received: from p-west3-cluster3-host9-snip4-1.eps.apple.com ([57.103.72.232] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXpo-00075p-1Q for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:29 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id A1238180011B; Fri, 6 Mar 2026 16:15:25 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id E92B7180013A; Fri, 6 Mar 2026 16:15:22 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813726; x=1775405726; bh=IzVSt1aVpyTkgRI+sV6HgtQSQ/A0iOy/FaOFV8C9G40=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=cQqhIHQfibx3xU/hymfWocKcNgX1fIOvu3fVCH7TRh9QpnpdOj1B5o+juumo3oxNfVcl5WBoyjfQ7fDT7vV7Pb/rBYUqmWPJZCEsqnDiurOvTVqQiaJcFsWT9GR7Tq+tFO6eH/vfL/U3W9CtZunU4FtBvMu3zkHSDaz7FcQ+4K85MTod+H1tVcU3TaH8OtY8abnj6MArf5bD1bi8QY+ZitJoCErk1HupTMPJ1Rw0ErZYVhu5URirFbtCy0c2VFolMXorjNRXystcz1lhlNOo8IB+aM6kUg2Tjzv3ccWlE8MCn4ROUNdrUP49iYaPzrLEQKU6T9qu4c4THvNZJLB4Mg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 04/17] hvf: hvf-all: stop including hvf_arm.h Date: Fri, 6 Mar 2026 17:14:56 +0100 Message-ID: <20260306161509.79712-5-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: rwMDNeTmymxBSJKsoiQrNXdGM0BpUgyG X-Proofpoint-ORIG-GUID: rwMDNeTmymxBSJKsoiQrNXdGM0BpUgyG X-Authority-Info-Out: v=2.4 cv=TZObdBQh c=1 sm=1 tr=0 ts=69aafd9e cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=uNs1HyugXjh6PdyaFdwA:9 a=NqO74GWdXPXpGKcKHaDJD/ajO6k=:19 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfXx8qLeGzW7H2w LmsEnMqod2Pea+yWGtCjNrPbiJBqHBPeBpsGLxtnL547D7j1VucyJDdQPTcqX18VXM248hdw+0K s+k8xwSVbkHH8JtHgEglCaneNckVGnEewQpqM7XIX7CiqbmbLbmbe8PeAzZu6h/9+UPQh0qd4b7 TVKBO+YdwP+II3SeV+wQ625pxdDpIiB7q6KL7eTKUoqmARdw5/fWa2sJrpfyiONuL40LOihzmi8 3fUz62QJVIEhfO4YXCErHvwvm7c4ZL/AgBHZyVjKkrsKHamRVoGL8gH8u7YAFmDhR8EOdlZMq3q 7rcTKqix8Hk98xuL5Q2gHqXD3NmabTe+caop+4eCTLsm31Huf7emTDKZOcyWK4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=660 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAAB2ubFuceEpBhTfP5Qsdy3PqUfrwjSahhyCAutZ77y6O3Qq/BkctSGjpRzM9kMXTqx4+Sc2umhwMxDTqNDECeyfhC48j71JFu7lkkRZJ1p/lt6JQ6gRgIuQZTL3ZPc28Vv4fodieb7CYEnBQD+Nq0XHvxxTzHIaPw+OyTMTtsMq3I14vlZCr1ftXoTrYmsYSRvQPQC/no0q1ZUPBgB7jG4KPSD809WgcI738NZyhspTebWZyzW0ZkK0VUKw9cGml9Gt5SWoDl8lbjq9/Y2UB3FQgruBrohhh6CPiHDG1YFOwCbHoKytUNznxdrUnXr/fCW1mO8kYivcX+cwNJdE82GQDThaFqIUt6ZWKHe21ByHGC2GYuG+r2uIaPJnTHoh/cB9Ii+YAjzuec/1lk2LzxtpDyIaAIsTj4AOr7x49ZbUN3deyk7pQlIrnnrIO8ZCuVEjVEUb/Z4TuYgK0JeMoAd/99gSWntGT+flCYWad1KKLsfBzkp2ytZLXQCbUOo2TeX6gIov9fyVtW4+sMxdYp3ZIYB5JynZFN+L2aKqeAdN1McfVPyYuDxIpc8+K3IXdmaWeHx6as9P8RUdIFhygGph9Fk/QWcLRBs8Y8f40jWpAmcCB/dPPwp1eOTdkOktUREaacAPFqLPdvJM/r53rNKjXdt++RH+pYrJE5b8BrTEstwq7xM9/+3Y2SqTx3IllUou97pMG2NdmNd//BotNAcHqzE1nzBcAI5boxwSDwMxXssxNQ5KpSlcPW2UHwHtEU/zOekV+w= 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.232; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813947020158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni Reviewed-by: Peter Maydell --- accel/hvf/hvf-all.c | 1 - 1 file changed, 1 deletion(-) diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index 033c677b6f..5f357c6d19 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -18,7 +18,6 @@ #include "system/hvf_int.h" #include "hw/core/cpu.h" #include "hw/core/boards.h" -#include "target/arm/hvf_arm.h" #include "trace.h" =20 bool hvf_allowed; --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813930; cv=none; d=zohomail.com; s=zohoarc; b=QFtLnslh7565+NT5CAC2rviff/17KS6OIo1V4xV3iyJn+2kflJmPO11jVm/gqsmmQyYfk1ZxI04ljBVNKohiUHr1c+U50aNLqqhJqQvdWPAy3dzAv6MHualzGrGMmqWih7U1iynk+yQ7yibk6enHtpX2T9mxWO8uq1rVVqeHyFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813930; 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=fZA8/l25pege+AA3tp9V2oguHyeiwhKKjkx8GHgz6Co=; b=k8iAA/HKub2DeObn/j4cf6P55hJCSuY/9ASb4FYqY03giyx97Lih9IGr7mmUHTri0K7PnPHzLWwovrPhK3QHMOaoudmvGg50q2ocIj1XnCOzH0EKm2LwybjpCPr13LSNBwZlCrHmuitrTpKcCbcwAHTj/it2jfnfplTGvZu3th8= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813930241500.4037332780738; Fri, 6 Mar 2026 08:18:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXq3-0004Aq-Un; Fri, 06 Mar 2026 11:15:44 -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 1vyXq1-00049D-Ik for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:41 -0500 Received: from p-west3-cluster3-host10-snip4-8.eps.apple.com ([57.103.72.249] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXpv-00076k-A9 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:40 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 79201180013D; Fri, 6 Mar 2026 16:15:28 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 8E2201800139; Fri, 6 Mar 2026 16:15:25 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813731; x=1775405731; bh=fZA8/l25pege+AA3tp9V2oguHyeiwhKKjkx8GHgz6Co=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=RJ20Khk5lJAIzM98lGUTioRUB8u/DMjXscs6phxXYWPHM/UJDpUBHyyKMIK06YXaoul+6vct8DkmqcjEZ8Jm/5eRmBJMpkRxS7KJxM7RCXdpQqT2/wxVvUw0TPnZCrtrveixQH6zLl0EJp+xeWVDGK365DP8KgC6xSLz65x3uAAEdpwDtN0lPAlrCprZer54IvBVBa1oILrGhs9+x/gPaD1J3KiI16fZpB0XtuVaMY2Xv481WUsTF19twV35al/cwoUfzLwf1k63AruFo3mxdSUAceD4H/wZC3gS0dUhyqDvmeUkOXwCRY8nhxnC2FCLa/8YJA8KtOGUbSfdFmzNRQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 05/17] hw/intc: Add hvf vGIC interrupt controller support Date: Fri, 6 Mar 2026 17:14:57 +0100 Message-ID: <20260306161509.79712-6-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 6E0_qdLCSpj8luZEaqDqAhOAbXENTxmX X-Proofpoint-GUID: 6E0_qdLCSpj8luZEaqDqAhOAbXENTxmX X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfXwHjAp7C2eI2A pRafFXxbwLnDLo0VW6SPEqp+zpcVihc9fIRKHXVYjdN9c2VGCLQ7lsYqu1sbNIcgm29Jrsl3NMC 4VSgoeuWqyh1INSg1swsfK7658b6fd1/Cud6MB2XE6sK8v/z+GEsvlFX76Xk7xyffcd3iCthRWu qvWABxeJyyIUM9Ko34kiQuOw5BWHYe+fJICUFXYN7iBcenI21UJU9CTpczku6gPD5xXvd7jXaMF mt/CauZcFEyVLYZzv8JCJsbX1BlG4QQWsoRd1ch22QSwkzm3vcm0RDz/Hpld6RbckOMOyx1txKT x8z7q9Db9lvhXGyH/6bDHvRGkmfCZEq0E9xFRnXYtmXvmB8sB5ZDC0rQnek2E4= X-Authority-Info-Out: v=2.4 cv=DMeCIiNb c=1 sm=1 tr=0 ts=69aafda1 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=D2JAlcJVxmvnjXxMMLIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 clxscore=1030 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABrVBXKuTIG6+UNKupfwle2O9ry8tSLp51tTtcHeURwNkGtAW0w0SkQqWYxyj3aGVjlSd2j7dRmK1AXBu5Qi+CdF2ip6K7sup6LiF07MBoWQrGXWTuwdqPPNwP3ZSlFysZcpZTK+vPoJMFz0K5iorNSXDcQRo2jfevhL/aNKo6xLR1wMcj8DBiYjfyluuStb1t3ut2VEsqoFMsRmYFOTA9+6lx65qFPMNhcFIq+A74Nucuki3tsiNQYoiKSc1C0QCXDMwKTTQei6PHRIrpBhzvqYwBrdqksp2WXo0HVD9Xi5bqYKWxlXvOh4QuD/IZOcRNNDds1+t+hmDbltLTymZz7mzNm5o0WuGC5pZXI2m5Zoyvegbwk+V2jXKLB6N+p1pKzIhVjLbxKXTz/03OEFBfDTwhhBpBbSoQfrH+oaAloXHj2g1FnytZUKavC13rQ3M+CAB7wj0QyEsqdl/cCXrLfzBGjg1rsfaDJG1A65um4XMjIV2x5u7QvAhY12PhK/JzOHZJzjVdYE51juyhCMPNNKUr2N6L5OP6ueAK2V/0FQYh5W/w3WRFcPIcNpU7Rx1W9ORf3CBKMhvywizT3bhI4I68272Azxp0e9h0bBm8gs954I0nZDdC2SPzwSZMVYCQSJ4K3R3qp2j1lzAoSXnRJAQmL85rUxnSHvEwWfAlalTlJrPuACyNq8IyvS6KWbyyN1F+muUFQD8Ciba1oD++NFdhw0ImODmzEn4T2LqBWm9hVEhi3vn0XbSVonXoxdTAXeC4S8IN/eYXjuI8Bp0ybhpfNoV+/BTJJ2jNEFT5oxE= 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.249; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813931191158500 This opens up the door to nested virtualisation support. Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/intc/arm_gicv3_hvf.c | 741 +++++++++++++++++++++++++++++ hw/intc/meson.build | 1 + include/hw/intc/arm_gicv3_common.h | 1 + 3 files changed, 743 insertions(+) create mode 100644 hw/intc/arm_gicv3_hvf.c diff --git a/hw/intc/arm_gicv3_hvf.c b/hw/intc/arm_gicv3_hvf.c new file mode 100644 index 0000000000..55171a796b --- /dev/null +++ b/hw/intc/arm_gicv3_hvf.c @@ -0,0 +1,741 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * ARM Generic Interrupt Controller using HVF platform support + * + * Copyright (c) 2025 Mohamed Mediouni + * Based on vGICv3 KVM code by Pavel Fedin + * + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/intc/arm_gicv3_common.h" +#include "qemu/error-report.h" +#include "qemu/module.h" +#include "system/runstate.h" +#include "system/hvf.h" +#include "system/hvf_int.h" +#include "hvf_arm.h" +#include "gicv3_internal.h" +#include "vgic_common.h" +#include "qom/object.h" +#include "target/arm/cpregs.h" +#include + +/* For the GIC, override the check outright, as availability is checked el= sewhere. */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability" + +struct HVFARMGICv3Class { + ARMGICv3CommonClass parent_class; + DeviceRealize parent_realize; + ResettablePhases parent_phases; +}; + +typedef struct HVFARMGICv3Class HVFARMGICv3Class; + +/* This is reusing the GICv3State typedef from ARM_GICV3_ITS_COMMON */ +DECLARE_OBJ_CHECKERS(GICv3State, HVFARMGICv3Class, + HVF_GICV3, TYPE_HVF_GICV3); + +/* + * Loop through each distributor IRQ related register; since bits + * corresponding to SPIs and PPIs are RAZ/WI when affinity routing + * is enabled, we skip those. + */ +#define for_each_dist_irq_reg(_irq, _max, _field_width) \ + for (_irq =3D GIC_INTERNAL; _irq < _max; _irq +=3D (32 / _field_width)) + +/* + * Wrap calls to the vGIC APIs to assert_hvf_ok() + * as a macro to keep the code clean. + */ +#define hv_gic_get_distributor_reg(offset, reg) \ + assert_hvf_ok(hv_gic_get_distributor_reg(offset, reg)) + +#define hv_gic_set_distributor_reg(offset, reg) \ + assert_hvf_ok(hv_gic_set_distributor_reg(offset, reg)) + +#define hv_gic_get_redistributor_reg(vcpu, reg, value) \ + assert_hvf_ok(hv_gic_get_redistributor_reg(vcpu, reg, value)) + +#define hv_gic_set_redistributor_reg(vcpu, reg, value) \ + assert_hvf_ok(hv_gic_set_redistributor_reg(vcpu, reg, value)) + +#define hv_gic_get_icc_reg(vcpu, reg, value) \ + assert_hvf_ok(hv_gic_get_icc_reg(vcpu, reg, value)) + +#define hv_gic_set_icc_reg(vcpu, reg, value) \ + assert_hvf_ok(hv_gic_set_icc_reg(vcpu, reg, value)) + +#define hv_gic_get_ich_reg(vcpu, reg, value) \ + assert_hvf_ok(hv_gic_get_ich_reg(vcpu, reg, value)) + +#define hv_gic_set_ich_reg(vcpu, reg, value) \ + assert_hvf_ok(hv_gic_set_ich_reg(vcpu, reg, value)) + +static void hvf_dist_get_priority(GICv3State *s, hv_gic_distributor_reg_t = offset + , uint8_t *bmp) +{ + uint64_t reg; + uint32_t *field; + int irq; + field =3D (uint32_t *)(bmp); + + for_each_dist_irq_reg(irq, s->num_irq, 8) { + hv_gic_get_distributor_reg(offset, ®); + *field =3D reg; + offset +=3D 4; + field++; + } +} + +static void hvf_dist_put_priority(GICv3State *s, hv_gic_distributor_reg_t = offset + , uint8_t *bmp) +{ + uint32_t reg, *field; + int irq; + field =3D (uint32_t *)(bmp); + + for_each_dist_irq_reg(irq, s->num_irq, 8) { + reg =3D *field; + hv_gic_set_distributor_reg(offset, reg); + offset +=3D 4; + field++; + } +} + +static void hvf_dist_get_edge_trigger(GICv3State *s, hv_gic_distributor_re= g_t offset, + uint32_t *bmp) +{ + uint64_t reg; + int irq; + + for_each_dist_irq_reg(irq, s->num_irq, 2) { + hv_gic_get_distributor_reg(offset, ®); + reg =3D half_unshuffle32(reg >> 1); + if (irq % 32 !=3D 0) { + reg =3D (reg << 16); + } + *gic_bmp_ptr32(bmp, irq) |=3D reg; + offset +=3D 4; + } +} + +static void hvf_dist_put_edge_trigger(GICv3State *s, hv_gic_distributor_re= g_t offset, + uint32_t *bmp) +{ + uint32_t reg; + int irq; + + for_each_dist_irq_reg(irq, s->num_irq, 2) { + reg =3D *gic_bmp_ptr32(bmp, irq); + if (irq % 32 !=3D 0) { + reg =3D (reg & 0xffff0000) >> 16; + } else { + reg =3D reg & 0xffff; + } + reg =3D half_shuffle32(reg) << 1; + hv_gic_set_distributor_reg(offset, reg); + offset +=3D 4; + } +} + +/* Read a bitmap register group from the kernel VGIC. */ +static void hvf_dist_getbmp(GICv3State *s, hv_gic_distributor_reg_t offset= , uint32_t *bmp) +{ + uint64_t reg; + int irq; + + for_each_dist_irq_reg(irq, s->num_irq, 1) { + + hv_gic_get_distributor_reg(offset, ®); + *gic_bmp_ptr32(bmp, irq) =3D reg; + offset +=3D 4; + } +} + +static void hvf_dist_putbmp(GICv3State *s, hv_gic_distributor_reg_t offset, + hv_gic_distributor_reg_t clroffset, uint32_t *= bmp) +{ + uint32_t reg; + int irq; + + for_each_dist_irq_reg(irq, s->num_irq, 1) { + /* + * If this bitmap is a set/clear register pair, first write to the + * clear-reg to clear all bits before using the set-reg to write + * the 1 bits. + */ + if (clroffset !=3D 0) { + reg =3D 0; + hv_gic_set_distributor_reg(clroffset, reg); + clroffset +=3D 4; + } + reg =3D *gic_bmp_ptr32(bmp, irq); + hv_gic_set_distributor_reg(offset, reg); + offset +=3D 4; + } +} + +static void hvf_gicv3_check(GICv3State *s) +{ + uint64_t reg; + uint32_t num_irq; + + /* Sanity checking s->num_irq */ + hv_gic_get_distributor_reg(HV_GIC_DISTRIBUTOR_REG_GICD_TYPER, ®); + num_irq =3D ((reg & 0x1f) + 1) * 32; + + if (num_irq < s->num_irq) { + error_report("Model requests %u IRQs, but HVF supports max %u", + s->num_irq, num_irq); + abort(); + } +} + +static void hvf_gicv3_put_cpu_el2(CPUState *cpu_state, run_on_cpu_data arg) +{ + int num_pri_bits; + + /* Redistributor state */ + GICv3CPUState *c =3D arg.host_ptr; + hv_vcpu_t vcpu =3D c->cpu->accel->fd; + + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_VMCR_EL2, c->ich_vmcr_el2); + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_HCR_EL2, c->ich_hcr_el2); + + for (int i =3D 0; i < GICV3_LR_MAX; i++) { + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_LR0_EL2, c->ich_lr_el2[i]); + } + + num_pri_bits =3D c->vpribits; + + switch (num_pri_bits) { + case 7: + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_AP0R0_EL2 + 3, + c->ich_apr[GICV3_G0][3]); + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_AP0R0_EL2 + 2, + c->ich_apr[GICV3_G0][2]); + /* fall through */ + case 6: + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_AP0R0_EL2 + 1, + c->ich_apr[GICV3_G0][1]); + /* fall through */ + default: + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_AP0R0_EL2, + c->ich_apr[GICV3_G0][0]); + } + + switch (num_pri_bits) { + case 7: + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_AP1R0_EL2 + 3, + c->ich_apr[GICV3_G1NS][3]); + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_AP1R0_EL2 + 2, + c->ich_apr[GICV3_G1NS][2]); + /* fall through */ + case 6: + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_AP1R0_EL2 + 1, + c->ich_apr[GICV3_G1NS][1]); + /* fall through */ + default: + hv_gic_set_ich_reg(vcpu, HV_GIC_ICH_REG_AP1R0_EL2, + c->ich_apr[GICV3_G1NS][0]); + } +} + +static void hvf_gicv3_put_cpu(CPUState *cpu_state, run_on_cpu_data arg) +{ + uint32_t reg; + uint64_t reg64; + int i, num_pri_bits; + + /* Redistributor state */ + GICv3CPUState *c =3D arg.host_ptr; + hv_vcpu_t vcpu =3D c->cpu->accel->fd; + + reg =3D c->gicr_waker; + hv_gic_set_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_IGROU= PR0, reg); + + reg =3D c->gicr_igroupr0; + hv_gic_set_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_IGROU= PR0, reg); + + reg =3D ~0; + hv_gic_set_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ICENA= BLER0, reg); + reg =3D c->gicr_ienabler0; + hv_gic_set_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ISENA= BLER0, reg); + + /* Restore config before pending so we treat level/edge correctly */ + reg =3D half_shuffle32(c->edge_trigger >> 16) << 1; + hv_gic_set_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ICFGR= 1, reg); + + reg =3D ~0; + hv_gic_set_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ICPEN= DR0, reg); + reg =3D c->gicr_ipendr0; + hv_gic_set_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ISPEN= DR0, reg); + + reg =3D ~0; + hv_gic_set_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ICACT= IVER0, reg); + reg =3D c->gicr_iactiver0; + hv_gic_set_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ISACT= IVER0, reg); + + for (i =3D 0; i < GIC_INTERNAL; i +=3D 4) { + reg =3D c->gicr_ipriorityr[i] | + (c->gicr_ipriorityr[i + 1] << 8) | + (c->gicr_ipriorityr[i + 2] << 16) | + (c->gicr_ipriorityr[i + 3] << 24); + hv_gic_set_redistributor_reg(vcpu, + HV_GIC_REDISTRIBUTOR_REG_GICR_IPRIORITYR0 + i, reg); + } + + /* CPU interface state */ + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_SRE_EL1, c->icc_sre_el1); + + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_CTLR_EL1, + c->icc_ctlr_el1[GICV3_NS]); + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_IGRPEN0_EL1, + c->icc_igrpen[GICV3_G0]); + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_IGRPEN1_EL1, + c->icc_igrpen[GICV3_G1NS]); + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_PMR_EL1, c->icc_pmr_el1); + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_BPR0_EL1, c->icc_bpr[GICV3_G0]= ); + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_BPR1_EL1, c->icc_bpr[GICV3_G1N= S]); + + num_pri_bits =3D ((c->icc_ctlr_el1[GICV3_NS] & + ICC_CTLR_EL1_PRIBITS_MASK) >> + ICC_CTLR_EL1_PRIBITS_SHIFT) + 1; + + switch (num_pri_bits) { + case 7: + reg64 =3D c->icc_apr[GICV3_G0][3]; + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_AP0R0_EL1 + 3, reg64); + reg64 =3D c->icc_apr[GICV3_G0][2]; + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_AP0R0_EL1 + 2, reg64); + /* fall through */ + case 6: + reg64 =3D c->icc_apr[GICV3_G0][1]; + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_AP0R0_EL1 + 1, reg64); + /* fall through */ + default: + reg64 =3D c->icc_apr[GICV3_G0][0]; + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_AP0R0_EL1, reg64); + } + + switch (num_pri_bits) { + case 7: + reg64 =3D c->icc_apr[GICV3_G1NS][3]; + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_AP1R0_EL1 + 3, reg64); + reg64 =3D c->icc_apr[GICV3_G1NS][2]; + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_AP1R0_EL1 + 2, reg64); + /* fall through */ + case 6: + reg64 =3D c->icc_apr[GICV3_G1NS][1]; + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_AP1R0_EL1 + 1, reg64); + /* fall through */ + default: + reg64 =3D c->icc_apr[GICV3_G1NS][0]; + hv_gic_set_icc_reg(vcpu, HV_GIC_ICC_REG_AP1R0_EL1, reg64); + } + + /* Registers beyond this point are with nested virt only */ + if (c->gic->maint_irq) { + hvf_gicv3_put_cpu_el2(cpu_state, arg); + } +} + +static void hvf_gicv3_put(GICv3State *s) +{ + uint32_t reg; + int ncpu, i; + + hvf_gicv3_check(s); + + reg =3D s->gicd_ctlr; + hv_gic_set_distributor_reg(HV_GIC_DISTRIBUTOR_REG_GICD_CTLR, reg); + + /* per-CPU state */ + + for (ncpu =3D 0; ncpu < s->num_cpu; ncpu++) { + run_on_cpu_data data; + data.host_ptr =3D &s->cpu[ncpu]; + run_on_cpu(s->cpu[ncpu].cpu, hvf_gicv3_put_cpu, data); + } + + /* s->enable bitmap -> GICD_ISENABLERn */ + hvf_dist_putbmp(s, HV_GIC_DISTRIBUTOR_REG_GICD_ISENABLER0 + , HV_GIC_DISTRIBUTOR_REG_GICD_ICENABLER0, s->enabled); + + /* s->group bitmap -> GICD_IGROUPRn */ + hvf_dist_putbmp(s, HV_GIC_DISTRIBUTOR_REG_GICD_IGROUPR0 + , 0, s->group); + + /* Restore targets before pending to ensure the pending state is set on + * the appropriate CPU interfaces in the kernel + */ + + /* s->gicd_irouter[irq] -> GICD_IROUTERn */ + for (i =3D GIC_INTERNAL; i < s->num_irq; i++) { + uint32_t offset =3D HV_GIC_DISTRIBUTOR_REG_GICD_IROUTER32 + (8 * i) + - (8 * GIC_INTERNAL); + hv_gic_set_distributor_reg(offset, s->gicd_irouter[i]); + } + + /* + * s->trigger bitmap -> GICD_ICFGRn + * (restore configuration registers before pending IRQs so we treat + * level/edge correctly) + */ + hvf_dist_put_edge_trigger(s, HV_GIC_DISTRIBUTOR_REG_GICD_ICFGR0, s->ed= ge_trigger); + + /* s->pending bitmap -> GICD_ISPENDRn */ + hvf_dist_putbmp(s, HV_GIC_DISTRIBUTOR_REG_GICD_ISPENDR0, + HV_GIC_DISTRIBUTOR_REG_GICD_ICPENDR0, s->pending); + + /* s->active bitmap -> GICD_ISACTIVERn */ + hvf_dist_putbmp(s, HV_GIC_DISTRIBUTOR_REG_GICD_ISACTIVER0, + HV_GIC_DISTRIBUTOR_REG_GICD_ICACTIVER0, s->active); + + /* s->gicd_ipriority[] -> GICD_IPRIORITYRn */ + hvf_dist_put_priority(s, HV_GIC_DISTRIBUTOR_REG_GICD_IPRIORITYR0, s->g= icd_ipriority); +} + +static void hvf_gicv3_get_cpu_el2(CPUState *cpu_state, run_on_cpu_data arg) +{ + int num_pri_bits; + + /* Redistributor state */ + GICv3CPUState *c =3D arg.host_ptr; + hv_vcpu_t vcpu =3D c->cpu->accel->fd; + + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_VMCR_EL2, &c->ich_vmcr_el2); + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_HCR_EL2, &c->ich_hcr_el2); + + for (int i =3D 0; i < GICV3_LR_MAX; i++) { + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_LR0_EL2, &c->ich_lr_el2[i]= ); + } + + num_pri_bits =3D c->vpribits; + + switch (num_pri_bits) { + case 7: + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_AP0R0_EL2 + 3, + &c->ich_apr[GICV3_G0][3]); + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_AP0R0_EL2 + 2, + &c->ich_apr[GICV3_G0][2]); + /* fall through */ + case 6: + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_AP0R0_EL2 + 1, + &c->ich_apr[GICV3_G0][1]); + /* fall through */ + default: + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_AP0R0_EL2, + &c->ich_apr[GICV3_G0][0]); + } + + switch (num_pri_bits) { + case 7: + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_AP1R0_EL2 + 3, + &c->ich_apr[GICV3_G1NS][3]); + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_AP1R0_EL2 + 2, + &c->ich_apr[GICV3_G1NS][2]); + /* fall through */ + case 6: + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_AP1R0_EL2 + 1, + &c->ich_apr[GICV3_G1NS][1]); + /* fall through */ + default: + hv_gic_get_ich_reg(vcpu, HV_GIC_ICH_REG_AP1R0_EL2, + &c->ich_apr[GICV3_G1NS][0]); + } +} + +static void hvf_gicv3_get_cpu(CPUState *cpu_state, run_on_cpu_data arg) +{ + uint64_t reg; + int i, num_pri_bits; + + /* Redistributor state */ + GICv3CPUState *c =3D arg.host_ptr; + hv_vcpu_t vcpu =3D c->cpu->accel->fd; + + hv_gic_get_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_IGROU= PR0, + ®); + c->gicr_igroupr0 =3D reg; + hv_gic_get_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ISENA= BLER0, + ®); + c->gicr_ienabler0 =3D reg; + hv_gic_get_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ICFGR= 1, + ®); + c->edge_trigger =3D half_unshuffle32(reg >> 1) << 16; + hv_gic_get_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ISPEN= DR0, + ®); + c->gicr_ipendr0 =3D reg; + hv_gic_get_redistributor_reg(vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_ISACT= IVER0, + ®); + c->gicr_iactiver0 =3D reg; + + for (i =3D 0; i < GIC_INTERNAL; i +=3D 4) { + hv_gic_get_redistributor_reg( + vcpu, HV_GIC_REDISTRIBUTOR_REG_GICR_IPRIORITYR0 + i, ®); + c->gicr_ipriorityr[i] =3D extract32(reg, 0, 8); + c->gicr_ipriorityr[i + 1] =3D extract32(reg, 8, 8); + c->gicr_ipriorityr[i + 2] =3D extract32(reg, 16, 8); + c->gicr_ipriorityr[i + 3] =3D extract32(reg, 24, 8); + } + + /* CPU interface */ + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_SRE_EL1, &c->icc_sre_el1); + + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_CTLR_EL1, + &c->icc_ctlr_el1[GICV3_NS]); + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_IGRPEN0_EL1, + &c->icc_igrpen[GICV3_G0]); + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_IGRPEN1_EL1, + &c->icc_igrpen[GICV3_G1NS]); + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_PMR_EL1, &c->icc_pmr_el1); + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_BPR0_EL1, &c->icc_bpr[GICV3_G0= ]); + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_BPR1_EL1, &c->icc_bpr[GICV3_G1= NS]); + num_pri_bits =3D ((c->icc_ctlr_el1[GICV3_NS] & ICC_CTLR_EL1_PRIBITS_MA= SK) >> + ICC_CTLR_EL1_PRIBITS_SHIFT) + + 1; + + switch (num_pri_bits) { + case 7: + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_AP0R0_EL1 + 3, + &c->icc_apr[GICV3_G0][3]); + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_AP0R0_EL1 + 2, + &c->icc_apr[GICV3_G0][2]); + /* fall through */ + case 6: + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_AP0R0_EL1 + 1, + &c->icc_apr[GICV3_G0][1]); + /* fall through */ + default: + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_AP0R0_EL1, + &c->icc_apr[GICV3_G0][0]); + } + + switch (num_pri_bits) { + case 7: + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_AP1R0_EL1 + 3, + &c->icc_apr[GICV3_G1NS][3]); + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_AP1R0_EL1 + 2, + &c->icc_apr[GICV3_G1NS][2]); + /* fall through */ + case 6: + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_AP1R0_EL1 + 1, + &c->icc_apr[GICV3_G1NS][1]); + /* fall through */ + default: + hv_gic_get_icc_reg(vcpu, HV_GIC_ICC_REG_AP1R0_EL1, + &c->icc_apr[GICV3_G1NS][0]); + } + + /* Registers beyond this point are with nested virt only */ + if (c->gic->maint_irq) { + hvf_gicv3_get_cpu_el2(cpu_state, arg); + } +} + +static void hvf_gicv3_get(GICv3State *s) +{ + uint64_t reg; + int ncpu, i; + + hvf_gicv3_check(s); + + hv_gic_get_distributor_reg(HV_GIC_DISTRIBUTOR_REG_GICD_CTLR, ®); + s->gicd_ctlr =3D reg; + + /* Redistributor state (one per CPU) */ + + for (ncpu =3D 0; ncpu < s->num_cpu; ncpu++) { + run_on_cpu_data data; + data.host_ptr =3D &s->cpu[ncpu]; + run_on_cpu(s->cpu[ncpu].cpu, hvf_gicv3_get_cpu, data); + } + + /* GICD_IGROUPRn -> s->group bitmap */ + hvf_dist_getbmp(s, HV_GIC_DISTRIBUTOR_REG_GICD_IGROUPR0, s->group); + + /* GICD_ISENABLERn -> s->enabled bitmap */ + hvf_dist_getbmp(s, HV_GIC_DISTRIBUTOR_REG_GICD_ISENABLER0, s->enabled); + + /* GICD_ISPENDRn -> s->pending bitmap */ + hvf_dist_getbmp(s, HV_GIC_DISTRIBUTOR_REG_GICD_ISPENDR0, s->pending); + + /* GICD_ISACTIVERn -> s->active bitmap */ + hvf_dist_getbmp(s, HV_GIC_DISTRIBUTOR_REG_GICD_ISACTIVER0, s->active); + + /* GICD_ICFGRn -> s->trigger bitmap */ + hvf_dist_get_edge_trigger(s, HV_GIC_DISTRIBUTOR_REG_GICD_ICFGR0 + , s->edge_trigger); + + /* GICD_IPRIORITYRn -> s->gicd_ipriority[] */ + hvf_dist_get_priority(s, HV_GIC_DISTRIBUTOR_REG_GICD_IPRIORITYR0 + , s->gicd_ipriority); + + /* GICD_IROUTERn -> s->gicd_irouter[irq] */ + for (i =3D GIC_INTERNAL; i < s->num_irq; i++) { + uint32_t offset =3D HV_GIC_DISTRIBUTOR_REG_GICD_IROUTER32 + + (8 * i) - (8 * GIC_INTERNAL); + hv_gic_get_distributor_reg(offset, &s->gicd_irouter[i]); + } +} + +static void hvf_gicv3_set_irq(void *opaque, int irq, int level) +{ + GICv3State *s =3D opaque; + if (irq > s->num_irq) { + return; + } + hv_gic_set_spi(GIC_INTERNAL + irq, !!level); +} + +static void hvf_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + GICv3CPUState *c; + + c =3D env->gicv3state; + c->icc_pmr_el1 =3D 0; + /* + * Architecturally the reset value of the ICC_BPR registers + * is UNKNOWN. We set them all to 0 here; when the kernel + * uses these values to program the ICH_VMCR_EL2 fields that + * determine the guest-visible ICC_BPR register values, the + * hardware's "writing a value less than the minimum sets + * the field to the minimum value" behaviour will result in + * them effectively resetting to the correct minimum value + * for the host GIC. + */ + c->icc_bpr[GICV3_G0] =3D 0; + c->icc_bpr[GICV3_G1] =3D 0; + c->icc_bpr[GICV3_G1NS] =3D 0; + + c->icc_sre_el1 =3D 0x7; + memset(c->icc_apr, 0, sizeof(c->icc_apr)); + memset(c->icc_igrpen, 0, sizeof(c->icc_igrpen)); +} + +static void hvf_gicv3_reset_hold(Object *obj, ResetType type) +{ + GICv3State *s =3D ARM_GICV3_COMMON(obj); + HVFARMGICv3Class *kgc =3D HVF_GICV3_GET_CLASS(s); + + if (kgc->parent_phases.hold) { + kgc->parent_phases.hold(obj, type); + } + + hvf_gicv3_put(s); +} + + +/* + * CPU interface registers of GIC needs to be reset on CPU reset. + * For the calling arm_gicv3_icc_reset() on CPU reset, we register + * below ARMCPRegInfo. As we reset the whole cpu interface under single + * register reset, we define only one register of CPU interface instead + * of defining all the registers. + */ +static const ARMCPRegInfo gicv3_cpuif_reginfo[] =3D { + { .name =3D "ICC_CTLR_EL1", .state =3D ARM_CP_STATE_BOTH, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 12, .crm =3D 12, .opc2 =3D 4, + /* + * If ARM_CP_NOP is used, resetfn is not called, + * So ARM_CP_NO_RAW is appropriate type. + */ + .type =3D ARM_CP_NO_RAW, + .access =3D PL1_RW, + .readfn =3D arm_cp_read_zero, + .writefn =3D arm_cp_write_ignore, + /* + * We hang the whole cpu interface reset routine off here + * rather than parcelling it out into one little function + * per register + */ + .resetfn =3D hvf_gicv3_icc_reset, + }, +}; + +static void hvf_gicv3_realize(DeviceState *dev, Error **errp) +{ + ERRP_GUARD(); + GICv3State *s =3D HVF_GICV3(dev); + HVFARMGICv3Class *kgc =3D HVF_GICV3_GET_CLASS(s); + int i; + + kgc->parent_realize(dev, errp); + if (*errp) { + return; + } + + if (s->revision !=3D 3) { + error_setg(errp, "unsupported GIC revision %d for platform GIC", + s->revision); + } + + if (s->security_extn) { + error_setg(errp, "the platform vGICv3 does not implement the " + "security extensions"); + return; + } + + if (s->nmi_support) { + error_setg(errp, "NMI is not supported with the platform GIC"); + return; + } + + if (s->nb_redist_regions > 1) { + error_setg(errp, "Multiple VGICv3 redistributor regions are not " + "supported by HVF"); + error_append_hint(errp, "A maximum of %d VCPUs can be used", + s->redist_region_count[0]); + return; + } + + gicv3_init_irqs_and_mmio(s, hvf_gicv3_set_irq, NULL); + + for (i =3D 0; i < s->num_cpu; i++) { + ARMCPU *cpu =3D ARM_CPU(qemu_get_cpu(i)); + + define_arm_cp_regs(cpu, gicv3_cpuif_reginfo); + } + + if (s->maint_irq && s->maint_irq !=3D HV_GIC_INT_MAINTENANCE) { + error_setg(errp, "vGIC maintenance IRQ mismatch with the hardcoded= one in HVF."); + return; + } +} + +static void hvf_gicv3_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + ARMGICv3CommonClass *agcc =3D ARM_GICV3_COMMON_CLASS(klass); + HVFARMGICv3Class *kgc =3D HVF_GICV3_CLASS(klass); + + agcc->pre_save =3D hvf_gicv3_get; + agcc->post_load =3D hvf_gicv3_put; + + device_class_set_parent_realize(dc, hvf_gicv3_realize, + &kgc->parent_realize); + resettable_class_set_parent_phases(rc, NULL, hvf_gicv3_reset_hold, NUL= L, + &kgc->parent_phases); +} + +static const TypeInfo hvf_arm_gicv3_info =3D { + .name =3D TYPE_HVF_GICV3, + .parent =3D TYPE_ARM_GICV3_COMMON, + .instance_size =3D sizeof(GICv3State), + .class_init =3D hvf_gicv3_class_init, + .class_size =3D sizeof(HVFARMGICv3Class), +}; + +static void hvf_gicv3_register_types(void) +{ + type_register_static(&hvf_arm_gicv3_info); +} + +type_init(hvf_gicv3_register_types) + +#pragma clang diagnostic pop diff --git a/hw/intc/meson.build b/hw/intc/meson.build index 96742df090..b7baf8a0f6 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -42,6 +42,7 @@ arm_common_ss.add(when: 'CONFIG_ARM_GIC', if_true: files(= 'arm_gicv3_cpuif_common arm_common_ss.add(when: 'CONFIG_ARM_GICV3', if_true: files('arm_gicv3_cpui= f.c')) specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c'= )) specific_ss.add(when: ['CONFIG_WHPX', 'TARGET_AARCH64'], if_true: files('a= rm_gicv3_whpx.c')) +specific_ss.add(when: ['CONFIG_HVF', 'CONFIG_ARM_GICV3'], if_true: files('= arm_gicv3_hvf.c')) specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: f= iles('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) arm_common_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_nvic.c')) specific_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_irqmp.c')) diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3= _common.h index c55cf18120..9adcab0a0c 100644 --- a/include/hw/intc/arm_gicv3_common.h +++ b/include/hw/intc/arm_gicv3_common.h @@ -315,6 +315,7 @@ DECLARE_OBJ_CHECKERS(GICv3State, ARMGICv3CommonClass, =20 /* Types for GICv3 kernel-irqchip */ #define TYPE_WHPX_GICV3 "whpx-arm-gicv3" +#define TYPE_HVF_GICV3 "hvf-arm-gicv3" =20 struct ARMGICv3CommonClass { /*< private >*/ --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772814197; cv=none; d=zohomail.com; s=zohoarc; b=kaNE7z6zHwhWfVTv7RJw0IuHXpL8FOctuf1IYxe6/VmZCak4jx9wl7W8EEHw5ipG9zSCS56KQEQPsSONA6hQtw5ih8Ka/lUSHPVwTfhEygD1I/gz/LUWwEK20TYZrx0Un6HYy88CM5hNxA6uzNqy0oCM+oRjR/jjBsTtSweWh7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772814197; 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=1RV2oa9C2DaRGIF3rfTp8Tdv8xxfIYsPZWi/MFo/wCM=; b=iHKC1iqX/4xK7RYBMvikYKFeXE2xbhNZrcJOBN4HzxCENUJytm7Bqbox/yG/wLlWQ42IRPWP1gd8g+fUjIZfdO1v5Xr8+BlXm/R/vLFv0R2uzG3hGqK9vrA1tt804mtSE3Y73n036fb8sKXnDIhGNS79Ga7PYVKWAS2+ctQ/e8g= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772814197527793.1485576006431; Fri, 6 Mar 2026 08:23:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXq6-0004Cm-BK; Fri, 06 Mar 2026 11:15:46 -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 1vyXq2-0004A2-DD for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:42 -0500 Received: from p-west3-cluster3-host12-snip4-10.eps.apple.com ([57.103.72.231] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXpx-00077R-1F for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:42 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 2C2251800119; Fri, 6 Mar 2026 16:15:30 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 2A5B518007B1; Fri, 6 Mar 2026 16:15:28 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813736; x=1775405736; bh=1RV2oa9C2DaRGIF3rfTp8Tdv8xxfIYsPZWi/MFo/wCM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=P6setRlzYInNuHpCL0K3vqUFQm072ElkcSSJ63CvI4R693+xChHWown6MtWJ9pdf7jCTy1mU1M3VEpm835uCAyA0hDh07XXbvOSAcY85Vv0/OFSIi2y1JlYkriD81qQP1cR78J6LFKA7/gFWxUliS6gbRzMRun9oydyHf21oLlNknuu3Tmi2BEXi53wi/hQPMIYlmAKbnqW5Bm3P6zPUR20UQdqSlI5ouyYgR/JQMhbP2hYBApGrdUaTxQ58oIXJXlELlFTPOMrGne5uIr4mDO020yC3gjP7YPDeercK2UospUNkog5Zt2H95o61rQSTIaQIhsK4UnBJquiKwyNB4Q== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 06/17] hw/intc: arm_gicv3_hvf: save/restore Apple GIC state Date: Fri, 6 Mar 2026 17:14:58 +0100 Message-ID: <20260306161509.79712-7-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: OtxGg7K5Vv9O9nwWeXwvyR0Zt8S5Lvas X-Proofpoint-GUID: OtxGg7K5Vv9O9nwWeXwvyR0Zt8S5Lvas X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX0Nr0KNpMx01c hXaMxaf7w9lDZ4iZoL6ceocD+aQVLC+ugRLcvjQ7WMGOINBATDP1yaQfyooaraKURd0BsKqRLCe aPrEybGT+cK2iWo7p4HMqmX5TYu1Z0fgQPAWUVaYsJSMLHn2eNz9CJvOTkm3iyKU743IKiNI/Py +9aL4/q6bR3aruHkbXUtvQx1vjWwEiWh/kWPFi0S1NzDsFrcd/dIkpk0ry6oo/Wok46R0ttWWke VrZlGv8RK0cnDjQyARuWFmPZBnFzeMDvjPpPwQvjW751RZQxrqobJ6W3SPJE3EjBhz9yQZQNqC1 2azOJ5U1EwfzqKVOiIfNV1+39GNPXmWMV2VX4W68leoX9aFzE/a0DrK1/dv4T8= X-Authority-Info-Out: v=2.4 cv=DMeCIiNb c=1 sm=1 tr=0 ts=69aafda4 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=kNOF8fv34t_zTB2Y_VIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 clxscore=1030 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABkz1uYaR++23G5ZSMWEdkW2ot/uuBv/faWgpKFiJhyk351B+swAyAdZ/0OW7UiWmU0p4IAmLswNJBu8AquZXxaqseyQt3xR6kbfolLJd4gyg9jcY9azLUSxSE8SKBmQk2OG+gMPLv7YGWKWEaNaS6eT6e8yqEub5iNem2aa6mjQH2SM20Csdb2m2hxZfyPnXywytHgLpCJNZKF4/dUJGssw2ytoft+RCXOANkuKwyItX+pkGBu/aFiyHsKBGchmkK9yF+IwNJfZPHH2xE8vJp5RSK9oQCYCIGJLcV4aEJ9sDLvxWp4mpkdX1AdLe+h/C9bUEwFyUqMObqm/BA9Bs40FZps3SA4/DXhHh7UrhOxFHoxwB5BhRWNCxJGO4bekcYmDjbM9pzSE1w5nUS18qPVlp9GmO65bmcEXf+fJPW4MX4/nuAgMqvt/Y0DZxtMt8b6ecofBAOew5RIc5XojTfSIsl0/9Zbu9ajT4wUyP4VRE+NnXNCAvibsolGc0J96j4tWdiI4B0gorG6APFB1zZcjvwFy7hewWRhqfOjaFxzTpTvyYaWlT7cnis8LzZxh9DWdJCUeDlfmcF+U4DolFjAyuNvGxjL7CbNhzOIzc03huxFMkP1akXl7kJbI8bQKa6DSIltKxc3VhBpvqABmqH6xSSAhLfVmjgrJlvCs61lzFNhdsK8YSWS7o9tvHD81klNLkUcpfdKcsf1NjB2KFyaqsncKKrFm2RiID9sxqrvQGdEVC6TU1Wkdwy3F9dMCh7gWGAsXXkssYKDHbW89OKyDo2VFetW9XTV6oUwpNoqylQnMaGMtBbYEo= 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.231; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772814199342154100 On HVF, some of the GIC state is in an opaque Apple-provided structure. Save/restore that state to be able to save/restore VMs that use the hardwar= e GIC. Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/intc/arm_gicv3_common.c | 1 + hw/intc/arm_gicv3_hvf.c | 95 ++++++++++++++++++++++++++++-- hw/intc/arm_gicv3_hvf_stub.c | 25 ++++++++ hw/intc/meson.build | 1 + include/hw/intc/arm_gicv3_common.h | 3 + 5 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 hw/intc/arm_gicv3_hvf_stub.c diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index 9200671c7a..9c3fb2f4bf 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -305,6 +305,7 @@ static const VMStateDescription vmstate_gicv3 =3D { .subsections =3D (const VMStateDescription * const []) { &vmstate_gicv3_gicd_no_migration_shift_bug, &vmstate_gicv3_gicd_nmi, + &vmstate_gicv3_hvf, NULL } }; diff --git a/hw/intc/arm_gicv3_hvf.c b/hw/intc/arm_gicv3_hvf.c index 55171a796b..18e5b3fe68 100644 --- a/hw/intc/arm_gicv3_hvf.c +++ b/hw/intc/arm_gicv3_hvf.c @@ -13,6 +13,7 @@ #include "qemu/error-report.h" #include "qemu/module.h" #include "system/runstate.h" +#include "migration/vmstate.h" #include "system/hvf.h" #include "system/hvf_int.h" #include "hvf_arm.h" @@ -34,8 +35,13 @@ struct HVFARMGICv3Class { =20 typedef struct HVFARMGICv3Class HVFARMGICv3Class; =20 -/* This is reusing the GICv3State typedef from ARM_GICV3_ITS_COMMON */ -DECLARE_OBJ_CHECKERS(GICv3State, HVFARMGICv3Class, +typedef struct HVFGICv3State { + GICv3State gicv3_state; + uint32_t size; + void *state; +} HVFGICv3State; + +DECLARE_OBJ_CHECKERS(HVFGICv3State, HVFARMGICv3Class, HVF_GICV3, TYPE_HVF_GICV3); =20 /* @@ -660,7 +666,7 @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] =3D { static void hvf_gicv3_realize(DeviceState *dev, Error **errp) { ERRP_GUARD(); - GICv3State *s =3D HVF_GICV3(dev); + GICv3State *s =3D (GICv3State *)HVF_GICV3(dev); HVFARMGICv3Class *kgc =3D HVF_GICV3_GET_CLASS(s); int i; =20 @@ -707,6 +713,87 @@ static void hvf_gicv3_realize(DeviceState *dev, Error = **errp) } } =20 +/* + * HVF doesn't have a way to save the RDIST pending tables + * to guest memory, only to an opaque data structure. + */ +static bool gicv3_is_hvf(void *opaque) +{ + return hvf_enabled() && hvf_irqchip_in_kernel(); +} + +static int hvf_gic_opaque_state_save(void *opaque) +{ + HVFGICv3State *gic =3D opaque; + hv_gic_state_t gic_state; + hv_return_t err; + size_t size; + + gic_state =3D hv_gic_state_create(); + if (gic_state =3D=3D NULL) { + error_report("hvf: vgic: failed to create hv_gic_state_create."); + return 1; + } + err =3D hv_gic_state_get_size(gic_state, &size); + gic->size =3D size; + if (err !=3D HV_SUCCESS) { + error_report("hvf: vgic: failed to get GIC state size."); + os_release(gic_state); + return 1; + } + gic->state =3D g_malloc(gic->size); + err =3D hv_gic_state_get_data(gic_state, gic->state); + if (err !=3D HV_SUCCESS) { + error_report("hvf: vgic: failed to get GIC state."); + os_release(gic_state); + return 1; + } + + os_release(gic_state); + return 0; +} + +static int hvf_gic_opaque_state_free(void *opaque) +{ + HVFGICv3State *gic =3D opaque; + free(gic->state); + return 0; +} + +static int hvf_gic_opaque_state_restore(void *opaque, int version_id) +{ + HVFGICv3State *gic =3D opaque; + hv_return_t err; + if (!gic->size) { + return 0; + } + err =3D hv_gic_set_state(gic->state, gic->size); + if (err !=3D HV_SUCCESS) { + error_report("hvf: vgic: failed to restore GIC state."); + return 1; + } + return 0; +} + +const VMStateDescription vmstate_gicv3_hvf =3D { + .name =3D "arm_gicv3/hvf_gic_state", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D gicv3_is_hvf, + .pre_save =3D hvf_gic_opaque_state_save, + .post_save =3D hvf_gic_opaque_state_free, + .post_load =3D hvf_gic_opaque_state_restore, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(size, HVFGICv3State), + VMSTATE_VBUFFER_ALLOC_UINT32(state, + HVFGICv3State, 0, 0, + size), + VMSTATE_END_OF_LIST() + }, +}; + static void hvf_gicv3_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -726,7 +813,7 @@ static void hvf_gicv3_class_init(ObjectClass *klass, co= nst void *data) static const TypeInfo hvf_arm_gicv3_info =3D { .name =3D TYPE_HVF_GICV3, .parent =3D TYPE_ARM_GICV3_COMMON, - .instance_size =3D sizeof(GICv3State), + .instance_size =3D sizeof(HVFGICv3State), .class_init =3D hvf_gicv3_class_init, .class_size =3D sizeof(HVFARMGICv3Class), }; diff --git a/hw/intc/arm_gicv3_hvf_stub.c b/hw/intc/arm_gicv3_hvf_stub.c new file mode 100644 index 0000000000..a587332c7c --- /dev/null +++ b/hw/intc/arm_gicv3_hvf_stub.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * ARM Generic Interrupt Controller using HVF platform support stub + * + * Copyright (c) 2026 Mohamed Mediouni + * + */ +#include "qemu/osdep.h" +#include "hw/intc/arm_gicv3_common.h" +#include "migration/vmstate.h" +#include "qemu/typedefs.h" + +static bool needed_never(void *opaque) +{ + return false; +} + +const VMStateDescription vmstate_gicv3_hvf =3D { + .name =3D "arm_gicv3/hvf_gic_state", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D needed_never, + .version_id =3D 1, + .minimum_version_id =3D 1, +}; diff --git a/hw/intc/meson.build b/hw/intc/meson.build index b7baf8a0f6..c6de2d9d00 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -43,6 +43,7 @@ arm_common_ss.add(when: 'CONFIG_ARM_GICV3', if_true: file= s('arm_gicv3_cpuif.c')) specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c'= )) specific_ss.add(when: ['CONFIG_WHPX', 'TARGET_AARCH64'], if_true: files('a= rm_gicv3_whpx.c')) specific_ss.add(when: ['CONFIG_HVF', 'CONFIG_ARM_GICV3'], if_true: files('= arm_gicv3_hvf.c')) +specific_ss.add(when: ['CONFIG_HVF', 'CONFIG_ARM_GICV3'], if_false: files(= 'arm_gicv3_hvf_stub.c')) specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: f= iles('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) arm_common_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_nvic.c')) specific_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_irqmp.c')) diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3= _common.h index 9adcab0a0c..03ab3e8f2f 100644 --- a/include/hw/intc/arm_gicv3_common.h +++ b/include/hw/intc/arm_gicv3_common.h @@ -339,4 +339,7 @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_h= andler handler, */ const char *gicv3_class_name(void); =20 +/* HVF vGIC-specific state: stubbed out on a build with HVF disabled */ +extern const VMStateDescription vmstate_gicv3_hvf; + #endif --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772814177; cv=none; d=zohomail.com; s=zohoarc; b=amKpamQScL/Qy1dXWPGgUu22CT8PWr9JVimS6eYSUa4HOlzbdDblsqo8CV+ienoJVGVH8cpnK7FQNhYgEHfzOKt+a/H0w+5C/H/O+hwuuJCty3/dewzaUpla6h553lfgh7RbUIJ7RAxQWHH4IzfrEgXiqFNHJVtn4sekqeyTlhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772814177; 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=WMu9ZUKRv2uBa5TRx8/7qzE106fv3LSJOQVn2oeM3i8=; b=Fq+cTbqt8FCmxby52oDJDzVYIm+5cKayXN51jgW1SWPDv5KbdlZqwL5SK3RPEmzCP7cK39Y7XfoyOl4bVxHY06Ohs5deNPQyKIAYfiQm/ArslwzTua/ixbVQ0Mf8GgCzh67rI+BkXaITIbtXSeXym+pIFDf6+Zn1sV3zEHRAOL0= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772814177131714.7519048262908; Fri, 6 Mar 2026 08:22:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXq6-0004DD-JX; Fri, 06 Mar 2026 11:15:46 -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 1vyXq2-00049o-8x for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:42 -0500 Received: from p-west3-cluster3-host8-snip4-2.eps.apple.com ([57.103.72.203] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXpw-00077B-QS for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:41 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 6A40818007B7; Fri, 6 Mar 2026 16:15:33 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id BD9C818007B9; Fri, 6 Mar 2026 16:15:30 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813734; x=1775405734; bh=WMu9ZUKRv2uBa5TRx8/7qzE106fv3LSJOQVn2oeM3i8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=glm8xjXSDKdm5aOh/i2xlkZ8JRXRy9QRFBVgBZvHnMPGwmyUIIXT/Y6hzoK9XxFXd3syeiYiVSZadwq+eNMAOuELSg39Qxil5bUtL39cnr06XQxOud9c8uNfk2jQPh0h6H5q0V6vPt30+PGxH1d+Stwsl31Hu9dQNJwh5D7KTt8bS8HtlE9Q7lBZwcC3dOTENkiIEYBAwyMyvx0j3IPQcGa5H9j0BindTOuqsMgU41mubP41Lwq2ft8gYFfKrp2lHji64tp9A6qKT6GkVXHLnSQhF3zWzGNbJmbMT+voyNF52SHVcut5cu3nDUxUjZpEBd1B3RTFCm5WWTe8k2nxPQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 07/17] accel, hw/arm, include/system/hvf: infrastructure changes for HVF vGIC Date: Fri, 6 Mar 2026 17:14:59 +0100 Message-ID: <20260306161509.79712-8-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=CcYFJbrl c=1 sm=1 tr=0 ts=69aafda6 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=n4FVybPFTm1vobq06wUA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: ouZ9USi2UuKSqSns-z747Nsbj0vLJlfA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfXyNyK7EJYM1da iA0ShHk8wZpkhDIiHAuoPBlNoFRqJ1CusBvo+49QYZyxJjURZqUpRj6xdoew11k07gWiff3M6t0 UlkUR5335vYInLH/w5JUSKzEAbC7yrZmeS63HskxSlaRdJvAlYZqqcPfrBxtEh/EGZiL+MmRO5n DDT8njcyehiHg7eIb8Hld4bgIH9ZsdjQiLAbbKnNr9Z1ukr1ZLu8O6AAGXLbMl3nYhRl4MHNhKI dqEE0IxOUkkj2kswLAu4VQR+BO+nB8IccNd45Of662vm/tZjzOvMOaU0maOa3E8E/mioLly9ixq it48y5pwrRLW0oKNgQMNV7DSpCEBCAHX+aIxzvWL10lPDUbAEXYp6K3t6TjlxQ= X-Proofpoint-ORIG-GUID: ouZ9USi2UuKSqSns-z747Nsbj0vLJlfA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 clxscore=1030 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABww7Rz8EEUeLjvPha/6vQUlFdGMvNT4qqEFFDT1YODp/P2RoGxCPudAIjU9BqgCYkR8eCjiQGUeyXII+Xww2HFU/JZmAD8Q8UbXgJg5mS6J81DJyMk4pnnAgf2cIhx9KxuJTzy5rbOCU5JOvSMKI0LfH2OUbgQ5a5+I2MvLtwDZGpQmHJ8KrnoDiQKDOHYpO6UstCRR9Nu5mms8c/nct4UI3CHaDnjJwGwyTYs8vU/UUPG3/enkaUxHzZefNipNkv0PMSVqmLNiNOSwDpa9/30jMZSliEmQHmcZo9oxYQBx7g3kT9b+tOlwU22Piq84U9mpSK10jqiZcUSE9punO34mUj+5DeE49JOQqnJEbw4ih//BFWEkig/rsL3NY1qSn3yOjd9K10r0I4FC8ZFdlLoVH6zju9oKJdMCp6tBx+F4meAgyahG4huz1fjN0whFiVbzDs9qNI3LLyMDwTBFNhfGcM8bt3wCZHBHx3TttTHKWXGCzRboo0dnz/VqzN2AiryAXPCJgW8SgCGV0A2roTtkcApAX+w3BX57zFBMWu8+rNJX0DvNsBKTts9Ftx64HnZB9lg0XnYUwMollKJHlyiGXaPTGAQEVR1Cx3NFLpSGw0j92Q54sNuwqg+MfDaXEpOqjbRt8hhaUsRIyfQq1CbztOLyaGg8ZyDBmXZVULCFHQHE14SsPXTiTzGnAoq5D55rMwXEj/WriFOKwI7sfIGN0SzZzJRHWrR+rHph1dTdqJWwViIag4CT7FaWdTWmiwPnR7gCNE1og0tun/h7KGTbyzcqaivQ== 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.203; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772814178640158500 Misc changes needed for HVF vGIC enablement. Note: x86_64 macOS exposes interrupt controller virtualisation since macOS = 12. Keeping an #ifdef here in case we end up supporting that... However, given that x86_64 macOS is on its way out, it'll probably (?) not = be supported in Qemu. Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/hvf/hvf-all.c | 50 ++++++++++++++++++++++++++++++++++++++ accel/stubs/hvf-stub.c | 1 + hw/arm/virt.c | 23 +++++++++++++++--- hw/intc/arm_gicv3_common.c | 3 +++ include/system/hvf.h | 3 +++ system/vl.c | 2 ++ 6 files changed, 78 insertions(+), 4 deletions(-) diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index 5f357c6d19..a296b108bc 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -10,6 +10,8 @@ =20 #include "qemu/osdep.h" #include "qemu/error-report.h" +#include "qapi/error.h" +#include "qapi/qapi-visit-common.h" #include "accel/accel-ops.h" #include "exec/cpu-common.h" #include "system/address-spaces.h" @@ -21,6 +23,7 @@ #include "trace.h" =20 bool hvf_allowed; +bool hvf_kernel_irqchip; =20 const char *hvf_return_string(hv_return_t ret) { @@ -216,6 +219,43 @@ static int hvf_gdbstub_sstep_flags(AccelState *as) return SSTEP_ENABLE | SSTEP_NOIRQ; } =20 +static void hvf_set_kernel_irqchip(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + OnOffSplit mode; + if (!visit_type_OnOffSplit(v, name, &mode, errp)) { + return; + } + + switch (mode) { + case ON_OFF_SPLIT_ON: +#ifdef HOST_X86_64 + /* macOS 12 onwards exposes an HVF virtual APIC. */ + error_setg(errp, "HVF: kernel irqchip is not currently implemented= for x86."); + break; +#else + hvf_kernel_irqchip =3D true; + break; +#endif + + case ON_OFF_SPLIT_OFF: + hvf_kernel_irqchip =3D false; + break; + + case ON_OFF_SPLIT_SPLIT: + error_setg(errp, "HVF: split irqchip is not supported on HVF."); + break; + + default: + /* + * The value was checked in visit_type_OnOffSplit() above. If + * we get here, then something is wrong in QEMU. + */ + abort(); + } +} + static void hvf_accel_class_init(ObjectClass *oc, const void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); @@ -223,6 +263,16 @@ static void hvf_accel_class_init(ObjectClass *oc, cons= t void *data) ac->init_machine =3D hvf_accel_init; ac->allowed =3D &hvf_allowed; ac->gdbstub_supported_sstep_flags =3D hvf_gdbstub_sstep_flags; +#ifdef HOST_X86_64 + hvf_kernel_irqchip =3D false; +#else + hvf_kernel_irqchip =3D true; +#endif + object_class_property_add(oc, "kernel-irqchip", "on|off|split", + NULL, hvf_set_kernel_irqchip, + NULL, NULL); + object_class_property_set_description(oc, "kernel-irqchip", + "Configure HVF irqchip"); } =20 static const TypeInfo hvf_accel_type =3D { diff --git a/accel/stubs/hvf-stub.c b/accel/stubs/hvf-stub.c index 42eadc5ca9..6bd08759ba 100644 --- a/accel/stubs/hvf-stub.c +++ b/accel/stubs/hvf-stub.c @@ -10,3 +10,4 @@ #include "system/hvf.h" =20 bool hvf_allowed; +bool hvf_kernel_irqchip; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7456614d05..7a6fad1094 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -837,7 +837,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) * interrupts; there are always 32 of the former (mandated by GIC spec= ). */ qdev_prop_set_uint32(vms->gic, "num-irq", NUM_IRQS + 32); - if (!kvm_irqchip_in_kernel()) { + if (!kvm_irqchip_in_kernel() && !hvf_irqchip_in_kernel()) { qdev_prop_set_bit(vms->gic, "has-security-extensions", vms->secure= ); } =20 @@ -860,7 +860,8 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) qdev_prop_set_array(vms->gic, "redist-region-count", redist_region_count); =20 - if (!kvm_irqchip_in_kernel()) { + if (!kvm_irqchip_in_kernel() && + !(hvf_enabled() && hvf_irqchip_in_kernel())) { if (vms->tcg_its) { object_property_set_link(OBJECT(vms->gic), "sysmem", OBJECT(mem), &error_fatal); @@ -871,7 +872,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) ARCH_GIC_MAINT_IRQ); } } else { - if (!kvm_irqchip_in_kernel()) { + if (!kvm_irqchip_in_kernel() && !hvf_irqchip_in_kernel()) { qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", vms->virt); } @@ -2118,7 +2119,15 @@ static void finalize_gic_version(VirtMachineState *v= ms) accel_name =3D "KVM with kernel-irqchip=3Doff"; } else if (whpx_enabled()) { gics_supported |=3D VIRT_GIC_VERSION_3_MASK; - } else if (tcg_enabled() || hvf_enabled() || qtest_enabled()) { + } else if (hvf_enabled()) { + if (!hvf_irqchip_in_kernel()) { + gics_supported |=3D VIRT_GIC_VERSION_2_MASK; + } + /* Hypervisor.framework doesn't expose EL2<->1 transition notifier= s */ + if (!(!hvf_irqchip_in_kernel() && vms->virt)) { + gics_supported |=3D VIRT_GIC_VERSION_3_MASK; + } + } else if (tcg_enabled() || qtest_enabled()) { gics_supported |=3D VIRT_GIC_VERSION_2_MASK; if (module_object_class_by_name("arm-gicv3")) { gics_supported |=3D VIRT_GIC_VERSION_3_MASK; @@ -2160,6 +2169,8 @@ static void finalize_msi_controller(VirtMachineState = *vms) vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; } else if (whpx_enabled()) { vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; + } else if (hvf_enabled() && hvf_irqchip_in_kernel()) { + vms->msi_controller =3D VIRT_MSI_CTRL_GICV2M; } else { vms->msi_controller =3D VIRT_MSI_CTRL_ITS; } @@ -2179,6 +2190,10 @@ static void finalize_msi_controller(VirtMachineState= *vms) error_report("ITS not supported on WHPX."); exit(1); } + if (hvf_enabled() && hvf_irqchip_in_kernel()) { + error_report("ITS not supported on HVF when using the hardware= vGIC."); + exit(1); + } } =20 assert(vms->msi_controller !=3D VIRT_MSI_CTRL_AUTO); diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index 9c3fb2f4bf..f7ba74e6d5 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -33,6 +33,7 @@ #include "hw/arm/linux-boot-if.h" #include "system/kvm.h" #include "system/whpx.h" +#include "system/hvf.h" =20 =20 static void gicv3_gicd_no_migration_shift_bug_post_load(GICv3State *cs) @@ -659,6 +660,8 @@ const char *gicv3_class_name(void) return "kvm-arm-gicv3"; } else if (whpx_enabled()) { return TYPE_WHPX_GICV3; + } else if (hvf_enabled() && hvf_irqchip_in_kernel()) { + return TYPE_HVF_GICV3; } else { if (kvm_enabled()) { error_report("Userspace GICv3 is not supported with KVM"); diff --git a/include/system/hvf.h b/include/system/hvf.h index d3dcf088b3..dc8da85979 100644 --- a/include/system/hvf.h +++ b/include/system/hvf.h @@ -26,8 +26,11 @@ #ifdef CONFIG_HVF_IS_POSSIBLE extern bool hvf_allowed; #define hvf_enabled() (hvf_allowed) +extern bool hvf_kernel_irqchip; +#define hvf_irqchip_in_kernel() (hvf_kernel_irqchip) #else /* !CONFIG_HVF_IS_POSSIBLE */ #define hvf_enabled() 0 +#define hvf_irqchip_in_kernel() 0 #endif /* !CONFIG_HVF_IS_POSSIBLE */ =20 #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf") diff --git a/system/vl.c b/system/vl.c index 3e341142a0..7a3db97ee6 100644 --- a/system/vl.c +++ b/system/vl.c @@ -1778,6 +1778,8 @@ static void qemu_apply_legacy_machine_options(QDict *= qdict) false); object_register_sugar_prop(ACCEL_CLASS_NAME("whpx"), "kernel-irqch= ip", value, false); + object_register_sugar_prop(ACCEL_CLASS_NAME("hvf"), "kernel-irqchi= p", value, + false); qdict_del(qdict, "kernel-irqchip"); } =20 --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813783; cv=none; d=zohomail.com; s=zohoarc; b=mjiVNSNhUwU+SePoYM/0L74I+5txwIOItSP0yTsc0feF7tiWSjvAwnrtD7qEEmNzKzNXcIgn7YXaj7+kpFr/CeX0zSO/hAiACVgsF5FnA0GPpTD8r7T8NRo36DZYCj5mdvYeLpJOMmvsK2GbyyJy5vtPJnNwvV5NSAfwQgEApAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813783; 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=Za1A/rWYBemEiFnwIdoGUen3C/FlkRo1GZfGqCovANM=; b=kpMCDAWp6QoMXjIuQC5l+DeEFeiCVP5oi6c+qCVdke+Ue06rvcEdz67uoldrz5VIy7E/z2IXSunHWwCygXO0QYSMw3WE5R/DAA5pQ1gLTC+c5nFcSamlmgFwnNY9ic9/Nxn9wRWehuVCBSDGakXkTtaIMe1lITZdRdOLrfXwGnM= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813783273170.95777517649026; Fri, 6 Mar 2026 08:16:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXq9-0004DY-Cg; Fri, 06 Mar 2026 11:15:49 -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 1vyXq3-0004At-FN for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:43 -0500 Received: from p-west3-cluster3-host9-snip4-10.eps.apple.com ([57.103.72.241] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXpz-000785-FC for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:43 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 385EA1800129; Fri, 6 Mar 2026 16:15:36 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 584C518007A9; Fri, 6 Mar 2026 16:15:33 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813738; x=1775405738; bh=Za1A/rWYBemEiFnwIdoGUen3C/FlkRo1GZfGqCovANM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=NYTH1+VTQCik2QtN91YViUpD7/ZVvs3sSru4thBRbQV7uhBpdaiQcKr4a+ACrBHKKKk5L3Dccwz4DO/6T9CN3IYbUVJCYUt1XZn3Cl4/nSX8CkO19Bxnm14RYoRbnGtgeQnKjk9Bhz7zXbj0UpqCjxHkDnZgz6cHSG8B4DcSNdy8R2HNTQVt6NmtUfUGDe3Hr1qG3Z0+8XqCdsnPCCvVUEJBXcboDImu1GwOw/Od1cdhLMZhP2B7Qi6i6srCEYehkTTVo8+i3py0CJecZ0NnwWvlntri89kj9XS6aAlkgcCw2f0QwT+PbsTZ6GZQLvs45ysSZoDSoVMMtFI836MTvw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 08/17] target/arm: hvf: instantiate GIC early Date: Fri, 6 Mar 2026 17:15:00 +0100 Message-ID: <20260306161509.79712-9-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: mKEqkHlW3SDjbnlZ6E9eFL4BIgReXTpE X-Authority-Info-Out: v=2.4 cv=T/qBjvKQ c=1 sm=1 tr=0 ts=69aafda9 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=XPPznyVi1VJc6oo_AzkA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: mKEqkHlW3SDjbnlZ6E9eFL4BIgReXTpE X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX6OMkpAy4HHBh 15mhIUv/DBheKIg2q20JddlAuM7lZoOzCelKb4C7hta8DHGd4Ax2nH8BLSVkAwD0xD0gFFGnUNJ 286lCS5SmMphorpeen7sR8WQxxoeInecmNFOC7LTlzlj7M3pg3Nu9KCY8vQQnsPiZPrpCtsPfzo PlxefDcntWK0j2HlclsCEhPQR+MRjpCL+S3BxCFtuQwxcudNY7+b+DiaUp9y244tZLqDKCwrjjU RlpreF26nSRgl4bQ4ltlvgCFK9jA7LVagANXfcOIebXc/RJMAreFb0QU2ehFrMMVzraH/hFhTkX 5AevfuJsZcTvzxXQ/L+SOfhKGc0d8qZnYnwSMBrNyMdlLlQh7WUNdSmBjuyacM= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 bulkscore=0 mlxscore=0 mlxlogscore=674 clxscore=1030 suspectscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABKqVFaVlnmGnOlGV9fI4aMnaIr2SshVI85taPDCV0Spe8o6GiZ9lVqEKdkM/evGIOSus40j8NdhBXmNWvj6VRhry7B+K0oZZO7hMbd+fQlyCukrbpFvygWSu7M2wv0ELNCsD9W2Wsg06uEoS8phGl8BQFU184XDkZUKaAGDZDblkwL/LlgWpvDzW8sO07O0JTo3eeddyGdaaXdvmeHO8RfdhbFvKgt6PHPSxB5llgmpNvn3gPTzFOcd4rNzBkxz9FkFVbRs962EbzZtrhLR0zAlkQy54zKtX9qlgxhqVcDAuE+6Ta9BJeWbRaEStyTw24oUjU/cZH6OFF9gO2JX7EmsOFUalLbPMtj7Oq/+byBJN+EyWdYAkD7x8B/fUCt43Bw2tgPfSXGfXXdeFsnM4lQln0QLeicuKlck2KL8RlSjguYML4y701V61eR8ZoFiMTVwvEsgS9cF83ykD78n2+wQ4Yl26ATuy6cdIcrYbgOiI2be/soVv9/w/3Sd4wTIlbO9f6HpVFCqFr2xTgNM9NRoKrRTkMhHsbd1SjNcwG0A7+uSHSDeDXhSNe8/DrfiWlVnXcmDLTFT8I1kNx05TTxvVn07983xk/vAAx6VTdM+ashFxnrTAlx/JDjOWxJO9KaWvl+eqltvetmYRnh2bFdTI8vF5p2q7cg7B/OJopLrOLJD7cYLby2/0Sh3WIbaBMCGIaWhrOX/RJNBZxOyBmt/KNfFQUhZgSYx4O7v6RfVIMnY+9+1y5NDROw9h7yNFdGcM= 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.241; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813784810154100 While figuring out a better spot for it, put it in hv_arch_vm_create(). After hv_vcpu_create is documented as too late, and deferring vCPU initialization isn't enough either. Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 5fc8f6bbbd..2ed1268ac9 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1230,6 +1230,24 @@ hv_return_t hvf_arch_vm_create(MachineState *ms, uin= t32_t pa_range) chosen_ipa_bit_size =3D pa_range; =20 ret =3D hv_vm_create(config); + if (__builtin_available(macOS 15.2, *)) { + if (hvf_irqchip_in_kernel()) { + /* + * Instantiate GIC. + * This must be done prior to the creation of any vCPU + * but past hv_vm_create() + */ + hv_gic_config_t cfg =3D hv_gic_config_create(); + hv_gic_config_set_distributor_base(cfg, 0x08000000); + hv_gic_config_set_redistributor_base(cfg, 0x080A0000); + hv_return_t err =3D hv_gic_create(cfg); + if (err !=3D HV_SUCCESS) { + error_report("error creating platform VGIC"); + goto cleanup; + } + os_release(cfg); + } + } =20 cleanup: os_release(config); --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813848; cv=none; d=zohomail.com; s=zohoarc; b=cYvS/sbMkU4rPWgpDw2R0aHr5nB5P9vII+cXULPKVhXauUskmBHJeVTis46IE7EG9C29oDC3d8NkVoHmrasvifpQ6RtcnshuUe9La4Sf5KhZbBqC7NDBg2aPKrHfKnR+U69DAheigUSkR1EJPDrbHWVGor4eJsLq66w4/dXoU5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813848; 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=fRkaIzrsiHcpewkizPo+VGrzP1Gah0QVvX6PsUYTLv0=; b=YXcvwyPClyJINe4LsRArNt+miYd6BJS/AoPk0N8KFBSr93PJ8BBSSHQLXfnP43T9vUs0wOzG5C/bdYAfI4ny93hHRktO2IMdr/LdUz7ak7M+FcD78NWu0895YpQ7WeoSf8++NesviqitQ59UvSPY4a3Am9oxKvehN3+1M0uMPxg= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813848060555.2729487563867; Fri, 6 Mar 2026 08:17:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXqB-0004G6-D1; Fri, 06 Mar 2026 11:15:51 -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 1vyXq5-0004CD-7F for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:45 -0500 Received: from p-west3-cluster3-host12-snip4-10.eps.apple.com ([57.103.72.231] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXq3-000796-7r for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:44 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id B118118007A9; Fri, 6 Mar 2026 16:15:38 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id E531A1800130; Fri, 6 Mar 2026 16:15:35 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813741; x=1775405741; bh=fRkaIzrsiHcpewkizPo+VGrzP1Gah0QVvX6PsUYTLv0=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=chMFi4UkcubxVXGBiWSYk9OGHmdGQIfnv3/2JKFkruooQTaCfhUnjFoiabKTqltUam/uG5pvc19TVnLsClgDTI88KKACiPqF7Ia9wWQH1XOsoM16W16XK+vXJhiGF5ph1XDQDwNFAWykqI0rSrIzSabxY1wEGjCIT5Mknlhl00ckRMQ+vriJLd9b426wqbFnBoGVkOiy0mPBUY/GZbCJt7xbIsc7SbG4msvntLhcVEJRsbZ3bg9xFLQcSljZ/Lj3id08/RRWwnfPJUyjGq7IUQiruAkJkcxQ5nIg9SfrfbtvKvxV5vS7C6cN7299cwOCWWTLo+/NHGINlhTn0obywg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 09/17] hw/arm, target/arm: nested virtualisation on HVF Date: Fri, 6 Mar 2026 17:15:01 +0100 Message-ID: <20260306161509.79712-10-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 0HWBRO9lZujlA-2hBTekDFrtCKQf_Ft1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX3zPzn2KcilTb oGlPZQHmkwWl60yUb2pkgpyT9OJB4R/TXTdEXkBSzKumnA9V5OAooRMZkg+FjcvUAmdOBqm0eSI LxuEWs5p8tHk+ewYS0tJ2gDPbgtVRatFhFuZqUdBLP+0X5lvJA19OSpWpKWKdQSwFNlofdb+Pe2 HJiAGVNnTntj0nrd24FGgtfnBZJTF2FpfneZDlAcfF8wnWzEij1YtB3V0HUFe6Z0BTn9AVcNwfc oEeC+j0bOGxadHbacLVSjoomiNgO8cpIvAp+rnohh71zVfbgR9Bu7SRv0v8at1FGu1ZuDDRe6ow SH2h0o+hLxuGFWl93fen9n+5ZGNE7os2NQlewT9aDnZxgPL/RmwDC2/HJwnnDU= X-Authority-Info-Out: v=2.4 cv=DrpbOW/+ c=1 sm=1 tr=0 ts=69aafdab cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=0QeE6rx795gg9bSW8oEA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: 0HWBRO9lZujlA-2hBTekDFrtCKQf_Ft1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=862 adultscore=0 mlxscore=0 bulkscore=0 clxscore=1030 malwarescore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABSE8tqLauVW4DcaW7lmPQQeYQej9D4KMiZdP3xlM5B4vzsIAO04Lr721byrKv96ttQ7ldV8zGQcKILEppeX7Wqvz41+k50oOZz4sTDYG/2me3h5yj/cQkQW/cFiczdgwiJomQqZJWH87IO9ZE4zk1KvTf8BgOtDrPLWiVvlK9e4/BBPolp/B73/OXK9swtb2voWbRZZAnQShSHVzNhQWVxS6S4KoFkTsSYhf/+AlyiDynQIvfPZNnfm9tU0jBn8BDWL4A+XIWBVbetCEJgplL+4uvomdO00FqvH/6f0LUwKEF2m6HPhXMg51hatrT0d4FOgjGKicnlPdaX21PvEGFmJmH8k6q3GwhMWuhghE2YHAmDXUNrZOjF6kJ+EohEdPqOD5UeXlJcanZxnEWg0npxn0xYuzOaqd4AwbFHssrPEYx5eE/27PVfr4zwngLFHzIv+42xbyvPF9JH/jNlHiqYyTfp9Wrn5Z8NjnWm0UJsIcvyzxDc7VjPvKZXCAR9BEkdSXpXDhp/17Ue2WU1fhPClLJcN5b9Yr7+1ozbGnrZmcILxuqNODvNeQ5Wg7v+OOxtIzWzC0zR6/SeNKbKVJXWCwXfPFS6mh1k6lgISdpBGsA2nIHAPfBt/ejlrA3AXxT2vvVLE0ZzEDTdZiQ1PfhOWiJ084X/RY+PihjMmlcWSYcWfRHF2et30AgO/mJLrlGXTCe+HfbjjqE+XlxyuUfI2xuEWmBYshalU+iwo+lIi4yyjchS4nKNQH15d/S+cZ+iemd 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.231; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813849134158500 Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- accel/hvf/hvf-all.c | 1 + accel/stubs/hvf-stub.c | 1 + hw/arm/virt.c | 5 +++++ include/system/hvf.h | 5 +++++ target/arm/hvf/hvf.c | 43 ++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index a296b108bc..1c1437b467 100644 --- a/accel/hvf/hvf-all.c +++ b/accel/hvf/hvf-all.c @@ -24,6 +24,7 @@ =20 bool hvf_allowed; bool hvf_kernel_irqchip; +bool hvf_nested_virt; =20 const char *hvf_return_string(hv_return_t ret) { diff --git a/accel/stubs/hvf-stub.c b/accel/stubs/hvf-stub.c index 6bd08759ba..cec1cbb056 100644 --- a/accel/stubs/hvf-stub.c +++ b/accel/stubs/hvf-stub.c @@ -11,3 +11,4 @@ =20 bool hvf_allowed; bool hvf_kernel_irqchip; +bool hvf_nested_virt; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7a6fad1094..90769936d0 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2661,6 +2661,11 @@ static void virt_set_virt(Object *obj, bool value, E= rror **errp) VirtMachineState *vms =3D VIRT_MACHINE(obj); =20 vms->virt =3D value; + /* + * At this point, HVF is not initialised yet. + * However, it needs to know if nested virt is enabled at init time. + */ + hvf_nested_virt_enable(value); } =20 static bool virt_get_highmem(Object *obj, Error **errp) diff --git a/include/system/hvf.h b/include/system/hvf.h index dc8da85979..0f0632f7ae 100644 --- a/include/system/hvf.h +++ b/include/system/hvf.h @@ -28,9 +28,14 @@ extern bool hvf_allowed; #define hvf_enabled() (hvf_allowed) extern bool hvf_kernel_irqchip; #define hvf_irqchip_in_kernel() (hvf_kernel_irqchip) +extern bool hvf_nested_virt; +#define hvf_nested_virt_enabled() (hvf_nested_virt) +#define hvf_nested_virt_enable(enable) hvf_nested_virt =3D enable #else /* !CONFIG_HVF_IS_POSSIBLE */ #define hvf_enabled() 0 #define hvf_irqchip_in_kernel() 0 +#define hvf_nested_virt_enabled() 0 +#define hvf_nested_virt_enable(enable) 0 #endif /* !CONFIG_HVF_IS_POSSIBLE */ =20 #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf") diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 2ed1268ac9..e4ff14e55f 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -27,6 +27,7 @@ #include "system/memory.h" #include "hw/core/boards.h" #include "hw/core/irq.h" +#include "hw/arm/virt.h" #include "qemu/main-loop.h" #include "system/cpus.h" #include "arm-powerctl.h" @@ -1103,6 +1104,10 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPU= Features *ahcf) (1ULL << ARM_FEATURE_PMU) | (1ULL << ARM_FEATURE_GENERIC_TIMER); =20 + if (hvf_nested_virt_enabled()) { + ahcf->features |=3D 1ULL << ARM_FEATURE_EL2; + } + for (i =3D 0; i < ARRAY_SIZE(regs); i++) { r |=3D hv_vcpu_config_get_feature_reg(config, regs[i].reg, &host_isar.idregs[regs[i].inde= x]); @@ -1218,6 +1223,20 @@ void hvf_arch_vcpu_destroy(CPUState *cpu) assert_hvf_ok(ret); } =20 +static bool hvf_arm_el2_supported(void) +{ + bool is_nested_virt_supported; + hv_return_t ret =3D 0; + if (__builtin_available(macOS 15.2, *)) { + hv_vm_config_get_el2_supported(&is_nested_virt_supported); + } else { + return false; + } + assert_hvf_ok(ret); + return is_nested_virt_supported; +} + + hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range) { hv_return_t ret; @@ -1229,6 +1248,20 @@ hv_return_t hvf_arch_vm_create(MachineState *ms, uin= t32_t pa_range) } chosen_ipa_bit_size =3D pa_range; =20 + if (__builtin_available(macOS 15.2, *)) { + if (hvf_nested_virt_enabled()) { + if (!hvf_arm_el2_supported()) { + error_report("Nested virtualization not supported on this = system."); + goto cleanup; + } + ret =3D hv_vm_config_set_el2_enabled(config, true); + if (ret !=3D HV_SUCCESS) { + error_report("Failed to enable nested virtualization."); + goto cleanup; + } + } + } + ret =3D hv_vm_create(config); if (__builtin_available(macOS 15.2, *)) { if (hvf_irqchip_in_kernel()) { @@ -1416,6 +1449,13 @@ static void hvf_psci_cpu_off(ARMCPU *arm_cpu) assert(ret =3D=3D QEMU_ARM_POWERCTL_RET_SUCCESS); } =20 +static int hvf_psci_get_target_el(void) +{ + if (hvf_nested_virt_enabled()) { + return 2; + } + return 1; +} /* * Handle a PSCI call. * @@ -1437,7 +1477,6 @@ static bool hvf_handle_psci_call(CPUState *cpu, int *= excp_ret) CPUState *target_cpu_state; ARMCPU *target_cpu; target_ulong entry; - int target_el =3D 1; int32_t ret =3D 0; =20 trace_arm_psci_call(param[0], param[1], param[2], param[3], @@ -1491,7 +1530,7 @@ static bool hvf_handle_psci_call(CPUState *cpu, int *= excp_ret) entry =3D param[2]; context_id =3D param[3]; ret =3D arm_set_cpu_on(mpidr, entry, context_id, - target_el, target_aarch64); + hvf_psci_get_target_el(), target_aarch64); break; case QEMU_PSCI_0_1_FN_CPU_OFF: case QEMU_PSCI_0_2_FN_CPU_OFF: --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813852; cv=none; d=zohomail.com; s=zohoarc; b=bgirGcrGS/uRIiejz16WCrotyZ7Saq8VPfU6m03QeaWqI3yE/LNM2SO/fjZRGNmvYHl+aoU5aZ8+Vod/N0FITdXjf2nEhNU+C+nbwCkdwm4ea0p/oXEioO20u+HswiNXo3EVu8t+GEo1mr/Pl/pL5o2ZvwWe+EyDYKX0sZEMK94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813852; 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=JY5TDaxmjc4xPHicBsUqy4bP+LreF1tQd+t0+vzZ5/Q=; b=T/gP3oypqAYyX+UhywXp+BciO4rZNXyDKowqYay+0rmhEvuBSZcL9bxOqL03otDdiY1hEbXipf9y/VeYV5M2Sk8NT37AlENI9qjqa6nCHPkFIRyoNoaT8bloBl5s9rZJeyVG9B0I9Dc5fqcJ0IzC2GUOUdpgeeTlz5a9bDxAwL0= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813852196110.89719005300606; Fri, 6 Mar 2026 08:17:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXqB-0004Fr-5J; Fri, 06 Mar 2026 11:15:51 -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 1vyXq6-0004Cp-4V for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:46 -0500 Received: from p-west3-cluster3-host6-snip4-10.eps.apple.com ([57.103.72.151] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXq4-00079r-LC for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:45 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 361A018007A4; Fri, 6 Mar 2026 16:15:41 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 7EDAF18007A0; Fri, 6 Mar 2026 16:15:38 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813743; x=1775405743; bh=JY5TDaxmjc4xPHicBsUqy4bP+LreF1tQd+t0+vzZ5/Q=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=Uf+ysLBskLxcfP1ltdcRlA44ehczyUvC+93Umkotq6M+L5306jedAX+VUuQuOvnaGcy98jwn2Sc7vQv261rN4r9LyUNkZmOtlNxeRvO7BSBQAvPzRVZhbCS0/ogwknaOL4A/n/PZlCi4xnfwkaAoZFWDEFpgX62stLI4vhSs7uT79Qh0G7I2W3h2S0DoUP1vj127jh3rpGQ/oKGM3YmWuJ+SXplmC50ZKX/K7i69USaW2KxS5wwwol38xhKE3d2rpmGGcHvP6I2wFY6j1USEL5TYzGgCHSxInw82gdyNdRzsZMrspF3jM+rQAO+Ntg6EFPedg/RJhr3YiFXhOlOCCA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 10/17] hvf: only call hvf_sync_vtimer() when running without the platform vGIC Date: Fri, 6 Mar 2026 17:15:02 +0100 Message-ID: <20260306161509.79712-11-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: MrZTimDh1jpOThXNPdh-f7zG7wlWY2d8 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX9NHCzQY0EBGk 4YyU5XvV4rHV7N6PenvtSnesNlygQ5UKujNX9A+DBpq2KDKt0bojwy37MMcpBpJwMBfPZKfuIr+ +tnR+X1tYkk3kHlxT5ieQ8htGkI8xswsRkRYM0Q5POKmcB6PnW8MPLtQsR9jy63tU3mtwtCtQHn lhUtIQTQkVFMS3Aqc3+82966ei6epbgbK6V/lOEq/igti52NMMbjbAnSjZgunsiiwb121Ao2Eew Lhd0yklQp1PhLarqKMjrDTpdgwhFffvwCw8o2GawsuzdUWYnEiA6Akl0jT6lvwZf6V2+StPoRGP Py3apTIeZWuzBio390P3Qpjq5lNwS0kBq0jL6wCZ9jw3k5x6sxPtli6cZOf2b8= X-Authority-Info-Out: v=2.4 cv=RKC+3oi+ c=1 sm=1 tr=0 ts=69aafdaf cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=PzQS8Z__MZ2uSZov3vkA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: MrZTimDh1jpOThXNPdh-f7zG7wlWY2d8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=905 bulkscore=0 adultscore=0 clxscore=1030 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAAB7AqTt5P/fAHtep6kZm2i+PzuTq3DaN6NnZB+GLYq9ftw6NbHOKeJzZ4Diude0jBqoRmWm3SYseVRDLbJ3dwvGpJD+lsfpIMYF6CJIcSf/4ONG1yH/CWQo7YEAT5noHt7mWHR63JOmqIr9JVnlZ7fgZ3A5hVy5+Tc65eYfIBSa12dv6mlbpANhsLjKxtU9ENzfhuHS61TyNNHK9YRKXGZTdBcwY3qN5JODWchIt4RCcT6RBBHsnrg9QwZ7VF0SlkliTT30YeODJuMQJP77CIyFPyNmpb2trf7/hBeTwuV3d77O4OqjpqghBnRYEMvbQgkJxBUzGLynKDpMDtlkYDqqXu/Lzz9x22oQbXDsp4iSW/wFVdaHL6V4Fnupitb9RQXRAyL2XYQ0HToZRbsbewj3nKzIXzHbkZJtzrhHiGFE3RrmTULmMUH01rjS7zpVCfsxdHUiiGus1xdYioL+dZXN4M/iT5SkrgasnnTLsEc6vi35NMCRhik+StA+MgqAllBmeUOZnVJCRd3jcHiMCEbS9LfyWrteOqxujQQDGSgh9P86uKuQQHQRlwljlIuFxRUO7R6Y6YvIbxEJTsEnw7JE5Alir5tBbQ3BQGjE+WFjKYZ7dVO4TeInq5RwDwpzC3VqMMQwYr9DyYyYkK3HWzDxQoKnwkJC/JinYLJGySrzyIOsdz+vwbQm6X5EgAUIVXby+B+FH69S2jFlpLCKkhl3RH13ce/59ZRpGKRwJg92qLz9b9eM2n0BBaouavLhIPGd+f3Yse8F2MEAJk46FpKCdhnpqM9odk= 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.151; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813858579158500 When running with the Apple vGIC, the EL1 vtimer is handled by the platform. Signed-off-by: Mohamed Mediouni Reviewed-by: Mads Ynddal Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index e4ff14e55f..f06a3088f8 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -2365,7 +2365,9 @@ static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_e= xit_t *exit) =20 switch (exit->reason) { case HV_EXIT_REASON_EXCEPTION: - hvf_sync_vtimer(cpu); + if (!hvf_irqchip_in_kernel()) { + hvf_sync_vtimer(cpu); + } ret =3D hvf_handle_exception(cpu, &exit->exception); break; case HV_EXIT_REASON_VTIMER_ACTIVATED: --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813860; cv=none; d=zohomail.com; s=zohoarc; b=CVAMBe+zpsxpA4w5/+MTqQjCxb2ni227qN280xJVpY+Mp+A0UANwwpJJbb2rq4tbrkPdEQ7XJOd9Ymzk+zXd4XVPttFvgjMHdJzNR3YyvVVblebbPfVbJhkDDOhOKmiSUb+Hh+Gv59qEuqgUsYzuV1oLOVO0CG5sQdfhhy6YeSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813860; 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=RdupMbasv3vfE7MWncsbZfwo8ETMcn2mJfgeWSq9R+8=; b=nQm5YpEqI83Fr53bowtX2Ja0ZxcRY1LTkAB+X/HhrMxEycC28IgQcg1L1oj8QwAk8woWCcoxW0EUROhEYteu2S6ZX++jx7M/XNzfuDefEQL5ZSGBEpXL0YZgGQNU7tYafEh077aQgso6qftdNCWgFCo3SV6fQViSdKYCVUAxqUg= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813860447326.09856856301224; Fri, 6 Mar 2026 08:17:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXqG-0004Hn-Gi; Fri, 06 Mar 2026 11:15:56 -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 1vyXqD-0004Gu-IP for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:53 -0500 Received: from p-west3-cluster3-host9-snip4-1.eps.apple.com ([57.103.72.232] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXqA-0007B1-9z for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:53 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 26ABB18007B0; Fri, 6 Mar 2026 16:15:43 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 224D5180079A; Fri, 6 Mar 2026 16:15:40 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813749; x=1775405749; bh=RdupMbasv3vfE7MWncsbZfwo8ETMcn2mJfgeWSq9R+8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=FAc0FoumzFfcidgqQCD1VTFFw+kUvK3EWgugFVELSotAav7KIj+A/OW1QjPJi5UKfkzDTAkqWUE5wUWSuFjR8ZNMPxxUvs/Fzqk6KaZBbYMvi4bKDgPHWuCmJ15zKro0Jhn4ZrzBKxmagMjaTm3Am0SLUfHWfKd7O37UB/qNATyu49M6zH/w2sPwGGdO8rbHgx2cql8vFKcrANhTOlZOqAc9XikRJsZxHfx4EbF3HBxN0UKOzrFcrTLgB29eNEG20S4yS2Si3jNwuWt9mte0VPoxZ2mdA4oeE4pNCqvLhaRaa/YR8YKmAr2cHVqlvqp8cFLfZEoiJG24yw/wnySHww== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 11/17] hvf: gate ARM_FEATURE_PMU register emulation behind not being at EL2 Date: Fri, 6 Mar 2026 17:15:03 +0100 Message-ID: <20260306161509.79712-12-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=WesBqkhX c=1 sm=1 tr=0 ts=69aafdb1 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=lOv7bB1OiAV5i3s2B4UA:9 a=NqO74GWdXPXpGKcKHaDJD/ajO6k=:19 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: rfSlUdcftab_3CAfKoLrj3Fxxc9VrXh4 X-Proofpoint-GUID: rfSlUdcftab_3CAfKoLrj3Fxxc9VrXh4 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX+A4T+0BilWx7 +GoOW1Qy/mocA0PNOq3OTyT19CdXOaMtlp/y6ycTkgj1AtnoyqgdHq6an+PRKK8prKl+PMtEF/j C8E6PZ74sGK45epz4OL+WO109g77aGkPUqn20wAh5A2wvLDVqg4SwZEViMnfbRB2WvC89m5eoqE tfH+FOg63Giurepl5upPnKgjMwabUJvIAemNU6B4OTcWuv1F8UKMWKDlzzzJSLOJKyyRvr2jM1S vngTSE8TDnYmH3IyovjfZBNLbUeVoVVVlNUDWoL31w00VrooVjAjZcyzn79W0kBULi/l1ORDHqS dz6j/CWo0f9FDynnqiQtzsR9kzB8iC0ST1AjaTC6H4nZ61qu7ybNwqUQjzn4Hc= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=752 mlxscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 clxscore=1030 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABpXXodEuu3VR0PPxYF7W4Um3CLP9PbhpmlSMNJntfqPot1TjQqMWnOG7o8r6epdlWRNCa3mGz22ACK9j9oBhRDAlSffM5VTdZDr2Fr9/dBC2FYm03t9/XtwgC2PAqhZu05SJ5VyXckBuyJHbLV1S7Xr7q1BX2xpKLTh57T7s0XLetlyPZVxNBZlMfBMz78F5qwqP9X46LEJexuP7+uwyKXGdJlipWiCD+5q4j0kGRjBBw2Hz2LCsuEJcC9iJEkEeEnSvXuVGq4ySxu2JFosAtWkjdeTNgd3IWrWCbpZe0JOvB2TrzcENeSczOqIWsyG8UgIHjR/82F/UEq7vxSAPfDmGTY8cc4DXeIpjnD/kQv0surNWAb2355054l5cshOMRm20pal2v3c+mQceMCCMG9/E5mznHbeljFNa7dkvQiRVl7Y6BEb9BrdqEmEDKRS/m/zIYu4easOhzBlwLWAdXAHqS/3P0jMhU77ydVC6X7F3W1uPy+6EBALEIZTyJMwGu+HtnRVzZYhtkrKHyTWtJhnFjISsogwpLtEmW47mKQEmsUt7tvRJWX80PcxRnKnh38nV34/k9gU2kJ9hAJLTk8DsZCiVTxvxrv0+hsaL9n2K520U7Ac10YxEFQyR2xMwZygVJxGiJbYofREvFscvAzksRUERxE+eewgPcSC7WMa6SivLHl+5Uf83aNqF40vA0VNkDNYkV+YzL5Y1N/AmZjNDuYq275NtA7B/p0lvOQTGhno/MqlhhjVlpHzNsINh9RA2m3W1o 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.232; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813860559158500 From Apple documentation: > When EL2 is disabled, PMU register accesses trigger "Trapped MSR, MRS, or > System Instruction" exceptions. When this happens, hv_vcpu_run()=E2=80=AF= returns, and the > =E2=80=AFhv_vcpu_exit_t=E2=80=AFobject contains the information about thi= s exception. > When EL2 is enabled, the handling of PMU register accesses is determined = by the PMUVer > field of ID_AA64DFR0_EL1=E2=80=AFregister. > If the PMUVer=E2=80=AFfield value is zero or is invalid, PMU register acc= esses generate "Undefined" > exceptions, which are sent to the guest. > If the PMUVer=E2=80=AFfield value is non-zero and valid, PMU register acc= esses are emulated by the framework. > The ID_AA64DFR0_EL1=E2=80=AFregister can be modified via hv_vcpu_set_sys_= reg=E2=80=AFAPI. Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index f06a3088f8..926a88ce9d 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1598,7 +1598,7 @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t re= g, uint64_t *val) ARMCPU *arm_cpu =3D ARM_CPU(cpu); CPUARMState *env =3D &arm_cpu->env; =20 - if (arm_feature(env, ARM_FEATURE_PMU)) { + if (!hvf_nested_virt_enabled() && arm_feature(env, ARM_FEATURE_PMU)) { switch (reg) { case SYSREG_PMCR_EL0: *val =3D env->cp15.c9_pmcr; @@ -1859,7 +1859,7 @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t r= eg, uint64_t val) SYSREG_OP2(reg), val); =20 - if (arm_feature(env, ARM_FEATURE_PMU)) { + if (!hvf_nested_virt_enabled() && arm_feature(env, ARM_FEATURE_PMU)) { switch (reg) { case SYSREG_PMCCNTR_EL0: pmu_op_start(env); --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813848; cv=none; d=zohomail.com; s=zohoarc; b=RAl1YUjvQQrGvu2I1d7oykiIcbSx/QnvhRY2BtW7Hiq19U07kvzDhx0Iwx5N7wiLzAD+AEnPY8b0dyFe2koaaS2SO3IfmHXWMSpYwoGWmCEE/rHK8ft5wRa6Da1EtnD+BamQG3NBFIgeky48Um2nvSmbMMwu75yA1awXT7t8GrI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813848; 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=NdAr8jiFn5AzUO3NtlP3Dsyqnl3XhiX8i1jilhhmbwg=; b=KHY2CyRTY6cpOVErUA8Vf5IB48ma0aJ5Ogn+ztcKEP0lRXLpavEe98Zx8dq5P0eqRMAmnhNUfcqld8cDipN8lXfw/weuDvtW+JYx1+SpMgw2WnZLFAxYhple5CTWtx7fCkrfQItQUpVknj5jlv0612vR4wUrEY/3dldZnjwgOms= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813848014598.4602350250506; Fri, 6 Mar 2026 08:17:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXqD-0004Gx-TO; Fri, 06 Mar 2026 11:15:53 -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 1vyXqC-0004GY-C4 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:52 -0500 Received: from p-west3-cluster3-host7-snip4-10.eps.apple.com ([57.103.72.201] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXq9-0007Ao-5L for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:52 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 3BF1718007AD; Fri, 6 Mar 2026 16:15:46 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id B51C01800794; Fri, 6 Mar 2026 16:15:43 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813748; x=1775405748; bh=NdAr8jiFn5AzUO3NtlP3Dsyqnl3XhiX8i1jilhhmbwg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=eNbTOfblgoyTvghVKXtTZq4hrIJER11vCHuA7HUQO0yx5QfqfC+qjLFq8BidJvjVb3T+9kFW4brrrbQahJB4c+hXXe5KXa1JEYxS6hcsm3AsOeGwbTGJHBpj08gTybMr4EYiJcsUcmWygr9H8UKjrpWFphgMYM6D9QX+Ml9AtgsmuFRVCBq6abUNTF3sydaiX47R3rF/fw5JjGukn7muPlyvwmFywo0gtkgx43/mM6b8mMCtzseO2XDLQpl6OtuYT+dakPdd+DqnIMvTWmgUHMqXb8jM4cxn5yetl3YrnHbeWyWKgHiBfMnbcykB31S0MTWZEg7XeP0J2ydfYI792A== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 12/17] hvf: arm: allow exposing minimal PMU when running with nested virt on Date: Fri, 6 Mar 2026 17:15:04 +0100 Message-ID: <20260306161509.79712-13-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: -_IFDDqr0C2MFIK9-OlgC2BuhvWpMXxE X-Authority-Info-Out: v=2.4 cv=PZzyRyhd c=1 sm=1 tr=0 ts=69aafdb3 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=DEZpVyLLCdwXg5o-P5sA:9 a=NqO74GWdXPXpGKcKHaDJD/ajO6k=:19 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: -_IFDDqr0C2MFIK9-OlgC2BuhvWpMXxE X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX0vkxhxB60niH SuF2hFIbPepqTuhpUbDgQL6+C1vbpj+T4NVGiJnhsrYyLDBcEC4UTxhFzfjk/P++iGYEuYIDOEp EZ7sjo49bYtQYzRwvq6qogQ9BM20efXiGpSJHKXfN1FjtGvlCaZ9N4s0ikm7HpFgJwnF/mgodt0 70YCL4nfWbJWqb3k7w0VX631NiZlQtGHCCNpSpHog5lsFHQkW03yVkzhPOz/zCY7Q8W28gHYWc6 PDUxDBd/dDXPko25Tyc1lUxC4YUuOnRP6pJo+/EWNK5vr5VrkCGd5EQbilL52RqgudZItrY8YVg P6tCdEY6oXTuPiOAEUGhlvbF/MN5hCWrc4Fo++JR2p/lDDgGOeKOiIbiJ8NC8w= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=673 phishscore=0 suspectscore=0 spamscore=0 clxscore=1030 malwarescore=0 bulkscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABEV/a3bG1RgewmSf8ZszZHHu26FGxQn/OEB8Y4tJDwiZ3bNDoYtU0b2x/O/4aMCYPkEU5TJUXKoq8A/PBqYtvGJfC6A/lt40V5oio00wdvB7I7MnsW3mg6MsSi64fcYIjHfeUF115Is8l+v19r/35NikE9z5Xfv/iRlDziHfLVoTjPwc7hZeovFqOBFRFdWWmRgUT6L9fJvuVxI2xUdVHT7wX+RRvZGbEyj94Qpks85fyKsq5HeoF8nH4wWpqk0iFSgmJ0fD7cbxSW6EUzRjZO0Rey09i0/eeCzHDXuwgXO/MagNI45rBuYdJpIY22UI74t8MDN8rwDx7w8aUj3YoQ+r0ePWKCEcHZJMNblukP747wj4iPYBHrUSoCmZIpz+hAI/ALsBoIWG8H4+ituOHUFP4ixdrdfH6QHDTf49l8RFY/9LHFhFv30W9znya8M/JGMpzTtd4qMuCouOPa6sKDOCP1Bt4bYqbVAcjfQAb30HUkeMQfYBQNvC9+jWdJL4Bq2XEUD2n5q8gE8mAtS2XW0CQxAXZqJP5F3cTXfjBx5nLcgFlFtIcNZzoPMp527mj0ie20WIKPsaqSxSzjEXMcWzr2QJC7fu4+s+APsVuZMprqhAuDx1Ar22BZZertTCbnCzkkuok4ApQdBYS7c8HtoJDldXsQfTM1IIYNZzBWnOAeclsMnYwndBE1SGkci0dKKyV+zgWAK1NCX98WklPmcs+DBFeL9A+jzHyXfm5SziVKBzuy8h4SxjE2XOmfUtlM4wjNHTFyQqnOBTOGQewYii3Tg== 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.201; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813850123154100 When running with nested virt on, a minimum PMU is exposed by Hypervisor.fr= amework if a valid PMUVer register value is set. That PMU isn't exposed otherwise. Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 926a88ce9d..2daa2ab132 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1145,6 +1145,10 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPU= Features *ahcf) =20 clamp_id_aa64mmfr0_parange_to_ipa_size(&host_isar); =20 + if (hvf_nested_virt_enabled()) { + FIELD_DP64_IDREG(&host_isar, ID_AA64DFR0, PMUVER, 0x1); + } + ahcf->isar =3D host_isar; =20 /* --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813884; cv=none; d=zohomail.com; s=zohoarc; b=TKRGxXL6mcuMUO9EWlL4XhHII4jFdNC/Gfvu+osJyvRiHELj0wNg5eorwjkzbrzwsy0ViwY9CMxE349FHVzFzr3e06qkaVNbI7I7NTKGop0fkGzHdsRrsiuG4C+heIxdBJm5B49PBm3oJblEcTOhM3F+4aKkoPWfK51Q5lb98pA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813884; 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=XPN2ek9vzGXI2utFTvmBBZ3jL3DtXEEa5/J5j669tcA=; b=ADohSXtavs20uuJFhU/xZln3bcaL06WMG7z3UgIE4F+jAFwAmCPr5rieMzyfauttDVbSNIeI1ZN43bPzJMyvsp4PbAtatT/E3SUE7ciTuMYfs+FQmLJDKPj6HjAozwBre7gNm7i8F7dnAzwiS6jqPodVUw1rbb5l/BtsvZqODDQ= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813884614303.532425629047; Fri, 6 Mar 2026 08:18:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXqH-0004IS-C0; Fri, 06 Mar 2026 11:15:57 -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 1vyXqD-0004Gw-J5 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:53 -0500 Received: from p-west3-cluster3-host9-snip4-10.eps.apple.com ([57.103.72.241] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXqB-0007BJ-B3 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:53 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id DC91A18007BF; Fri, 6 Mar 2026 16:15:48 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 27B7718007A5; Fri, 6 Mar 2026 16:15:46 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813750; x=1775405750; bh=XPN2ek9vzGXI2utFTvmBBZ3jL3DtXEEa5/J5j669tcA=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=dKn0r181O0qB3pXW21bj1UfDAZG6KJw0oc41YwN/mznXJ4mBXZvxjVptTCRYDm3enLB3kIJZm7MpKxvZtpB8bMePF0TsyRWUYIEAv9VkwrAmKt1rmrz+6FweQsiR1FhQMoh8SSi1OK3AFc5GlGCK4chLTc0DJsCYUsPV1ZWx/XkBlQ3jz3v9y/2pH8y0A5O576YNOrdJK5Q1H3D3PceWn5SpohDTLbohpQO1wB7AvSK/BCWmOmJ1kbB8q2l7qihLq89l6Y3f4u6eqsc6HjkdnR34Vxu0JiRhi8zmMaXBVVLuG8xkCIEtnsgoJ+4N31ht9rak13yaPfJyzQ4O55Zb+g== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 13/17] target/arm: hvf: add asserts for code paths not leveraged when using the vGIC Date: Fri, 6 Mar 2026 17:15:05 +0100 Message-ID: <20260306161509.79712-14-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: moVBsHTQ_TTLJcBvWeKdjOWrB4Dm7pZz X-Authority-Info-Out: v=2.4 cv=G70R0tk5 c=1 sm=1 tr=0 ts=69aafdb6 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=vbFX7M0ab_H1AmF9bzsA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: moVBsHTQ_TTLJcBvWeKdjOWrB4Dm7pZz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfXyrGKOoJcs8NJ hz+UqjNNXhD/A8twf27W6JpPVIKr8ib30g2id+a6pbsI+u/he3zhGAVBhRre91etisrbCHXCnzc NwKmiN77T5S6iD/Xl/S/Zt55nkRfRKTtqkMAPL0iMfbSROxMYTH90wxPtWdK0XJGqa7izTzBo97 3LxH58ck6CwsJVoVL0Z8wwsGMBbunIfDIB5EevuGXoRBVmMnU2Nb/tjXQt3QSK/T8w4g1vNi2Qk Lc2bsFcAz1SHBj+LjYoJsVaTl94gZKAC8tZzohipifkUXbJ3BjU04Ql1qvON5sguHONrwmHUX/B d6fWgXEXvzm4zjUoCdg2aQnFmQzkBPUlgXsVJ5u5Hi8bKWznxhTQemN0Ke0H0Q= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=531 clxscore=1030 adultscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABWjXv4Pt+xvF/071PrRQ+POfaoQCjRbBVCCyO296PNEfjSoD0smykXHBW+vzYRbC1PttvMZOh8Gz009uw3l04qB0oAGtKHphZdzybbqXsbw0PKUiG7cs7xRaE7Lf3ao0AEwAjDDgcbEIW4jTexzohNexIBxq9JQd2bhi+Kh6xcoYdU3XuAHXm+AjBVS9rj7JMo7uQe++cHdGgjPe5uUN7FQpkrjN84U5JMjMe1Izbeih+ZVMaaowcQj4os3rUq2KuIqN429gGkYuzYzbfOiS+6xBO2LmhICMBDGJXAkpXaJGnnoFU7zcp+C4RYbWmSB15nQ4DOBkMqf0veEbgouEqGXMcUblRXWrIJ+kFJLQhQixDtkIgXtkxnQFZ9dLoMh25Fbn4zv9Co0H50Tryvy8qxPq7KzEPlHLngTOmrVw/+QUtAwoyqJvboxn916XQzikIqNPj3vJLE/zFmxgf2DoSEvxZWNzKK9D3bmdl+DTmpjIPWBbknTRA3aUeRDYJpj794JBRkiXSp0QiLHC4VZ30PuZnaxKAhZKIST7LZULwTC9KoxjQ4JsJ6NEVjNBWbittMV0EDG76J+j5EJr5Btg+mfrQfiAeZzCAFNlZS/LWKD3GtNHbnssKlm10RCmjTc2xu1RO8EYIbc9S7w68uUIDTPEMmyuvEdQhidf98qQKUGHqG3XlrC5eS4ngtwkbUJ6QpHuo5oRqJxCUFErWg+nIHX2OZwncEdQpNSubYqQVCW5sMJ6BKmnOnnSkihnlwWnsiIp6gOel 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.241; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813886697158500 When using the vGIC, timers are directly handled by the platform. No vmexits ought to happen in that case. Abort if reaching those code paths. Signed-off-by: Mohamed Mediouni Reviewed-by: Mads Ynddal Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 2daa2ab132..9c986178c4 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1678,6 +1678,7 @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t re= g, uint64_t *val) case SYSREG_ICC_SGI1R_EL1: case SYSREG_ICC_SRE_EL1: case SYSREG_ICC_CTLR_EL1: + assert(!hvf_irqchip_in_kernel()); /* Call the TCG sysreg handler. This is only safe for GICv3 regs. = */ if (hvf_sysreg_read_cp(cpu, "GICv3", reg, val)) { return 0; @@ -1968,6 +1969,7 @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t r= eg, uint64_t val) case SYSREG_ICC_SGI0R_EL1: case SYSREG_ICC_SGI1R_EL1: case SYSREG_ICC_SRE_EL1: + assert(!hvf_irqchip_in_kernel()); /* Call the TCG sysreg handler. This is only safe for GICv3 regs. = */ if (hvf_sysreg_write_cp(cpu, "GICv3", reg, val)) { return 0; @@ -2375,6 +2377,7 @@ static int hvf_handle_vmexit(CPUState *cpu, hv_vcpu_e= xit_t *exit) ret =3D hvf_handle_exception(cpu, &exit->exception); break; case HV_EXIT_REASON_VTIMER_ACTIVATED: + assert(!hvf_irqchip_in_kernel()); qemu_set_irq(arm_cpu->gt_timer_outputs[GTIMER_VIRT], 1); cpu->accel->vtimer_masked =3D true; break; --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772813808; cv=none; d=zohomail.com; s=zohoarc; b=eNuKa+QffoU+BHcnKIffndiOAI27sUBVvYYAxEU/YQ1T091lFhpsiWgbWUDHrPf08S8NyjCjKaNdQm0OfGbxDhy80JS3SyHrGhoJ5Mhg4hjM59CPSFfZTv2pM2QmzRYHrs1oIxyylbJhjkxrYSRgWgiDEFc9zkbFeHd3QV3SuXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772813808; h=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=TjawJ6vyeCiiH9NFyTznB07X1dvJ23pGgt/1AETBF88=; b=k1O11v/YIDGsTQYfehyk1NRIAsjdZA850uIRX5p4dOW4/FzGFObOeeLE/aTwhqGxYVdGeTDP2uH1wsUNdmszh0Uo02lzbWVeP7kxUgfRLAm6oPWb+YM4wYfNHZ4HY0yJUY2BzsRGr18fZKrkN4uen6HA0bpfxsStqhQ9Q/X/2eQ= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772813808093262.8056568859506; Fri, 6 Mar 2026 08:16:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXqJ-0004Jv-30; Fri, 06 Mar 2026 11:15:59 -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 1vyXqH-0004IG-E5 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:57 -0500 Received: from p-west3-cluster3-host12-snip4-1.eps.apple.com ([57.103.72.222] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXqF-0007CV-1N for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:56 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 973171800109; Fri, 6 Mar 2026 16:15:51 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id B546618007BC; Fri, 6 Mar 2026 16:15:48 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813753; x=1775405753; bh=TjawJ6vyeCiiH9NFyTznB07X1dvJ23pGgt/1AETBF88=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Sz7qQJiWi/Cqc28pGWCo66DHl7c5XYIEMGQ5OBZEFW1A3C4jLwGrkcSiYhBQopClsL4ntYkayUAzMEH/wCCmcxR6/S95UuEOeFLvBI+zFhlUgxnPCxSiLz4GxpNq8hjfIX5nATX6z98W5cHAbXqwYEWM8UB1sACfIhIPG+wwoSXFDXUMuxdPJaFTmaL5hyy0aIUuGOfKTYSJ+1okWO7yjbCcz0xndNXEStQvX1+LalJlGhpOYzKzj2k1D0hbmNExt//Y1xO3iugG6YaqPMKyMk+7yuSe9Ks6ldtnGjJwVxUBQJPQsgDWuGvNg1UWg9Tn2UeRBDdGEKv2ySIdisXaVg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 14/17] hvf: sync registers used at EL2 Date: Fri, 6 Mar 2026 17:15:06 +0100 Message-ID: <20260306161509.79712-15-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=aua/yCZV c=1 sm=1 tr=0 ts=69aafdb8 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Ml6fgdKjPmdD6r9HfocA:9 X-Proofpoint-GUID: JDVHoKMiDQZppmGhDY48S3NRhQJzuSui X-Proofpoint-ORIG-GUID: JDVHoKMiDQZppmGhDY48S3NRhQJzuSui X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX/iO/mbs1wY1L JuDDJLaW2uioBXLHOL0FWH5bTSgY95qxJMtGfbwT5WoZAs3RCuOFeUx5CRzdnq/HzYOzSZSSK45 BEoZKYNI5P6IZ7jaxR/USD50rYiIwjZM5TARPYvuVU5NeD5kn9t01t9hBstTqtN21XaYVpW06T2 njAm+4BqZOQTylreHCMS7sPA1qT9wVbRV3ZSHl8T5n9ZuwzVW3qyOvIH6vLhq6ETIqKY0NlPTTd Lvp4D7x1CTQ7aVHrRTeyWaRXEZP6n5NYm1XvX+Gh8yLS8IbQs/ib9f/ahI8z3JgrJQCzFdkNuSh WiG8I10RcC0ESzW7A+o3CJ2SdkmBgqcGmZ3jNDTImYcPezVvt10Wrh7ufAz3yU= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxscore=0 clxscore=1030 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABfanpRC99HBlvWkSweQg9plwbUBdv7f1RCsdYQNZ/T/ccfkCjRQw0Z/OKMGMp3hQw6rosNe46IA7cCgBsokTmAgGDILcrWbYn+Pl7Fpu4ISYkmUouxwebFGYyQfJQV12YXZ5ubU9akK8eBej503t8WCx2yIN8l076YrSNaIYTmQmG3cpT7P35KFSBPe1jO7VyF2v5hIAlJH2Tdc03hgo045BY1mLuG9iZ5Xu1KCs/FoOLmbdareYgCuURhQOD45SWhc60KfvPEYmfH2fA/IYNyi4T2lSO1Igahxuhmx3ob5UWwpSrD5DysQWinp/0/ShPFrhpmM/Viw3dX0mCoabift83PjmH/u/r/gkZZOyXyQN9W9ZtXXonyIwLdl11X3N+TItXkC9tjEI1VPhDJP7WXwwQjsfdwPEBcMVKnfycm6F+8Hd1h3qYc++ucIAKnpfotXrlEDiWg16d77n5M57jnTwVAX2e2igzlXn0vd5trhl5uhXZ3J1RSN8N0wpn1jMS/kHWdR/U6Zu+jAjEiXxjZkp1yOiYisBD6zHcDjpWtedDtHmnBo3i5VXCfE5SrlebIv1ulQggV5zh9MMJ6ZIUqQHpnR51vYynTzbqZCadCVdWLc0pH7iWfD6WUOb63hOmVvh7t6VI8uOlLEJyK0cZh7IUZypnAOjLZY34gw9Fg3cQF02LU9nYXKMMTfcF5EcqXZsFmxWWY11Mymm1ZPm3qF8wMOUBxkeb8TVa9uEM2MESwgpe8+jYrOsFrA84VCc= 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.222; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772813809608154100 Content-Type: text/plain; charset="utf-8" When starting up the VM at EL2, more sysregs are available. Sync the state = of those. In addition, sync the state of the EL1 physical timer when the vGIC is used= , even if running at EL1. However, no OS running at EL1 is expected to use those r= egisters. Signed-off-by: Mohamed Mediouni --- target/arm/hvf/hvf.c | 63 ++++++++++++++++++++++++++++++++----- target/arm/hvf/sysreg.c.inc | 44 ++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 7 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 9c986178c4..df82bdad6b 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -467,37 +467,75 @@ static const struct hvf_reg_match hvf_sme2_preg_match= [] =3D { * * SME2 registers are guarded by a runtime availability attribute instead = of a * compile-time def, so verify those at runtime in hvf_arch_init_vcpu() be= low. + * + * Nested virt registers are handled via a runtime check, so override the = guarded + * availability check done by Clang. */ =20 +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability" + #define DEF_SYSREG(HVF_ID, ...) \ QEMU_BUILD_BUG_ON(HVF_ID !=3D KVMID_TO_HVF(KVMID_AA64_SYS_REG64(__VA_ARG= S__))); #define DEF_SYSREG_15_02(...) =20 +#define DEF_SYSREG_EL2(HVF_ID, ...) \ + QEMU_BUILD_BUG_ON(HVF_ID !=3D KVMID_TO_HVF(KVMID_AA64_SYS_REG64(__VA_ARG= S__))); + +#define DEF_SYSREG_VGIC(HVF_ID, ...) \ + QEMU_BUILD_BUG_ON(HVF_ID !=3D KVMID_TO_HVF(KVMID_AA64_SYS_REG64(__VA_ARG= S__))); + +#define DEF_SYSREG_VGIC_EL2(HVF_ID, ...) \ + QEMU_BUILD_BUG_ON(HVF_ID !=3D KVMID_TO_HVF(KVMID_AA64_SYS_REG64(__VA_ARG= S__))); + #include "sysreg.c.inc" =20 #undef DEF_SYSREG #undef DEF_SYSREG_15_02 +#undef DEF_SYSREG_EL2 +#undef DEF_SYSREG_VGIC +#undef DEF_SYSREG_VGIC_EL2 =20 -#define DEF_SYSREG(HVF_ID, op0, op1, crn, crm, op2) HVF_ID, +#define DEF_SYSREG(HVF_ID, op0, op1, crn, crm, op2) {HVF_ID}, #define DEF_SYSREG_15_02(...) +#define DEF_SYSREG_EL2(HVF_ID, op0, op1, crn, crm, op2) {HVF_ID, .el2 =3D= true}, +#define DEF_SYSREG_VGIC(HVF_ID, op0, op1, crn, crm, op2) {HVF_ID, .vgic = =3D true}, +#define DEF_SYSREG_VGIC_EL2(HVF_ID, op0, op1, crn, crm, op2) {HVF_ID, tru= e, true}, + +struct hvf_sreg { + hv_sys_reg_t sreg; + bool vgic; + bool el2; +}; =20 -static const hv_sys_reg_t hvf_sreg_list[] =3D { +static struct hvf_sreg hvf_sreg_list[] =3D { #include "sysreg.c.inc" }; =20 #undef DEF_SYSREG #undef DEF_SYSREG_15_02 +#undef DEF_SYSREG_EL2 +#undef DEF_SYSREG_VGIC +#undef DEF_SYSREG_VGIC_EL2 + +#pragma clang diagnostic pop =20 #define DEF_SYSREG(...) -#define DEF_SYSREG_15_02(HVF_ID, op0, op1, crn, crm, op2) HVF_ID, +#define DEF_SYSREG_15_02(HVF_ID, op0, op1, crn, crm, op2) {HVF_ID}, +#define DEF_SYSREG_EL2(...) +#define DEF_SYSREG_VGIC(...) +#define DEF_SYSREG_VGIC_EL2(...) =20 API_AVAILABLE(macos(15.2)) -static const hv_sys_reg_t hvf_sreg_list_sme2[] =3D { +static struct hvf_sreg hvf_sreg_list_sme2[] =3D { #include "sysreg.c.inc" }; =20 #undef DEF_SYSREG #undef DEF_SYSREG_15_02 +#undef DEF_SYSREG_EL2 +#undef DEF_SYSREG_VGIC +#undef DEF_SYSREG_VGIC_EL2 =20 /* * For FEAT_SME2 migration, we need to store PSTATE.{SM,ZA} bits which are @@ -1317,6 +1355,9 @@ int hvf_arch_init_vcpu(CPUState *cpu) #define DEF_SYSREG_15_02(HVF_ID, ...) \ g_assert(HVF_ID =3D=3D KVMID_TO_HVF(KVMID_AA64_SYS_REG64(__VA_ARGS= __))); #define DEF_SYSREG(...) +#define DEF_SYSREG_EL2(...) +#define DEF_SYSREG_VGIC(...) +#define DEF_SYSREG_VGIC_EL2(...) =20 #include "sysreg.c.inc" =20 @@ -1343,12 +1384,20 @@ int hvf_arch_init_vcpu(CPUState *cpu) memset(arm_cpu->cpreg_values, 0, sregs_match_len * sizeof(uint64_t)); =20 /* Populate cp list for all known sysregs */ - for (i =3D 0; i < ARRAY_SIZE(hvf_sreg_list); i++) { - hv_sys_reg_t hvf_id =3D hvf_sreg_list[i]; + for (i =3D 0; i < sregs_match_len; i++) { + hv_sys_reg_t hvf_id =3D hvf_sreg_list[i].sreg; uint64_t kvm_id =3D HVF_TO_KVMID(hvf_id); uint32_t key =3D kvm_to_cpreg_id(kvm_id); const ARMCPRegInfo *ri =3D get_arm_cp_reginfo(arm_cpu->cp_regs, ke= y); =20 + if (hvf_sreg_list[i].vgic && !hvf_irqchip_in_kernel()) { + continue; + } + + if (hvf_sreg_list[i].el2 && !hvf_nested_virt_enabled()) { + continue; + } + if (ri) { assert(!(ri->type & ARM_CP_NO_RAW)); arm_cpu->cpreg_indexes[sregs_cnt++] =3D kvm_id; @@ -1357,7 +1406,7 @@ int hvf_arch_init_vcpu(CPUState *cpu) if (__builtin_available(macOS 15.2, *)) { if (hvf_arm_sme2_supported()) { for (i =3D 0; i < ARRAY_SIZE(hvf_sreg_list_sme2); i++) { - hv_sys_reg_t hvf_id =3D hvf_sreg_list_sme2[i]; + hv_sys_reg_t hvf_id =3D hvf_sreg_list_sme2[i].sreg; uint64_t kvm_id =3D HVF_TO_KVMID(hvf_id); uint32_t key =3D kvm_to_cpreg_id(kvm_id); const ARMCPRegInfo *ri =3D get_arm_cp_reginfo(arm_cpu->cp_= regs, key); diff --git a/target/arm/hvf/sysreg.c.inc b/target/arm/hvf/sysreg.c.inc index 7a2f880f78..c11dbf274e 100644 --- a/target/arm/hvf/sysreg.c.inc +++ b/target/arm/hvf/sysreg.c.inc @@ -153,3 +153,47 @@ DEF_SYSREG_15_02(HV_SYS_REG_ID_AA64ZFR0_EL1, 3, 0, 0, = 4, 4) DEF_SYSREG_15_02(HV_SYS_REG_ID_AA64SMFR0_EL1, 3, 0, 0, 4, 5) DEF_SYSREG_15_02(HV_SYS_REG_SMPRI_EL1, 3, 0, 1, 2, 4) DEF_SYSREG_15_02(HV_SYS_REG_SMCR_EL1, 3, 0, 1, 2, 6) +/* + * Block these because of the same issue as virtual counters in + * that caused the revert in 28b0ed32b32c7e5094cf2f1ec9c0645c65fad2aa + * + * DEF_SYSREG_VGIC(HV_SYS_REG_CNTP_CTL_EL0, 3, 3, 14, 2, 1) + * DEF_SYSREG_VGIC(HV_SYS_REG_CNTP_CVAL_EL0, 3, 3, 14, 2, 2) + */ +#ifdef SYNC_NO_RAW_REGS +DEF_SYSREG_VGIC(HV_SYS_REG_CNTP_TVAL_EL0, 3, 3, 14, 2, 0) +#endif + +/* + * Also block these because of the same issue as virtual counters in + * that caused the revert in 28b0ed32b32c7e5094cf2f1ec9c0645c65fad2aa + * + * DEF_SYSREG_VGIC_EL2(HV_SYS_REG_CNTHP_CVAL_EL2, 3, 4, 14, 2, 2) + * DEF_SYSREG_VGIC_EL2(HV_SYS_REG_CNTHP_CTL_EL2, 3, 4, 14, 2, 1) + */ +DEF_SYSREG_VGIC_EL2(HV_SYS_REG_CNTHCTL_EL2, 3, 4, 14, 1, 0) +#ifdef SYNC_NO_RAW_REGS +DEF_SYSREG_VGIC_EL2(HV_SYS_REG_CNTHP_TVAL_EL2, 3, 4, 14, 2, 0) +#endif +DEF_SYSREG_VGIC_EL2(HV_SYS_REG_CNTVOFF_EL2, 3, 4, 14, 0, 3) + +DEF_SYSREG_EL2(HV_SYS_REG_CPTR_EL2, 3, 4, 1, 1, 2) +DEF_SYSREG_EL2(HV_SYS_REG_ELR_EL2, 3, 4, 4, 0, 1) +DEF_SYSREG_EL2(HV_SYS_REG_ESR_EL2, 3, 4, 5, 2, 0) +DEF_SYSREG_EL2(HV_SYS_REG_FAR_EL2, 3, 4, 6, 0, 0) +DEF_SYSREG_EL2(HV_SYS_REG_HCR_EL2, 3, 4, 1, 1, 0) +DEF_SYSREG_EL2(HV_SYS_REG_HPFAR_EL2, 3, 4, 6, 0, 4) +DEF_SYSREG_EL2(HV_SYS_REG_MAIR_EL2, 3, 4, 10, 2, 0) +DEF_SYSREG_EL2(HV_SYS_REG_MDCR_EL2, 3, 4, 1, 1, 1) +DEF_SYSREG_EL2(HV_SYS_REG_SCTLR_EL2, 3, 4, 1, 0, 0) +DEF_SYSREG_EL2(HV_SYS_REG_SPSR_EL2, 3, 4, 4, 0, 0) +DEF_SYSREG_EL2(HV_SYS_REG_SP_EL2, 3, 6, 4, 1, 0) +DEF_SYSREG_EL2(HV_SYS_REG_TCR_EL2, 3, 4, 2, 0, 2) +DEF_SYSREG_EL2(HV_SYS_REG_TPIDR_EL2, 3, 4, 13, 0, 2) +DEF_SYSREG_EL2(HV_SYS_REG_TTBR0_EL2, 3, 4, 2, 0, 0) +DEF_SYSREG_EL2(HV_SYS_REG_TTBR1_EL2, 3, 4, 2, 0, 1) +DEF_SYSREG_EL2(HV_SYS_REG_VBAR_EL2, 3, 4, 12, 0, 0) +DEF_SYSREG_EL2(HV_SYS_REG_VMPIDR_EL2, 3, 4, 0, 0, 5) +DEF_SYSREG_EL2(HV_SYS_REG_VPIDR_EL2, 3, 4, 0, 0, 0) +DEF_SYSREG_EL2(HV_SYS_REG_VTCR_EL2, 3, 4, 2, 1, 2) +DEF_SYSREG_EL2(HV_SYS_REG_VTTBR_EL2, 3, 4, 2, 1, 0) --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772814108; cv=none; d=zohomail.com; s=zohoarc; b=GceC0PVWrkIKg4lzbywH9fcZiD8HGOwe5wfBC/pUGEhiLLX9vvuAbttx7m9N+ViHYo8DJhgVSbM5PD/jpqkMUopi6JztLNiCxbxY7tVix4JxFvbqm3UTVmWbOZWvmkE+21wf+hStt1eaqpZKREf++Ys0pspLZONUPUqfWhS9rzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772814108; 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=d2eYFvkazVi+pdiwcmm5jeFsF+hENCAavYE5AM82wmE=; b=PnAv9ImOuMPKRRbetPIDM7e1kJBZXzBa3D6xEB93ksGIoOGn68JDutm1gvMxtxvWgPkPPxcN+f2llMGCjdne0JJJID63caPfhxVrEIRPxQDNNUBzS/4Vq2AxaTyL/m+ouWOrsTQXAm8jWBOUmiTOeBggHW5DwOV9E0FWT/1J1V0= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17728141079871023.6490820116809; Fri, 6 Mar 2026 08:21:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXqL-0004Kz-AZ; Fri, 06 Mar 2026 11:16:01 -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 1vyXqI-0004JY-9X for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:58 -0500 Received: from p-west3-cluster3-host8-snip4-8.eps.apple.com ([57.103.72.209] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXqG-0007Cx-II for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:15:58 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 25E3B18007BD; Fri, 6 Mar 2026 16:15:53 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 50CE018007B4; Fri, 6 Mar 2026 16:15:51 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813755; x=1775405755; bh=d2eYFvkazVi+pdiwcmm5jeFsF+hENCAavYE5AM82wmE=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=cde+nM0kxCt/APSIaiSwgWiEptTMBN172nREvuq3BUejT10/enqJWJ7Gf7OLaJDUs5hY2wZAf9/oUXju8/3J988Mpoovd+XQvYc+aKvIVDV7s3wHSjudJdRWP1i2XWqpZM4jdW3X0YXsB/fyZFghOE4z5v1J/s6V9e7ZEncsz1VpFuLG4NIJTX7UHXxzhUl9Am+XSe53Mb7Yumovzy1V4PtwJI56pMAdMgkJ851ak17akTSLFtDC0PbjGoZZLc7b0+EiIR1pv6OM8Snv60qUdgowheZXxpjyqXDcSAjaTdzpJlTAc1vfX4e322X8JuD44ga+BTeX9P+zXaGGZXShJQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 15/17] target/arm: hvf: pass through CNTHCTL_EL2 and MDCCINT_EL1 Date: Fri, 6 Mar 2026 17:15:07 +0100 Message-ID: <20260306161509.79712-16-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=aZhsXBot c=1 sm=1 tr=0 ts=69aafdbb cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=L1bH-B2CdzmaWMF7168A:9 a=NqO74GWdXPXpGKcKHaDJD/ajO6k=:19 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: lNNrm7DquGQhVGQcgPhpRazsVfYDlfgQ X-Proofpoint-ORIG-GUID: lNNrm7DquGQhVGQcgPhpRazsVfYDlfgQ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfXySCGlVaYc4vE +CaI7hgH1Go5JnnR5F7Qb3uCxTDeAjG6A7V6sXG8MUg+Ycq1RQ5tD6aorahw9CtWO/XtWmGW1wu hpdRNGRacmCEBF6hbM8N5LOOcvxRL/v7uRH1q2AQCCXOV/Nj2uUpI0sAed0qI1otGpB5ghgibUa ZKNjZnbRv+P9HKFh0F17rCM+4PvFhMX9u1C0ovPAO2COSy96U/DMZeUtLWW8+dMh3YfD2XCs+7C xL4WuHztoqToFZY2e2bB6pO3a8fBIGqpbntZgVcIPbyObbbv2zz1T90CU5QWj/I7jmAxKsxKZyN iZBWn+v64ctDc1N0Ce6czOaStrmOOSO0N1P+S6pn7Hsw9HaoCr7DYtfWrXFfM8= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 spamscore=0 adultscore=0 mlxlogscore=648 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1030 bulkscore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABaFTlSBvAWulahyuKzm/ClmBTmIcp74uGyAX0TlvLvpHUWmv7aWPm9uxxXvRNclRuvb78uVKuHlB+H8LWIXpG6S2DnLTJ88GT7G88ZPDRSpZEAv58sVyzF1fiagWLQ9TGsg+PdkxlAkGKkdt1OVYnkMXAlJBooyazVf7hDw89NFCHXv6pakrM5OwdyhvAJ6+oqcyYE5HemOEwdXOWOBzazhcWxcZ7CmQRcfPNgNK8lAKFDi43+gLDrFcHSblKdN9tPSpXice3obs5IEJkB4nYSa1Trx+3N4xrwSthyNx3IS15iX0lfwTDbb9tjTaTgDGx6mtIFSttYY3z/Fspc3fDKtVt4auic56yqRRiF4UzzTXToOrsdTGylK+uOpUSBuM/XnUuy14dpRdcfdDqtF4Ws9WAx0GR61t3fdYi/elZCnydOiLS0k4Zdk0u/YnaGJsKCdzVmaS/TLWfBYAnlmYFdj1zRehOceThKu2AE6ubDEmRbGtSpwKwxmvIyUJEbxegChRckjl4dRxqrh2v0rn2iJtpzmyS2Lp92Nr5X0oFxY2JCrp5xIXE0jriy5imjEbX51Xr3Rm5PhRiP0ySm/LU8j8Kz1R9mfk1EwoFX3P/gIWkrkCoax5jWG/gbLVyNRlerwUd+oWqiFJJSewejW5XuoffQqV2+LI2n0A+EAf5hPKXscOCfjY9zH0wvOAREioMkieRkkyyN+oFhRoJRusyizDnwysP8oM8OyJZ1kG0d+nJ2ZDfYL3GkuT0CNxj/oXWH2o0mCMkwU4D6sSQrlCpOmo= 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.209; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772814109945158500 HVF traps accesses to CNTHCTL_EL2. For nested guests, HVF traps accesses to= MDCCINT_EL1. Pass through those accesses to the Hypervisor.framework library. Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/hvf/hvf.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index df82bdad6b..fd5d248e20 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -296,6 +296,10 @@ void hvf_arm_init_debug(void) #define SYSREG_DBGWVR15_EL1 SYSREG(2, 0, 0, 15, 6) #define SYSREG_DBGWCR15_EL1 SYSREG(2, 0, 0, 15, 7) =20 +/* EL2 registers */ +#define SYSREG_CNTHCTL_EL2 SYSREG(3, 4, 14, 1, 0) +#define SYSREG_MDCCINT_EL1 SYSREG(2, 0, 0, 2, 0) + #define WFX_IS_WFE (1 << 0) =20 #define TMR_CTL_ENABLE (1 << 0) @@ -1701,6 +1705,14 @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t r= eg, uint64_t *val) case SYSREG_OSDLR_EL1: /* Dummy register */ return 0; + case SYSREG_CNTHCTL_EL2: + if (__builtin_available(macOS 15.0, *)) { + assert_hvf_ok(hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_C= NTHCTL_EL2, val)); + } + return 0; + case SYSREG_MDCCINT_EL1: + assert_hvf_ok(hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_MDCCI= NT_EL1, val)); + return 0; case SYSREG_ICC_AP0R0_EL1: case SYSREG_ICC_AP0R1_EL1: case SYSREG_ICC_AP0R2_EL1: @@ -1989,6 +2001,14 @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t = reg, uint64_t val) case SYSREG_OSDLR_EL1: /* Dummy register */ return 0; + case SYSREG_CNTHCTL_EL2: + if (__builtin_available(macOS 15.0, *)) { + assert_hvf_ok(hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_C= NTHCTL_EL2, val)); + } + return 0; + case SYSREG_MDCCINT_EL1: + assert_hvf_ok(hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_MDCCI= NT_EL1, val)); + return 0; case SYSREG_LORC_EL1: /* Dummy register */ return 0; --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772814177; cv=none; d=zohomail.com; s=zohoarc; b=h6PaKvIusjgFrPgPsZL49fT0I0OqICLTZCzQIdXY+/12bh5yAKCQQgQoOk2X1RzLHPdvLw0+xKFqnMD86LccfXkeGRucoJ5H0xVnPpVknmBQZWWqTSVomoLJWWO3JYRWzwR7vyC7uNikPygCxWbcCoeEeQY51cpwIMMr8YBAG4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772814177; h=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=kOA1yy4anKfg0TU4LmBU8Uljdi+od0eTtMcvlK7MTEY=; b=c6SDc3TXJVQqZpgDBVEnFI1lfvlHSmbEnRsZzN80SFKxKNWpLaVG/Bo8iHp+R3GTAnsKSvUdKS09Mw2aqSc/D5TkwianSEL2t6j2PImTDEUGbZ4ag32rXCgBTzcoB/b2vRuJ+7aQz8v75Q/3y3J2zLbh7nm8nMqD3xVUpnIGk/U= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772814177518422.7540788276085; Fri, 6 Mar 2026 08:22:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXqO-0004Mq-4k; Fri, 06 Mar 2026 11:16: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 1vyXqL-0004Lj-SR for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:16:01 -0500 Received: from p-west3-cluster3-host4-snip4-6.eps.apple.com ([57.103.72.187] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXqJ-0007Dx-B2 for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:16:01 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 9CFF618007AF; Fri, 6 Mar 2026 16:15:56 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id E057518007BC; Fri, 6 Mar 2026 16:15:53 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813758; x=1775405758; bh=kOA1yy4anKfg0TU4LmBU8Uljdi+od0eTtMcvlK7MTEY=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=f8lXDTYXLN1HzTes37p3QLo9+gt2A0RGmTq1ibpXgnuY56NXkjcgNBplajGDJgzOkQFA2NBw/ulNnnzJRrwUGjeDQ0bPHkB1rqA89a2gcVlFpgprFs6gSKiuBopeniD/Rz1j2kOiLzp2QtlsuMIXfe4ScKcRb1uHHMpgADUciiHA21x01ZbRPm0UM4J/UEcLdAxYnYLRUDPLV7WccmPI+dE6oSaxzLBPVQxYfnzYwKUrrBfkWCcPUUZItNb5o5b6XudbrWq3Uq7CzVHVZEulD5BjXAG03OIwRSBYJVuQJqfWT5EMaX81iPyBEHIcMow9VX5d6Uxb1htw2hKwFxiYzQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 16/17] hvf: arm: disable SME when nested virt is active Date: Fri, 6 Mar 2026 17:15:08 +0100 Message-ID: <20260306161509.79712-17-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=MN1tWcZl c=1 sm=1 tr=0 ts=69aafdbd cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=h9724yil-ocX87RSi0QA:9 a=NqO74GWdXPXpGKcKHaDJD/ajO6k=:19 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX1aIKJfMIeB+A 0aEa/RM1TQJZz9z3sBEWJ0Z7iwaLd7ay1frsYDS2jCcQWhuhjWA/q9rmpQ5s3PCd/3vpXnc91z/ 31WzsL1XQzHADSvNOpgz0iqA1O6bOMpKpXPTkcyIDTvwmOHepvI5jiusczS8FZ5fPCflEJRuqSt +Z+9rNde9wpv/0Zw6K7TLGJ86bf5WqCEhnFgc09JjaKavrNmKkYTFmox/DTTopjZkJuz0FCMqTF iCcW4jRLQNi20VP0kyF4/eyD+xH4Q3Y25+M3E5QlM5RZr8ZkFkUtbzmNyfWSmze0RoKz1ynuN90 NILMRqNrcYf8c5yEea5HWPf298RbtrvsmjAyRd47Llry29SIVtq12eUvEkl+OY= X-Proofpoint-GUID: tnnvevIHsj-9OfYQhUf30NWQRCwX_EFZ X-Proofpoint-ORIG-GUID: tnnvevIHsj-9OfYQhUf30NWQRCwX_EFZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=842 phishscore=0 suspectscore=0 adultscore=0 clxscore=1030 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABv/G9bUoWe8Uzu0ra9ykAJedqPaWTdP6BJTUbjBGUKEwTRM9TzTfy7nwOrRJz6+shjsXwVQb7GsevLmYP7LIoCBcfr3pSFNSfVVjHFsk19G+IGDngv1Ct+ztqhdw7mWVxN0l/Cp53K4niEHtGsrR5uj/bdcwNDp/6ZR5WAQ/pOHGJi2ls765UCMBgH00vqD3c5GOS0pbEekIx1g5nNhHgWaR7DPpJmT0vBXJAX9Qg3F7rY5sxzYgXXonugkOuejn6J90CSqs47M11yzXWKSrE5WQEs+vlNi9b9QG17k9bTJwalbAQRvkb/DAgazsmgf9iGggi+EfreKU1CVc9t6uxH9XtxfdvOB/kIlkWWMyBYD/wnTZnkqDC5a1v7RP/y+Z/yE+sneuCccxCk1tN1R2AJckkH89tyFX/YseDZWYIX9jB3Vo0SEZ7Zi/e4GQadkr285w0vmSedH/IoSAGm+Rzo95y5jNIa5CwYB/Ev8AU/20kiQ6cXvWv6b1L3JOtDOgbU9sWwUiKWSAwhwXW8Un7ArgM3Ubz8yZFxWTfPWiMw0RXzQ/kcbzL5odoKNAbiVXbKQ4li2q1/1MMs3Xvx3+73DRRNcefZq0ls96V6q/JrZeTNG0wRzG0Ds9d3XrF85iP8gKQpmhe9fyJIvVvyAjWcZgtkTTJCCTDeH58s5GDKTkgC5p/R9dk77Xhla0OJoTifzcBa7ETk34+bRxynof23r2pjGbOfm0zq9gCbq4gX2vK9a09HrC/fbEz63kHZf4ecaecXGkEJQ== 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.187; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772814178956154100 Content-Type: text/plain; charset="utf-8" Currently, Apple doesn't support the nested virtualisation + SME combinatio= n. Signed-off-by: Mohamed Mediouni --- target/arm/hvf/hvf.c | 3 +++ target/arm/hvf_arm.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index fd5d248e20..1559b2eecd 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1189,6 +1189,9 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUF= eatures *ahcf) =20 if (hvf_nested_virt_enabled()) { FIELD_DP64_IDREG(&host_isar, ID_AA64DFR0, PMUVER, 0x1); + /* SME is not implemented with nested virt on the Apple side */ + SET_IDREG(&host_isar, ID_AA64PFR1, + GET_IDREG(&host_isar, ID_AA64PFR1) & ~R_ID_AA64PFR1_SME_MASK= ); } =20 ahcf->isar =3D host_isar; diff --git a/target/arm/hvf_arm.h b/target/arm/hvf_arm.h index 6b1c3b9792..9cb58ad9ab 100644 --- a/target/arm/hvf_arm.h +++ b/target/arm/hvf_arm.h @@ -11,6 +11,7 @@ #ifndef QEMU_HVF_ARM_H #define QEMU_HVF_ARM_H =20 +#include "system/hvf.h" #include "target/arm/cpu-qom.h" =20 /** @@ -35,6 +36,10 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu); if (__builtin_available(macOS 15.2, *)) { size_t svl_bytes; hv_return_t result =3D hv_sme_config_get_max_svl_bytes(&svl_by= tes); + /* Nested virt not supported together with SME right now. */ + if (hvf_nested_virt_enabled()) { + return false; + } if (result =3D=3D HV_UNSUPPORTED) { return false; } --=20 2.50.1 (Apple Git-155) From nobody Mon Apr 13 10:52:57 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=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1772814142; cv=none; d=zohomail.com; s=zohoarc; b=NWuX7ssQCkl1H3JQOPluWpMwZ/cWtEO4xsYlpvFvTCEg3fQ5WynBCF2wCAJilBi6QNVoVVmkKuscVnbxMtN5LrUU5JOCMChQUil99StfnjhxIAGAcbcEi04p6eq8xK1eLWR+hWkZO+g05iBxkPAnc1zElC+5aEpmcxQlUG86rko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772814142; 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=ijV/TFHDkMx/sDtjnbI4Tcf5/3qsWHHZ7tvtB+wJk+k=; b=UrIR1Vgw2/WQbpFvzfvszvrolPmQ453ButOp8Hd6S3TyLzhE8qStzPiu2+FCxh4mtlo1EIcI1eWIupfY2J78lZrTiPfv+LLmaJkIa22yAvfQn+d3otNFPUauQfbrwPrEFpWycLNqjtEi160MP+pz229+tccF0Jyo9UpLwS01P0I= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772814142966507.1012139166446; Fri, 6 Mar 2026 08:22:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyXqP-0004Nd-2Y; Fri, 06 Mar 2026 11:16:05 -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 1vyXqN-0004MJ-4E for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:16:03 -0500 Received: from p-west3-cluster3-host7-snip4-5.eps.apple.com ([57.103.72.196] helo=outbound.ms.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyXqL-0007Eg-Jt for qemu-devel@nongnu.org; Fri, 06 Mar 2026 11:16:02 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPS id 3CDE218007A0; Fri, 6 Mar 2026 16:15:59 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-20-percent-2 (Postfix) with ESMTPSA id 7B80B180010E; Fri, 6 Mar 2026 16:15:56 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772813760; x=1775405760; bh=ijV/TFHDkMx/sDtjnbI4Tcf5/3qsWHHZ7tvtB+wJk+k=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=cSBN92suwee11dbvU1n1NykgNdpxvn90GB2XLHYes9IJMTbe+iU5yaI1AdbGpxNJZY/3T6rD7axywq6WSVf3t17CQkzpOU/wYv7RdOYPvgPjLthPjRB1DJdooRV+zxe8477F/UVKP1E+1aNK/oHsJry7Bc73R11IOuysbXZdkVv8wQiYC7lVbs12wNYnCAhwe0WFE/wpbvr89G8tTol+QL7+hTl1rRJ9AiUTbBFWB0hqx59qrZrX0vg59dZSYYItV/TqQM1sdFlVWnrbD0SGLPGfDU1w2jBbKawFIaKwxm55olRA/z3KcwB7zspfUpimi5Na46k0jUXPYs/cDnOodg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Mads Ynddal , Cameron Esfahani , Alexander Graf , Paolo Bonzini , Manos Pitsidianakis , qemu-arm@nongnu.org, Peter Maydell , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mohamed Mediouni Subject: [PATCH v16 17/17] hvf: enable nested virtualisation support Date: Fri, 6 Mar 2026 17:15:09 +0100 Message-ID: <20260306161509.79712-18-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260306161509.79712-1-mohamed@unpredictable.fr> References: <20260306161509.79712-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: SHk51t-eAu_qDSYTmJ5Hyb6aw5lJIaHN X-Proofpoint-ORIG-GUID: SHk51t-eAu_qDSYTmJ5Hyb6aw5lJIaHN X-Authority-Info-Out: v=2.4 cv=c5+mgB9l c=1 sm=1 tr=0 ts=69aafdc0 cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=5Chse3eIq3h0lgOaJ4gA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA2MDE1NCBTYWx0ZWRfX1ssP9WRv0f+D 1rA+AqDN9L8oLBolHfWQHW+EPWJ/DayD+HKWXIzE0VOosIczDoFIBDGli/Qb/TmS4+tLxlbrEQn lhFFquuovOqYAipOoFgVm/7PGA8ZqtssR97plBh5wAHHEA6gBEOa47Pz8WvA8Qh3OI40lqQ08KL mamZhH4jEiaq3fmzWDTpEPlxB6YWdmgDzlrw2AEpDDiirYXkyoJi9GHMWhAivIqvaRXrgBxZV8k WHrp/bzA6Jw9J2CjuQUEtH54A2JMyKY7pjRbSvPqQOtMeRjVpP4Y2fdmBfGYejQTpGtpns5Fo3r xkISTnIyHclYNA7FWadBwDFqYOIsnUGUjhjPV0ZI6WjWj653QUwWTsJCYGoY+U= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-06_05,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=985 phishscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 clxscore=1030 bulkscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2603060154 X-JNJ: AAAAAAABHYgTnmz2yZhp0t6uKmhyjPwfoLAK7hv314F+TwF9QUuJNtNAltZDd3svmPBNAZ4q168+scWMpCNTG1ykW4tNPnjj3JPLi6GiCkTt3E+9Q/rcJ8u8s265YF8CovXDcEyrXAa65ohz+/4mm0dtL5Ttd72YST8QAmhks1S0PlD3f2KINmSXnbBQV2C8vzRV8for5etJRO0A88bgvyNK2GwkIxO2lOZHSpy4fbo75EPIwnCT/fakV+rr68UvgepvoFjuxmtDwrgs+S36/RvhgAuy4i/UMKgCJ7cqFGY0Oh8p6D58RsvephYk3cmDbMAXDoQ2b4UJ+mRd4ojN26x7xlkVPn0l92VJDTkmgAwIsGo3TUnF+gRRW5J+aTjyRPCl1TglVvqRtr7X+Hr53EMgWXGTQXxZr2ucm7bHmPNB9pCI0p1KK49eUTdzyg80WAluLCcKzgUEW4fzgrv6/h8g1cnnGrGjGvGWSXtWMIbdrclweDeUrSpmVUt9yDCrqb/QbDhbPSKiTHhAvELYQ9+SyM3cHY3sZuD3T4CS3FYpmX3CydJVRiuS72YNVZ8MX8ot0JMrV0wrCvjDYNW18lX/UTd7aEJArd2UWcKlekXgZvG/wWGbfzuPsNMn38QzyTrZsl27baDFzdaY2xnlCg7bvX5nQl/VUsgi7R+DSnFjxjUPFlI774upNhxiUhnuJ5RH3GycBg3pHmVT3xgFE9G1B5Zlmx+XSfMKhxtRio1t7Sw6ZNOzDLjI6TZi+YQPCeEV9YtHFLE0lg== 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.72.196; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 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_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @unpredictable.fr) X-ZM-MESSAGEID: 1772814144363154100 Signed-off-by: Mohamed Mediouni Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/virt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 90769936d0..bced9f67f4 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2393,13 +2393,20 @@ static void machvirt_init(MachineState *machine) exit(1); } =20 - if (vms->virt && !kvm_enabled() && !tcg_enabled() && !qtest_enabled())= { + if (vms->virt && !kvm_enabled() && !tcg_enabled() + && !hvf_enabled() && !qtest_enabled()) { error_report("mach-virt: %s does not support providing " "Virtualization extensions to the guest CPU", current_accel_name()); exit(1); } =20 + if (vms->virt && hvf_enabled() && !hvf_irqchip_in_kernel()) { + error_report("mach-virt: For HVF and Virtualization extensions " + "only kernel-irqchip=3Don is currently supported"); + exit(1); + } + if (vms->mte && hvf_enabled()) { error_report("mach-virt: %s does not support providing " "MTE to the guest CPU", --=20 2.50.1 (Apple Git-155)