]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: x86: Capture "struct x86_exception" in inject_emulated_exception()
authorHou Wenlong <houwenlong.hwl@antgroup.com>
Fri, 15 May 2026 22:26:30 +0000 (15:26 -0700)
committerSean Christopherson <seanjc@google.com>
Thu, 21 May 2026 21:21:28 +0000 (14:21 -0700)
As all callers in inject_emulated_exception() use "struct x86_exception"
directly, capture it locally instead of using the context.

No functional change intended.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
Reviewed-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260515222638.1949982-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c

index b01f9a4d33630ba80f03b17ab2609ac8b0ca353c..6934c0d01419ffb6d45a260f5a9bf538161f9f17 100644 (file)
@@ -8979,15 +8979,14 @@ static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
 
 static void inject_emulated_exception(struct kvm_vcpu *vcpu)
 {
-       struct x86_emulate_ctxt *ctxt = vcpu->arch.emulate_ctxt;
+       struct x86_exception *ex = &vcpu->arch.emulate_ctxt->exception;
 
-       if (ctxt->exception.vector == PF_VECTOR)
-               kvm_inject_emulated_page_fault(vcpu, &ctxt->exception);
-       else if (ctxt->exception.error_code_valid)
-               kvm_queue_exception_e(vcpu, ctxt->exception.vector,
-                                     ctxt->exception.error_code);
+       if (ex->vector == PF_VECTOR)
+               kvm_inject_emulated_page_fault(vcpu, ex);
+       else if (ex->error_code_valid)
+               kvm_queue_exception_e(vcpu, ex->vector, ex->error_code);
        else
-               kvm_queue_exception(vcpu, ctxt->exception.vector);
+               kvm_queue_exception(vcpu, ex->vector);
 }
 
 static struct x86_emulate_ctxt *alloc_emulate_ctxt(struct kvm_vcpu *vcpu)