diff mbox series

[RFC,3/3] virt: Check KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 for smp_cpus > 256

Message ID 20190827160554.30995-4-eric.auger@redhat.com
State New
Headers show
Series KVM/ARM: Fix >256 vcpus | expand

Commit Message

Eric Auger Aug. 27, 2019, 4:05 p.m. UTC
Host kernel within [4.18, 5.3] report an erroneous KVM_MAX_VCPUS=512
for ARM. The actual capability to instantiate more than 256 vcpus
was fixed in 5.4 with the upgrade of the KVM_IRQ_LINE ABI to support
vcpu id encoded on 12 bits instead of 8 and a redistributor consuming
a single KVM IO device instead of 2.

So let's check this capability when attempting to use more than 256
vcpus.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 hw/arm/virt.c        |  7 +++++++
 target/arm/kvm.c     |  7 +++++++
 target/arm/kvm_arm.h | 13 +++++++++++++
 3 files changed, 27 insertions(+)

Comments

Richard Henderson Aug. 28, 2019, 3:28 a.m. UTC | #1
On 8/27/19 9:05 AM, Eric Auger wrote:
> +++ b/target/arm/kvm_arm.h
> @@ -233,6 +233,14 @@ bool kvm_arm_pmu_supported(CPUState *cs);
>   */
>  int kvm_arm_get_max_vm_ipa_size(MachineState *ms);
>  
> +/**
> + * kvm_arm_irq_line_layout_2 - Returns whether more than 256
> + * vcpus are supported by KVM_IRQ_LINE
> + *
> + * @ms: Machine state handle
> + */
> +bool kvm_arm_irq_line_layout_2(MachineState *ms);
> +
>  /**
>   * kvm_arm_sync_mpstate_to_kvm
>   * @cpu: ARMCPU
> @@ -280,6 +288,11 @@ static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
>      return -ENOENT;
>  }
>  
> +static inline int kvm_arm_irq_line_layout_2(MachineState *ms)
> +{
> +    return -ENOENT;
> +}
> +

These signatures don't match.


r~
Eric Auger Aug. 28, 2019, 6:19 a.m. UTC | #2
Hi Richard,

On 8/28/19 5:28 AM, Richard Henderson wrote:
> On 8/27/19 9:05 AM, Eric Auger wrote:
>> +++ b/target/arm/kvm_arm.h
>> @@ -233,6 +233,14 @@ bool kvm_arm_pmu_supported(CPUState *cs);
>>   */
>>  int kvm_arm_get_max_vm_ipa_size(MachineState *ms);
>>  
>> +/**
>> + * kvm_arm_irq_line_layout_2 - Returns whether more than 256
>> + * vcpus are supported by KVM_IRQ_LINE
>> + *
>> + * @ms: Machine state handle
>> + */
>> +bool kvm_arm_irq_line_layout_2(MachineState *ms);
>> +
>>  /**
>>   * kvm_arm_sync_mpstate_to_kvm
>>   * @cpu: ARMCPU
>> @@ -280,6 +288,11 @@ static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
>>      return -ENOENT;
>>  }
>>  
>> +static inline int kvm_arm_irq_line_layout_2(MachineState *ms)
>> +{
>> +    return -ENOENT;
>> +}
>> +
> 
> These signatures don't match.
thanks for spotting this. I will fix it.

Best Regards

Eric
> 
> 
> r~
>
Peter Maydell Sept. 6, 2019, 10:16 a.m. UTC | #3
On Tue, 27 Aug 2019 at 17:06, Eric Auger <eric.auger@redhat.com> wrote:
>
> Host kernel within [4.18, 5.3] report an erroneous KVM_MAX_VCPUS=512
> for ARM. The actual capability to instantiate more than 256 vcpus
> was fixed in 5.4 with the upgrade of the KVM_IRQ_LINE ABI to support
> vcpu id encoded on 12 bits instead of 8 and a redistributor consuming
> a single KVM IO device instead of 2.
>
> So let's check this capability when attempting to use more than 256
> vcpus.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
>  hw/arm/virt.c        |  7 +++++++
>  target/arm/kvm.c     |  7 +++++++
>  target/arm/kvm_arm.h | 13 +++++++++++++
>  3 files changed, 27 insertions(+)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 0d1629ccb3..bcc8d64384 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1575,6 +1575,13 @@ static void machvirt_init(MachineState *machine)
>          virt_max_cpus = GIC_NCPU;
>      }
>
> +    if (kvm_enabled() && max_cpus > 256 &&
> +        !kvm_arm_irq_line_layout_2(MACHINE(vms))) {
> +        error_report("Using more than 256 vcpus require a host kernel "
> +                     "with KVM_CAP_ARM_IRQ_LINE_LAYOUT_2");
> +        exit(1);
> +    }

Is there some place we could put this check that isn't specific
to the virt board, so that we don't need to duplicate it in
any other future KVM-supporting boards we add?

thanks
-- PMM
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 0d1629ccb3..bcc8d64384 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1575,6 +1575,13 @@  static void machvirt_init(MachineState *machine)
         virt_max_cpus = GIC_NCPU;
     }
 
+    if (kvm_enabled() && max_cpus > 256 &&
+        !kvm_arm_irq_line_layout_2(MACHINE(vms))) {
+        error_report("Using more than 256 vcpus require a host kernel "
+                     "with KVM_CAP_ARM_IRQ_LINE_LAYOUT_2");
+        exit(1);
+    }
+
     if (max_cpus > virt_max_cpus) {
         error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
                      "supported by machine 'mach-virt' (%d)",
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index b2eaa50b8d..db88fcc5bf 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -171,6 +171,13 @@  bool kvm_arm_pmu_supported(CPUState *cpu)
     return kvm_check_extension(s, KVM_CAP_ARM_PMU_V3);
 }
 
+bool kvm_arm_irq_line_layout_2(MachineState *ms)
+{
+    KVMState *s = KVM_STATE(ms->accelerator);
+
+    return kvm_check_extension(s, KVM_CAP_ARM_IRQ_LINE_LAYOUT_2);
+}
+
 int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
 {
     KVMState *s = KVM_STATE(ms->accelerator);
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
index b3106c8600..06b4db4513 100644
--- a/target/arm/kvm_arm.h
+++ b/target/arm/kvm_arm.h
@@ -233,6 +233,14 @@  bool kvm_arm_pmu_supported(CPUState *cs);
  */
 int kvm_arm_get_max_vm_ipa_size(MachineState *ms);
 
+/**
+ * kvm_arm_irq_line_layout_2 - Returns whether more than 256
+ * vcpus are supported by KVM_IRQ_LINE
+ *
+ * @ms: Machine state handle
+ */
+bool kvm_arm_irq_line_layout_2(MachineState *ms);
+
 /**
  * kvm_arm_sync_mpstate_to_kvm
  * @cpu: ARMCPU
@@ -280,6 +288,11 @@  static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
     return -ENOENT;
 }
 
+static inline int kvm_arm_irq_line_layout_2(MachineState *ms)
+{
+    return -ENOENT;
+}
+
 static inline int kvm_arm_vgic_probe(void)
 {
     return 0;