[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <07daa8dbe1e3d6fec8db47a3ff3422a9bc460548.1667110240.git.isaku.yamahata@intel.com>
Date: Sat, 29 Oct 2022 23:22:21 -0700
From: isaku.yamahata@...el.com
To: kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: isaku.yamahata@...el.com, isaku.yamahata@...il.com,
Paolo Bonzini <pbonzini@...hat.com>, erdemaktas@...gle.com,
Sean Christopherson <seanjc@...gle.com>,
Sagi Shahar <sagis@...gle.com>,
David Matlack <dmatlack@...gle.com>
Subject: [PATCH v10 020/108] KVM: Support KVM_CAP_MAX_VCPUS for KVM_ENABLE_CAP
From: Isaku Yamahata <isaku.yamahata@...el.com>
TDX attestation includes the maximum number of vcpu that the guest can
accommodate. For that, the maximum number of vcpu needs to be specified
instead of constant, KVM_MAX_VCPUS. Make KVM_ENABLE_CAP support
KVM_CAP_MAX_VCPUS.
Suggested-by: Sagi Shahar <sagis@...gle.com>
Signed-off-by: Isaku Yamahata <isaku.yamahata@...el.com>
---
virt/kvm/kvm_main.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index b9c270f97c88..3b05a3396f89 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4967,6 +4967,27 @@ static int kvm_vm_ioctl_enable_cap_generic(struct kvm *kvm,
case KVM_CAP_DIRTY_LOG_RING:
case KVM_CAP_DIRTY_LOG_RING_ACQ_REL:
return kvm_vm_ioctl_enable_dirty_log_ring(kvm, cap->args[0]);
+ case KVM_CAP_MAX_VCPUS: {
+ int r;
+
+ if (cap->flags || cap->args[0] == 0)
+ return -EINVAL;
+ if (cap->args[0] > kvm_vm_ioctl_check_extension(kvm, KVM_CAP_MAX_VCPUS))
+ return -E2BIG;
+
+ mutex_lock(&kvm->lock);
+ /* Only decreasing is allowed. */
+ if (cap->args[0] > kvm->max_vcpus)
+ r = -E2BIG;
+ else if (kvm->created_vcpus)
+ r = -EBUSY;
+ else {
+ kvm->max_vcpus = cap->args[0];
+ r = 0;
+ }
+ mutex_unlock(&kvm->lock);
+ return r;
+ }
default:
return kvm_vm_ioctl_enable_cap(kvm, cap);
}
--
2.25.1
Powered by blists - more mailing lists