All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: Alexander Graf <agraf@suse.de>, kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 4/5] KVM: PPC: Book3S PR: Invalidate SLB entries properly
Date: Sat, 22 Jun 2013 17:15:24 +1000	[thread overview]
Message-ID: <20130622071524.GE2791@iris.ozlabs.ibm.com> (raw)
In-Reply-To: <20130622071244.GA2791@iris.ozlabs.ibm.com>

At present, if the guest creates a valid SLB (segment lookaside buffer)
entry with the slbmte instruction, then invalidates it with the slbie
instruction, then reads the entry with the slbmfee/slbmfev instructions,
the result of the slbmfee will have the valid bit set, even though the
entry is not actually considered valid by the host.  This is confusing,
if not worse.  This fixes it by zeroing out the orige and origv fields
of the SLB entry structure when the entry is invalidated.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
 arch/powerpc/kvm/book3s_64_mmu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
index 2e93bb5..7519124 100644
--- a/arch/powerpc/kvm/book3s_64_mmu.c
+++ b/arch/powerpc/kvm/book3s_64_mmu.c
@@ -376,6 +376,8 @@ static void kvmppc_mmu_book3s_64_slbie(struct kvm_vcpu *vcpu, u64 ea)
 	dprintk("KVM MMU: slbie(0x%llx, 0x%llx)\n", ea, slbe->esid);
 
 	slbe->valid = false;
+	slbe->orige = 0;
+	slbe->origv = 0;
 
 	kvmppc_mmu_map_segment(vcpu, ea);
 }
@@ -386,8 +388,11 @@ static void kvmppc_mmu_book3s_64_slbia(struct kvm_vcpu *vcpu)
 
 	dprintk("KVM MMU: slbia()\n");
 
-	for (i = 1; i < vcpu->arch.slb_nr; i++)
+	for (i = 1; i < vcpu->arch.slb_nr; i++) {
 		vcpu->arch.slb[i].valid = false;
+		vcpu->arch.slb[i].orige = 0;
+		vcpu->arch.slb[i].origv = 0;
+	}
 
 	if (vcpu->arch.shared->msr & MSR_IR) {
 		kvmppc_mmu_flush_segments(vcpu);
-- 
1.8.3.1


WARNING: multiple messages have this Message-ID (diff)
From: Paul Mackerras <paulus@samba.org>
To: Alexander Graf <agraf@suse.de>, kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 4/5] KVM: PPC: Book3S PR: Invalidate SLB entries properly
Date: Sat, 22 Jun 2013 07:15:24 +0000	[thread overview]
Message-ID: <20130622071524.GE2791@iris.ozlabs.ibm.com> (raw)
In-Reply-To: <20130622071244.GA2791@iris.ozlabs.ibm.com>

At present, if the guest creates a valid SLB (segment lookaside buffer)
entry with the slbmte instruction, then invalidates it with the slbie
instruction, then reads the entry with the slbmfee/slbmfev instructions,
the result of the slbmfee will have the valid bit set, even though the
entry is not actually considered valid by the host.  This is confusing,
if not worse.  This fixes it by zeroing out the orige and origv fields
of the SLB entry structure when the entry is invalidated.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
 arch/powerpc/kvm/book3s_64_mmu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
index 2e93bb5..7519124 100644
--- a/arch/powerpc/kvm/book3s_64_mmu.c
+++ b/arch/powerpc/kvm/book3s_64_mmu.c
@@ -376,6 +376,8 @@ static void kvmppc_mmu_book3s_64_slbie(struct kvm_vcpu *vcpu, u64 ea)
 	dprintk("KVM MMU: slbie(0x%llx, 0x%llx)\n", ea, slbe->esid);
 
 	slbe->valid = false;
+	slbe->orige = 0;
+	slbe->origv = 0;
 
 	kvmppc_mmu_map_segment(vcpu, ea);
 }
@@ -386,8 +388,11 @@ static void kvmppc_mmu_book3s_64_slbia(struct kvm_vcpu *vcpu)
 
 	dprintk("KVM MMU: slbia()\n");
 
-	for (i = 1; i < vcpu->arch.slb_nr; i++)
+	for (i = 1; i < vcpu->arch.slb_nr; i++) {
 		vcpu->arch.slb[i].valid = false;
+		vcpu->arch.slb[i].orige = 0;
+		vcpu->arch.slb[i].origv = 0;
+	}
 
 	if (vcpu->arch.shared->msr & MSR_IR) {
 		kvmppc_mmu_flush_segments(vcpu);
-- 
1.8.3.1


  parent reply	other threads:[~2013-06-22  7:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-22  7:12 [PATCH 0/5] Some fixes and improvements for PR KVM Paul Mackerras
2013-06-22  7:12 ` Paul Mackerras
2013-06-22  7:13 ` [PATCH 1/5] KVM: PPC: Book3S PR: Fix proto-VSID calculations Paul Mackerras
2013-06-22  7:13   ` Paul Mackerras
2013-06-22  7:14 ` [PATCH 2/5] KVM: PPC: Book3S PR: Fix invalidation of SLB entry 0 on guest entry Paul Mackerras
2013-06-22  7:14   ` Paul Mackerras
2013-06-22  7:14 ` [PATCH 3/5] KVM: PPC: Book3S PR: Don't keep scanning HPTEG after we find a match Paul Mackerras
2013-06-22  7:14   ` Paul Mackerras
2013-06-22 17:42   ` Alexander Graf
2013-06-22 17:42     ` Alexander Graf
2013-06-22  7:15 ` Paul Mackerras [this message]
2013-06-22  7:15   ` [PATCH 4/5] KVM: PPC: Book3S PR: Invalidate SLB entries properly Paul Mackerras
2013-06-22 17:48   ` Alexander Graf
2013-06-22 17:48     ` Alexander Graf
2013-06-22 23:30     ` Paul Mackerras
2013-06-22 23:30       ` Paul Mackerras
2013-06-22 23:38       ` Alexander Graf
2013-06-22 23:38         ` Alexander Graf
2013-06-22  7:16 ` [PATCH 5/5] KVM: PPC: Book3S PR: Allow guest to use 1TB segments Paul Mackerras
2013-06-22  7:16   ` Paul Mackerras
2013-06-22 17:57 ` [PATCH 0/5] Some fixes and improvements for PR KVM Alexander Graf
2013-06-22 17:57   ` Alexander Graf

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=20130622071524.GE2791@iris.ozlabs.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.