aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2010-08-02 10:46:44 -0400
committerAvi Kivity <avi@redhat.com>2010-10-24 04:50:32 -0400
commit52c65a30a5c6f31cd66dba57c22d18cafa5e327f (patch)
treea2bb3effc2bfac345335bfecbdc9be52dafc7c00
parent4132779b1718f066ec2d06a71c8958039865cd49 (diff)
KVM: SVM: Check for nested vmrun intercept before emulating vmrun
This patch lets the nested vmrun fail if the L1 hypervisor has not intercepted vmrun. This fixes the "vmrun intercept check" unit test. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/kvm/svm.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 116e0341bf4c..a0e5c7e26104 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2014,6 +2014,14 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
2014 return true; 2014 return true;
2015} 2015}
2016 2016
2017static bool nested_vmcb_checks(struct vmcb *vmcb)
2018{
2019 if ((vmcb->control.intercept & (1ULL << INTERCEPT_VMRUN)) == 0)
2020 return false;
2021
2022 return true;
2023}
2024
2017static bool nested_svm_vmrun(struct vcpu_svm *svm) 2025static bool nested_svm_vmrun(struct vcpu_svm *svm)
2018{ 2026{
2019 struct vmcb *nested_vmcb; 2027 struct vmcb *nested_vmcb;
@@ -2028,6 +2036,17 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm)
2028 if (!nested_vmcb) 2036 if (!nested_vmcb)
2029 return false; 2037 return false;
2030 2038
2039 if (!nested_vmcb_checks(nested_vmcb)) {
2040 nested_vmcb->control.exit_code = SVM_EXIT_ERR;
2041 nested_vmcb->control.exit_code_hi = 0;
2042 nested_vmcb->control.exit_info_1 = 0;
2043 nested_vmcb->control.exit_info_2 = 0;
2044
2045 nested_svm_unmap(page);
2046
2047 return false;
2048 }
2049
2031 trace_kvm_nested_vmrun(svm->vmcb->save.rip - 3, vmcb_gpa, 2050 trace_kvm_nested_vmrun(svm->vmcb->save.rip - 3, vmcb_gpa,
2032 nested_vmcb->save.rip, 2051 nested_vmcb->save.rip,
2033 nested_vmcb->control.int_ctl, 2052 nested_vmcb->control.int_ctl,