From: Paolo Bonzini <pbonzini@redhat.com>
To: Jim Mattson <jmattson@google.com>
Cc: kvm list <kvm@vger.kernel.org>, Oliver Upton <oupton@google.com>
Subject: Re: [PATCH 02/12] KVM: x86: Wake up a vCPU when kvm_check_nested_events fails
Date: Mon, 24 May 2021 18:43:39 +0200 [thread overview]
Message-ID: <e2ed4a75-e7d2-e391-0a19-5977bf087cdf@redhat.com> (raw)
In-Reply-To: <CALMp9eQ0LQoesyRYA+PN=nzjLDVXjpNw6OxgupmL8vOgWqjiMA@mail.gmail.com>
On 24/05/21 18:39, Jim Mattson wrote:
> Without this patch, the accompanying selftest never wakes up from HLT
> in L2. If you can get the selftest to work without this patch, feel
> free to drop it.
Ok, that's a pretty good reason. I'll try to debug it.
Paolo
> On Mon, May 24, 2021 at 8:43 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> On 21/05/21 01:03, Jim Mattson wrote:
>>> At present, there are two reasons why kvm_check_nested_events may
>>> return a non-zero value:
>>>
>>> 1) we just emulated a shutdown VM-exit from L2 to L1.
>>> 2) we need to perform an immediate VM-exit from vmcs02.
>>>
>>> In either case, transition the vCPU to "running."
>>>
>>> Signed-off-by: Jim Mattson <jmattson@google.com>
>>> Reviewed-by: Oliver Upton <oupton@google.com>
>>> ---
>>> arch/x86/kvm/x86.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>> index d517460db413..d3fea8ea3628 100644
>>> --- a/arch/x86/kvm/x86.c
>>> +++ b/arch/x86/kvm/x86.c
>>> @@ -9468,8 +9468,8 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu)
>>>
>>> static inline bool kvm_vcpu_running(struct kvm_vcpu *vcpu)
>>> {
>>> - if (is_guest_mode(vcpu))
>>> - kvm_check_nested_events(vcpu);
>>> + if (is_guest_mode(vcpu) && kvm_check_nested_events(vcpu))
>>> + return true;
>>
>> That doesn't make the vCPU running. You still need to go through
>> vcpu_block, which would properly update the vCPU's mp_state.
>>
>> What is this patch fixing?
>>
>> Paolo
>>
>>> return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE &&
>>> !vcpu->arch.apf.halted);
>>>
>>
>
next prev parent reply other threads:[~2021-05-24 16:43 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-20 23:03 [PATCH 00/12] KVM: nVMX: Fix vmcs02 PID use-after-free issue Jim Mattson
2021-05-20 23:03 ` [PATCH 01/12] KVM: x86: Remove guest mode check from kvm_check_nested_events Jim Mattson
2021-05-20 23:03 ` [PATCH 02/12] KVM: x86: Wake up a vCPU when kvm_check_nested_events fails Jim Mattson
2021-05-24 15:43 ` Paolo Bonzini
2021-05-24 16:39 ` Jim Mattson
2021-05-24 16:43 ` Paolo Bonzini [this message]
2021-05-24 17:10 ` Jim Mattson
2021-05-24 23:10 ` Sean Christopherson
2021-05-24 23:23 ` Jim Mattson
2021-05-24 23:24 ` Sean Christopherson
2021-05-24 23:29 ` Jim Mattson
2021-05-24 23:34 ` Sean Christopherson
2021-05-20 23:03 ` [PATCH 03/12] KVM: nVMX: Add a return code to vmx_complete_nested_posted_interrupt Jim Mattson
2021-05-20 23:03 ` [PATCH 04/12] KVM: x86: Add a return code to inject_pending_event Jim Mattson
2021-05-20 23:03 ` [PATCH 05/12] KVM: x86: Add a return code to kvm_apic_accept_events Jim Mattson
2021-05-25 19:24 ` Reiji Watanabe
2021-05-25 20:35 ` Jim Mattson
2021-05-20 23:03 ` [PATCH 06/12] KVM: nVMX: Fail on MMIO completion for nested posted interrupts Jim Mattson
2021-05-20 23:03 ` [PATCH 07/12] KVM: nVMX: Disable vmcs02 posted interrupts if vmcs12 PID isn't mappable Jim Mattson
2021-05-24 23:21 ` Sean Christopherson
2021-05-24 23:27 ` Jim Mattson
2021-05-24 23:45 ` Sean Christopherson
2021-05-25 0:03 ` Jim Mattson
2021-05-25 0:11 ` Sean Christopherson
2021-05-25 0:15 ` Jim Mattson
2021-05-25 0:57 ` Sean Christopherson
2021-05-20 23:03 ` [PATCH 08/12] KVM: selftests: Move APIC definitions into a separate file Jim Mattson
2021-05-20 23:03 ` [PATCH 09/12] KVM: selftests: Hoist APIC functions out of individual tests Jim Mattson
2021-05-20 23:03 ` [PATCH 10/12] KVM: selftests: Introduce x2APIC register manipulation functions Jim Mattson
2021-05-20 23:03 ` [PATCH 11/12] KVM: selftests: Introduce prepare_tpr_shadow Jim Mattson
2021-05-20 23:03 ` [PATCH 12/12] KVM: selftests: Add a test of an unbacked nested PI descriptor Jim Mattson
2021-05-21 0:58 ` [PATCH 00/12] KVM: nVMX: Fix vmcs02 PID use-after-free issue Sean Christopherson
2021-05-21 12:04 ` Jim Mattson
2021-05-24 15:50 ` Paolo Bonzini
2021-05-24 16:46 ` Paolo Bonzini
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=e2ed4a75-e7d2-e391-0a19-5977bf087cdf@redhat.com \
--to=pbonzini@redhat.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=oupton@google.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;
as well as URLs for NNTP newsgroup(s).