public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Kechen Lu <kechenl@nvidia.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"chao.gao@intel.com" <chao.gao@intel.com>,
	"vkuznets@redhat.com" <vkuznets@redhat.com>,
	Somdutta Roy <somduttar@nvidia.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH v4 5/7] KVM: x86: add vCPU scoped toggling for disabled exits
Date: Wed, 20 Jul 2022 19:30:25 +0000	[thread overview]
Message-ID: <YthX0brdWCZVFB3n@google.com> (raw)
In-Reply-To: <DM6PR12MB35008628D97A59AA302E772FCA8E9@DM6PR12MB3500.namprd12.prod.outlook.com>

On Wed, Jul 20, 2022, Kechen Lu wrote:
> > > @@ -6036,14 +6045,17 @@ int kvm_vm_ioctl_enable_cap(struct kvm kvm,
> > >                       break;
> > >
> > >               mutex_lock(&kvm->lock);
> > > -             if (kvm->created_vcpus)
> > > -                     goto disable_exits_unlock;
> > > +             if (kvm->created_vcpus) {
> > 
> > I retract my comment about using a request, I got ahead of myself.
> > 
> > Don't update vCPUs, the whole point of adding the !kvm->created_vcpus
> > check was to avoid having to update vCPUs when the per-VM behavior
> > changed.
> > 
> > In other words, keep the restriction and drop the request.
> > 
> 
> I see. If we keep the restriction here and not updating vCPUs when
> kvm->created_vcpus is true, the per-VM and per-vCPU assumption would be
> different here? Not sure if I understand right:
> For per-VM, we assume the per-VM cap enabling is only before vcpus creation.
> For per-vCPU cap enabling, we are able to toggle the disabled exits runtime.

Yep.  The main reason being that there's no use case for changing per-VM settings
after vCPUs are created.  I.e. we could lift the restriction in the future if a
use case pops up, but until then, keep things simple.

> If I understand correctly, this also makes sense though.

Paging this all back in...

There are two (sane) options for defining KVM's ABI:

  1) KVM combines the per-VM and per-vCPU settings
  2) The per-vCPU settings override the per-VM settings

This series implements (2).

For (1), KVM would need to recheck the per-VM state during the per-vCPU update,
e.g. instead of simply modifying the per-vCPU flags, the vCPU-scoped handler
for KVM_CAP_X86_DISABLE_EXITS would need to merge the incoming settings with the
existing kvm->arch.xxx_in_guest flags.

I like (2) because it's simpler to implement and document (merging state is always
messy) and is more flexible.  E.g. with (1), the only way to have per-vCPU settings
is for userspace to NOT set the per-VM disables and then set disables on a per-vCPU
basis.  Whereas with (2), userspace can set (or not) the per-VM disables and then
override as needed.

  reply	other threads:[~2022-07-20 19:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22  0:49 [RFC PATCH v4 0/7] KVM: x86: add per-vCPU exits disable capability Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 1/7] KVM: x86: only allow exits disable before vCPUs created Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 2/7] KVM: x86: Move *_in_guest power management flags to vCPU scope Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 3/7] KVM: x86: Reject disabling of MWAIT interception when not allowed Kechen Lu
2022-07-20 17:53   ` Sean Christopherson
2022-07-20 18:37     ` Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 4/7] KVM: x86: Let userspace re-enable previously disabled exits Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 5/7] KVM: x86: add vCPU scoped toggling for " Kechen Lu
2022-07-20 18:41   ` Sean Christopherson
2022-07-20 19:04     ` Kechen Lu
2022-07-20 19:30       ` Sean Christopherson [this message]
2022-07-20 20:23         ` Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 6/7] KVM: x86: Add a new guest_debug flag forcing exit to userspace Kechen Lu
2022-07-20 17:06   ` Sean Christopherson
2022-07-20 19:11     ` Kechen Lu
2022-06-22  0:49 ` [RFC PATCH v4 7/7] KVM: selftests: Add tests for VM and vCPU cap KVM_CAP_X86_DISABLE_EXITS Kechen Lu
2022-06-22  6:44   ` Huang, Shaoqin
2022-06-22 23:30     ` Kechen Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YthX0brdWCZVFB3n@google.com \
    --to=seanjc@google.com \
    --cc=chao.gao@intel.com \
    --cc=kechenl@nvidia.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=somduttar@nvidia.com \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox