From nobody Mon Feb 9 10:58:17 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=1768452779; cv=none; d=zohomail.com; s=zohoarc; b=OMQ30eeXoZ1RucX2f0YkNgBI0+WZHmEToeJt07H5iZjGxmspGgUb3N5If3IAmpniJTLwf0B3MjIb8zjIT4qb0yHal7L9DnthQ1wk5FS9dG3pL1ZPHrkyOcjcH/D43ANT6nsgJe3fzuuVDcwa5nrETWchLlReNjPFTMCYgO8kiDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768452779; 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=p/Og09zyXma5zEKqD8+aADBRurM/Hqot2SAD32iQMYk=; b=Jn7OATV2GjKaD//aft+2tE0lRINIieoxv11joLGrunjfMdOp5ifSgBhULQH8KQAt9+UXXWFr5Mb/TiWNF4eo2f00u8k1kQ7Z3KR/F51NUKarnFcAJmAlPN43nBmKk5AtI+wQgk1eWb7yt14ED8T8j8O081kBMoiFU9u83IpwxGI= 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 1768452779876689.3759251613047; Wed, 14 Jan 2026 20:52:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vgFK8-0004aG-7z; Wed, 14 Jan 2026 23:51:08 -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 1vgFK3-0004YN-Gn for qemu-devel@nongnu.org; Wed, 14 Jan 2026 23:51:05 -0500 Received: from p-west3-cluster2-host12-snip4-2.eps.apple.com ([57.103.74.95] 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 1vgFJx-00062E-Hx for qemu-devel@nongnu.org; Wed, 14 Jan 2026 23:51:00 -0500 Received: from outbound.ms.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-3a-10-percent-0 (Postfix) with ESMTPS id A1D99180009E; Thu, 15 Jan 2026 04:50:53 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.154.37]) by p00-icloudmta-asmtp-us-west-3a-10-percent-0 (Postfix) with ESMTPSA id 40ED218007C1; Thu, 15 Jan 2026 04:50:50 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=p/Og09zyXma5zEKqD8+aADBRurM/Hqot2SAD32iQMYk=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=LfnkjoJ2h/hudbSwa/A0rOkX6wJlqYm0kuiCOSsU/TUb1ifIdtY4kaKGPlxVElLqcP7D1PMfXFhyFoyZbCcFozptOS2F9f+OcV9T1ePSfhal9IbjVFXpohmvuAm58QSrzQ76XrNYBT2157U/xQgfKywwPaoyqsVkAQbPHUZ2hAtGEe/t9VeovayMT3h8ENXo/lshv6eh+EgdV/WH+xyQCJhvlRg2IiKVdWDIEwrU/fcgWzCMC1Zg+o3JAT0crvJyikyZa2xNCMxYxkWu4q66wLoDBiTBTCuH16sKCg3BhrOVDry6qpXypqc4bXimgFLe5C+PUC7KW6EnXcv9MMQsUg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Alexander Graf , Cameron Esfahani , Paolo Bonzini , Mads Ynddal , qemu-arm@nongnu.org, Phil Dennis-Jordan , Peter Maydell , Roman Bolshakov , Mohamed Mediouni Subject: [PATCH v7 02/10] accel, hw/arm, include/system/hvf: infrastructure changes for HVF vGIC Date: Thu, 15 Jan 2026 05:50:34 +0100 Message-ID: <20260115045042.70086-3-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260115045042.70086-1-mohamed@unpredictable.fr> References: <20260115045042.70086-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTE1MDAyOSBTYWx0ZWRfX576iomPFzzrB MKuyH53TlyT6ao4t3cAxbmnP2tTf6wCTpx/H2xiPzw5+2/vOB70OTv8xQrJzmiDgpDsY6V2+YTI LoNv4sApJ9vFie8AXqkmK6zy2Bs5nMYootz2CXWVQP5vtIXVEutpcptwgwpqkVi5rhYG9YocGT2 MUkCie122h8yHvfnI2rChfRFWOKiSDcVRZ05MltsZQKEPYDNFscsED07Xwoj+ruTPIPmDpmKM2N FrwbvGOh3VDKtnmc4lqbX/8gieYBM0Yv9Us602HlZEiCohw6iJxGpcexVs6GyeHwkUeXEFgFy6C iKZoHykqMf7685ccIQH X-Authority-Info: v=2.4 cv=UaRciaSN c=1 sm=1 tr=0 ts=6968722e cx=c_apl:c_apl_out:c_pps a=qkKslKyYc0ctBTeLUVfTFg==:117 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=n4FVybPFTm1vobq06wUA:9 X-Proofpoint-GUID: HjKG4lg6JsolvamMWA6MSuR3KNnH6fyW X-Proofpoint-ORIG-GUID: HjKG4lg6JsolvamMWA6MSuR3KNnH6fyW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2026-01-15_01,2026-01-14_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 clxscore=1030 phishscore=0 adultscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2601150029 X-JNJ: AAAAAAABdWiV4k/DQ4VGgDZz1NRc7Km/x0jWAsl6YWhJl5iGsklh9DNrjoDOEw/QuXr/berPz4tzOkgK3T/vLDA39MCZFLtji29+wlgt5j9Srejnn/MWQOPVQnRSnwACIReh4BaZQcotSDWUU0f5+LXROTmXT/tD08k3om4hVkW3LHLiuLE9j5TpNZ+AWNLmv4w4YY6PMk88AOgoU0SBsSlO8c9jlE62Lcqfbp4zOPk22HRJIxbtOHfbgs8F25XAzcGvqgY8ks6qX/nG6RAHiwD23G0jxHwlv4X6YU6NM6i7KnjqNh88egp3K1BrcfGn3+NcUGWRciNi0jNKwQIO+qfzvYC1S3r63QvSyeiyk864HHJMQ0ozszkVSXdvJkEvwBtUgfnOxhPp/tAlhGD+XxSK/PLVTHXb6DqcwC3Q8dgzuxDZhoXK/5vaQ0dE+N7UPhKmn+uKrocNjUATbMUt3tM+QNTLweJk9/4jWvvOW3wRgSbttffkkg6b13ADdHfEjHep+/atqQizpVtLOVKAtPYKOLDljwDSHeKNVgnXMMJ1OXhTOVdwowzkIpoEEgsS6tLNYFJTh68eBOTRczQZwXpS6GfMrMi6VAInPFZVt6AxTCJsdoUNxDWAoq+J3cY+qnmOIMxzCK8DHWihvKabOnSTCDDYLNR95XVmfSNHpQnjdtrrI0zjYTr9c4P0NRdXEjswqhZpVmRqg5oFGlcWa34KBfGZmGFrHtNlkMj74oyvBlQMgA== 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 (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.74.95; envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1768452780664158500 Content-Type: text/plain; charset="utf-8" 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 --- accel/hvf/hvf-all.c | 50 ++++++++++++++++++++++++++++++++++++++ accel/stubs/hvf-stub.c | 1 + hw/arm/virt.c | 25 ++++++++++++++++--- hw/intc/arm_gicv3_common.c | 3 +++ include/system/hvf.h | 3 +++ system/vl.c | 2 ++ 6 files changed, 80 insertions(+), 4 deletions(-) diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c index 033c677b6f..929f53fd37 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" @@ -22,6 +24,7 @@ #include "trace.h" =20 bool hvf_allowed; +bool hvf_kernel_irqchip; =20 const char *hvf_return_string(hv_return_t ret) { @@ -217,6 +220,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); @@ -224,6 +264,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 1cc4f2a1ad..b0fc6c4577 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -757,6 +757,11 @@ static void create_its(VirtMachineState *vms) exit(1); } =20 + if (hvf_enabled() && hvf_irqchip_in_kernel()) { + error_report("ITS not supported on HVF when using the hardware vGI= C."); + exit(1); + } + dev =3D qdev_new(its_class_name()); =20 object_property_set_link(OBJECT(dev), "parent-gicv3", OBJECT(vms->gic), @@ -847,7 +852,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 @@ -870,7 +875,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); @@ -881,7 +887,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); } @@ -2121,7 +2127,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; @@ -2725,6 +2739,9 @@ bool virt_is_its_enabled(VirtMachineState *vms) if (whpx_enabled() && whpx_irqchip_in_kernel()) { return false; } + if (hvf_enabled() && hvf_irqchip_in_kernel()) { + return false; + } if (vms->gic_version =3D=3D VIRT_GIC_VERSION_2) { return false; } diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index 9054143ea7..d98f95be00 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) @@ -666,6 +667,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 aa9a155041..d3f311eff8 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)