From: Paolo Bonzini <pbonzini@redhat.com>
To: Bandan Das <bsd@redhat.com>, Haozhong Zhang <haozhong.zhang@intel.com>
Cc: kvm@vger.kernel.org, Gleb Natapov <gleb@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: nVMX: remove incorrect vpid check in nested invvpid emulation
Date: Wed, 25 Nov 2015 17:21:20 +0100 [thread overview]
Message-ID: <5655E000.9000400@redhat.com> (raw)
In-Reply-To: <jpgr3jehylb.fsf@linux.bootlegged.copy>
On 25/11/2015 16:45, Bandan Das wrote:
> Haozhong Zhang <haozhong.zhang@intel.com> writes:
>
>> This patch removes the vpid check when emulating nested invvpid
>> instruction of type all-contexts invalidation. The existing code is
>> incorrect because:
>> (1) According to Intel SDM Vol 3, Section "INVVPID - Invalidate
>> Translations Based on VPID", invvpid instruction does not check
>> vpid in the invvpid descriptor when its type is all-contexts
>> invalidation.
>
> But iirc isn't vpid=0 reserved for root mode ? I think we don't want
> L1 hypervisor to be able do a invvpid(0).
The instruction simply "invalidates all mappings tagged with all
non-zero VPIDs", which in our case is all L0 mappings tagged with vpid02.
Paolo
>> (2) According to the same document, invvpid of type all-contexts
>> invalidation does not require there is an active VMCS, so/and
>> get_vmcs12() in the existing code may result in a NULL-pointer
>> dereference. In practice, it can crash both KVM itself and L1
>> hypervisors that use invvpid (e.g. Xen).
>
> If that is the case, then just check if it's null and return without
> doing anything.
>
>> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
>> ---
>> arch/x86/kvm/vmx.c | 5 -----
>> 1 file changed, 5 deletions(-)
>>
>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>> index 87acc52..af823a3 100644
>> --- a/arch/x86/kvm/vmx.c
>> +++ b/arch/x86/kvm/vmx.c
>> @@ -7394,11 +7394,6 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
>>
>> switch (type) {
>> case VMX_VPID_EXTENT_ALL_CONTEXT:
>> - if (get_vmcs12(vcpu)->virtual_processor_id == 0) {
>> - nested_vmx_failValid(vcpu,
>> - VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
>> - return 1;
>> - }
>> __vmx_flush_tlb(vcpu, to_vmx(vcpu)->nested.vpid02);
>> nested_vmx_succeed(vcpu);
>> break;
>
> I also noticed a BUG() here in the default. It might be a good idea to replace
> it with a WARN.
>
prev parent reply other threads:[~2015-11-25 16:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-25 9:21 [PATCH] KVM: nVMX: remove incorrect vpid check in nested invvpid emulation Haozhong Zhang
2015-11-25 15:45 ` Bandan Das
2015-11-25 16:18 ` Haozhong Zhang
2015-11-25 16:36 ` Bandan Das
2015-11-25 16:21 ` Paolo Bonzini [this message]
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=5655E000.9000400@redhat.com \
--to=pbonzini@redhat.com \
--cc=bsd@redhat.com \
--cc=gleb@kernel.org \
--cc=haozhong.zhang@intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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).