lkml.org 
[lkml]   [2023]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v11 017/113] KVM: Support KVM_CAP_MAX_VCPUS for KVM_ENABLE_CAP
On Thu, 12 Jan 2023 08:31:25 -0800
isaku.yamahata@intel.com wrote:

> From: Isaku Yamahata <isaku.yamahata@intel.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@google.com>
> Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
> ---
> virt/kvm/kvm_main.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index a235b628b32f..1cfa7da92ad0 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -4945,7 +4945,27 @@ static int kvm_vm_ioctl_enable_cap_generic(struct
> kvm *kvm, }
>
> mutex_unlock(&kvm->slots_lock);
> + return r;
> + }
> + case KVM_CAP_MAX_VCPUS: {

Better mention the KVM_CAP_MAX_VCPUS defined in XXX patch in the comments.

> + 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:

\
 
 \ /
  Last update: 2023-03-26 23:39    [W:1.190 / U:2.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site