KVM: x86: Explicitly pass an exception struct to check_intercept
authorSean Christopherson <sean.j.christopherson@intel.com>
Tue, 18 Feb 2020 23:29:42 +0000 (15:29 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 16 Mar 2020 16:57:50 +0000 (17:57 +0100)
Explicitly pass an exception struct when checking for intercept from
the emulator, which eliminates the last reference to arch.emulate_ctxt
in vendor specific code.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/svm.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c

index 316ec6c..af42644 100644 (file)
@@ -1170,7 +1170,8 @@ struct kvm_x86_ops {
 
        int (*check_intercept)(struct kvm_vcpu *vcpu,
                               struct x86_instruction_info *info,
-                              enum x86_intercept_stage stage);
+                              enum x86_intercept_stage stage,
+                              struct x86_exception *exception);
        void (*handle_exit_irqoff)(struct kvm_vcpu *vcpu,
                enum exit_fastpath_completion *exit_fastpath);
        bool (*mpx_supported)(void);
index 48c9390..7f32c40 100644 (file)
@@ -6175,7 +6175,8 @@ static const struct __x86_intercept {
 
 static int svm_check_intercept(struct kvm_vcpu *vcpu,
                               struct x86_instruction_info *info,
-                              enum x86_intercept_stage stage)
+                              enum x86_intercept_stage stage,
+                              struct x86_exception *exception)
 {
        struct vcpu_svm *svm = to_svm(vcpu);
        int vmexit, ret = X86EMUL_CONTINUE;
index 743b816..57742dd 100644 (file)
@@ -7174,10 +7174,10 @@ static int vmx_check_intercept_io(struct kvm_vcpu *vcpu,
 
 static int vmx_check_intercept(struct kvm_vcpu *vcpu,
                               struct x86_instruction_info *info,
-                              enum x86_intercept_stage stage)
+                              enum x86_intercept_stage stage,
+                              struct x86_exception *exception)
 {
        struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
-       struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
 
        switch (info->intercept) {
        /*
@@ -7186,8 +7186,8 @@ static int vmx_check_intercept(struct kvm_vcpu *vcpu,
         */
        case x86_intercept_rdtscp:
                if (!nested_cpu_has2(vmcs12, SECONDARY_EXEC_RDTSCP)) {
-                       ctxt->exception.vector = UD_VECTOR;
-                       ctxt->exception.error_code_valid = false;
+                       exception->vector = UD_VECTOR;
+                       exception->error_code_valid = false;
                        return X86EMUL_PROPAGATE_FAULT;
                }
                break;
index fbf68c3..762a682 100644 (file)
@@ -6212,7 +6212,8 @@ static int emulator_intercept(struct x86_emulate_ctxt *ctxt,
                              struct x86_instruction_info *info,
                              enum x86_intercept_stage stage)
 {
-       return kvm_x86_ops->check_intercept(emul_to_vcpu(ctxt), info, stage);
+       return kvm_x86_ops->check_intercept(emul_to_vcpu(ctxt), info, stage,
+                                           &ctxt->exception);
 }
 
 static bool emulator_get_cpuid(struct x86_emulate_ctxt *ctxt,