Skip to content

Commit 545f53b

Browse files
Zenghui YuWill Deacon
Zenghui Yu
authored and
Will Deacon
committed
UPSTREAM: KVM: arm64: Resolve all pending PC updates before immediate exit
Commit 26778aaa134a ("KVM: arm64: Commit pending PC adjustemnts before returning to userspace") fixed the PC updating issue by forcing an explicit synchronisation of the exception state on vcpu exit to userspace. However, we forgot to take into account the case where immediate_exit is set by userspace and KVM_RUN will exit immediately. Fix it by resolving all pending PC updates before returning to userspace. Since __kvm_adjust_pc() relies on a loaded vcpu context, I moved the immediate_exit checking right after vcpu_load(). We will get some overhead if immediate_exit is true (which should hopefully be rare). Fixes: 26778aaa134a ("KVM: arm64: Commit pending PC adjustemnts before returning to userspace") Signed-off-by: Zenghui Yu <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] # 5.11 (cherry picked from commit e3e880bb1518eb10a4b4bb4344ed614d6856f190) Signed-off-by: Will Deacon <[email protected]> Bug: 190594147 Change-Id: I9a8dd5cebd950a578fb6fbde1d302474b6dffdd4
1 parent 120bb2d commit 545f53b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/arm64/kvm/arm.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -727,11 +727,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
727727
return ret;
728728
}
729729

730-
if (run->immediate_exit)
731-
return -EINTR;
732-
733730
vcpu_load(vcpu);
734731

732+
if (run->immediate_exit) {
733+
ret = -EINTR;
734+
goto out;
735+
}
736+
735737
kvm_sigset_activate(vcpu);
736738

737739
ret = 1;
@@ -904,6 +906,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
904906

905907
kvm_sigset_deactivate(vcpu);
906908

909+
out:
907910
/*
908911
* In the unlikely event that we are returning to userspace
909912
* with pending exceptions or PC adjustment, commit these

0 commit comments

Comments
 (0)