From: Lai Jiangshan <jiangshan.ljs@xxxxxxxxxxxx> For PVM, the exception is injected and delivered directly in the callback before VM enter, so it will clear 'vcpu->arch.exception.injected'. Therefore, if 'vcpu->arch.exception.injected' is set to true after the vendor callback, it may inject the same exception repeatedly in PVM. To address this, move the setting of 'vcpu->arch.exception.injected' to true before the vendor callback in kvm_inject_exception(). This adjustment has no influence on VMX/SVM, as they don't change it in their callbacks. No functional change. Signed-off-by: Lai Jiangshan <jiangshan.ljs@xxxxxxxxxxxx> Signed-off-by: Hou Wenlong <houwenlong.hwl@xxxxxxxxxxxx> --- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1a3aaa7dafae..35ad6dd5eaf6 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10137,6 +10137,7 @@ static void kvm_inject_exception(struct kvm_vcpu *vcpu) vcpu->arch.exception.error_code, vcpu->arch.exception.injected); + vcpu->arch.exception.injected = true; static_call(kvm_x86_inject_exception)(vcpu); } @@ -10288,7 +10289,6 @@ static int kvm_check_and_inject_events(struct kvm_vcpu *vcpu, kvm_inject_exception(vcpu); vcpu->arch.exception.pending = false; - vcpu->arch.exception.injected = true; can_inject = false; } -- 2.19.1.6.gb485710b