All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: agraf@suse.de, alex.williamson@redhat.com, qemu-ppc@nongnu.org,
	qemu-devel@nongnu.org, benh@kernel.crashing.org, aik@ozlabs.ru,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PULL 14/14] ppc/hash64: Fix support for LPCR:ISL
Date: Tue,  5 Jul 2016 15:10:48 +1000	[thread overview]
Message-ID: <1467695448-7780-15-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1467695448-7780-1-git-send-email-david@gibson.dropbear.id.au>

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

We need to ignore the segment page size and essentially treat
all pages as coming from a 4K segment.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[dwg: Adjusted for differencesin my version of the prereq patches]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 target-ppc/mmu-hash64.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c
index 7f31444..bcd1c9d 100644
--- a/target-ppc/mmu-hash64.c
+++ b/target-ppc/mmu-hash64.c
@@ -488,7 +488,8 @@ static unsigned hpte_page_shift(const struct ppc_one_seg_page_size *sps,
 }
 
 static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
-                                     ppc_slb_t *slb, target_ulong ptem,
+                                     const struct ppc_one_seg_page_size *sps,
+                                     target_ulong ptem,
                                      ppc_hash_pte64_t *pte, unsigned *pshift)
 {
     CPUPPCState *env = &cpu->env;
@@ -508,7 +509,7 @@ static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash,
 
         /* This compares V, B, H (secondary) and the AVPN */
         if (HPTE64_V_COMPARE(pte0, ptem)) {
-            *pshift = hpte_page_shift(slb->sps, pte0, pte1);
+            *pshift = hpte_page_shift(sps, pte0, pte1);
             /*
              * If there is no match, ignore the PTE, it could simply
              * be for a different segment size encoding and the
@@ -543,23 +544,31 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU *cpu,
     hwaddr pte_offset;
     hwaddr hash;
     uint64_t vsid, epnmask, epn, ptem;
+    const struct ppc_one_seg_page_size *sps = slb->sps;
 
     /* The SLB store path should prevent any bad page size encodings
      * getting in there, so: */
-    assert(slb->sps);
+    assert(sps);
 
-    epnmask = ~((1ULL << slb->sps->page_shift) - 1);
+    /* If ISL is set in LPCR we need to clamp the page size to 4K */
+    if (env->spr[SPR_LPCR] & LPCR_ISL) {
+        /* We assume that when using TCG, 4k is first entry of SPS */
+        sps = &env->sps.sps[0];
+        assert(sps->page_shift == 12);
+    }
+
+    epnmask = ~((1ULL << sps->page_shift) - 1);
 
     if (slb->vsid & SLB_VSID_B) {
         /* 1TB segment */
         vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT_1T;
         epn = (eaddr & ~SEGMENT_MASK_1T) & epnmask;
-        hash = vsid ^ (vsid << 25) ^ (epn >> slb->sps->page_shift);
+        hash = vsid ^ (vsid << 25) ^ (epn >> sps->page_shift);
     } else {
         /* 256M segment */
         vsid = (slb->vsid & SLB_VSID_VSID) >> SLB_VSID_SHIFT;
         epn = (eaddr & ~SEGMENT_MASK_256M) & epnmask;
-        hash = vsid ^ (epn >> slb->sps->page_shift);
+        hash = vsid ^ (epn >> sps->page_shift);
     }
     ptem = (slb->vsid & SLB_VSID_PTEM) | ((epn >> 16) & HPTE64_V_AVPN);
     ptem |= HPTE64_V_VALID;
@@ -576,7 +585,8 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU *cpu,
             " vsid=" TARGET_FMT_lx " ptem=" TARGET_FMT_lx
             " hash=" TARGET_FMT_plx "\n",
             env->htab_base, env->htab_mask, vsid, ptem,  hash);
-    pte_offset = ppc_hash64_pteg_search(cpu, hash, slb, ptem, pte, pshift);
+    pte_offset = ppc_hash64_pteg_search(cpu, hash, slb->sps,
+                                        ptem, pte, pshift);
 
     if (pte_offset == -1) {
         /* Secondary PTEG lookup */
@@ -587,7 +597,8 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU *cpu,
                 " hash=" TARGET_FMT_plx "\n", env->htab_base,
                 env->htab_mask, vsid, ptem, ~hash);
 
-        pte_offset = ppc_hash64_pteg_search(cpu, ~hash, slb, ptem, pte, pshift);
+        pte_offset = ppc_hash64_pteg_search(cpu, ~hash, slb->sps,
+                                            ptem, pte, pshift);
     }
 
     return pte_offset;
-- 
2.7.4

  parent reply	other threads:[~2016-07-05  5:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-05  5:10 [Qemu-devel] [PULL 00/14] ppc-for-2.7 queue 20160705 David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 01/14] ppc: Fix xsrdpi, xvrdpi and xvrspi rounding David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 02/14] spapr: Ensure thread0 of CPU core is always realized first David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 03/14] ppc: simplify max_smt initialization in ppc_cpu_realizefn() David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 04/14] spapr_iommu: Realloc guest visible TCE table when starting/stopping listening David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 05/14] vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2) David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 06/14] vfio: Add host side DMA window capabilities David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 07/14] vfio/spapr: Create DMA window dynamically (SPAPR IOMMU v2) David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 08/14] spapr_pci/spapr_pci_vfio: Support Dynamic DMA Windows (DDW) David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 09/14] ppc: simplify ppc_hash64_hpte_page_shift_noslb() David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 10/14] target-ppc: Correct page size decoding in ppc_hash64_pteg_search() David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 11/14] target-ppc: Simplify HPTE matching David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 12/14] target-ppc: Return page shift from PTEG search David Gibson
2016-07-05  5:10 ` [Qemu-devel] [PULL 13/14] ppc/hash64: Add proper real mode translation support David Gibson
2016-07-05  5:10 ` David Gibson [this message]
2016-07-05  5:12   ` [Qemu-devel] [PULL 14/14] ppc/hash64: Fix support for LPCR:ISL Benjamin Herrenschmidt
2016-07-05  5:16     ` David Gibson
2016-07-05  5:32 ` [Qemu-devel] [PULL 00/14] ppc-for-2.7 queue 20160705 David Gibson
2016-07-05  5:36   ` Benjamin Herrenschmidt
2016-07-05  5:31 [Qemu-devel] [PULL 00/14] ppc-for-2.7 queue 20160705 (v2) David Gibson
2016-07-05  5:31 ` [Qemu-devel] [PULL 14/14] ppc/hash64: Fix support for LPCR:ISL David Gibson

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=1467695448-7780-15-git-send-email-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=alex.williamson@redhat.com \
    --cc=benh@kernel.crashing.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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.