From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from outbound.qs.icloud.com (p-east3-cluster5-host8-snip4-10.eps.apple.com [57.103.86.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 506D02FF65D for ; Sat, 20 Sep 2025 14:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.86.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758376970; cv=none; b=s6Igydkht1dpYsrJR2HamyPfaUCkWw4CtZdOMEvpNyH0DfGdQm9DMETcWwno385IPDY2W/G54go5xmaV8IU8+bdJ6oFaG5Ic22ugtEVPyunEfGMB3XzwRhP02RNLg3zexaDijv9fG2H82KfaaRK9uIOWVTdsewYnB8s5PfrOD0Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758376970; c=relaxed/simple; bh=HUcqV+gHE5QYB6Goia5NvtszIUI0meHfzcQDK/w5Y4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TBNfhL7dpBO06o5N64DKDZRjwkQuwlDCox69io9YXbGmu+M/pn4yIx9VFC+dj5XpCkl4KNKh50/Nq06Mf+xrTA21wq++2gkYtJ9ogyKlh5W4QQWUDX3YlsjxLj4yoYHI99NL/N5jwzJhkeaxIpTJ3qbRe/8sn+35RaAPUcVpLrk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=unpredictable.fr; spf=pass smtp.mailfrom=unpredictable.fr; dkim=pass (2048-bit key) header.d=unpredictable.fr header.i=@unpredictable.fr header.b=UVPBmXbH; arc=none smtp.client-ip=57.103.86.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=unpredictable.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unpredictable.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=unpredictable.fr header.i=@unpredictable.fr header.b="UVPBmXbH" 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) 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 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) 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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=off 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, VirtMachineState *vms) nb_nodes = num_smmus + 1; /* RC and SMMUv3 */ rc_mapping_count = rc_smmu_idmaps_len; - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* * Knowing the ID ranges from the RC to the SMMU, it's possible to * determine the ID ranges from RC that go directly to ITS. @@ -483,7 +483,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) rc_mapping_count += rc_its_idmaps->len; } } else { - if (vms->its) { + if (virt_is_its_enabled(vms)) { nb_nodes = 2; /* RC and ITS */ rc_mapping_count = 1; /* Direct map to ITS */ } else { @@ -498,7 +498,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) build_append_int_noprefix(table_data, IORT_NODE_OFFSET, 4); build_append_int_noprefix(table_data, 0, 4); /* Reserved */ - if (vms->its) { + if (virt_is_its_enabled(vms)) { /* Table 12 ITS Group Format */ build_append_int_noprefix(table_data, 0 /* ITS Group */, 1); /* Type */ node_size = 20 /* fixed header size */ + 4 /* 1 GIC ITS Identifier */; @@ -517,7 +517,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) int smmu_mapping_count, offset_to_id_array; int irq = sdev->irq; - if (vms->its) { + if (virt_is_its_enabled(vms)) { smmu_mapping_count = 1; /* ITS Group node */ offset_to_id_array = SMMU_V3_ENTRY_SIZE; /* Just after the header */ } else { @@ -610,7 +610,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } } - 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, VirtMachineState *vms) memmap[VIRT_HIGH_GIC_REDIST2].size); } - 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, VirtMachineState *vms) } } - if (!vms->its && !vms->no_gicv3_with_gicv2m) { + if (!virt_is_its_enabled(vms) && !vms->no_gicv3_with_gicv2m) { const uint16_t spi_base = vms->irqmap[VIRT_GIC_V2M] + ARM_SPI_BASE; /* 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; - 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; } + 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 = qdev_new(its_class_name()); object_property_set_link(OBJECT(dev), "parent-gicv3", OBJECT(vms->gic), @@ -955,7 +964,7 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) fdt_add_gic_node(vms); - if (vms->gic_version != VIRT_GIC_VERSION_2 && vms->its) { + if (vms->gic_version != VIRT_GIC_VERSION_2 && virt_is_its_enabled(vms)) { create_its(vms); } else if (vms->gic_version != 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 = size; } -static bool virt_get_its(Object *obj, Error **errp) +bool virt_is_its_enabled(VirtMachineState *vms) +{ + if (vms->its == ON_OFF_AUTO_OFF) { + return false; + } + if (vms->its == 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 = VIRT_MACHINE(obj); + OnOffAuto its = vms->its; - return vms->its; + visit_type_OnOffAuto(v, name, &its, errp); } -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 = VIRT_MACHINE(obj); - vms->its = value; + visit_type_OnOffAuto(v, name, &vms->its, errp); } 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"); - 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 = true; vms->highmem_redists = true; - /* Default allows ITS instantiation */ - vms->its = true; + /* Default allows ITS instantiation if available */ + vms->its = ON_OFF_AUTO_AUTO; /* Allow ITS emulation if the machine version supports it */ vms->tcg_its = !vmc->no_tcg_its; vms->no_gicv3_with_gicv2m = 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(VirtMachineState *vms) vms->highmem_redists) ? 2 : 1; } +bool virt_is_its_enabled(VirtMachineState *vms); + #endif /* QEMU_ARM_VIRT_H */ -- 2.50.1 (Apple Git-155)