diff mbox series

[v3,07/12] hw/arm/virt: Move post cpu realize check into its own function

Message ID 20eedb95441ecec7b23527cde78aa5b63c67b400.1600135462.git.haibo.xu@linaro.org (mailing list archive)
State New, archived
Headers show
Series target/arm: Add vSPE support to KVM guest | expand

Commit Message

Haibo Xu Sept. 15, 2020, 3:11 a.m. UTC
From: Andrew Jones <drjones@redhat.com>

We'll add more to this new function in coming patches so we also
state the gic must be created and call it below create_gic().

No functional change intended.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/virt.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

Comments

Andrew Jones Sept. 15, 2020, 6:22 a.m. UTC | #1
On Tue, Sep 15, 2020 at 03:11:43AM +0000, Haibo Xu wrote:
> From: Andrew Jones <drjones@redhat.com>
> 
> We'll add more to this new function in coming patches so we also
> state the gic must be created and call it below create_gic().
> 
> No functional change intended.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/arm/virt.c | 38 ++++++++++++++++++++++----------------
>  1 file changed, 22 insertions(+), 16 deletions(-)

This still isn't the right version of this patch. You need
https://www.mail-archive.com/qemu-devel@nongnu.org/msg727591.html

> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 3f6d26c531..2ffcb073af 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1672,6 +1672,26 @@ static void finalize_gic_version(VirtMachineState *vms)
>      }
>  }
>  
> +static void virt_cpu_post_init(VirtMachineState *vms)
> +{
> +    bool aarch64;
> +
> +    aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL);
> +
> +    if (!kvm_enabled()) {
> +        if (aarch64 && vms->highmem) {
> +            int requested_pa_size = 64 - clz64(vms->highest_gpa);
> +            int pamax = arm_pamax(ARM_CPU(first_cpu));
> +
> +            if (pamax < requested_pa_size) {
> +                error_report("VCPU supports less PA bits (%d) than requested "
> +                            "by the memory map (%d)", pamax, requested_pa_size);
> +                exit(1);
> +            }
> +        }
> +     }
> +}
> +
>  static void machvirt_init(MachineState *machine)
>  {
>      VirtMachineState *vms = VIRT_MACHINE(machine);
> @@ -1890,22 +1910,6 @@ static void machvirt_init(MachineState *machine)
>      fdt_add_timer_nodes(vms);
>      fdt_add_cpu_nodes(vms);
>  
> -   if (!kvm_enabled()) {
> -        ARMCPU *cpu = ARM_CPU(first_cpu);
> -        bool aarch64 = object_property_get_bool(OBJECT(cpu), "aarch64", NULL);
> -
> -        if (aarch64 && vms->highmem) {
> -            int requested_pa_size, pamax = arm_pamax(cpu);
> -
> -            requested_pa_size = 64 - clz64(vms->highest_gpa);
> -            if (pamax < requested_pa_size) {
> -                error_report("VCPU supports less PA bits (%d) than requested "
> -                            "by the memory map (%d)", pamax, requested_pa_size);
> -                exit(1);
> -            }
> -        }
> -    }
> -
>      memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base,
>                                  machine->ram);
>      if (machine->device_memory) {
> @@ -1917,6 +1921,8 @@ static void machvirt_init(MachineState *machine)
>  
>      create_gic(vms);
>  
> +    virt_cpu_post_init(vms);
> +
>      fdt_add_pmu_nodes(vms);
>  
>      create_uart(vms, VIRT_UART, sysmem, serial_hd(0));
> -- 
> 2.17.1
> 
>
Haibo Xu Sept. 15, 2020, 7:03 a.m. UTC | #2
On Tue, 15 Sep 2020 at 14:22, Andrew Jones <drjones@redhat.com> wrote:
>
> On Tue, Sep 15, 2020 at 03:11:43AM +0000, Haibo Xu wrote:
> > From: Andrew Jones <drjones@redhat.com>
> >
> > We'll add more to this new function in coming patches so we also
> > state the gic must be created and call it below create_gic().
> >
> > No functional change intended.
> >
> > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> > ---
> >  hw/arm/virt.c | 38 ++++++++++++++++++++++----------------
> >  1 file changed, 22 insertions(+), 16 deletions(-)
>
> This still isn't the right version of this patch. You need
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg727591.html
>

My fault! Very sorry for forgetting to address that in this version.
Shall I re-send this patch with the fix? Or fix it in the next version?

> >
> > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> > index 3f6d26c531..2ffcb073af 100644
> > --- a/hw/arm/virt.c
> > +++ b/hw/arm/virt.c
> > @@ -1672,6 +1672,26 @@ static void finalize_gic_version(VirtMachineState *vms)
> >      }
> >  }
> >
> > +static void virt_cpu_post_init(VirtMachineState *vms)
> > +{
> > +    bool aarch64;
> > +
> > +    aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL);
> > +
> > +    if (!kvm_enabled()) {
> > +        if (aarch64 && vms->highmem) {
> > +            int requested_pa_size = 64 - clz64(vms->highest_gpa);
> > +            int pamax = arm_pamax(ARM_CPU(first_cpu));
> > +
> > +            if (pamax < requested_pa_size) {
> > +                error_report("VCPU supports less PA bits (%d) than requested "
> > +                            "by the memory map (%d)", pamax, requested_pa_size);
> > +                exit(1);
> > +            }
> > +        }
> > +     }
> > +}
> > +
> >  static void machvirt_init(MachineState *machine)
> >  {
> >      VirtMachineState *vms = VIRT_MACHINE(machine);
> > @@ -1890,22 +1910,6 @@ static void machvirt_init(MachineState *machine)
> >      fdt_add_timer_nodes(vms);
> >      fdt_add_cpu_nodes(vms);
> >
> > -   if (!kvm_enabled()) {
> > -        ARMCPU *cpu = ARM_CPU(first_cpu);
> > -        bool aarch64 = object_property_get_bool(OBJECT(cpu), "aarch64", NULL);
> > -
> > -        if (aarch64 && vms->highmem) {
> > -            int requested_pa_size, pamax = arm_pamax(cpu);
> > -
> > -            requested_pa_size = 64 - clz64(vms->highest_gpa);
> > -            if (pamax < requested_pa_size) {
> > -                error_report("VCPU supports less PA bits (%d) than requested "
> > -                            "by the memory map (%d)", pamax, requested_pa_size);
> > -                exit(1);
> > -            }
> > -        }
> > -    }
> > -
> >      memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base,
> >                                  machine->ram);
> >      if (machine->device_memory) {
> > @@ -1917,6 +1921,8 @@ static void machvirt_init(MachineState *machine)
> >
> >      create_gic(vms);
> >
> > +    virt_cpu_post_init(vms);
> > +
> >      fdt_add_pmu_nodes(vms);
> >
> >      create_uart(vms, VIRT_UART, sysmem, serial_hd(0));
> > --
> > 2.17.1
> >
> >
>
Andrew Jones Sept. 15, 2020, 7:31 a.m. UTC | #3
On Tue, Sep 15, 2020 at 03:03:49PM +0800, Haibo Xu wrote:
> On Tue, 15 Sep 2020 at 14:22, Andrew Jones <drjones@redhat.com> wrote:
> >
> > On Tue, Sep 15, 2020 at 03:11:43AM +0000, Haibo Xu wrote:
> > > From: Andrew Jones <drjones@redhat.com>
> > >
> > > We'll add more to this new function in coming patches so we also
> > > state the gic must be created and call it below create_gic().
> > >
> > > No functional change intended.
> > >
> > > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > > Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> > > ---
> > >  hw/arm/virt.c | 38 ++++++++++++++++++++++----------------
> > >  1 file changed, 22 insertions(+), 16 deletions(-)
> >
> > This still isn't the right version of this patch. You need
> > https://www.mail-archive.com/qemu-devel@nongnu.org/msg727591.html
> >
> 
> My fault! Very sorry for forgetting to address that in this version.
> Shall I re-send this patch with the fix? Or fix it in the next version?

I can wait. It'll be awhile before this series can be merged anyway, since
the KVM patches haven't been merged yet.

Thanks,
drew

> 
> > >
> > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> > > index 3f6d26c531..2ffcb073af 100644
> > > --- a/hw/arm/virt.c
> > > +++ b/hw/arm/virt.c
> > > @@ -1672,6 +1672,26 @@ static void finalize_gic_version(VirtMachineState *vms)
> > >      }
> > >  }
> > >
> > > +static void virt_cpu_post_init(VirtMachineState *vms)
> > > +{
> > > +    bool aarch64;
> > > +
> > > +    aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL);
> > > +
> > > +    if (!kvm_enabled()) {
> > > +        if (aarch64 && vms->highmem) {
> > > +            int requested_pa_size = 64 - clz64(vms->highest_gpa);
> > > +            int pamax = arm_pamax(ARM_CPU(first_cpu));
> > > +
> > > +            if (pamax < requested_pa_size) {
> > > +                error_report("VCPU supports less PA bits (%d) than requested "
> > > +                            "by the memory map (%d)", pamax, requested_pa_size);
> > > +                exit(1);
> > > +            }
> > > +        }
> > > +     }
> > > +}
> > > +
> > >  static void machvirt_init(MachineState *machine)
> > >  {
> > >      VirtMachineState *vms = VIRT_MACHINE(machine);
> > > @@ -1890,22 +1910,6 @@ static void machvirt_init(MachineState *machine)
> > >      fdt_add_timer_nodes(vms);
> > >      fdt_add_cpu_nodes(vms);
> > >
> > > -   if (!kvm_enabled()) {
> > > -        ARMCPU *cpu = ARM_CPU(first_cpu);
> > > -        bool aarch64 = object_property_get_bool(OBJECT(cpu), "aarch64", NULL);
> > > -
> > > -        if (aarch64 && vms->highmem) {
> > > -            int requested_pa_size, pamax = arm_pamax(cpu);
> > > -
> > > -            requested_pa_size = 64 - clz64(vms->highest_gpa);
> > > -            if (pamax < requested_pa_size) {
> > > -                error_report("VCPU supports less PA bits (%d) than requested "
> > > -                            "by the memory map (%d)", pamax, requested_pa_size);
> > > -                exit(1);
> > > -            }
> > > -        }
> > > -    }
> > > -
> > >      memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base,
> > >                                  machine->ram);
> > >      if (machine->device_memory) {
> > > @@ -1917,6 +1921,8 @@ static void machvirt_init(MachineState *machine)
> > >
> > >      create_gic(vms);
> > >
> > > +    virt_cpu_post_init(vms);
> > > +
> > >      fdt_add_pmu_nodes(vms);
> > >
> > >      create_uart(vms, VIRT_UART, sysmem, serial_hd(0));
> > > --
> > > 2.17.1
> > >
> > >
> >
>
Haibo Xu Sept. 15, 2020, 7:34 a.m. UTC | #4
On Tue, 15 Sep 2020 at 15:31, Andrew Jones <drjones@redhat.com> wrote:
>
> On Tue, Sep 15, 2020 at 03:03:49PM +0800, Haibo Xu wrote:
> > On Tue, 15 Sep 2020 at 14:22, Andrew Jones <drjones@redhat.com> wrote:
> > >
> > > On Tue, Sep 15, 2020 at 03:11:43AM +0000, Haibo Xu wrote:
> > > > From: Andrew Jones <drjones@redhat.com>
> > > >
> > > > We'll add more to this new function in coming patches so we also
> > > > state the gic must be created and call it below create_gic().
> > > >
> > > > No functional change intended.
> > > >
> > > > Signed-off-by: Andrew Jones <drjones@redhat.com>
> > > > Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> > > > ---
> > > >  hw/arm/virt.c | 38 ++++++++++++++++++++++----------------
> > > >  1 file changed, 22 insertions(+), 16 deletions(-)
> > >
> > > This still isn't the right version of this patch. You need
> > > https://www.mail-archive.com/qemu-devel@nongnu.org/msg727591.html
> > >
> >
> > My fault! Very sorry for forgetting to address that in this version.
> > Shall I re-send this patch with the fix? Or fix it in the next version?
>
> I can wait. It'll be awhile before this series can be merged anyway, since
> the KVM patches haven't been merged yet.
>
> Thanks,
> drew
>

Ok, I will fix it in the next version.
Thanks again for the review!

Regards,
Haibo

> >
> > > >
> > > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> > > > index 3f6d26c531..2ffcb073af 100644
> > > > --- a/hw/arm/virt.c
> > > > +++ b/hw/arm/virt.c
> > > > @@ -1672,6 +1672,26 @@ static void finalize_gic_version(VirtMachineState *vms)
> > > >      }
> > > >  }
> > > >
> > > > +static void virt_cpu_post_init(VirtMachineState *vms)
> > > > +{
> > > > +    bool aarch64;
> > > > +
> > > > +    aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL);
> > > > +
> > > > +    if (!kvm_enabled()) {
> > > > +        if (aarch64 && vms->highmem) {
> > > > +            int requested_pa_size = 64 - clz64(vms->highest_gpa);
> > > > +            int pamax = arm_pamax(ARM_CPU(first_cpu));
> > > > +
> > > > +            if (pamax < requested_pa_size) {
> > > > +                error_report("VCPU supports less PA bits (%d) than requested "
> > > > +                            "by the memory map (%d)", pamax, requested_pa_size);
> > > > +                exit(1);
> > > > +            }
> > > > +        }
> > > > +     }
> > > > +}
> > > > +
> > > >  static void machvirt_init(MachineState *machine)
> > > >  {
> > > >      VirtMachineState *vms = VIRT_MACHINE(machine);
> > > > @@ -1890,22 +1910,6 @@ static void machvirt_init(MachineState *machine)
> > > >      fdt_add_timer_nodes(vms);
> > > >      fdt_add_cpu_nodes(vms);
> > > >
> > > > -   if (!kvm_enabled()) {
> > > > -        ARMCPU *cpu = ARM_CPU(first_cpu);
> > > > -        bool aarch64 = object_property_get_bool(OBJECT(cpu), "aarch64", NULL);
> > > > -
> > > > -        if (aarch64 && vms->highmem) {
> > > > -            int requested_pa_size, pamax = arm_pamax(cpu);
> > > > -
> > > > -            requested_pa_size = 64 - clz64(vms->highest_gpa);
> > > > -            if (pamax < requested_pa_size) {
> > > > -                error_report("VCPU supports less PA bits (%d) than requested "
> > > > -                            "by the memory map (%d)", pamax, requested_pa_size);
> > > > -                exit(1);
> > > > -            }
> > > > -        }
> > > > -    }
> > > > -
> > > >      memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base,
> > > >                                  machine->ram);
> > > >      if (machine->device_memory) {
> > > > @@ -1917,6 +1921,8 @@ static void machvirt_init(MachineState *machine)
> > > >
> > > >      create_gic(vms);
> > > >
> > > > +    virt_cpu_post_init(vms);
> > > > +
> > > >      fdt_add_pmu_nodes(vms);
> > > >
> > > >      create_uart(vms, VIRT_UART, sysmem, serial_hd(0));
> > > > --
> > > > 2.17.1
> > > >
> > > >
> > >
> >
>
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 3f6d26c531..2ffcb073af 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1672,6 +1672,26 @@  static void finalize_gic_version(VirtMachineState *vms)
     }
 }
 
