Skip to content

Commit e3e880b

Browse files
Zenghui YuMarc Zyngier
authored andcommitted
KVM: arm64: Resolve all pending PC updates before immediate exit
Commit 26778aa ("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: 26778aa ("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
1 parent cb853de commit e3e880b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/arm64/kvm/arm.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
720720
return ret;
721721
}
722722

723-
if (run->immediate_exit)
724-
return -EINTR;
725-
726723
vcpu_load(vcpu);
727724

725+
if (run->immediate_exit) {
726+
ret = -EINTR;
727+
goto out;
728+
}
729+
728730
kvm_sigset_activate(vcpu);
729731

730732
ret = 1;
@@ -897,6 +899,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
897899

898900
kvm_sigset_deactivate(vcpu);
899901

902+
out:
900903
/*
901904
* In the unlikely event that we are returning to userspace
902905
* with pending exceptions or PC adjustment, commit these

0 commit comments

Comments
 (0)