{"id":2230488,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230488/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260429190532.26538-4-mohamed@unpredictable.fr/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260429190532.26538-4-mohamed@unpredictable.fr>","date":"2026-04-29T19:05:20","name":"[v21,03/15] accel, hw/arm, include/system/hvf: infrastructure changes for HVF vGIC","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"466bd55f5ceee3e13f5f00043c5885bec360cd80","submitter":{"id":91318,"url":"http://patchwork.ozlabs.org/api/1.1/people/91318/?format=json","name":"Mohamed Mediouni","email":"mohamed@unpredictable.fr"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260429190532.26538-4-mohamed@unpredictable.fr/mbox/","series":[{"id":502138,"url":"http://patchwork.ozlabs.org/api/1.1/series/502138/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502138","date":"2026-04-29T19:05:29","name":"HVF: Add support for platform vGIC and nested virtualisation","version":21,"mbox":"http://patchwork.ozlabs.org/series/502138/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230488/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230488/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=unpredictable.fr header.i=@unpredictable.fr\n header.a=rsa-sha256 header.s=sig1 header.b=Lf9wyI5f;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5Rdk3YRjz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 05:07:54 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wIAEN-0001hQ-F0; Wed, 29 Apr 2026 15:05:55 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <mohamed@unpredictable.fr>)\n id 1wIAEM-0001hE-Ph\n for qemu-devel@nongnu.org; Wed, 29 Apr 2026 15:05:54 -0400","from ms-2001a-snip4-11.eps.apple.com ([57.103.73.141]\n helo=outbound.ms.icloud.com)\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <mohamed@unpredictable.fr>)\n id 1wIAEJ-0000J6-6K\n for qemu-devel@nongnu.org; Wed, 29 Apr 2026 15:05:54 -0400","from outbound.ms.icloud.com (unknown [127.0.0.2])\n by p00-icloudmta-asmtp-us-west-3a-60-percent-6 (Postfix) with ESMTPS id\n 9E2A518002E1; Wed, 29 Apr 2026 19:05:47 +0000 (UTC)","from localhost.localdomain (unknown [17.57.154.37])\n by p00-icloudmta-asmtp-us-west-3a-60-percent-6 (Postfix) with ESMTPSA id\n A9BA118000C6; Wed, 29 Apr 2026 19:05:44 +0000 (UTC)"],"X-ICL-Out-Info":"\n HUtFAUMHWwJACUgBTUQeDx5WFlZNRAJCTQFIHV8DWRxBAUkdXw9LVxQEFVwFVgZXFHkNXR1FDlYZWgxSD1sOHBZLWFUJCgZdGFgVVgl3HlwASx1XBFQfUxJVHR0LRUtAEwRJAE1fDl4fBBdGGVUERx5dVl4eGQJRHFYNV0NUBF9QSQxBUGxaAEcXSB1dGVlvUF0cDhhZG0AVXRFQGVYJXhUXHkFNWgJWTQVKA18BWwZCAEkKXQJYAF4LTgZeD0YGXVQXWwxaDlYwTBZDH1IPWxNNGVEBUkVUAgdYRxRHDg8TTAtHAlo0Vh9UGVoD","Dkim-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr;\n s=sig1; t=1777489549; x=1780081549;\n bh=NatLKEv6d0zG65diyXKXr77lBgzgowHBdS0lt+oeRus=;\n h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme;\n b=Lf9wyI5fXsyJ4S0151/vFeITW6Kkx4wmTVt4ol2tnEzTqQ4aq4BoXudT1rL6fqHqxgfahxtVuiuE5cPnezAShHuMFGJRnqYxV6vygMEEybr1s1bodZZCTqtV3goOczH2D7hgEzSJaq/b7Is82CYfxZPd185ajOpNzFGyXpkNGFl7T0wi8IRyYndJJAAdVK/WQDD1gGv4s0ynApATWkfGAc4a8Oljfh4PqSniEuz6UptYN6pPJJQ+PKH8o0HMjznwGWDm4zD+urXYEy4dk6TWxVszM1P23mBw5pYdi4SW07qiLG6SwwhenRUIBeNnlNZKBmooaFqRboSkyt6ccKzFNQ==","mail-alias-created-date":"1752046281608","From":"Mohamed Mediouni <mohamed@unpredictable.fr>","To":"qemu-devel@nongnu.org","Cc":"Phil Dennis-Jordan <phil@philjordan.eu>,\n Yanan Wang <wangyanan55@huawei.com>, Paolo Bonzini <pbonzini@redhat.com>,\n Roman Bolshakov <rbolshakov@ddn.com>,\n =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>,\n qemu-arm@nongnu.org, Zhao Liu <zhao1.liu@intel.com>,\n Alexander Graf <agraf@csgraf.de>, Eduardo Habkost <eduardo@habkost.net>,\n Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,\n Peter Maydell <peter.maydell@linaro.org>,\n Mohamed Mediouni <mohamed@unpredictable.fr>","Subject":"[PATCH v21 03/15] accel, hw/arm,\n include/system/hvf: infrastructure changes for HVF vGIC","Date":"Wed, 29 Apr 2026 21:05:20 +0200","Message-ID":"<20260429190532.26538-4-mohamed@unpredictable.fr>","X-Mailer":"git-send-email 2.50.1","In-Reply-To":"<20260429190532.26538-1-mohamed@unpredictable.fr>","References":"<20260429190532.26538-1-mohamed@unpredictable.fr>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Authority-Info-Out":"v=2.4 cv=bcFmkePB c=1 sm=1 tr=0 ts=69f2568c\n cx=c_apl:c_pps:t_out a=qkKslKyYc0ctBTeLUVfTFg==:117 a=A5OVakUREuEA:10\n a=VkNPw1HP01LnGYTKEx00:22 a=n4FVybPFTm1vobq06wUA:9","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDI5MDE5MCBTYWx0ZWRfX5R3lcag1UCwJ\n 2ppbAVxOtmSHMfoVpUpleDF2kC1dkNtVdJ5ky3LFbMBT9TBaqyw+KlMdAxwknbFZXBvkM7rH+JY\n JSFaX3E5VqTXyvwA+uP6ZBrI1MVJymQtvzXu6KV/1Ows8+GxJLyo6e8c4Zn7bMRi2ucWIkkaUUI\n laJJGUNIHDeT16dLgpRow9TqarOyZER/s69AN+nBaDieDhuNjPcDPhabeo4qDwGuocOHK+CY0Y2\n fGvSDIKgkvn1kaXRSDMKcpBSIL+/kFFqpA95zhaciEWJUwnYT84DhqTNVOoFNawBJ73pFsGGokG\n cpakpHAR9NcUINJyL2SHzNf1MHiW0Rj6JzP9eKxE9DFy1hedudS5hMrEs/qmYo=","X-Proofpoint-GUID":"tjCcbUcjSlmEf5j9lly3nWDqwdcg7ZBR","X-Proofpoint-ORIG-GUID":"tjCcbUcjSlmEf5j9lly3nWDqwdcg7ZBR","Received-SPF":"pass client-ip=57.103.73.141;\n envelope-from=mohamed@unpredictable.fr; helo=outbound.ms.icloud.com","X-Spam_score_int":"-27","X-Spam_score":"-2.8","X-Spam_bar":"--","X-Spam_report":"(-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,\n 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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Misc changes needed for HVF vGIC enablement.\n\nNote: x86_64 macOS exposes interrupt controller virtualisation since macOS 12.\nKeeping an #ifdef here in case we end up supporting that...\n\nHowever, given that x86_64 macOS is on its way out, it'll probably (?)\nnot be supported in QEMU.\n\nSigned-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>\n---\n accel/hvf/hvf-all.c        | 46 ++++++++++++++++++++++++++++++++++++++\n accel/stubs/hvf-stub.c     |  1 +\n hw/arm/virt.c              | 23 +++++++++++++++----\n hw/intc/arm_gicv3_common.c |  3 +++\n include/system/hvf.h       |  3 +++\n system/vl.c                |  2 ++\n 6 files changed, 74 insertions(+), 4 deletions(-)","diff":"diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c\nindex 5f357c6d19..add265e0c8 100644\n--- a/accel/hvf/hvf-all.c\n+++ b/accel/hvf/hvf-all.c\n@@ -10,6 +10,8 @@\n \n #include \"qemu/osdep.h\"\n #include \"qemu/error-report.h\"\n+#include \"qapi/error.h\"\n+#include \"qapi/qapi-visit-common.h\"\n #include \"accel/accel-ops.h\"\n #include \"exec/cpu-common.h\"\n #include \"system/address-spaces.h\"\n@@ -21,6 +23,7 @@\n #include \"trace.h\"\n \n bool hvf_allowed;\n+bool hvf_kernel_irqchip;\n \n const char *hvf_return_string(hv_return_t ret)\n {\n@@ -216,6 +219,43 @@ static int hvf_gdbstub_sstep_flags(AccelState *as)\n     return SSTEP_ENABLE | SSTEP_NOIRQ;\n }\n \n+static void hvf_set_kernel_irqchip(Object *obj, Visitor *v,\n+                                   const char *name, void *opaque,\n+                                   Error **errp)\n+{\n+    OnOffSplit mode;\n+    if (!visit_type_OnOffSplit(v, name, &mode, errp)) {\n+        return;\n+    }\n+\n+    switch (mode) {\n+    case ON_OFF_SPLIT_ON:\n+#ifdef HOST_X86_64\n+        /* macOS 12 onwards exposes an HVF virtual APIC. */\n+        error_setg(errp, \"HVF: kernel irqchip is not currently implemented for x86.\");\n+        break;\n+#else\n+        hvf_kernel_irqchip = true;\n+        break;\n+#endif\n+\n+    case ON_OFF_SPLIT_OFF:\n+        hvf_kernel_irqchip = false;\n+        break;\n+\n+    case ON_OFF_SPLIT_SPLIT:\n+        error_setg(errp, \"HVF: split irqchip is not supported on HVF.\");\n+        break;\n+\n+    default:\n+        /*\n+         * The value was checked in visit_type_OnOffSplit() above. If\n+         * we get here, then something is wrong in QEMU.\n+         */\n+        abort();\n+    }\n+}\n+\n static void hvf_accel_class_init(ObjectClass *oc, const void *data)\n {\n     AccelClass *ac = ACCEL_CLASS(oc);\n@@ -223,6 +263,12 @@ static void hvf_accel_class_init(ObjectClass *oc, const void *data)\n     ac->init_machine = hvf_accel_init;\n     ac->allowed = &hvf_allowed;\n     ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags;\n+    hvf_kernel_irqchip = false;\n+    object_class_property_add(oc, \"kernel-irqchip\", \"on|off|split\",\n+        NULL, hvf_set_kernel_irqchip,\n+        NULL, NULL);\n+    object_class_property_set_description(oc, \"kernel-irqchip\",\n+        \"Configure HVF irqchip\");\n }\n \n static const TypeInfo hvf_accel_type = {\ndiff --git a/accel/stubs/hvf-stub.c b/accel/stubs/hvf-stub.c\nindex 42eadc5ca9..6bd08759ba 100644\n--- a/accel/stubs/hvf-stub.c\n+++ b/accel/stubs/hvf-stub.c\n@@ -10,3 +10,4 @@\n #include \"system/hvf.h\"\n \n bool hvf_allowed;\n+bool hvf_kernel_irqchip;\ndiff --git a/hw/arm/virt.c b/hw/arm/virt.c\nindex 77891f0820..47400214a2 100644\n--- a/hw/arm/virt.c\n+++ b/hw/arm/virt.c\n@@ -1163,7 +1163,7 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)\n      * interrupts; there are always 32 of the former (mandated by GIC spec).\n      */\n     qdev_prop_set_uint32(vms->gic, \"num-irq\", NUM_IRQS + 32);\n-    if (!kvm_irqchip_in_kernel()) {\n+    if (!kvm_irqchip_in_kernel() && !hvf_irqchip_in_kernel()) {\n         qdev_prop_set_bit(vms->gic, \"has-security-extensions\", vms->secure);\n     }\n \n@@ -1186,7 +1186,8 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)\n         qdev_prop_set_array(vms->gic, \"redist-region-count\",\n                             redist_region_count);\n \n-        if (!kvm_irqchip_in_kernel()) {\n+        if (!kvm_irqchip_in_kernel() &&\n+         !(hvf_enabled() && hvf_irqchip_in_kernel())) {\n             if (vms->tcg_its) {\n                 object_property_set_link(OBJECT(vms->gic), \"sysmem\",\n                                          OBJECT(mem), &error_fatal);\n@@ -1197,7 +1198,7 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)\n                                  ARCH_GIC_MAINT_IRQ);\n         }\n     } else {\n-        if (!kvm_irqchip_in_kernel()) {\n+        if (!kvm_irqchip_in_kernel() && !hvf_irqchip_in_kernel()) {\n             qdev_prop_set_bit(vms->gic, \"has-virtualization-extensions\",\n                               vms->virt);\n         }\n@@ -2444,7 +2445,15 @@ static void finalize_gic_version(VirtMachineState *vms)\n         accel_name = \"KVM with kernel-irqchip=off\";\n     } else if (whpx_enabled()) {\n         gics_supported |= VIRT_GIC_VERSION_3_MASK;\n-    } else if (tcg_enabled() || hvf_enabled() || qtest_enabled())  {\n+    } else if (hvf_enabled()) {\n+        if (!hvf_irqchip_in_kernel()) {\n+            gics_supported |= VIRT_GIC_VERSION_2_MASK;\n+        }\n+        /* Hypervisor.framework doesn't expose EL2<->1 transition notifiers */\n+        if (!(!hvf_irqchip_in_kernel() && vms->virt)) {\n+            gics_supported |= VIRT_GIC_VERSION_3_MASK;\n+        }\n+    } else if (tcg_enabled() || qtest_enabled())  {\n         gics_supported |= VIRT_GIC_VERSION_2_MASK;\n         if (module_object_class_by_name(\"arm-gicv3\")) {\n             gics_supported |= VIRT_GIC_VERSION_3_MASK;\n@@ -2486,6 +2495,8 @@ static void finalize_msi_controller(VirtMachineState *vms)\n             vms->msi_controller = VIRT_MSI_CTRL_GICV2M;\n         } else if (whpx_enabled()) {\n             vms->msi_controller = VIRT_MSI_CTRL_GICV2M;\n+        }  else if (hvf_enabled() && hvf_irqchip_in_kernel()) {\n+            vms->msi_controller = VIRT_MSI_CTRL_GICV2M;\n         } else {\n             vms->msi_controller = VIRT_MSI_CTRL_ITS;\n         }\n@@ -2505,6 +2516,10 @@ static void finalize_msi_controller(VirtMachineState *vms)\n             error_report(\"ITS not supported on WHPX.\");\n             exit(1);\n         }\n+        if (hvf_enabled() && hvf_irqchip_in_kernel()) {\n+            error_report(\"ITS not supported on HVF when using the hardware vGIC.\");\n+            exit(1);\n+        }\n     }\n \n     assert(vms->msi_controller != VIRT_MSI_CTRL_AUTO);\ndiff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c\nindex 9c3fb2f4bf..f7ba74e6d5 100644\n--- a/hw/intc/arm_gicv3_common.c\n+++ b/hw/intc/arm_gicv3_common.c\n@@ -33,6 +33,7 @@\n #include \"hw/arm/linux-boot-if.h\"\n #include \"system/kvm.h\"\n #include \"system/whpx.h\"\n+#include \"system/hvf.h\"\n \n \n static void gicv3_gicd_no_migration_shift_bug_post_load(GICv3State *cs)\n@@ -659,6 +660,8 @@ const char *gicv3_class_name(void)\n         return \"kvm-arm-gicv3\";\n     } else if (whpx_enabled()) {\n         return TYPE_WHPX_GICV3;\n+    } else if (hvf_enabled() && hvf_irqchip_in_kernel()) {\n+        return TYPE_HVF_GICV3;\n     } else {\n         if (kvm_enabled()) {\n             error_report(\"Userspace GICv3 is not supported with KVM\");\ndiff --git a/include/system/hvf.h b/include/system/hvf.h\nindex d3dcf088b3..dc8da85979 100644\n--- a/include/system/hvf.h\n+++ b/include/system/hvf.h\n@@ -26,8 +26,11 @@\n #ifdef CONFIG_HVF_IS_POSSIBLE\n extern bool hvf_allowed;\n #define hvf_enabled() (hvf_allowed)\n+extern bool hvf_kernel_irqchip;\n+#define hvf_irqchip_in_kernel()  (hvf_kernel_irqchip)\n #else /* !CONFIG_HVF_IS_POSSIBLE */\n #define hvf_enabled() 0\n+#define hvf_irqchip_in_kernel() 0\n #endif /* !CONFIG_HVF_IS_POSSIBLE */\n \n #define TYPE_HVF_ACCEL ACCEL_CLASS_NAME(\"hvf\")\ndiff --git a/system/vl.c b/system/vl.c\nindex 0e1fc217b4..516ed7890b 100644\n--- a/system/vl.c\n+++ b/system/vl.c\n@@ -1781,6 +1781,8 @@ static void qemu_apply_legacy_machine_options(QDict *qdict)\n                                    false);\n         object_register_sugar_prop(ACCEL_CLASS_NAME(\"whpx\"), \"kernel-irqchip\", value,\n                                    false);\n+        object_register_sugar_prop(ACCEL_CLASS_NAME(\"hvf\"), \"kernel-irqchip\", value,\n+                                   false);\n         qdict_del(qdict, \"kernel-irqchip\");\n     }\n \n","prefixes":["v21","03/15"]}