From: Laurentiu Tudor <b10716@freescale.com>
To: kvm-ppc@vger.kernel.org
Subject: [PATCH] KVM: PPC: e6500: support powers of 2K TLB1 sizes
Date: Thu, 24 Sep 2015 12:57:57 +0000 [thread overview]
Message-ID: <5603F355.6070409@freescale.com> (raw)
Book-E MMUv2 present in e6500 cores supports
powers of 2K page sizes while older MMUv1 cores
support only powers of 4K page sizes, or in other
words the LSB of TSIZE on MMUv1 is always 0.
Thus, on MMUv2 we must not strip the LSB.
Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
[Laurentiu.Tudor@freescale.com: addressed review
feedback, split in distinct patch]
Signed-off-by: Laurentiu Tudor <Laurentiu.Tudor@freescale.com>
---
arch/powerpc/kvm/e500_mmu_host.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index 4d33e19..12d5c67 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -371,6 +371,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
unsigned long start, end;
unsigned long slot_start, slot_end;
+ int tsize_inc;
pfnmap = 1;
@@ -392,10 +393,20 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
MAS1_TSIZE_SHIFT;
/*
- * e500 doesn't implement the lowest tsize bit,
- * or 1K pages.
+ * MMUv1 doesn't implement the lowest tsize bit,
+ * or translations smaller than 4K.
*/
- tsize = max(BOOK3E_PAGESZ_4K, tsize & ~1);
+ if (!has_feature(&vcpu_e500->vcpu, VCPU_FTR_MMU_V2))
+ tsize &= ~1;
+ tsize = max(BOOK3E_PAGESZ_4K, tsize);
+
+ /*
+ * Calculate TSIZE increment. MMUv2 supports
+ * power of 2K translations while MMUv1 is limited
+ * to power of 4K sizes.
+ */
+ tsize_inc = has_feature(&vcpu_e500->vcpu,
+ VCPU_FTR_MMU_V2) ? 1 : 2;
/*
* Now find the largest tsize (up to what the guest
@@ -404,7 +415,8 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
* aligned.
*/
- for (; tsize > BOOK3E_PAGESZ_4K; tsize -= 2) {
+ for (; tsize > BOOK3E_PAGESZ_4K;
+ tsize -= tsize_inc) {
unsigned long gfn_start, gfn_end;
tsize_pages = 1 << (tsize - 2);
@@ -437,10 +449,12 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
tsize = min(__ilog2(psize) - 10, tsize);
/*
- * e500 doesn't implement the lowest tsize bit,
- * or 1K pages.
+ * MMUv1 doesn't implement the lowest tsize bit,
+ * or translations smaller than 4K.
*/
- tsize = max(BOOK3E_PAGESZ_4K, tsize & ~1);
+ if (!has_feature(&vcpu_e500->vcpu, VCPU_FTR_MMU_V2))
+ tsize &= ~1;
+ tsize = max(BOOK3E_PAGESZ_4K, tsize);
}
up_read(¤t->mm->mmap_sem);
--
1.8.3.1
next reply other threads:[~2015-09-24 12:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 12:57 Laurentiu Tudor [this message]
2015-09-24 20:23 ` [PATCH] KVM: PPC: e6500: support powers of 2K TLB1 sizes Scott Wood
2015-09-25 14:30 ` Laurentiu Tudor
2015-09-25 17:12 ` Scott Wood
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=5603F355.6070409@freescale.com \
--to=b10716@freescale.com \
--cc=kvm-ppc@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.