public inbox for kvm@vger.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 3/5] KVM: PPC: Book3S PR: Don't keep scanning HPTEG after we find a match
Date: Sat, 22 Jun 2013 17:14:48 +1000	[thread overview]
Message-ID: <20130622071448.GD2791@iris.ozlabs.ibm.com> (raw)
In-Reply-To: <20130622071244.GA2791@iris.ozlabs.ibm.com>

The loop in kvmppc_mmu_book3s_64_xlate() that looks up a translation
in the guest hashed page table (HPT) keeps going if it finds an
HPTE that matches but doesn't allow access.  This is incorrect; it
is different from what the hardware does, and there should never be
more than one matching HPTE anyway.  This fixes it to stop when any
matching HPTE is found.

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

diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
index b871721..2e93bb5 100644
--- a/arch/powerpc/kvm/book3s_64_mmu.c
+++ b/arch/powerpc/kvm/book3s_64_mmu.c
@@ -167,7 +167,6 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
 	int i;
 	u8 key = 0;
 	bool found = false;
-	bool perm_err = false;
 	int second = 0;
 	ulong mp_ea = vcpu->arch.magic_page_ea;
 
@@ -248,11 +247,6 @@ do_second:
 				break;
 			}
 
-			if (!gpte->may_read) {
-				perm_err = true;
-				continue;
-			}
-
 			dprintk("KVM MMU: Translated 0x%lx [0x%llx] -> 0x%llx "
 				"-> 0x%lx\n",
 				eaddr, avpn, gpte->vpage, gpte->raddr);
@@ -281,6 +275,8 @@ do_second:
 		if (pteg[i+1] != oldr)
 			copy_to_user((void __user *)ptegp, pteg, sizeof(pteg));
 
+		if (!gpte->may_read)
+			return -EPERM;
 		return 0;
 	} else {
 		dprintk("KVM MMU: No PTE found (ea=0x%lx sdr1=0x%llx "
@@ -296,13 +292,7 @@ do_second:
 		}
 	}
 
-
 no_page_found:
-
-
-	if (perm_err)
-		return -EPERM;
-
 	return -ENOENT;
 
 no_seg_found:
-- 
1.8.3.1


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

Thread overview: 11+ 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:13 ` [PATCH 1/5] KVM: PPC: Book3S PR: Fix proto-VSID calculations 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 [this message]
2013-06-22 17:42   ` [PATCH 3/5] KVM: PPC: Book3S PR: Don't keep scanning HPTEG after we find a match Alexander Graf
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 23:30     ` Paul Mackerras
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 17:57 ` [PATCH 0/5] Some fixes and improvements for PR KVM 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=20130622071448.GD2791@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox