Skip to content

Commit 52dad81

Browse files
committed
Merge tag 'kvmarm-fixes-7.0-4' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 7.0, take #4 - Clear the pending exception state from a vcpu coming out of reset, as it could otherwise affect the first instruction executed in the guest. - Fix the address translation emulation icode to set the Hardware Access bit on the correct PTE instead of some other location.
2 parents 12fd965 + 0496acc commit 52dad81

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

arch/arm64/kvm/at.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,7 @@ int __kvm_at_swap_desc(struct kvm *kvm, gpa_t ipa, u64 old, u64 new)
17531753
if (!writable)
17541754
return -EPERM;
17551755

1756-
ptep = (u64 __user *)hva + offset;
1756+
ptep = (void __user *)hva + offset;
17571757
if (cpus_have_final_cap(ARM64_HAS_LSE_ATOMICS))
17581758
r = __lse_swap_desc(ptep, old, new);
17591759
else

arch/arm64/kvm/reset.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,20 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
247247
kvm_vcpu_set_be(vcpu);
248248

249249
*vcpu_pc(vcpu) = target_pc;
250+
251+
/*
252+
* We may come from a state where either a PC update was
253+
* pending (SMC call resulting in PC being increpented to
254+
* skip the SMC) or a pending exception. Make sure we get
255+
* rid of all that, as this cannot be valid out of reset.
256+
*
257+
* Note that clearing the exception mask also clears PC
258+
* updates, but that's an implementation detail, and we
259+
* really want to make it explicit.
260+
*/
261+
vcpu_clear_flag(vcpu, PENDING_EXCEPTION);
262+
vcpu_clear_flag(vcpu, EXCEPT_MASK);
263+
vcpu_clear_flag(vcpu, INCREMENT_PC);
250264
vcpu_set_reg(vcpu, 0, reset_state.r0);
251265
}
252266

0 commit comments

Comments
 (0)