From nobody Mon Mar 2 10:47: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=1772316586; cv=none; d=zohomail.com; s=zohoarc; b=fSlEOczSf/HC3jrgcm++B9lH5HhnqaNWhotyz7M02cNiv4n44RiXlwE0b4dURlyQa5bJ+1wgpnR7rIO/ggCRofaYNPJPdyXQnUIMBNTDhnFQ9pgxLwwpsmWiv1ezz6+GxT94t8TdIShsmgkylmyZDaxb4R5VU2A3VtvA5OJQxiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772316586; 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=yU7J0uqM6sRIZcVN5B3+x/ofAMix31Z4QeYnMclqMMU=; b=ePtHkPBZiKrhpBT4ppmbhqadBCWrBOTYZ20y91UlDeUgl4ni6P6Dos94lAfYHToaNa5aiG4cgBWZNWjTD0A1jPbpeXTNgr9LB9omCcLNst23MVV1CvEO++V1GgabwWCiebuXHqcX08NN0U3PfV2DTH3FAKaPtmpN9q3VdNXPLdc= 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 1772316586784146.58994635240992; Sat, 28 Feb 2026 14:09:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vwSUY-0002Sr-NT; Sat, 28 Feb 2026 17:08:54 -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 1vwSUW-0002RX-Q1 for qemu-devel@nongnu.org; Sat, 28 Feb 2026 17:08:52 -0500 Received: from qs-2004h-snip4-5.eps.apple.com ([57.103.84.78] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vwSUU-0005mU-V4 for qemu-devel@nongnu.org; Sat, 28 Feb 2026 17:08:52 -0500 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id B499B180038A; Sat, 28 Feb 2026 22:08:46 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id 620E218000AF; Sat, 28 Feb 2026 22:08:44 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1772316529; x=1774908529; bh=yU7J0uqM6sRIZcVN5B3+x/ofAMix31Z4QeYnMclqMMU=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=J4SuB0HLbBzzRI+b5sekMpfEc1ik34yI+pl3Ax+elgfERnkgWnB9aHyqc+3P391y0XeHk9aVb2aVhLZmgt1qbQ/dAKo6ImLwk5btZiPnH0UvXklARk9p7Or0EnOtVye/3wncpyw/VmUYjCl4fEjQEj2jDksw81m2QmV8/51I5ZgmmSqI4+0q8BUcmudQjLOdW2X3sgw/rxIdCtB9Jx8NS9+/+B+LVJ5EWeDpyHmkcFvAI1NxEw6zqMPdKpQkqbc7CszmEXdc7Lc6O2adHIEjsc8xQ7Q9CPdvLyYRCV7lIIBoWHwfN8mIvt1OIFATyzWTsWdJ+7o4x/66BpVIYnvb3w== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Peter Maydell , Phil Dennis-Jordan , Paolo Bonzini , Alexander Graf , Mads Ynddal , Cameron Esfahani , qemu-arm@nongnu.org, Roman Bolshakov , Mohamed Mediouni Subject: [PATCH v11 03/12] accel, hw/arm, include/system/hvf: infrastructure changes for HVF vGIC Date: Sat, 28 Feb 2026 23:08:28 +0100 Message-ID: <20260228220837.35275-4-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260228220837.35275-1-mohamed@unpredictable.fr> References: <20260228220837.35275-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=KtlAGGWN c=1 sm=1 tr=0 ts=69a36770 cx=c_apl:c_apl_out:c_pps a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=n4FVybPFTm1vobq06wUA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjI4MDIwNyBTYWx0ZWRfXymN/zVyhPBKQ Kl8vS0bOR4X1oEy9IqOU+gzMrzJl2P6/EvapWoLGeHgbDOK9gAi0WZoTyxhIjGF5UGX6VKTstqZ 6utus4NbMSeGT+1Yt3YENZhYKcBGPUnMEq5XhgQzrZ9offnfkrcHROefCqq5AO2IW4nxsZv/QJr Kk0YMHMcJI7LSTV6fJO7tiZaJSDeDE+Yeib0DBk5lDA1jCc0a/OpyuIXsC0DHcezI+r+7MbYKFl MwGYS91A0Pj8rZ0djSYb2r7mAzF4wZ/IcunZd5J5coS4/ZB/zz8RamRpXXHJ/C2vI4bx7jGXFHg Ze+B5cpxknRj0lPa5JcWHwa9fNZ0wpkTR+tk9e1P3LKKuHX0cPN4fpTB4NA6is= X-Proofpoint-GUID: 8xuCikze7IHV7uqjUXHr4LYXN26xyG2F X-Proofpoint-ORIG-GUID: 8xuCikze7IHV7uqjUXHr4LYXN26xyG2F X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-28_07,2026-02-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 clxscore=1030 malwarescore=0 phishscore=0 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602280207 X-JNJ: AAAAAAABTSWE9bqCSNTojzyQ9RstwEns4tDUh/4xk9yDQ57Gx/truYkhB1XxyWdKT0mHe2Y761uu1co3f/OkqjjGpq36KLqiG6NpPCzPSCr+hES19vQyot7nyjkYSckhrZA3ZNndNZs9gypu9becw0+z0OhWu1d2Og7CwLjzQs9jjP3y+YFOPtUpeFSMJ+0aVtewVT3QQwfVflZCUvnRt2T7vF8SRDUpqAVdg8C7x1/kppd8E2L93oWAWiM2pdnSLCusfEkQYGI2x9II9ulYbMa4yjUbtJ3gdWOK0UqepTRZPHKNyU78kgHdM/RlsjFCIYujqB/vrB7RfyVDuxIHkX//072v0CqZ9HX7efyOLZIj61pG0LhB/sQgyaGveEHclMS+Sm5Du34R5q0SQ3eyh7pseLx9XIkzsoL44tdk9AvxlQMn44ywmWwJeREc5/OP/86mmNM1msnjYgu5ZSBjZD8LJ3sAckd5GfD4CHIRCyckjgy+AMr3bNGUkSdXzcmu9fC7vp9BuspiicTpLFRqRWHtEoEQvMmN/wqmGnZik9yEaePSKtwYa1mkvybIij73miLBen+i/4OTz89ys1r0I73AbTLlrCXScuxpV0A0eN1EqNMFmblRCPkWPS78RcbQ28fOZ+595uR0nYK9jUCYsva7+gDoLv4Z0ILbRMFuSwNt4XfwewkHKRASjMwcQG6FUn2/xL/EpK37hYsPi8CITFiufhSVQ433IURpDM+nfd9A7RMxzFk/ItJbUA== 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.84.78; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.icloud.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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.966, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.722, 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: 1772316589384158500 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 | 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 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 cab2e21e8a..8db5611f7f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -838,7 +838,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 @@ -861,7 +861,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); @@ -872,7 +873,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); } @@ -2119,7 +2120,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; @@ -2161,6 +2170,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; } @@ -2180,6 +2191,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)