Skip to contentSkip to conversation

target-xtensa queue

GIT PULL New Max Filippov 1 participant 5 messages Apr 5, 2012

lore
Share & tools
lore
#0 lore raw

The following changes since commit 8f8d364f2447e58768132fc10f48a67af371ee38:

Merge branch 's390-for-upstream' of git://repo.or.cz/qemu/agraf (2012-04-04 20:45:03 +0000)

are available in the git repository at:

git://jcmvbkbc.spb.ru/dumb/qemu-xtensa.git xtensa

Lluís Vilanova (1):
target-xtensa: Move helpers.h to helper.h

Max Filippov (3):
target-xtensa: improve unit tests debugging
target-xtensa: add test for LEND invalidation
target-xtensa: fix tb invalidation for IBREAK and LOOP

 exec-all.h                            |    1 +
 exec.c                                |    9 ++++++---
 target-xtensa/{helpers.h => helper.h} |    0
 target-xtensa/op_helper.c             |   31 +++++++++++++++++++------------
 target-xtensa/translate.c             |    6 +++---
 tests/tcg/xtensa/Makefile             |    3 +++
 tests/tcg/xtensa/macros.inc           |   17 +++++++++++++++++
 tests/tcg/xtensa/test_loop.S          |   25 +++++++++++++++++++++++++
 xtensa-semi.c                         |    2 +-
 9 files changed, 75 insertions(+), 19 deletions(-)
 rename target-xtensa/{helpers.h => helper.h} (100%)
#1 lore raw

PATCH 1/4 target-xtensa: Move helpers.h to helper.h

From: Lluís Vilanova <[email protected]>

Provides a file naming scheme consistent with other targets.

---
 target-xtensa/{helpers.h => helper.h} |    0
 target-xtensa/op_helper.c             |    2 +-
 target-xtensa/translate.c             |    6 +++---
 xtensa-semi.c                         |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
 rename target-xtensa/{helpers.h => helper.h} (100%)
target-xtensa/helper.h renamed from target-xtensa/helpers.h +0 -0
similarity index 100%
rename from target-xtensa/helpers.h
rename to target-xtensa/helper.h
target-xtensa/op_helper.c +1 -1
index cdef0db..806384f 100644
@@ -27,7 +27,7 @@
 
 #include "cpu.h"
 #include "dyngen-exec.h"
-#include "helpers.h"
+#include "helper.h"
 #include "host-utils.h"
 
 static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
target-xtensa/translate.c +3 -3
index e0ff72b..492dbcc 100644
@@ -37,9 +37,9 @@
 #include "qemu-log.h"
 #include "sysemu.h"
 
-#include "helpers.h"
+#include "helper.h"
 #define GEN_HELPER 1
-#include "helpers.h"
+#include "helper.h"
 
 typedef struct DisasContext {
     const XtensaConfig *config;
@@ -183,7 +183,7 @@ void xtensa_translate_init(void)
         }
     }
 #define GEN_HELPER 2
-#include "helpers.h"
+#include "helper.h"
 }
 
 static inline bool option_bits_enabled(DisasContext *dc, uint64_t opt)
xtensa-semi.c +1 -1
index 5754b77..b7c8c34 100644
@@ -31,7 +31,7 @@
 #include <stddef.h>
 #include "cpu.h"
 #include "dyngen-exec.h"
-#include "helpers.h"
+#include "helper.h"
 #include "qemu-log.h"
 
 enum {
Signature · 1 line
1.7.7.6
#2 lore raw

PATCH 2/4 target-xtensa: improve unit tests debugging

In reply to Max Filippov

- add testcase announcement;
- add global symbols for individual tests;
- add host-debug-* makefile target.

---
 tests/tcg/xtensa/Makefile   |    3 +++
 tests/tcg/xtensa/macros.inc |   17 +++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)
