From nobody Sun Sep 28 17:00:04 2025 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=1758377037; cv=none; d=zohomail.com; s=zohoarc; b=hPCAK+X7R4FlUt7AzejTopUbvtXjfMhHRZJYNnDCFX0xZ/8alQdohCa9FQ68g1Qt5zaLp0L1Fycg4KGNME4FWVahX66E7rxAu1cWPomsl1Gp8vOfvBinMt9leMGN+FpAew6zuQbDsQDBgClKeZtC69A4d/pm7luMfonE0y8lfsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758377037; 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=AIsNP+RidfLKbhplR+2jpzcRVGTF8epybj6a7LoyA3Y=; b=Pnzmz3kc/tG7tm5ZpEnM5D9u6/2AV8SdDEN5V1Q5cpuC4B7N89Jirz0zCao9xC77DP5+Bdg2f3m8svc1idt9v5kp3YTeC3Eb6BE/amwgA5dNwa48ojz5lV6Ph6NjGjPHLMao3BFYMhUYD3WpsOCil4hZhtil4hyaetlgdp+cFcs= 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 1758377036996477.8155413309639; Sat, 20 Sep 2025 07:03:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzyB5-0006dv-Ty; Sat, 20 Sep 2025 10:03:03 -0400 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 1uzyAs-0006b2-39 for qemu-devel@nongnu.org; Sat, 20 Sep 2025 10:02:55 -0400 Received: from p-east3-cluster5-host5-snip4-6.eps.apple.com ([57.103.86.177] 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 1uzyAq-00087W-2t for qemu-devel@nongnu.org; Sat, 20 Sep 2025 10:02:49 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-3 (Postfix) with ESMTPS id A6F691817205; Sat, 20 Sep 2025 14:02:44 +0000 (UTC) Received: from localhost.localdomain (qs-asmtp-me-k8s.p00.prod.me.com [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-3 (Postfix) with ESMTPSA id 2925B181721B; Sat, 20 Sep 2025 14:02:09 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; bh=AIsNP+RidfLKbhplR+2jpzcRVGTF8epybj6a7LoyA3Y=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=UVPBmXbH4XcF8Oz0o0ThKBs0pBQMUVStkQgArLInjjYkOdzq4ma8tvxhpmM7gB4fTj38idOZcc4xJlkMBXx7MT7Auy/x/Gq2j3aGruRtzisttzk7xm2FU8Mo+t9EMseaIcs6BeBvk/jPbDgZ+J4QRAGrCK8IEHbShQKXwDTeW3J91bkoxAl0S9M9Ojms38HbxS2fBFPSho0jnMOcCsL/Qx1D9G4IJ3JUfX1JW7QzhnDDeGtdWLQbFk5mKVltlfT+bV2r5LMH0AOfppcAHEa24ffg+E0JqGzt52/pdkICk//DK7Gzw/BO/FOefmuiQKCY8JMHrd3VhQkyDBBK5TmPvg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Shannon Zhao , Yanan Wang , Phil Dennis-Jordan , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Mads Ynddal , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Cameron Esfahani , Paolo Bonzini , Zhao Liu , "Michael S. Tsirkin" , kvm@vger.kernel.org, Igor Mammedov , qemu-arm@nongnu.org, Richard Henderson , Roman Bolshakov , Pedro Barbuda , Alexander Graf , Sunil Muthuswamy , Eduardo Habkost , Ani Sinha , Marcel Apfelbaum , Mohamed Mediouni , Peter Maydell Subject: [PATCH v6 14/23] hw/arm: virt: cleanly fail on attempt to use the platform vGIC together with ITS Date: Sat, 20 Sep 2025 16:01:15 +0200 Message-ID: <20250920140124.63046-15-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250920140124.63046-1-mohamed@unpredictable.fr> References: <20250920140124.63046-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: ZnU9JhgNEsA_ILgTY1_YsGV31GcgcS0K X-Proofpoint-ORIG-GUID: ZnU9JhgNEsA_ILgTY1_YsGV31GcgcS0K X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDEzNiBTYWx0ZWRfX2bezf6zIvFsx KwclAdDjZg6Fu72ifwGsk0dLdFoFVUtiNpYbtMw7Jve3iYbSbcyHGQxkny2LhBu0l0/Gps98V22 hXhIq1pywOIRrs7OHhb4ZiQaOsfj2ItLDD04jLrrWe3AHCH8+BqdjbxzQbU6KyvWtz2sR9ko+KV YySlblNltPBFLuM/zkD3SEL1ijmd0bRYP11GHGl8e4JjUw9bqis8mfAg0gPd5vKpdASHYfFlv5o phzKWYPLGM8lSrTiBThenK3m02WfhbgT6lgEw7oJsfUnWXs4ZGUkg+LtA1vst0/PS08IFnvmA= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-20_05,2025-09-19_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 clxscore=1030 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2509200136 X-JNJ: AAAAAAABa5Iex0WJzPC8sUom3Y/srkxU6k0hQEGcTweuc5gJghDDJBzQYPGITbKAk+Zj6SaewbE//do0NNVuNDqmaz5H4f4NoIXAwkOe9H4SnG6iDKgYVw97/63gri26IjA1Pu3K9UCEdFaf85yYvr7zqBa91e0KQdxF4IM0OMI1K6w9OuDFjJ/uJ66/X6GyMRE4o7yRI/RuUJLIe7BhiywAAxzU2gumTE89sV3EhrWOWLB5+80GmFwqzUQmute7iGpCiM8yTd4uQD4Fv3qGqzcTMImEKK+CBtEHNQ4QMrFd+ufT1pBPLd90qOi7mC/pvlnYoxK1HyG9hojKEITKriU45PK8hH5zIeGX+kX6qx1waNQy5d4TO7Q53htbTjy/IZlD6xUw1WAo58JVFeZniN1KvFTK6Q9PztbwT463BE2/9SHKzpINaD+ERPh3DiayIjLkPXrmlDpbt7S66I+ooySCE2M/jTZTce1W7jBP1YRZVcNBjO8nxS6EUn1BuKx/GWG1kOoU6uWqgFRuEnp0YCNq7OyB/NzAPRlLfgtR7kdqQDLuo7MtnVEE+nqEkwYEWuZmtCZHCdonTX0vR+yp+y0Pzf5vk4qm8gqCrzLMA/FkQ3f/CgvF3rYuZXjA2bhgd8X5DqCdfZUidW7vK6yaQvjZhhIddz/BIqmgnCsJKEADmTnG4Shctk0/AQ1s650rbQtdo1rE0FH7rUxk6/EqaMy35+IdQHPPzElV9WJ6jPciOcz9PuT2HUf7ubQs/2fo6ETONN0ETXve08os7uZY82TjU4aXg6ZPRQi1qzh4C5JIl2/rdkPRD7sPLbv3GTAfmRyRH0L2zK6OPPvN7RtWIHfzmsycLo6McANXjCDNfuitO0wkG6bHBhfgPoTa 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.86.177; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758377039579116600 Content-Type: text/plain; charset="utf-8" Switch its to a tristate. Windows Hypervisor Platform's vGIC doesn't support ITS. Deal with this by reporting to the user and exiting. Regular configuration: GICv3 + ITS New default configuration with WHPX: GICv3 with GICv2m And its=3Doff explicitly for the newest machine version: GICv3 + GICv2m Signed-off-by: Mohamed Mediouni --- hw/arm/virt-acpi-build.c | 14 ++++++------ hw/arm/virt.c | 46 +++++++++++++++++++++++++++++++--------- include/hw/arm/virt.h | 4 +++- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 7a049b8328..76035f6548 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -472,7 +472,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) nb_nodes =3D num_smmus + 1; /* RC and SMMUv3 */ rc_mapping_count =3D rc_smmu_idmaps_len; =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* * Knowing the ID ranges from the RC to the SMMU, it's possibl= e to * determine the ID ranges from RC that go directly to ITS. @@ -483,7 +483,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) rc_mapping_count +=3D rc_its_idmaps->len; } } else { - if (vms->its) { + if (virt_is_its_enabled(vms)) { nb_nodes =3D 2; /* RC and ITS */ rc_mapping_count =3D 1; /* Direct map to ITS */ } else { @@ -498,7 +498,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) build_append_int_noprefix(table_data, IORT_NODE_OFFSET, 4); build_append_int_noprefix(table_data, 0, 4); /* Reserved */ =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* Table 12 ITS Group Format */ build_append_int_noprefix(table_data, 0 /* ITS Group */, 1); /* Ty= pe */ node_size =3D 20 /* fixed header size */ + 4 /* 1 GIC ITS Identif= ier */; @@ -517,7 +517,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) int smmu_mapping_count, offset_to_id_array; int irq =3D sdev->irq; =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { smmu_mapping_count =3D 1; /* ITS Group node */ offset_to_id_array =3D SMMU_V3_ENTRY_SIZE; /* Just after the h= eader */ } else { @@ -610,7 +610,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) } } =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* * Map bypassed (don't go through the SMMU) RIDs (input) to * ITS Group node directly: RC -> ITS. @@ -945,7 +945,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) memmap[VIRT_HIGH_GIC_REDIST2].si= ze); } =20 - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* * ACPI spec, Revision 6.0 Errata A * (original 6.0 definition has invalid Length) @@ -961,7 +961,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) } } =20 - if (!vms->its && !vms->no_gicv3_with_gicv2m) { + if (!virt_is_its_enabled(vms) && !vms->no_gicv3_with_gicv2m) { const uint16_t spi_base =3D vms->irqmap[VIRT_GIC_V2M] + ARM_SPI_BA= SE; =20 /* 5.2.12.16 GIC MSI Frame Structure */ diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 36f6cfe25c..c8eca368c9 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -735,7 +735,7 @@ static void create_its(VirtMachineState *vms) { DeviceState *dev; =20 - assert(vms->its); + assert(virt_is_its_enabled(vms)); if (!kvm_irqchip_in_kernel() && !vms->tcg_its) { /* * Do nothing if ITS is neither supported by the host nor emulated= by @@ -744,6 +744,15 @@ static void create_its(VirtMachineState *vms) return; } =20 + if (whpx_enabled() && vms->tcg_its) { + /* + * Signal to the user when ITS is neither supported by the host + * nor emulated by the machine. + */ + info_report("ITS not supported on WHPX."); + exit(1); + } + dev =3D qdev_new(its_class_name()); =20 object_property_set_link(OBJECT(dev), "parent-gicv3", OBJECT(vms->gic), @@ -955,7 +964,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) =20 fdt_add_gic_node(vms); =20 - if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && vms->its) { + if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && virt_is_its_enabled(vm= s)) { create_its(vms); } else if (vms->gic_version !=3D VIRT_GIC_VERSION_2 && !vms->no_gicv3_= with_gicv2m) { create_v2m(vms); @@ -2688,18 +2697,34 @@ static void virt_set_highmem_mmio_size(Object *obj,= Visitor *v, extended_memmap[VIRT_HIGH_PCIE_MMIO].size =3D size; } =20 -static bool virt_get_its(Object *obj, Error **errp) +bool virt_is_its_enabled(VirtMachineState *vms) +{ + if (vms->its =3D=3D ON_OFF_AUTO_OFF) { + return false; + } + if (vms->its =3D=3D ON_OFF_AUTO_AUTO) { + if (whpx_enabled()) { + return false; + } + } + return true; +} + +static void virt_get_its(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(obj); + OnOffAuto its =3D vms->its; =20 - return vms->its; + visit_type_OnOffAuto(v, name, &its, errp); } =20 -static void virt_set_its(Object *obj, bool value, Error **errp) +static void virt_set_its(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(obj); =20 - vms->its =3D value; + visit_type_OnOffAuto(v, name, &vms->its, errp); } =20 static bool virt_get_dtb_randomness(Object *obj, Error **errp) @@ -3409,8 +3434,9 @@ static void virt_machine_class_init(ObjectClass *oc, = const void *data) "guest CPU which implements the = ARM " "Memory Tagging Extension"); =20 - object_class_property_add_bool(oc, "its", virt_get_its, - virt_set_its); + object_class_property_add(oc, "its", "OnOffAuto", + virt_get_its, virt_set_its, + NULL, NULL); object_class_property_set_description(oc, "its", "Set on/off to enable/disable " "ITS instantiation"); @@ -3470,8 +3496,8 @@ static void virt_instance_init(Object *obj) vms->highmem_mmio =3D true; vms->highmem_redists =3D true; =20 - /* Default allows ITS instantiation */ - vms->its =3D true; + /* Default allows ITS instantiation if available */ + vms->its =3D ON_OFF_AUTO_AUTO; /* Allow ITS emulation if the machine version supports it */ vms->tcg_its =3D !vmc->no_tcg_its; vms->no_gicv3_with_gicv2m =3D false; diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 3c030f4b5d..9bf6294522 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -148,7 +148,7 @@ struct VirtMachineState { bool highmem_ecam; bool highmem_mmio; bool highmem_redists; - bool its; + OnOffAuto its; bool tcg_its; bool virt; bool ras; @@ -216,4 +216,6 @@ static inline int virt_gicv3_redist_region_count(VirtMa= chineState *vms) vms->highmem_redists) ? 2 : 1; } =20 +bool virt_is_its_enabled(VirtMachineState *vms); + #endif /* QEMU_ARM_VIRT_H */ --=20 2.50.1 (Apple Git-155)