aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorNadav Har'El <nyh@il.ibm.com>2011-05-25 16:08:00 -0400
committerAvi Kivity <avi@redhat.com>2011-07-12 04:45:13 -0400
commit6a4d7550601b5b17df227959bdbec208384f729c (patch)
treeccc7403ae0e31c34ad5f769bbcaf445817092a6b /arch/x86/kvm
parent63846663eac783eabbc1ab7c325e41a3627d986f (diff)
KVM: nVMX: Implement VMPTRST
This patch implements the VMPTRST instruction. Signed-off-by: Nadav Har'El <nyh@il.ibm.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/vmx.c28
-rw-r--r--arch/x86/kvm/x86.c3
-rw-r--r--arch/x86/kvm/x86.h4
3 files changed, 33 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 54866f538c6f..2bc521c9dabe 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4937,6 +4937,32 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
4937 return 1; 4937 return 1;
4938} 4938}
4939 4939
4940/* Emulate the VMPTRST instruction */
4941static int handle_vmptrst(struct kvm_vcpu *vcpu)
4942{
4943 unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
4944 u32 vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO);
4945 gva_t vmcs_gva;
4946 struct x86_exception e;
4947
4948 if (!nested_vmx_check_permission(vcpu))
4949 return 1;
4950
4951 if (get_vmx_mem_address(vcpu, exit_qualification,
4952 vmx_instruction_info, &vmcs_gva))
4953 return 1;
4954 /* ok to use *_system, as nested_vmx_check_permission verified cpl=0 */
4955 if (kvm_write_guest_virt_system(&vcpu->arch.emulate_ctxt, vmcs_gva,
4956 (void *)&to_vmx(vcpu)->nested.current_vmptr,
4957 sizeof(u64), &e)) {
4958 kvm_inject_page_fault(vcpu, &e);
4959 return 1;
4960 }
4961 nested_vmx_succeed(vcpu);
4962 skip_emulated_instruction(vcpu);
4963 return 1;
4964}
4965
4940/* 4966/*
4941 * The exit handlers return 1 if the exit was handled fully and guest execution 4967 * The exit handlers return 1 if the exit was handled fully and guest execution
4942 * may resume. Otherwise they set the kvm_run parameter to indicate what needs 4968 * may resume. Otherwise they set the kvm_run parameter to indicate what needs
@@ -4961,7 +4987,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
4961 [EXIT_REASON_VMCLEAR] = handle_vmclear, 4987 [EXIT_REASON_VMCLEAR] = handle_vmclear,
4962 [EXIT_REASON_VMLAUNCH] = handle_vmx_insn, 4988 [EXIT_REASON_VMLAUNCH] = handle_vmx_insn,
4963 [EXIT_REASON_VMPTRLD] = handle_vmptrld, 4989 [EXIT_REASON_VMPTRLD] = handle_vmptrld,
4964 [EXIT_REASON_VMPTRST] = handle_vmx_insn, 4990 [EXIT_REASON_VMPTRST] = handle_vmptrst,
4965 [EXIT_REASON_VMREAD] = handle_vmx_insn, 4991 [EXIT_REASON_VMREAD] = handle_vmx_insn,
4966 [EXIT_REASON_VMRESUME] = handle_vmx_insn, 4992 [EXIT_REASON_VMRESUME] = handle_vmx_insn,
4967 [EXIT_REASON_VMWRITE] = handle_vmx_insn, 4993 [EXIT_REASON_VMWRITE] = handle_vmx_insn,
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c1b5a1817e43..de262a086863 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3869,7 +3869,7 @@ static int kvm_read_guest_virt_system(struct x86_emulate_ctxt *ctxt,
3869 return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, 0, exception); 3869 return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, 0, exception);
3870} 3870}
3871 3871
3872static int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt, 3872int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
3873 gva_t addr, void *val, 3873 gva_t addr, void *val,
3874 unsigned int bytes, 3874 unsigned int bytes,
3875 struct x86_exception *exception) 3875 struct x86_exception *exception)
@@ -3901,6 +3901,7 @@ static int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
3901out: 3901out:
3902 return r; 3902 return r;
3903} 3903}
3904EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system);
3904 3905
3905static int emulator_read_emulated(struct x86_emulate_ctxt *ctxt, 3906static int emulator_read_emulated(struct x86_emulate_ctxt *ctxt,
3906 unsigned long addr, 3907 unsigned long addr,
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 6f150539b262..256da82856bd 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -85,4 +85,8 @@ int kvm_read_guest_virt(struct x86_emulate_ctxt *ctxt,
85 gva_t addr, void *val, unsigned int bytes, 85 gva_t addr, void *val, unsigned int bytes,
86 struct x86_exception *exception); 86 struct x86_exception *exception);
87 87
88int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
89 gva_t addr, void *val, unsigned int bytes,
90 struct x86_exception *exception);
91
88#endif 92#endif