tests/tcg/xtensa/Makefile +3 -0
index 7e1e619..0ff0ccf 100644
@@ -72,5 +72,8 @@ run-test_fail.tst: test_fail.tst
 debug-%.tst: %.tst
 	$(SIM) $(SIMDEBUG) $(SIMFLAGS) ./$<
 
+host-debug-%.tst: %.tst
+	gdb --args $(SIM) $(SIMFLAGS) ./$<
+
 clean:
 	$(RM) -fr $(TESTCASES) $(CRT)
tests/tcg/xtensa/macros.inc +17 -0
index 2d4515e..23bf3e9 100644
@@ -29,7 +29,24 @@ main:
     exit
 .endm
 
+.macro print text
+.data
+97: .ascii "\text\n"
+98:
+    .align 4
+.text
+    movi    a2, 4
+    movi    a3, 2
+    movi    a4, 97b
+    movi    a5, 98b
+    sub     a5, a5, a4
+    simcall
+.endm
+
 .macro test name
+    //print test_\name
+test_\name:
+.global test_\name
 .endm
 
 .macro test_end
Signature · 1 line
1.7.7.6
#3 lore raw

PATCH 3/4 target-xtensa: add test for LEND invalidation

In reply to Max Filippov
---
 tests/tcg/xtensa/test_loop.S |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
tests/tcg/xtensa/test_loop.S +25 -0
index a5ea933..9ebc18d 100644
@@ -74,4 +74,29 @@ test loop_excm
     assert  eqi, a2, 1
 test_end
 
+test loop_invalidation
+    movi    a2, 0
+    movi    a3, 5
+    movi    a4, 1f
+    movi    a5, 2f
+    wsr     a3, lcount
+    wsr     a4, lbeg
+    wsr     a5, lend
+    isync
+    j       1f
+.align 4
+1:
+    addi    a2, a2, 1
+2:
+    beqi    a3, 3, 1f
+    assert  eqi, a2, 6
+    movi    a3, 3
+    wsr     a3, lcount
+    wsr     a4, lend
+    isync
+    j       1b
+1:
+    assert  eqi, a2, 7
+test_end
+
 test_suite_end
Signature · 1 line
1.7.7.6
#4 lore raw

PATCH 4/4 target-xtensa: fix tb invalidation for IBREAK and LOOP

In reply to Max Filippov

Instruction breakpoint/zero overhead loop handling code is built into TBs pointed to by IBREAKA/LEND SRs. When these or related SRs get changed TBs at virtual addresses corresponding to their old and their new values must be invalidated.

Virtual address range is passed to the tb_invalidate_phys_page_range, which is incorrect in system emulation mode.

To fix it use guest TLB/MMU to translate virtual address to physical address.

However the guest may not have virtual-to-physical mapping at the moment of IBREAKA/LEND change, thus this fix is not 100% accurate.

---
 exec-all.h                |    1 +
 exec.c                    |    9 ++++++---
 target-xtensa/op_helper.c |   29 ++++++++++++++++++-----------
 3 files changed, 25 insertions(+), 14 deletions(-)
exec-all.h +1 -0
index 93a5b22..3da16ca 100644
@@ -96,6 +96,7 @@ void QEMU_NORETURN cpu_loop_exit(CPUArchState *env1);
 int page_unprotect(target_ulong address, unsigned long pc, void *puc);
 void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,
                                    int is_cpu_write_access);
+void tb_invalidate_phys_addr(target_phys_addr_t addr);
 void tlb_flush_page(CPUArchState *env, target_ulong addr);
 void tlb_flush(CPUArchState *env, int flush_global);
 #if !defined(CONFIG_USER_ONLY)
exec.c +6 -3
index 6731ab8..130ecaa 100644
@@ -1463,13 +1463,11 @@ static void breakpoint_invalidate(CPUArchState *env, target_ulong pc)
     tb_invalidate_phys_page_range(pc, pc + 1, 0);
 }
 #else
