diff options
author | Paul Mackerras <paulus@samba.org> | 2014-05-26 05:48:36 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2014-05-30 08:26:28 -0400 |
commit | 55765483e1df8135102ae9ca77dccbca9a7a6184 (patch) | |
tree | 476ccf436ad7c734e32e47fd1a2b9aa779a99f8a /arch/powerpc/kvm | |
parent | e1d8a96daf641aea11c25268eab678a76215541a (diff) |
KVM: PPC: Book3S HV: Fix check for running inside guest in global_invalidates()
The global_invalidates() function contains a check that is intended
to tell whether we are currently executing in the context of a hypercall
issued by the guest. The reason is that the optimization of using a
local TLB invalidate instruction is only valid in that context. The
check was testing local_paca->kvm_hstate.kvm_vcore, which gets set
when entering the guest but no longer gets cleared when exiting the
guest. To fix this, we use the kvm_vcpu field instead, which does
get cleared when exiting the guest, by the kvmppc_release_hwthread()
calls inside kvmppc_run_core().
The effect of having the check wrong was that when kvmppc_do_h_remove()
got called from htab_write() on the destination machine during a
migration, it cleared the current cpu's bit in kvm->arch.need_tlb_flush.
This meant that when the guest started running in the destination VM,
it may miss out on doing a complete TLB flush, and therefore may end
up using stale TLB entries from a previous guest that used the same
LPID value.
This should make migration more reliable.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm')
-rw-r--r-- | arch/powerpc/kvm/book3s_hv_rm_mmu.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c index 1d6c56ad5b60..ac840c6dfa9b 100644 --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c | |||
@@ -42,13 +42,14 @@ static int global_invalidates(struct kvm *kvm, unsigned long flags) | |||
42 | 42 | ||
43 | /* | 43 | /* |
44 | * If there is only one vcore, and it's currently running, | 44 | * If there is only one vcore, and it's currently running, |
45 | * as indicated by local_paca->kvm_hstate.kvm_vcpu being set, | ||
45 | * we can use tlbiel as long as we mark all other physical | 46 | * we can use tlbiel as long as we mark all other physical |
46 | * cores as potentially having stale TLB entries for this lpid. | 47 | * cores as potentially having stale TLB entries for this lpid. |
47 | * If we're not using MMU notifiers, we never take pages away | 48 | * If we're not using MMU notifiers, we never take pages away |
48 | * from the guest, so we can use tlbiel if requested. | 49 | * from the guest, so we can use tlbiel if requested. |
49 | * Otherwise, don't use tlbiel. | 50 | * Otherwise, don't use tlbiel. |
50 | */ | 51 | */ |
51 | if (kvm->arch.online_vcores == 1 && local_paca->kvm_hstate.kvm_vcore) | 52 | if (kvm->arch.online_vcores == 1 && local_paca->kvm_hstate.kvm_vcpu) |
52 | global = 0; | 53 | global = 0; |
53 | else if (kvm->arch.using_mmu_notifiers) | 54 | else if (kvm->arch.using_mmu_notifiers) |
54 | global = 1; | 55 | global = 1; |