qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes
@ 2012-05-27 14:34 Max Filippov
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 1/6] target-xtensa: flush TLB page for new MMU mapping Max Filippov
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Max Filippov @ 2012-05-27 14:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

Hello.

This series fixes subtle bugs in the xtensa hardware pagewalking implementation
and adds more MMU test cases.

The following changes since commit aeb29b6459cb9496b38c820f3faff64cf2369d0d:

  audio: Always call fini on exit (2012-05-24 19:35:27 +0400)

are available in the git repository at:
  git://jcmvbkbc.spb.ru/dumb/qemu-xtensa.git xtensa

Max Filippov (6):
  target-xtensa: flush TLB page for new MMU mapping
  target-xtensa: update EXCVADDR in case of page table lookup
  target-xtensa: extract TLB entry setting method
  target-xtensa: update autorefill TLB entries conditionally
  target-xtensa: control page table lookup explicitly
  target-xtensa: add MMU pagewalking tests

 target-xtensa/cpu.h         |    5 +-
 target-xtensa/helper.c      |   61 +++++++-----
 target-xtensa/op_helper.c   |   20 +++-
 tests/tcg/xtensa/test_mmu.S |  221 ++++++++++++++++++++++++++++++++++++++++---
 4 files changed, 260 insertions(+), 47 deletions(-)

-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1.1 1/6] target-xtensa: flush TLB page for new MMU mapping
  2012-05-27 14:34 [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Max Filippov
@ 2012-05-27 14:34 ` Max Filippov
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 2/6] target-xtensa: update EXCVADDR in case of page table lookup Max Filippov
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Max Filippov @ 2012-05-27 14:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

Both old and new mappings need flushing because their VPN may be
different in MMU case.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 target-xtensa/op_helper.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c
index 364dc19..ce61157 100644
--- a/target-xtensa/op_helper.c
+++ b/target-xtensa/op_helper.c
@@ -669,6 +669,7 @@ void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb,
             entry->paddr = pte & xtensa_tlb_get_addr_mask(env, dtlb, wi);
             entry->asid = (env->sregs[RASID] >> ((pte >> 1) & 0x18)) & 0xff;
             entry->attr = pte & 0xf;
+            tlb_flush_page(env, entry->vaddr);
         } else {
             qemu_log("%s %d, %d, %d trying to set immutable entry\n",
                     __func__, dtlb, wi, ei);
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1.1 2/6] target-xtensa: update EXCVADDR in case of page table lookup
  2012-05-27 14:34 [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Max Filippov
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 1/6] target-xtensa: flush TLB page for new MMU mapping Max Filippov
@ 2012-05-27 14:34 ` Max Filippov
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 3/6] target-xtensa: extract TLB entry setting method Max Filippov
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Max Filippov @ 2012-05-27 14:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

According to ISA, 4.4.2.6, EXCVADDR may be changed by any TLB miss, even
if the miss is handled entirely by processor hardware.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 target-xtensa/helper.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c
index 2094227..43a6611 100644
--- a/target-xtensa/helper.c
+++ b/target-xtensa/helper.c
@@ -516,6 +516,7 @@ static int autorefill_mmu(CPUXtensaState *env, uint32_t vaddr, bool dtlb,
         *wi = (++env->autorefill_idx) & 0x3;
         split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, *wi, ei);
         xtensa_tlb_set_entry(env, dtlb, *wi, *ei, vpn, pte);
+        env->sregs[EXCVADDR] = vaddr;
         qemu_log("%s: autorefill(%08x): %08x -> %08x\n",
                 __func__, vaddr, vpn, pte);
     }
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1.1 3/6] target-xtensa: extract TLB entry setting method
  2012-05-27 14:34 [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Max Filippov
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 1/6] target-xtensa: flush TLB page for new MMU mapping Max Filippov
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 2/6] target-xtensa: update EXCVADDR in case of page table lookup Max Filippov
@ 2012-05-27 14:34 ` Max Filippov
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 4/6] target-xtensa: update autorefill TLB entries conditionally Max Filippov
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Max Filippov @ 2012-05-27 14:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 target-xtensa/cpu.h       |    3 +++
 target-xtensa/op_helper.c |   15 +++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h
index 6d0ea7c..6c590fe 100644
--- a/target-xtensa/cpu.h
+++ b/target-xtensa/cpu.h
@@ -370,6 +370,9 @@ void split_tlb_entry_spec_way(const CPUXtensaState *env, uint32_t v, bool dtlb,
         uint32_t *vpn, uint32_t wi, uint32_t *ei);
 int xtensa_tlb_lookup(const CPUXtensaState *env, uint32_t addr, bool dtlb,
         uint32_t *pwi, uint32_t *pei, uint8_t *pring);
+void xtensa_tlb_set_entry_mmu(const CPUXtensaState *env,
+        xtensa_tlb_entry *entry, bool dtlb,
+        unsigned wi, unsigned ei, uint32_t vpn, uint32_t pte);
 void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb,
         unsigned wi, unsigned ei, uint32_t vpn, uint32_t pte);
 int xtensa_get_physical_addr(CPUXtensaState *env,
diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c
index ce61157..663bb6d 100644
--- a/target-xtensa/op_helper.c
+++ b/target-xtensa/op_helper.c
@@ -655,6 +655,16 @@ uint32_t HELPER(ptlb)(uint32_t v, uint32_t dtlb)
     }
 }
 
+void xtensa_tlb_set_entry_mmu(const CPUXtensaState *env,
+        xtensa_tlb_entry *entry, bool dtlb,
+        unsigned wi, unsigned ei, uint32_t vpn, uint32_t pte)
+{
+    entry->vaddr = vpn;
+    entry->paddr = pte & xtensa_tlb_get_addr_mask(env, dtlb, wi);
+    entry->asid = (env->sregs[RASID] >> ((pte >> 1) & 0x18)) & 0xff;
+    entry->attr = pte & 0xf;
+}
+
 void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb,
         unsigned wi, unsigned ei, uint32_t vpn, uint32_t pte)
 {
@@ -665,10 +675,7 @@ void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb,
             if (entry->asid) {
                 tlb_flush_page(env, entry->vaddr);
             }
-            entry->vaddr = vpn;
-            entry->paddr = pte & xtensa_tlb_get_addr_mask(env, dtlb, wi);
-            entry->asid = (env->sregs[RASID] >> ((pte >> 1) & 0x18)) & 0xff;
-            entry->attr = pte & 0xf;
+            xtensa_tlb_set_entry_mmu(env, entry, dtlb, wi, ei, vpn, pte);
             tlb_flush_page(env, entry->vaddr);
         } else {
             qemu_log("%s %d, %d, %d trying to set immutable entry\n",
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1.1 4/6] target-xtensa: update autorefill TLB entries conditionally
  2012-05-27 14:34 [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Max Filippov
                   ` (2 preceding siblings ...)
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 3/6] target-xtensa: extract TLB entry setting method Max Filippov
@ 2012-05-27 14:34 ` Max Filippov
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 5/6] target-xtensa: control page table lookup explicitly Max Filippov
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Max Filippov @ 2012-05-27 14:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

This is to avoid interference of internal QEMU helpers
(cpu_get_phys_page_debug, tb_invalidate_virtual_addr) with guest-visible
TLB state.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 target-xtensa/cpu.h       |    2 +-
 target-xtensa/helper.c    |   56 +++++++++++++++++++++++++-------------------
 target-xtensa/op_helper.c |    4 +-
 3 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h
index 6c590fe..d5b50d1 100644
--- a/target-xtensa/cpu.h
+++ b/target-xtensa/cpu.h
@@ -375,7 +375,7 @@ void xtensa_tlb_set_entry_mmu(const CPUXtensaState *env,
         unsigned wi, unsigned ei, uint32_t vpn, uint32_t pte);
 void xtensa_tlb_set_entry(CPUXtensaState *env, bool dtlb,
         unsigned wi, unsigned ei, uint32_t vpn, uint32_t pte);
-int xtensa_get_physical_addr(CPUXtensaState *env,
+int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb,
         uint32_t vaddr, int is_write, int mmu_idx,
         uint32_t *paddr, uint32_t *page_size, unsigned *access);
 void reset_mmu(CPUXtensaState *env);
diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c
index 43a6611..86c33d2 100644
--- a/target-xtensa/helper.c
+++ b/target-xtensa/helper.c
@@ -135,11 +135,11 @@ target_phys_addr_t cpu_get_phys_page_debug(CPUXtensaState *env, target_ulong add
     uint32_t page_size;
     unsigned access;
 
-    if (xtensa_get_physical_addr(env, addr, 0, 0,
+    if (xtensa_get_physical_addr(env, false, addr, 0, 0,
                 &paddr, &page_size, &access) == 0) {
         return paddr;
     }
-    if (xtensa_get_physical_addr(env, addr, 2, 0,
+    if (xtensa_get_physical_addr(env, false, addr, 2, 0,
                 &paddr, &page_size, &access) == 0) {
         return paddr;
     }
@@ -448,10 +448,9 @@ static bool is_access_granted(unsigned access, int is_write)
     }
 }
 
-static int autorefill_mmu(CPUXtensaState *env, uint32_t vaddr, bool dtlb,
-        uint32_t *wi, uint32_t *ei, uint8_t *ring);
+static int get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte);
 
-static int get_physical_addr_mmu(CPUXtensaState *env,
+static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb,
         uint32_t vaddr, int is_write, int mmu_idx,
         uint32_t *paddr, uint32_t *page_size, unsigned *access)
 {
@@ -459,19 +458,38 @@ static int get_physical_addr_mmu(CPUXtensaState *env,
     uint32_t wi;
     uint32_t ei;
     uint8_t ring;
+    uint32_t vpn;
+    uint32_t pte;
+    const xtensa_tlb_entry *entry = NULL;
+    xtensa_tlb_entry tmp_entry;
     int ret = xtensa_tlb_lookup(env, vaddr, dtlb, &wi, &ei, &ring);
 
     if ((ret == INST_TLB_MISS_CAUSE || ret == LOAD_STORE_TLB_MISS_CAUSE) &&
             (mmu_idx != 0 || ((vaddr ^ env->sregs[PTEVADDR]) & 0xffc00000)) &&
-            autorefill_mmu(env, vaddr, dtlb, &wi, &ei, &ring) == 0) {
+            get_pte(env, vaddr, &pte) == 0) {
+        ring = (pte >> 4) & 0x3;
+        wi = 0;
+        split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei);
+
+        if (update_tlb) {
+            wi = ++env->autorefill_idx & 0x3;
+            xtensa_tlb_set_entry(env, dtlb, wi, ei, vpn, pte);
+            env->sregs[EXCVADDR] = vaddr;
+            qemu_log("%s: autorefill(%08x): %08x -> %08x\n",
+                    __func__, vaddr, vpn, pte);
+        } else {
+            xtensa_tlb_set_entry_mmu(env, &tmp_entry, dtlb, wi, ei, vpn, pte);
+            entry = &tmp_entry;
+        }
         ret = 0;
     }
     if (ret != 0) {
         return ret;
     }
 
-    const xtensa_tlb_entry *entry =
-        xtensa_tlb_get_entry(env, dtlb, wi, ei);
+    if (entry == NULL) {
+        entry = xtensa_tlb_get_entry(env, dtlb, wi, ei);
+    }
 
     if (ring < mmu_idx) {
         return dtlb ?
@@ -494,31 +512,21 @@ static int get_physical_addr_mmu(CPUXtensaState *env,
     return 0;
 }
 
-static int autorefill_mmu(CPUXtensaState *env, uint32_t vaddr, bool dtlb,
-        uint32_t *wi, uint32_t *ei, uint8_t *ring)
+static int get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte)
 {
     uint32_t paddr;
     uint32_t page_size;
     unsigned access;
     uint32_t pt_vaddr =
         (env->sregs[PTEVADDR] | (vaddr >> 10)) & 0xfffffffc;
-    int ret = get_physical_addr_mmu(env, pt_vaddr, 0, 0,
+    int ret = get_physical_addr_mmu(env, false, pt_vaddr, 0, 0,
             &paddr, &page_size, &access);
 
     qemu_log("%s: trying autorefill(%08x) -> %08x\n", __func__,
             vaddr, ret ? ~0 : paddr);
 
     if (ret == 0) {
-        uint32_t vpn;
-        uint32_t pte = ldl_phys(paddr);
-
-        *ring = (pte >> 4) & 0x3;
-        *wi = (++env->autorefill_idx) & 0x3;
-        split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, *wi, ei);
-        xtensa_tlb_set_entry(env, dtlb, *wi, *ei, vpn, pte);
-        env->sregs[EXCVADDR] = vaddr;
-        qemu_log("%s: autorefill(%08x): %08x -> %08x\n",
-                __func__, vaddr, vpn, pte);
+        *pte = ldl_phys(paddr);
     }
     return ret;
 }
@@ -554,13 +562,13 @@ static int get_physical_addr_region(CPUXtensaState *env,
  *
  * \return 0 if ok, exception cause code otherwise
  */
-int xtensa_get_physical_addr(CPUXtensaState *env,
+int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb,
         uint32_t vaddr, int is_write, int mmu_idx,
         uint32_t *paddr, uint32_t *page_size, unsigned *access)
 {
     if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
-        return get_physical_addr_mmu(env, vaddr, is_write, mmu_idx,
-                paddr, page_size, access);
+        return get_physical_addr_mmu(env, update_tlb,
+                vaddr, is_write, mmu_idx, paddr, page_size, access);
     } else if (xtensa_option_bits_enabled(env->config,
                 XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) |
                 XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION))) {
diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c
index 663bb6d..41107ff 100644
--- a/target-xtensa/op_helper.c
+++ b/target-xtensa/op_helper.c
@@ -79,7 +79,7 @@ void tlb_fill(CPUXtensaState *env1, target_ulong vaddr, int is_write, int mmu_id
         uint32_t paddr;
         uint32_t page_size;
         unsigned access;
-        int ret = xtensa_get_physical_addr(env, vaddr, is_write, mmu_idx,
+        int ret = xtensa_get_physical_addr(env, true, vaddr, is_write, mmu_idx,
                 &paddr, &page_size, &access);
 
         qemu_log("%s(%08x, %d, %d) -> %08x, ret = %d\n", __func__,
@@ -103,7 +103,7 @@ static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr)
     uint32_t paddr;
     uint32_t page_size;
     unsigned access;
-    int ret = xtensa_get_physical_addr(env, vaddr, 2, 0,
+    int ret = xtensa_get_physical_addr(env, false, vaddr, 2, 0,
             &paddr, &page_size, &access);
     if (ret == 0) {
         tb_invalidate_phys_addr(paddr);
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1.1 5/6] target-xtensa: control page table lookup explicitly
  2012-05-27 14:34 [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Max Filippov
                   ` (3 preceding siblings ...)
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 4/6] target-xtensa: update autorefill TLB entries conditionally Max Filippov
@ 2012-05-27 14:34 ` Max Filippov
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 6/6] target-xtensa: add MMU pagewalking tests Max Filippov
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Max Filippov @ 2012-05-27 14:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

Hardware pagetable walking may not be nested. Stop guessing and pass
explicit flag to the get_physical_addr_mmu function that controls page
table lookup.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 target-xtensa/helper.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c
index 86c33d2..8ebef72 100644
--- a/target-xtensa/helper.c
+++ b/target-xtensa/helper.c
@@ -452,7 +452,8 @@ static int get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte);
 
 static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb,
         uint32_t vaddr, int is_write, int mmu_idx,
-        uint32_t *paddr, uint32_t *page_size, unsigned *access)
+        uint32_t *paddr, uint32_t *page_size, unsigned *access,
+        bool may_lookup_pt)
 {
     bool dtlb = is_write != 2;
     uint32_t wi;
@@ -465,8 +466,7 @@ static int get_physical_addr_mmu(CPUXtensaState *env, bool update_tlb,
     int ret = xtensa_tlb_lookup(env, vaddr, dtlb, &wi, &ei, &ring);
 
     if ((ret == INST_TLB_MISS_CAUSE || ret == LOAD_STORE_TLB_MISS_CAUSE) &&
-            (mmu_idx != 0 || ((vaddr ^ env->sregs[PTEVADDR]) & 0xffc00000)) &&
-            get_pte(env, vaddr, &pte) == 0) {
+            may_lookup_pt && get_pte(env, vaddr, &pte) == 0) {
         ring = (pte >> 4) & 0x3;
         wi = 0;
         split_tlb_entry_spec_way(env, vaddr, dtlb, &vpn, wi, &ei);
@@ -520,7 +520,7 @@ static int get_pte(CPUXtensaState *env, uint32_t vaddr, uint32_t *pte)
     uint32_t pt_vaddr =
         (env->sregs[PTEVADDR] | (vaddr >> 10)) & 0xfffffffc;
     int ret = get_physical_addr_mmu(env, false, pt_vaddr, 0, 0,
-            &paddr, &page_size, &access);
+            &paddr, &page_size, &access, false);
 
     qemu_log("%s: trying autorefill(%08x) -> %08x\n", __func__,
             vaddr, ret ? ~0 : paddr);
@@ -568,7 +568,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb,
 {
     if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) {
         return get_physical_addr_mmu(env, update_tlb,
-                vaddr, is_write, mmu_idx, paddr, page_size, access);
+                vaddr, is_write, mmu_idx, paddr, page_size, access, true);
     } else if (xtensa_option_bits_enabled(env->config,
                 XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) |
                 XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION))) {
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH 1.1 6/6] target-xtensa: add MMU pagewalking tests
  2012-05-27 14:34 [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Max Filippov
                   ` (4 preceding siblings ...)
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 5/6] target-xtensa: control page table lookup explicitly Max Filippov
@ 2012-05-27 14:34 ` Max Filippov
  2012-05-27 14:54 ` [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Andreas Färber
  2012-06-09 11:30 ` Blue Swirl
  7 siblings, 0 replies; 10+ messages in thread
From: Max Filippov @ 2012-05-27 14:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 tests/tcg/xtensa/test_mmu.S |  221 ++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 207 insertions(+), 14 deletions(-)

diff --git a/tests/tcg/xtensa/test_mmu.S b/tests/tcg/xtensa/test_mmu.S
index 52d5774..5d87fbb 100644
--- a/tests/tcg/xtensa/test_mmu.S
+++ b/tests/tcg/xtensa/test_mmu.S
@@ -293,26 +293,219 @@ test store_prohibited
     assert  eq, a2, a3
 test_end
 
-test dtlb_autoload
-    set_vector kernel, 0
-
-    movi    a2, 0xd4000000
+/* Set up page table entry vaddr->paddr, ring=pte_ring, attr=pte_attr
+ * and DTLB way 7 to cover this PTE, ring=pt_ring, attr=pt_attr
+ */
+.macro pt_setup pt_ring, pt_attr, pte_ring, vaddr, paddr, pte_attr
+    movi    a2, 0x80000000
     wsr     a2, ptevaddr
-    movi    a3, 0x00001013
-    s32i    a3, a2, 4
+
+    movi    a3, 0x80000007 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */
+    movi    a4, 0x04000003 | ((\pt_ring) << 4) /* PADDR 64M */
+    wdtlb   a4, a3
+    isync
+
+    movi    a3, ((\paddr) & 0xfffff000) | ((\pte_ring) << 4) | (\pte_attr)
+    movi    a1, ((\vaddr) >> 12) << 2
+    add     a2, a1, a2
+    s32i    a3, a2, 0
+
+    movi    a3, 0x80000007 | (((\vaddr) >> 10) & 0xfffff000) /* way 7 */
+    movi    a4, 0x04000000 | ((\pt_ring) << 4) | (\pt_attr) /* PADDR 64M */
+    wdtlb   a4, a3
+    isync
+
+    movi    a3, (\vaddr)
+.endm
+
+/* out: PS.RING=ring, PS.EXCM=excm, a3=vaddr */
+.macro go_ring ring, excm, vaddr
+    movi    a3, 10f
+    pitlb   a3, a3
+    ritlb1  a2, a3
+    movi    a1, 0x10
+    or      a2, a2, a1
+    movi    a1, 0x000ff000
+    and     a3, a3, a1
+    movi    a1, 4
+    or      a3, a3, a1
+    witlb   a2, a3
+    movi    a3, 10f
+    movi    a1, 0x000fffff
+    and     a1, a3, a1
+
+    movi    a2, 0
+    wsr     a2, excvaddr
+
+    movi    a3, \vaddr
+    movi    a2, 0x4000f | ((\ring) << 6) | ((\excm) << 4)
+    jx      a1
+10:
+    wsr     a2, ps
+    isync
+.endm
+
+/* in: a3 -- virtual address to test */
+.macro assert_auto_tlb
+    movi    a2, 0x4000f
+    wsr     a2, ps
+    isync
+    pdtlb   a2, a3
+    movi    a1, 0xfffff01f
+    and     a2, a2, a1
+    movi    a1, 0xfffff000
+    and     a1, a1, a3
+    xor     a1, a1, a2
+    assert  gei, a1, 0x10
+    movi    a2, 0x14
+    assert  lt, a1, a2
+.endm
+
+/* in: a3 -- virtual address to test */
+.macro assert_no_auto_tlb
+    movi    a2, 0x4000f
+    wsr     a2, ps
+    isync
     pdtlb   a2, a3
     movi    a1, 0x10
     and     a1, a1, a2
     assert  eqi, a1, 0
-    l8ui    a1, a3, 0
-    pdtlb   a2, a3
-    movi    a1, 0xfffff010
-    and     a1, a1, a2
-    movi    a3, 0x00001010
-    assert  eq, a1, a3
-    movi    a1, 0xf
+.endm
+
+.macro assert_sr sr, v
+    rsr     a2, \sr
+    movi    a1, (\v)
+    assert  eq, a1, a2
+.endm
+
+.macro assert_epc1_1m vaddr
+    movi    a2, (\vaddr)
+    movi    a1, 0xfffff
     and     a1, a1, a2
-    assert  lti, a1, 4
+    rsr     a2, epc1
+    assert  eq, a1, a2
+.endm
+
+test dtlb_autoload
+    set_vector kernel, 0
+
+    pt_setup    0, 3, 1, 0x1000, 0x1000, 3
+    assert_no_auto_tlb
+
+    l8ui    a1, a3, 0
+
+    rsr     a2, excvaddr
+    assert  eq, a2, a3
+
+    assert_auto_tlb
+test_end
+
+test autoload_load_store_privilege
+    set_vector kernel, 0
+    set_vector double, 2f
+
+    pt_setup    0, 3, 0, 0x2000, 0x2000, 3
+    movi    a3, 0x2004
+    assert_no_auto_tlb
+
+    movi    a2, 0x4005f    /* ring 1 + excm => cring == 0 */
+    wsr     a2, ps
+    isync
+1:
+    l32e    a2, a3, -4     /* ring used */
+    test_fail
+2:
+    rsr     a2, excvaddr
+    addi    a1, a3, -4
+    assert  eq, a1, a2
+
+    assert_auto_tlb
+    assert_sr depc, 1b
+    assert_sr exccause, 26
+test_end
+
+test autoload_pte_load_prohibited
+    set_vector kernel, 2f
+
+    pt_setup    0, 3, 0, 0x3000, 0, 0xc
+    assert_no_auto_tlb
+1:
+    l32i    a2, a3, 0
+    test_fail
+2:
+    rsr     a2, excvaddr
+    assert  eq, a2, a3
+
+    assert_auto_tlb
+    assert_sr epc1, 1b
+    assert_sr exccause, 28
+test_end
+
+test autoload_pt_load_prohibited
+    set_vector kernel, 2f
+
+    pt_setup    0, 0xc, 0, 0x4000, 0x4000, 3
+    assert_no_auto_tlb
+1:
+    l32i    a2, a3, 0
+    test_fail
+2:
+    rsr     a2, excvaddr
+    assert  eq, a2, a3
+
+    assert_no_auto_tlb
+    assert_sr epc1, 1b
+    assert_sr exccause, 24
+test_end
+
+test autoload_pt_privilege
+    set_vector  kernel, 2f
+    pt_setup    0, 3, 1, 0x5000, 0, 3
+    go_ring     1, 0, 0x5001
+
+    l8ui    a2, a3, 0
+1:
+    syscall
+2:
+    rsr     a2, excvaddr
+    assert  eq, a2, a3
+
+    assert_auto_tlb
+    assert_epc1_1m 1b
+    assert_sr exccause, 1
+test_end
+
+test autoload_pte_privilege
+    set_vector  kernel, 2f
+    pt_setup    0, 3, 0, 0x6000, 0, 3
+    go_ring     1, 0, 0x6001
+1:
+    l8ui    a2, a3, 0
+    syscall
+2:
+    rsr     a2, excvaddr
+    assert  eq, a2, a3
+
+    assert_auto_tlb
+    assert_epc1_1m 1b
+    assert_sr exccause, 26
+test_end
+
+test autoload_3_level_pt
+    set_vector  kernel, 2f
+    pt_setup    1, 3, 1, 0x00400000, 0, 3
+    pt_setup    1, 3, 1, 0x80001000, 0x2000000, 3
+    go_ring     1, 0, 0x00400001
+1:
+    l8ui    a2, a3, 0
+    syscall
+2:
+    rsr     a2, excvaddr
+    assert  eq, a2, a3
+
+    assert_no_auto_tlb
+    assert_epc1_1m 1b
+    assert_sr exccause, 24
 test_end
 
 test_suite_end
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes
  2012-05-27 14:34 [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Max Filippov
                   ` (5 preceding siblings ...)
  2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 6/6] target-xtensa: add MMU pagewalking tests Max Filippov
