public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: Alexander Graf <agraf@suse.de>
Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
Subject: [PATCH 3/7] KVM: PPC: Book3S HV: Fix check for running inside guest in global_invalidates()
Date: Sat, 24 May 2014 18:21:57 +1000	[thread overview]
Message-ID: <1400919721-14264-4-git-send-email-paulus@samba.org> (raw)
In-Reply-To: <1400919721-14264-1-git-send-email-paulus@samba.org>

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>
---
 arch/powerpc/kvm/book3s_hv_rm_mmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
index 1d6c56a..ac840c6 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)
 
 	/*
 	 * If there is only one vcore, and it's currently running,
+	 * as indicated by local_paca->kvm_hstate.kvm_vcpu being set,
 	 * we can use tlbiel as long as we mark all other physical
 	 * cores as potentially having stale TLB entries for this lpid.
 	 * If we're not using MMU notifiers, we never take pages away
 	 * from the guest, so we can use tlbiel if requested.
 	 * Otherwise, don't use tlbiel.
 	 */
-	if (kvm->arch.online_vcores == 1 && local_paca->kvm_hstate.kvm_vcore)
+	if (kvm->arch.online_vcores == 1 && local_paca->kvm_hstate.kvm_vcpu)
 		global = 0;
 	else if (kvm->arch.using_mmu_notifiers)
 		global = 1;
-- 
2.0.0.rc2


  parent reply	other threads:[~2014-05-24  8:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-24  8:21 [PATCH 0/7] Bug fixes for HV KVM Paul Mackerras
2014-05-24  8:21 ` [PATCH 1/7] KVM: PPC: Book3S: Add ONE_REG register names that were missed Paul Mackerras
2014-05-24  8:21 ` [PATCH 2/7] KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number Paul Mackerras
2014-05-24  8:21 ` Paul Mackerras [this message]
2014-05-24  8:21 ` [PATCH 4/7] KVM: PPC: Book3S HV: Fix dirty map for hugepages Paul Mackerras
2014-05-25 10:00   ` Alexander Graf
2014-05-26  3:30     ` Paul Mackerras
2014-05-24  8:21 ` [PATCH 5/7] KVM: PPC: Book3S HV: Make sure we don't miss dirty pages Paul Mackerras
2014-05-24  8:22 ` [PATCH 6/7] KVM: PPC: Book3S HV: Work around POWER8 performance monitor bugs Paul Mackerras
2014-05-25 10:07   ` Alexander Graf
2014-05-24  8:22 ` [PATCH 7/7] KVM: PPC: Book3S HV: Fix machine check delivery to guest Paul Mackerras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400919721-14264-4-git-send-email-paulus@samba.org \
    --to=paulus@samba.org \
    --cc=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox