[PATCH v10 17/28] hw: arm: virt-acpi-build: add hack

Mohamed Mediouni posted 28 patches 2 weeks, 1 day ago
Maintainers: Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Mads Ynddal <mads@ynddal.dk>, Pedro Barbuda <pbarbuda@microsoft.com>, Mohamed Mediouni <mohamed@unpredictable.fr>, Peter Maydell <peter.maydell@linaro.org>, Shannon Zhao <shannon.zhaosl@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Alexander Graf <agraf@csgraf.de>
[PATCH v10 17/28] hw: arm: virt-acpi-build: add hack
Posted by Mohamed Mediouni 2 weeks, 1 day ago
Looks like in the prior Qemu ACPI table handling, GICv2 configurations
had vms->its=1...

Match that assumption to not make the test suite fail. Probably not merge-worthy...

And then maybe see what to do for older releases too?

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
 hw/arm/virt-acpi-build.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index a6a56455a9..39dd3d1020 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 (virt_is_its_enabled(vms)) {
+        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
             /*
              * 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 (virt_is_its_enabled(vms)) {
+        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
             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 (virt_is_its_enabled(vms)) {
+    if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
         /* 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 (virt_is_its_enabled(vms)) {
+        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
             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 (virt_is_its_enabled(vms)) {
+        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
             /*
              * Map bypassed (don't go through the SMMU) RIDs (input) to
              * ITS Group node directly: RC -> ITS.
-- 
2.50.1 (Apple Git-155)
Re: [PATCH v10 17/28] hw: arm: virt-acpi-build: add hack
Posted by Gustavo Romero 1 week, 1 day ago
Hi Mohamed and Phil,

On 10/29/25 17:54, Mohamed Mediouni wrote:
> Looks like in the prior Qemu ACPI table handling, GICv2 configurations
> had vms->its=1...

To me, ITS should not be present on machines that have GICv2, so we should not generate
any ACPI table advertising ITS when GICv2 is used.


Cheers,
Gustavo

> Match that assumption to not make the test suite fail. Probably not merge-worthy...
> 
> And then maybe see what to do for older releases too?
> 
> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> ---
>   hw/arm/virt-acpi-build.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index a6a56455a9..39dd3d1020 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 (virt_is_its_enabled(vms)) {
> +        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>               /*
>                * 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 (virt_is_its_enabled(vms)) {
> +        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>               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 (virt_is_its_enabled(vms)) {
> +    if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>           /* 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 (virt_is_its_enabled(vms)) {
> +        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>               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 (virt_is_its_enabled(vms)) {
> +        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>               /*
>                * Map bypassed (don't go through the SMMU) RIDs (input) to
>                * ITS Group node directly: RC -> ITS.
Re: [PATCH v10 17/28] hw: arm: virt-acpi-build: add hack
Posted by Mohamed Mediouni 1 week, 1 day ago

> On 6. Nov 2025, at 10:40, Gustavo Romero <gustavo.romero@linaro.org> wrote:
> 
> Hi Mohamed and Phil,
> 
> On 10/29/25 17:54, Mohamed Mediouni wrote:
>> Looks like in the prior Qemu ACPI table handling, GICv2 configurations
>> had vms->its=1...
> 
> To me, ITS should not be present on machines that have GICv2, so we should not generate
> any ACPI table advertising ITS when GICv2 is used.
> 
The problem is breaking migration/backwards compatibility… is it an ignorable concern or
should be the new behaviour be quirked to apply to only Qemu 11.0 onwards?

Thank you,
-Mohamed
> Cheers,
> Gustavo
> 
>> Match that assumption to not make the test suite fail. Probably not merge-worthy...
>> And then maybe see what to do for older releases too?
>> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
>> ---
>>  hw/arm/virt-acpi-build.c | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> index a6a56455a9..39dd3d1020 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 (virt_is_its_enabled(vms)) {
>> +        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>>              /*
>>               * 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 (virt_is_its_enabled(vms)) {
>> +        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>>              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 (virt_is_its_enabled(vms)) {
>> +    if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>>          /* 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 (virt_is_its_enabled(vms)) {
>> +        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>>              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 (virt_is_its_enabled(vms)) {
>> +        if (virt_is_its_enabled(vms) || vms->gic_version == 2) {
>>              /*
>>               * Map bypassed (don't go through the SMMU) RIDs (input) to
>>               * ITS Group node directly: RC -> ITS.
> 
>