@ 2012-05-27 14:54 ` Andreas Färber
  2012-05-27 15:27   ` Max Filippov
  2012-06-09 11:30 ` Blue Swirl
  7 siblings, 1 reply; 10+ messages in thread
From: Andreas Färber @ 2012-05-27 14:54 UTC (permalink / raw)
  To: Max Filippov; +Cc: Blue Swirl, Anthony Liguori, qemu-devel

Am 27.05.2012 16:34, schrieb Max Filippov:
> Hello.
> 
> This series fixes subtle bugs in the xtensa hardware pagewalking implementation
> and adds more MMU test cases.
> 
> The following changes since commit aeb29b6459cb9496b38c820f3faff64cf2369d0d:
> 
>   audio: Always call fini on exit (2012-05-24 19:35:27 +0400)
> 
> are available in the git repository at:
>   git://jcmvbkbc.spb.ru/dumb/qemu-xtensa.git xtensa
> 
> Max Filippov (6):
>   target-xtensa: flush TLB page for new MMU mapping

At least this patch seems to have never reached my inbox before. The
expected procedure is to first patches on the list, wait for review and
only after acks have been received or sufficient time passed and a ping
remained without acks, post a PULL request that can then be applied
without review of contents, only making sure it doesn't break the build
or significantly regresses the target(s).

This patch itself looks okay, but I'm pointing it out since the list
seems to be lagging once again and because you're sending it for the
final RC.

Regards,
Andreas

>   target-xtensa: update EXCVADDR in case of page table lookup
>   target-xtensa: extract TLB entry setting method
>   target-xtensa: update autorefill TLB entries conditionally
>   target-xtensa: control page table lookup explicitly
>   target-xtensa: add MMU pagewalking tests
> 
>  target-xtensa/cpu.h         |    5 +-
>  target-xtensa/helper.c      |   61 +++++++-----
>  target-xtensa/op_helper.c   |   20 +++-
>  tests/tcg/xtensa/test_mmu.S |  221 ++++++++++++++++++++++++++++++++++++++++---
>  4 files changed, 260 insertions(+), 47 deletions(-)

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes
  2012-05-27 14:54 ` [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Andreas Färber
@ 2012-05-27 15:27   ` Max Filippov
  0 siblings, 0 replies; 10+ messages in thread
From: Max Filippov @ 2012-05-27 15:27 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Blue Swirl, Anthony Liguori, qemu-devel

On Sun, May 27, 2012 at 6:54 PM, Andreas Färber <afaerber@suse.de> wrote:
> Am 27.05.2012 16:34, schrieb Max Filippov:
>> Hello.
>>
>> This series fixes subtle bugs in the xtensa hardware pagewalking implementation
>> and adds more MMU test cases.
>>
>> The following changes since commit aeb29b6459cb9496b38c820f3faff64cf2369d0d:
>>
>>   audio: Always call fini on exit (2012-05-24 19:35:27 +0400)
>>
>> are available in the git repository at:
>>   git://jcmvbkbc.spb.ru/dumb/qemu-xtensa.git xtensa
>>
>> Max Filippov (6):
>>   target-xtensa: flush TLB page for new MMU mapping
>
> At least this patch seems to have never reached my inbox before. The

My bad, actually I send it for the first time, should have been mere
patch series. Please review.

> expected procedure is to first patches on the list, wait for review and
> only after acks have been received or sufficient time passed and a ping
> remained without acks, post a PULL request that can then be applied
> without review of contents, only making sure it doesn't break the build
> or significantly regresses the target(s).
>
> This patch itself looks okay, but I'm pointing it out since the list
> seems to be lagging once again and because you're sending it for the
> final RC.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes
  2012-05-27 14:34 [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Max Filippov
                   ` (6 preceding siblings ...)
  2012-05-27 14:54 ` [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Andreas Färber
@ 2012-06-09 11:30 ` Blue Swirl
  7 siblings, 0 replies; 10+ messages in thread
From: Blue Swirl @ 2012-06-09 11:30 UTC (permalink / raw)
  To: Max Filippov; +Cc: Anthony Liguori, qemu-devel

Thanks, applied all.

On Sun, May 27, 2012 at 2:34 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> Hello.
>
> This series fixes subtle bugs in the xtensa hardware pagewalking implementation
> and adds more MMU test cases.
>
> The following changes since commit aeb29b6459cb9496b38c820f3faff64cf2369d0d:
>
>  audio: Always call fini on exit (2012-05-24 19:35:27 +0400)
>
> are available in the git repository at:
>  git://jcmvbkbc.spb.ru/dumb/qemu-xtensa.git xtensa
>
> Max Filippov (6):
>  target-xtensa: flush TLB page for new MMU mapping
>  target-xtensa: update EXCVADDR in case of page table lookup
>  target-xtensa: extract TLB entry setting method
>  target-xtensa: update autorefill TLB entries conditionally
>  target-xtensa: control page table lookup explicitly
>  target-xtensa: add MMU pagewalking tests
>
>  target-xtensa/cpu.h         |    5 +-
>  target-xtensa/helper.c      |   61 +++++++-----
>  target-xtensa/op_helper.c   |   20 +++-
>  tests/tcg/xtensa/test_mmu.S |  221 ++++++++++++++++++++++++++++++++++++++++---
>  4 files changed, 260 insertions(+), 47 deletions(-)
>
> --
> 1.7.7.6

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-06-09 11:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-27 14:34 [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Max Filippov
2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 1/6] target-xtensa: flush TLB page for new MMU mapping Max Filippov
2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 2/6] target-xtensa: update EXCVADDR in case of page table lookup Max Filippov
2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 3/6] target-xtensa: extract TLB entry setting method Max Filippov
2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 4/6] target-xtensa: update autorefill TLB entries conditionally Max Filippov
2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 5/6] target-xtensa: control page table lookup explicitly Max Filippov
2012-05-27 14:34 ` [Qemu-devel] [PATCH 1.1 6/6] target-xtensa: add MMU pagewalking tests Max Filippov
2012-05-27 14:54 ` [Qemu-devel] [PULL 1.1 0/6] target-xtensa MMU fixes Andreas Färber
2012-05-27 15:27   ` Max Filippov
2012-06-09 11:30 ` Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).