From: Sean Christopherson <seanjc@google.com>
To: Yuan Yao <yuan.yao@linux.intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Like Xu <like.xu.linux@gmail.com>
Subject: Re: [PATCH 2/4] KVM: x86: Rely solely on preempted_in_kernel flag for directed yield
Date: Wed, 10 Jan 2024 09:13:28 -0800 [thread overview]
Message-ID: <ZZ7QOMxBwHZW8oij@google.com> (raw)
In-Reply-To: <20240110075520.psahkt47hoqodqqf@yy-desk-7060>
On Wed, Jan 10, 2024, Yuan Yao wrote:
> On Tue, Jan 09, 2024 at 04:39:36PM -0800, Sean Christopherson wrote:
> > @@ -13093,7 +13092,7 @@ bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *vcpu)
> >
> > bool kvm_arch_vcpu_preempted_in_kernel(struct kvm_vcpu *vcpu)
> > {
> > - return kvm_arch_vcpu_in_kernel(vcpu);
> > + return vcpu->arch.preempted_in_kernel;
> > }
> >
> > bool kvm_arch_dy_runnable(struct kvm_vcpu *vcpu)
> > @@ -13116,9 +13115,6 @@ bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)
> > if (vcpu->arch.guest_state_protected)
> > return true;
> >
> > - if (vcpu != kvm_get_running_vcpu())
> > - return vcpu->arch.preempted_in_kernel;
> > -
>
> Now this function accepts vcpu parameter but can only get information from
> "current" vcpu loaded on hardware for VMX. I'm not sure whether need
> "WARN_ON(vcpu != kvm_get_running_vcpu())" here to guard it. i.e.
> kvm_guest_state() still uses this function (although it did chekcing before).
Eh, I don't think it's worth adding a one-off kvm_get_running_vcpu() sanity check.
In the vast majority of cases, if VMREAD or VMWRITE is used improperly, the
instruction will fail at some point due to the pCPU not having any VMCS loaded.
It's really just cross-vCPU checks that could silently do the wrong thing, and
those flows are so few and far between that I'm comfortable taking a "just get
it right stance".
If we want to add sanity checks, I think my vote would be to plumb @vcpu down
into vmcs_read{16,32,64,l} and add sanity checks there, probably with some sort
of guard so that the sanity checks can be enabled only for debug kernels.
next prev parent reply other threads:[~2024-01-10 17:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 0:39 [PATCH 0/4] KVM: Clean up "preempted in-kernel" logic Sean Christopherson
2024-01-10 0:39 ` [PATCH 1/4] KVM: Add dedicated arch hook for querying if vCPU was preempted in-kernel Sean Christopherson
2024-01-11 12:48 ` Yuan Yao
2024-01-10 0:39 ` [PATCH 2/4] KVM: x86: Rely solely on preempted_in_kernel flag for directed yield Sean Christopherson
2024-01-10 7:55 ` Yuan Yao
2024-01-10 17:13 ` Sean Christopherson [this message]
2024-01-11 12:47 ` Yuan Yao
2024-01-10 0:39 ` [PATCH 3/4] KVM: x86: Clean up directed yield API for "has pending interrupt" Sean Christopherson
2024-01-11 12:49 ` Yuan Yao
2024-01-10 0:39 ` [PATCH 4/4] KVM: Add a comment explaining the directed yield pending interrupt logic Sean Christopherson
2024-02-23 1:35 ` [PATCH 0/4] KVM: Clean up "preempted in-kernel" logic Sean Christopherson
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=ZZ7QOMxBwHZW8oij@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yuan.yao@linux.intel.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