+static void virt_cpu_post_init(VirtMachineState *vms)
+{
+    bool aarch64;
+
+    aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL);
+
+    if (!kvm_enabled()) {
+        if (aarch64 && vms->highmem) {
+            int requested_pa_size = 64 - clz64(vms->highest_gpa);
+            int pamax = arm_pamax(ARM_CPU(first_cpu));
+
+            if (pamax < requested_pa_size) {
+                error_report("VCPU supports less PA bits (%d) than requested "
+                            "by the memory map (%d)", pamax, requested_pa_size);
+                exit(1);
+            }
+        }
+     }
+}
+
 static void machvirt_init(MachineState *machine)
 {
     VirtMachineState *vms = VIRT_MACHINE(machine);
@@ -1890,22 +1910,6 @@  static void machvirt_init(MachineState *machine)
     fdt_add_timer_nodes(vms);
     fdt_add_cpu_nodes(vms);
 
-   if (!kvm_enabled()) {
-        ARMCPU *cpu = ARM_CPU(first_cpu);
-        bool aarch64 = object_property_get_bool(OBJECT(cpu), "aarch64", NULL);
-
-        if (aarch64 && vms->highmem) {
-            int requested_pa_size, pamax = arm_pamax(cpu);
-
-            requested_pa_size = 64 - clz64(vms->highest_gpa);
-            if (pamax < requested_pa_size) {
-                error_report("VCPU supports less PA bits (%d) than requested "
-                            "by the memory map (%d)", pamax, requested_pa_size);
-                exit(1);
-            }
-        }
-    }
-
     memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base,
                                 machine->ram);
     if (machine->device_memory) {
@@ -1917,6 +1921,8 @@  static void machvirt_init(MachineState *machine)
 
     create_gic(vms);
 
+    virt_cpu_post_init(vms);
+
     fdt_add_pmu_nodes(vms);
 
     create_uart(vms, VIRT_UART, sysmem, serial_hd(0));