]> www.infradead.org Git - linux.git/commitdiff
KVM: x86: Prevent excluding the BSP on setting max_vcpu_ids
authorSean Christopherson <seanjc@google.com>
Fri, 14 Jun 2024 20:28:57 +0000 (22:28 +0200)
committerSean Christopherson <seanjc@google.com>
Tue, 18 Jun 2024 15:59:50 +0000 (08:59 -0700)
If the BSP vCPU ID was already set, ensure it doesn't get excluded when
limiting vCPU IDs via KVM_CAP_MAX_VCPU_ID.

[mks: provide commit message, code by Sean]

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Link: https://lore.kernel.org/r/20240614202859.3597745-4-minipli@grsecurity.net
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c

index f371943f2c72841062cfa044607e69c667d11437..994aa281b07d532eda5afd7928aa025823d63d93 100644 (file)
@@ -6707,7 +6707,9 @@ split_irqchip_unlock:
                        break;
 
                mutex_lock(&kvm->lock);
-               if (kvm->arch.max_vcpu_ids == cap->args[0]) {
+               if (kvm->arch.bsp_vcpu_id > cap->args[0]) {
+                       ;
+               } else if (kvm->arch.max_vcpu_ids == cap->args[0]) {
                        r = 0;
                } else if (!kvm->arch.max_vcpu_ids) {
                        kvm->arch.max_vcpu_ids = cap->args[0];