@samitouri / QOSamiQemu / commits / b380e88021

hw/arm/virt: Allow user to select GICv5

Allow the user to select a GICv5 via '-machine gic-version=x-5', and document this. The 'x-' prefix indicates that the emulation is still in an "experimental" state as far as QEMU is concerned; the documentation describes what "experimental" means for the user and what parts are not yet implemented. We do not make 'gic-version=max' enable GICv5 here because: * the GICv5 architectural spec is still at the EAC level and could have minor changes between now and its final version; only users who specifically want to start working with the GICv5 should select it * QEMU's implementation here is still not fully featured, and selecting it instead of GICv3 will mean losing functionality such as MSIs * the GICv5 is not backwards compatible with the GICv3/GICv4 for system software, so silently "upgrading" an existing command line to GICv5 is just going to break existing guest kernels The last one in particular suggests that even when the emulation moves out of "experimental" status we will probably not want to change "max". Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20260327111700.795099-66-peter.maydell@linaro.org

Peter Maydell committed Mar 27, 2026 at 11:17 UTC b380e88021af0b05075d7c582ec1bc5952a1c440
2 files changed +27 -3
docs/system/arm/virt.rst
+19
@@ -161,6 +161,25 @@ gic-version
161 GICv3. This allows up to 512 CPUs.
162 ``4``
163 GICv4. Requires ``virtualization`` to be ``on``; allows up to 317 CPUs.
164 + ``x-5``
165 + GICv5 (experimental). This is an experimental emulation of the GICv5,
166 + based on the EAC release of the GICv5 architecture specification.
167 + Experimental means:
168 +
169 + - guest-visible behaviour may change when the final version of
170 + the specification is released and QEMU implements it
171 + - migration support is not yet implemented
172 + - the GICv5 is not exposed to the guest via ACPI tables, only via DTB
173 + - the way the interrupt controller is exposed to the guest and the
174 + command line syntax for enabling it may change
175 +
176 + The current implementation supports only an EL1 guest (no EL2 or
177 + EL3 and no Realm support), and does not implement the ITS (no
178 + MSI support).
179 +
180 + Note that as the GICv5 is an Armv9 feature, enabling it will
181 + automatically disable support for AArch32 at all exception levels
182 + except for EL0 (userspace).
183 ``host``
184 Use the same GIC version the host provides, when using KVM
185 ``max``
hw/arm/virt.c
+8 -3
@@ -3570,6 +3570,9 @@ static char *virt_get_gic_version(Object *obj, Error **errp)
3570 const char *val;
3571
3572 switch (vms->gic_version) {
3573 + case VIRT_GIC_VERSION_5:
3574 + val = "x-5";
3575 + break;
3576 case VIRT_GIC_VERSION_4:
3577 val = "4";
3578 break;
@@ -3587,7 +3590,9 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp)
3590 {
3591 VirtMachineState *vms = VIRT_MACHINE(obj);
3592
3590 - if (!strcmp(value, "4")) {
3593 + if (!strcmp(value, "x-5")) {
3594 + vms->gic_version = VIRT_GIC_VERSION_5;
3595 + } else if (!strcmp(value, "4")) {
3596 vms->gic_version = VIRT_GIC_VERSION_4;
3597 } else if (!strcmp(value, "3")) {
3598 vms->gic_version = VIRT_GIC_VERSION_3;
@@ -3599,7 +3604,7 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp)
3604 vms->gic_version = VIRT_GIC_VERSION_MAX; /* Will probe later */
3605 } else {
3606 error_setg(errp, "Invalid gic-version value");
3602 - error_append_hint(errp, "Valid values are 2, 3, 4, host, and max.\n");
3607 + error_append_hint(errp, "Valid values are 2, 3, 4, x-5, host, and max.\n");
3608 }
3609 }
3610
@@ -4192,7 +4197,7 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data)
4197 virt_set_gic_version);
4198 object_class_property_set_description(oc, "gic-version",
4199 "Set GIC version. "
4195 - "Valid values are 2, 3, 4, host and max");
4200 + "Valid values are 2, 3, 4, x-5, host and max");
4201
4202 object_class_property_add_str(oc, "iommu", virt_get_iommu, virt_set_iommu);
4203 object_class_property_set_description(oc, "iommu",