diff mbox

[1/2] hw/arm/virt-acpi-build: fix MADT generation

Message ID 1476117341-32690-2-git-send-email-drjones@redhat.com
State New
Headers show

Commit Message

Andrew Jones Oct. 10, 2016, 4:35 p.m. UTC
We can't return early from build_* functions, as build_header is
only called at the end.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 hw/arm/virt-acpi-build.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

Comments

Eric Auger Oct. 10, 2016, 6:54 p.m. UTC | #1
Hi Drew,
On 10/10/2016 18:35, Andrew Jones wrote:
> We can't return early from build_* functions, as build_header is
> only called at the end.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  hw/arm/virt-acpi-build.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 7b39b1d2d676..c31349561c95 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -556,15 +556,13 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
>          gicr->base_address = cpu_to_le64(memmap[VIRT_GIC_REDIST].base);
>          gicr->range_length = cpu_to_le32(memmap[VIRT_GIC_REDIST].size);
>  
> -        if (!its_class_name()) {
> -            return;
> +        if (its_class_name()) {
> +            gic_its = acpi_data_push(table_data, sizeof *gic_its);
> +            gic_its->type = ACPI_APIC_GENERIC_TRANSLATOR;
> +            gic_its->length = sizeof(*gic_its);
> +            gic_its->translation_id = 0;
> +            gic_its->base_address = cpu_to_le64(memmap[VIRT_GIC_ITS].base);
>          }
> -
> -        gic_its = acpi_data_push(table_data, sizeof *gic_its);
> -        gic_its->type = ACPI_APIC_GENERIC_TRANSLATOR;
> -        gic_its->length = sizeof(*gic_its);
> -        gic_its->translation_id = 0;
> -        gic_its->base_address = cpu_to_le64(memmap[VIRT_GIC_ITS].base);
>      } else {
>          gic_msi = acpi_data_push(table_data, sizeof *gic_msi);
>          gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;
> 
Thanks for spotting the issue

Reviewed-by: Eric Auger <eric.auger@redhat.com>

Eric
diff mbox

Patch

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 7b39b1d2d676..c31349561c95 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -556,15 +556,13 @@  build_madt(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)
         gicr->base_address = cpu_to_le64(memmap[VIRT_GIC_REDIST].base);
         gicr->range_length = cpu_to_le32(memmap[VIRT_GIC_REDIST].size);
 
-        if (!its_class_name()) {
-            return;
+        if (its_class_name()) {
+            gic_its = acpi_data_push(table_data, sizeof *gic_its);
+            gic_its->type = ACPI_APIC_GENERIC_TRANSLATOR;
+            gic_its->length = sizeof(*gic_its);
+            gic_its->translation_id = 0;
+            gic_its->base_address = cpu_to_le64(memmap[VIRT_GIC_ITS].base);
         }
-
-        gic_its = acpi_data_push(table_data, sizeof *gic_its);
-        gic_its->type = ACPI_APIC_GENERIC_TRANSLATOR;
-        gic_its->length = sizeof(*gic_its);
-        gic_its->translation_id = 0;
-        gic_its->base_address = cpu_to_le64(memmap[VIRT_GIC_ITS].base);
     } else {
         gic_msi = acpi_data_push(table_data, sizeof *gic_msi);
         gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;