-static void breakpoint_invalidate(CPUArchState *env, target_ulong pc)
+void tb_invalidate_phys_addr(target_phys_addr_t addr)
 {
-    target_phys_addr_t addr;
     ram_addr_t ram_addr;
     MemoryRegionSection *section;
 
-    addr = cpu_get_phys_page_debug(env, pc);
     section = phys_page_find(addr >> TARGET_PAGE_BITS);
     if (!(memory_region_is_ram(section->mr)
           || (section->mr->rom_device && section->mr->readable))) {
@@ -1479,6 +1477,11 @@ static void breakpoint_invalidate(CPUArchState *env, target_ulong pc)
         + section_addr(section, addr);
     tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0);
 }
+
+static void breakpoint_invalidate(CPUArchState *env, target_ulong pc)
+{
+    tb_invalidate_phys_addr(cpu_get_phys_page_debug(env, pc));
+}
 #endif
 #endif /* TARGET_HAS_ICE */
 
target-xtensa/op_helper.c +18 -11
index 806384f..03cc789 100644
@@ -99,6 +99,18 @@ void tlb_fill(CPUXtensaState *env1, target_ulong vaddr, int is_write, int mmu_id
     env = saved_env;
 }
 
+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,
+            &paddr, &page_size, &access);
+    if (ret == 0) {
+        tb_invalidate_phys_addr(paddr);
+    }
+}
+
 void HELPER(exception)(uint32_t excp)
 {
     env->exception_index = excp;
@@ -358,8 +370,7 @@ void HELPER(movsp)(uint32_t pc)
 void HELPER(wsr_lbeg)(uint32_t v)
 {
     if (env->sregs[LBEG] != v) {
-        tb_invalidate_phys_page_range(
-                env->sregs[LEND] - 1, env->sregs[LEND], 0);
+        tb_invalidate_virtual_addr(env, env->sregs[LEND] - 1);
         env->sregs[LBEG] = v;
     }
 }
@@ -367,11 +378,9 @@ void HELPER(wsr_lbeg)(uint32_t v)
 void HELPER(wsr_lend)(uint32_t v)
 {
     if (env->sregs[LEND] != v) {
-        tb_invalidate_phys_page_range(
-                env->sregs[LEND] - 1, env->sregs[LEND], 0);
+        tb_invalidate_virtual_addr(env, env->sregs[LEND] - 1);
         env->sregs[LEND] = v;
-        tb_invalidate_phys_page_range(
-                env->sregs[LEND] - 1, env->sregs[LEND], 0);
+        tb_invalidate_virtual_addr(env, env->sregs[LEND] - 1);
     }
 }
 
@@ -692,8 +701,7 @@ void HELPER(wsr_ibreakenable)(uint32_t v)
 
     for (i = 0; i < env->config->nibreak; ++i) {
         if (change & (1 << i)) {
-            tb_invalidate_phys_page_range(
-                    env->sregs[IBREAKA + i], env->sregs[IBREAKA + i] + 1, 0);
+            tb_invalidate_virtual_addr(env, env->sregs[IBREAKA + i]);
         }
     }
     env->sregs[IBREAKENABLE] = v & ((1 << env->config->nibreak) - 1);
@@ -702,9 +710,8 @@ void HELPER(wsr_ibreakenable)(uint32_t v)
 void HELPER(wsr_ibreaka)(uint32_t i, uint32_t v)
 {
     if (env->sregs[IBREAKENABLE] & (1 << i) && env->sregs[IBREAKA + i] != v) {
-        tb_invalidate_phys_page_range(
-                env->sregs[IBREAKA + i], env->sregs[IBREAKA + i] + 1, 0);
-        tb_invalidate_phys_page_range(v, v + 1, 0);
+        tb_invalidate_virtual_addr(env, env->sregs[IBREAKA + i]);
+        tb_invalidate_virtual_addr(env, v);
     }
     env->sregs[IBREAKA + i] = v;
 }
Signature · 1 line
1.7.7.6