mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: bsd@redhat.com, Wanpeng Li <wanpeng.li@hotmail.com>
Subject: [FYI PATCH 18/20] KVM: nVMX: emulate the INVVPID instruction
Date: Mon, 28 Sep 2015 12:39:03 +0200	[thread overview]
Message-ID: <1443436745-38086-19-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1443436745-38086-1-git-send-email-pbonzini@redhat.com>

From: Wanpeng Li <wanpeng.li@hotmail.com>

Add the INVVPID instruction emulation.

Reviewed-by: Wincy Van <fanwenyi0529@gmail.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/include/asm/vmx.h |  1 +
 arch/x86/kvm/vmx.c         | 23 ++++++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 448b7ca61aee..53c9567a29d1 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -397,6 +397,7 @@ enum vmcs_field {
 #define IDENTITY_PAGETABLE_PRIVATE_MEMSLOT	(KVM_USER_MEM_SLOTS + 2)
 
 #define VMX_NR_VPIDS				(1 << 16)
+#define VMX_VPID_EXTENT_INDIVIDUAL_ADDR 	0
 #define VMX_VPID_EXTENT_SINGLE_CONTEXT		1
 #define VMX_VPID_EXTENT_ALL_CONTEXT		2
 
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index e1cb4aa026a2..bb7ae30caa13 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -7186,7 +7186,28 @@ static int handle_invept(struct kvm_vcpu *vcpu)
 
 static int handle_invvpid(struct kvm_vcpu *vcpu)
 {
-	kvm_queue_exception(vcpu, UD_VECTOR);
+	u32 vmx_instruction_info;
+	unsigned long type;
+
+	if (!nested_vmx_check_permission(vcpu))
+		return 1;
+
+	vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO);
+	type = kvm_register_readl(vcpu, (vmx_instruction_info >> 28) & 0xf);
+
+	switch (type) {
+	case VMX_VPID_EXTENT_INDIVIDUAL_ADDR:
+	case VMX_VPID_EXTENT_SINGLE_CONTEXT:
+	case VMX_VPID_EXTENT_ALL_CONTEXT:
+		vmx_flush_tlb(vcpu);
+		nested_vmx_succeed(vcpu);
+		break;
+	default:
+		nested_vmx_failInvalid(vcpu);
+		break;
+	}
+
+	skip_emulated_instruction(vcpu);
 	return 1;
 }
 
-- 
1.8.3.1



  parent reply	other threads:[~2015-09-28 10:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28 10:38 [FYI PATCH 00/20] kvm/queue will be merged soon to kvm/next Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 01/20] KVM: x86: set TMR when the interrupt is accepted Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 02/20] KVM: x86: store IOAPIC-handled vectors in each VCPU Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 03/20] KVM: x86: replace vm_has_apicv hook with cpu_uses_apicv Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 04/20] KVM: x86: introduce lapic_in_kernel Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 05/20] KVM: x86: unify handling of interrupt window Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 06/20] KVM: x86: Split the APIC from the rest of IRQCHIP Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 07/20] KVM: x86: Add KVM exit for IOAPIC EOIs Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 08/20] KVM: x86: Add EOI exit bitmap inference Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 09/20] KVM: x86: Add support for local interrupt requests from userspace Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 10/20] kvm: use kmalloc() instead of kzalloc() during iodev register/unregister Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 11/20] kvm: add tracepoint for fast mmio Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 12/20] kvm: add capability for any-length ioeventfds Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 13/20] kvm/x86: Hyper-V HV_X64_MSR_RESET msr Paolo Bonzini
2015-09-28 10:38 ` [FYI PATCH 14/20] kvm/x86: Hyper-V HV_X64_MSR_VP_INDEX export for QEMU Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 15/20] kvm/x86: Hyper-V HV_X64_MSR_VP_RUNTIME support Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 16/20] KVM: VMX: adjust interface to allocate/free_vpid Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 17/20] KVM: VMX: introduce __vmx_flush_tlb to handle specific vpid Paolo Bonzini
2015-09-28 10:39 ` Paolo Bonzini [this message]
2015-09-28 10:39 ` [FYI PATCH 19/20] KVM: nVMX: nested VPID emulation Paolo Bonzini
2015-09-28 10:39 ` [FYI PATCH 20/20] KVM: vmx: disable posted interrupts if no local APIC 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=1443436745-38086-19-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=bsd@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wanpeng.li@hotmail.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

all inboxes | Powered by JetHome®