qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/4] target-xtensa queue
@ 2012-04-05 22:46 Max Filippov
  2012-04-05 22:46 ` [Qemu-devel] [PATCH 1/4] target-xtensa: Move helpers.h to helper.h Max Filippov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Max Filippov @ 2012-04-05 22:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

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%)

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

* [Qemu-devel] [PATCH 1/4] target-xtensa: Move helpers.h to helper.h
  2012-04-05 22:46 [Qemu-devel] [PULL 0/4] target-xtensa queue Max Filippov
@ 2012-04-05 22:46 ` Max Filippov
  2012-04-05 22:46 ` [Qemu-devel] [PATCH 2/4] target-xtensa: improve unit tests debugging Max Filippov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2012-04-05 22:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori, Lluís Vilanova

From: Lluís Vilanova <vilanova@ac.upc.edu>

Provides a file naming scheme consistent with other targets.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 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%)

diff --git a/target-xtensa/helpers.h b/target-xtensa/helper.h
similarity index 100%
rename from target-xtensa/helpers.h
rename to target-xtensa/helper.h
diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c
index cdef0db..806384f 100644
--- a/target-xtensa/op_helper.c
+++ b/target-xtensa/op_helper.c
@@ -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,
diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c
index e0ff72b..492dbcc 100644
--- a/target-xtensa/translate.c
+++ b/target-xtensa/translate.c
@@ -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)
diff --git a/xtensa-semi.c b/xtensa-semi.c
index 5754b77..b7c8c34 100644
--- a/xtensa-semi.c
+++ b/xtensa-semi.c
@@ -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 {
-- 
1.7.7.6

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

* [Qemu-devel] [PATCH 2/4] target-xtensa: improve unit tests debugging
  2012-04-05 22:46 [Qemu-devel] [PULL 0/4] target-xtensa queue Max Filippov
  2012-04-05 22:46 ` [Qemu-devel] [PATCH 1/4] target-xtensa: Move helpers.h to helper.h Max Filippov
@ 2012-04-05 22:46 ` Max Filippov
  2012-04-05 22:46 ` [Qemu-devel] [PATCH 3/4] target-xtensa: add test for LEND invalidation Max Filippov
  2012-04-05 22:46 ` [Qemu-devel] [PATCH 4/4] target-xtensa: fix tb invalidation for IBREAK and LOOP Max Filippov
  3 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2012-04-05 22:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

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

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 tests/tcg/xtensa/Makefile   |    3 +++
 tests/tcg/xtensa/macros.inc |   17 +++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/tests/tcg/xtensa/Makefile b/tests/tcg/xtensa/Makefile
index 7e1e619..0ff0ccf 100644
--- a/tests/tcg/xtensa/Makefile
+++ b/tests/tcg/xtensa/Makefile
@@ -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)
diff --git a/tests/tcg/xtensa/macros.inc b/tests/tcg/xtensa/macros.inc
index 2d4515e..23bf3e9 100644
--- a/tests/tcg/xtensa/macros.inc
+++ b/tests/tcg/xtensa/macros.inc
@@ -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
-- 
1.7.7.6

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

* [Qemu-devel] [PATCH 3/4] target-xtensa: add test for LEND invalidation
  2012-04-05 22:46 [Qemu-devel] [PULL 0/4] target-xtensa queue Max Filippov
  2012-04-05 22:46 ` [Qemu-devel] [PATCH 1/4] target-xtensa: Move helpers.h to helper.h Max Filippov
  2012-04-05 22:46 ` [Qemu-devel] [PATCH 2/4] target-xtensa: improve unit tests debugging Max Filippov
@ 2012-04-05 22:46 ` Max Filippov
  2012-04-05 22:46 ` [Qemu-devel] [PATCH 4/4] target-xtensa: fix tb invalidation for IBREAK and LOOP Max Filippov
  3 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2012-04-05 22:46 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_loop.S |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/tests/tcg/xtensa/test_loop.S b/tests/tcg/xtensa/test_loop.S
index a5ea933..9ebc18d 100644
--- a/tests/tcg/xtensa/test_loop.S
+++ b/tests/tcg/xtensa/test_loop.S
@@ -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
-- 
1.7.7.6

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

* [Qemu-devel] [PATCH 4/4] target-xtensa: fix tb invalidation for IBREAK and LOOP
  2012-04-05 22:46 [Qemu-devel] [PULL 0/4] target-xtensa queue Max Filippov
                   ` (2 preceding siblings ...)
  2012-04-05 22:46 ` [Qemu-devel] [PATCH 3/4] target-xtensa: add test for LEND invalidation Max Filippov
@ 2012-04-05 22:46 ` Max Filippov
  3 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2012-04-05 22:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Max Filippov, Anthony Liguori

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.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 exec-all.h                |    1 +
 exec.c                    |    9 ++++++---
 target-xtensa/op_helper.c |   29 ++++++++++++++++++-----------
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/exec-all.h b/exec-all.h
index 93a5b22..3da16ca 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -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)
diff --git a/exec.c b/exec.c
index 6731ab8..130ecaa 100644
--- a/exec.c
+++ b/exec.c
@@ -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 */
 
diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c
index 806384f..03cc789 100644
--- a/target-xtensa/op_helper.c
+++ b/target-xtensa/op_helper.c
@@ -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;
 }
-- 
1.7.7.6

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

end of thread, other threads:[~2012-04-05 22:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-05 22:46 [Qemu-devel] [PULL 0/4] target-xtensa queue Max Filippov
2012-04-05 22:46 ` [Qemu-devel] [PATCH 1/4] target-xtensa: Move helpers.h to helper.h Max Filippov
2012-04-05 22:46 ` [Qemu-devel] [PATCH 2/4] target-xtensa: improve unit tests debugging Max Filippov
2012-04-05 22:46 ` [Qemu-devel] [PATCH 3/4] target-xtensa: add test for LEND invalidation Max Filippov
2012-04-05 22:46 ` [Qemu-devel] [PATCH 4/4] target-xtensa: fix tb invalidation for IBREAK and LOOP Max Filippov

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).