Skip to contentSkip to conversation

target-xtensa queue

GIT PULL In review Max Filippov 4 participants 19 messages Feb 18, 2012 – Mar 3, 2012

lore
Share & tools
lore
#0 lore raw

Hi.

This is a pull request for my current target-xtensa queue. Changes in the queue are:
- 'info tlb' monitor command;
- debug option implementation;
- a few minor fixes.

Debug option series has been posted to the list as an RFC, there were no changes in it since then.

Please pull.

Thanks.
-- Max

The following changes since commit 99c7f87826337fa81f2f0f9baa9ca0a44faf90e9:

input: send kbd+mouse events only to running guests. (2012-02-17 11:02:55 -0600)

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

Max Filippov (12):
target-xtensa: define TLB_TEMPLATE for MMU-less cores
target-xtensa: implement info tlb monitor command
target-xtensa: fetch 3rd opcode byte only when needed
target-xtensa: add DEBUGCAUSE SR and configuration
target-xtensa: implement instruction breakpoints
target-xtensa: add ICOUNT SR and debug exception
exec: add missing breaks to the watch_mem_write
exec: fix check_watchpoint exiting cpu_loop
exec: let cpu_watchpoint_insert accept larger watchpoints
target-xtensa: add DBREAK data breakpoints
target-xtensa: add DEBUG_SECTION to overlay tool
target-xtensa: add breakpoint tests

 exec.c                        |   18 +++-
 hmp-commands.hx               |    2 +-
 monitor.c                     |    4 +-
 target-xtensa/core-dc232b.c   |    1 +
 target-xtensa/core-fsf.c      |    1 +
 target-xtensa/cpu.h           |   43 ++++++++
 target-xtensa/helper.c        |  110 ++++++++++++++++++++
 target-xtensa/helpers.h       |    7 ++
 target-xtensa/op_helper.c     |  100 ++++++++++++++++++
 target-xtensa/overlay_tool.h  |   23 ++++-
 target-xtensa/translate.c     |  156 ++++++++++++++++++++++++++++-
 tests/tcg/xtensa/Makefile     |    1 +
 tests/tcg/xtensa/test_break.S |  223 +++++++++++++++++++++++++++++++++++++++++
 13 files changed, 674 insertions(+), 15 deletions(-)
 create mode 100644 tests/tcg/xtensa/test_break.S
Signature · 1 line
1.7.7.6
#1 lore raw

Am 18.02.2012 12:30, schrieb Max Filippov:

Quoted 10 lines

Hi.

This is a pull request for my current target-xtensa queue. Changes in the queue are:
- 'info tlb' monitor command;
- debug option implementation;
- a few minor fixes.

Debug option series has been posted to the list as an RFC, there were no changes in it since then.

It would be nice to see those 12 patches threaded to the PULL message, especially when there's been no feedback yet (which may indicate either that people had no objections or didn't look at it yet).

Andreas

Quoted 42 lines

Please pull.

Thanks.
-- Max

The following changes since commit 99c7f87826337fa81f2f0f9baa9ca0a44faf90e9:

input: send kbd+mouse events only to running guests. (2012-02-17 11:02:55 -0600)

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

Max Filippov (12):
target-xtensa: define TLB_TEMPLATE for MMU-less cores
target-xtensa: implement info tlb monitor command
target-xtensa: fetch 3rd opcode byte only when needed
target-xtensa: add DEBUGCAUSE SR and configuration
target-xtensa: implement instruction breakpoints
target-xtensa: add ICOUNT SR and debug exception
exec: add missing breaks to the watch_mem_write
exec: fix check_watchpoint exiting cpu_loop
exec: let cpu_watchpoint_insert accept larger watchpoints
target-xtensa: add DBREAK data breakpoints
target-xtensa: add DEBUG_SECTION to overlay tool
target-xtensa: add breakpoint tests

 exec.c                        |   18 +++-
 hmp-commands.hx               |    2 +-
 monitor.c                     |    4 +-
 target-xtensa/core-dc232b.c   |    1 +
 target-xtensa/core-fsf.c      |    1 +
 target-xtensa/cpu.h           |   43 ++++++++
 target-xtensa/helper.c        |  110 ++++++++++++++++++++
 target-xtensa/helpers.h       |    7 ++
 target-xtensa/op_helper.c     |  100 ++++++++++++++++++
 target-xtensa/overlay_tool.h  |   23 ++++-
 target-xtensa/translate.c     |  156 ++++++++++++++++++++++++++++-
 tests/tcg/xtensa/Makefile     |    1 +
 tests/tcg/xtensa/test_break.S |  223 +++++++++++++++++++++++++++++++++++++++++
 13 files changed, 674 insertions(+), 15 deletions(-)
 create mode 100644 tests/tcg/xtensa/test_break.S
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#2 lore raw

PATCH 1/12 target-xtensa: define TLB_TEMPLATE for MMU-less cores

In reply to Max Filippov

TLB_TEMPLATE macro specifies TLB geometry in the core configuration. Make TLB_TEMPLATE available for region protection core variants, defining 1 way ITLB and DTLB with 8 entries each.

---
 target-xtensa/overlay_tool.h |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
target-xtensa/overlay_tool.h +16 -2
index df19cc9..e7c4c3a 100644
@@ -251,6 +251,8 @@
     .nextint = XCHAL_NUM_EXTINTERRUPTS, \
     .extint = EXTINTS
 
+#if XCHAL_HAVE_PTP_MMU
+
 #define TLB_TEMPLATE(ways, refill_way_size, way56) { \
         .nways = ways, \
         .way_size = { \
@@ -268,11 +270,23 @@
 #define DTLB(varway56) \
     TLB_TEMPLATE(10, 1 << XCHAL_DTLB_ARF_ENTRIES_LOG2, varway56)
 
-#if XCHAL_HAVE_PTP_MMU
 #define TLB_SECTION \
     .itlb = ITLB(XCHAL_HAVE_SPANNING_WAY), \
     .dtlb = DTLB(XCHAL_HAVE_SPANNING_WAY)
-#else
+
+#elif XCHAL_HAVE_XLT_CACHEATTR || XCHAL_HAVE_MIMIC_CACHEATTR
+
+#define TLB_TEMPLATE { \
+        .nways = 1, \
+        .way_size = { \
+            8, \
+        } \
+    }
+
+#define TLB_SECTION \
+    .itlb = TLB_TEMPLATE, \
+    .dtlb = TLB_TEMPLATE
+
 #endif
 
 #if (defined(TARGET_WORDS_BIGENDIAN) != 0) == (XCHAL_HAVE_BE != 0)
Signature · 1 line
1.7.7.6
#3 lore raw

PATCH 2/12 target-xtensa: implement info tlb monitor command

Command dumps valid ITLB and DTLB entries.

---
 hmp-commands.hx        |    2 +-
 monitor.c              |    4 +-
 target-xtensa/cpu.h    |    1 +
 target-xtensa/helper.c |   67 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+), 3 deletions(-)
hmp-commands.hx +1 -1
index 573b823..454d619 100644
@@ -1341,7 +1341,7 @@ show i8259 (PIC) state
 @item info pci
 show emulated PCI device info
 @item info tlb
-show virtual to physical memory mappings (i386, SH4, SPARC, and PPC only)
+show virtual to physical memory mappings (i386, SH4, SPARC, PPC, and Xtensa only)
 @item info mem
 show the active virtual memory mappings (i386 only)
 @item info jit
monitor.c +2 -2
index aadbdcb..2ac1965 100644
@@ -1935,7 +1935,7 @@ static void tlb_info(Monitor *mon)
 
 #endif
 
-#if defined(TARGET_SPARC) || defined(TARGET_PPC)
+#if defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_XTENSA)
 static void tlb_info(Monitor *mon)
 {
     CPUState *env1 = mon_get_cpu();
@@ -2382,7 +2382,7 @@ static mon_cmd_t info_cmds[] = {
         .mhandler.info = hmp_info_pci,
     },
 #if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
-    defined(TARGET_PPC)
+    defined(TARGET_PPC) || defined(TARGET_XTENSA)
     {
         .name       = "tlb",
         .args_type  = "",
target-xtensa/cpu.h +1 -0
index 0db83a6..c32bf35 100644
@@ -344,6 +344,7 @@ void xtensa_tlb_set_entry(CPUState *env, bool dtlb,
 int xtensa_get_physical_addr(CPUState *env,
         uint32_t vaddr, int is_write, int mmu_idx,
         uint32_t *paddr, uint32_t *page_size, unsigned *access);
+void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUState *env);
 
 
 #define XTENSA_OPTION_BIT(opt) (((uint64_t)1) << (opt))
target-xtensa/helper.c +67 -0

70 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#4 lore raw

PATCH 3/12 target-xtensa: fetch 3rd opcode byte only when needed

In reply to Max Filippov

According to ISA, 3.5.4, third opcode byte should not be fetched for 2-byte instructions.

---
 target-xtensa/translate.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
target-xtensa/translate.c +2 -1
index c81450d..6a0177f 100644
@@ -749,7 +749,7 @@ static void disas_xtensa_insn(DisasContext *dc)
 
     uint8_t b0 = ldub_code(dc->pc);
     uint8_t b1 = ldub_code(dc->pc + 1);
-    uint8_t b2 = ldub_code(dc->pc + 2);
+    uint8_t b2 = 0;
 
     static const uint32_t B4CONST[] = {
         0xffffffff, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
@@ -764,6 +764,7 @@ static void disas_xtensa_insn(DisasContext *dc)
         HAS_OPTION(XTENSA_OPTION_CODE_DENSITY);
     } else {
         dc->next_pc = dc->pc + 3;
+        b2 = ldub_code(dc->pc + 2);
     }
 
     switch (OP0) {
Signature · 1 line
1.7.7.6
#5 lore raw

PATCH 4/12 target-xtensa: add DEBUGCAUSE SR and configuration

In reply to Max Filippov

DEBUGCAUSE SR holds information about the most recent debug exception. See ISA, 4.7.7 for more details.

---
 target-xtensa/cpu.h       |   15 +++++++++++++++
 target-xtensa/translate.c |    6 ++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
target-xtensa/cpu.h +15 -0
index c32bf35..c77fe13 100644
@@ -137,6 +137,7 @@ enum {
     PS = 230,
     VECBASE = 231,
     EXCCAUSE = 232,
+    DEBUGCAUSE = 233,
     CCOUNT = 234,
     PRID = 235,
     EXCVADDR = 238,
@@ -161,6 +162,15 @@ enum {
 
 #define PS_WOE 0x40000
 
+#define DEBUGCAUSE_IC 0x1
+#define DEBUGCAUSE_IB 0x2
+#define DEBUGCAUSE_DB 0x4
+#define DEBUGCAUSE_BI 0x8
+#define DEBUGCAUSE_BN 0x10
+#define DEBUGCAUSE_DI 0x20
+#define DEBUGCAUSE_DBNUM 0xf00
+#define DEBUGCAUSE_DBNUM_SHIFT 8
+
 #define MAX_NAREG 64
 #define MAX_NINTERRUPT 32
 #define MAX_NLEVEL 6
@@ -279,6 +289,11 @@ typedef struct XtensaConfig {
     uint32_t timerint[MAX_NCCOMPARE];
     unsigned nextint;
     unsigned extint[MAX_NINTERRUPT];
+
+    unsigned debug_level;
+    unsigned nibreak;
+    unsigned ndbreak;
+
     uint32_t clock_freq_khz;
 
     xtensa_tlb itlb;
target-xtensa/translate.c +6 -0
index 6a0177f..da5fdb5 100644
@@ -119,6 +119,7 @@ static const char * const sregnames[256] = {
     [PS] = "PS",
     [VECBASE] = "VECBASE",
     [EXCCAUSE] = "EXCCAUSE",
+    [DEBUGCAUSE] = "DEBUGCAUSE",
     [CCOUNT] = "CCOUNT",
     [PRID] = "PRID",
     [EXCVADDR] = "EXCVADDR",
@@ -535,6 +536,10 @@ static void gen_wsr_ps(DisasContext *dc, uint32_t sr, TCGv_i32 v)
     gen_jumpi_check_loop_end(dc, -1);
 }
 
+static void gen_wsr_debugcause(DisasContext *dc, uint32_t sr, TCGv_i32 v)
+{
+}
+
 static void gen_wsr_prid(DisasContext *dc, uint32_t sr, TCGv_i32 v)
 {
 }
@@ -571,6 +576,7 @@ static void gen_wsr(DisasContext *dc, uint32_t sr, TCGv_i32 s)
         [INTCLEAR] = gen_wsr_intclear,
         [INTENABLE] = gen_wsr_intenable,
         [PS] = gen_wsr_ps,
+        [DEBUGCAUSE] = gen_wsr_debugcause,
         [PRID] = gen_wsr_prid,
         [CCOMPARE] = gen_wsr_ccompare,
         [CCOMPARE + 1] = gen_wsr_ccompare,
Signature · 1 line
1.7.7.6
#6 lore raw

PATCH 5/12 target-xtensa: implement instruction breakpoints

In reply to Max Filippov

Add IBREAKA/IBREAKENABLE SRs and implement debug exception, BREAK and BREAK.N instructions and IBREAK breakpoints.

IBREAK breakpoint address is considered constant for TB lifetime. On IBREAKA/IBREAKENABLE change corresponding TBs are invalidated.

---
 target-xtensa/cpu.h       |    9 ++++++
 target-xtensa/helper.c    |    2 +
 target-xtensa/helpers.h   |    5 +++
 target-xtensa/op_helper.c |   38 +++++++++++++++++++++++++
 target-xtensa/translate.c |   68 +++++++++++++++++++++++++++++++++++++++++++--
 5 files changed, 119 insertions(+), 3 deletions(-)
target-xtensa/cpu.h +9 -0
index c77fe13..a18072b 100644
@@ -126,6 +126,8 @@ enum {
     RASID = 90,
     ITLBCFG = 91,
     DTLBCFG = 92,
+    IBREAKENABLE = 96,
+    IBREAKA = 128,
     EPC1 = 177,
     DEPC = 192,
     EPS2 = 194,
@@ -196,6 +198,7 @@ enum {
     EXC_KERNEL,
     EXC_USER,
     EXC_DOUBLE,
+    EXC_DEBUG,
     EXC_MAX
 };
 
@@ -425,6 +428,7 @@ static inline int cpu_mmu_index(CPUState *env)
 #define XTENSA_TBFLAG_RING_MASK 0x3
 #define XTENSA_TBFLAG_EXCM 0x4
 #define XTENSA_TBFLAG_LITBASE 0x8
+#define XTENSA_TBFLAG_DEBUG 0x10
 
 static inline void cpu_get_tb_cpu_state(CPUState *env, target_ulong *pc,
         target_ulong *cs_base, int *flags)
@@ -440,6 +444,11 @@ static inline void cpu_get_tb_cpu_state(CPUState *env, target_ulong *pc,
             (env->sregs[LITBASE] & 1)) {
         *flags |= XTENSA_TBFLAG_LITBASE;
     }
+    if (xtensa_option_enabled(env->config, XTENSA_OPTION_DEBUG)) {
+        if (xtensa_get_cintlevel(env) < env->config->debug_level) {
+            *flags |= XTENSA_TBFLAG_DEBUG;
+        }
+    }
 }
 
 #include "cpu-all.h"
target-xtensa/helper.c +2 -0
index 973c268..0a26f8d 100644
@@ -44,6 +44,7 @@ void cpu_reset(CPUXtensaState *env)
     env->sregs[PS] = xtensa_option_enabled(env->config,
             XTENSA_OPTION_INTERRUPT) ? 0x1f : 0x10;
     env->sregs[VECBASE] = env->config->vecbase;
+    env->sregs[IBREAKENABLE] = 0;
 
     env->pending_irq_level = 0;
     reset_mmu(env);
@@ -193,6 +194,7 @@ void do_interrupt(CPUState *env)
     case EXC_KERNEL:
     case EXC_USER:
     case EXC_DOUBLE:
+    case EXC_DEBUG:
         qemu_log_mask(CPU_LOG_INT, "%s(%d) "
                 "pc = %08x, a0 = %08x, ps = %08x, ccount = %08x\n",
                 __func__, env->exception_index,
target-xtensa/helpers.h +5 -0
index 09ab332..afe39d4 100644
@@ -3,6 +3,8 @@
 DEF_HELPER_1(exception, void, i32)
 DEF_HELPER_2(exception_cause, void, i32, i32)
 DEF_HELPER_3(exception_cause_vaddr, void, i32, i32, i32)
+DEF_HELPER_2(debug_exception, void, i32, i32)
+
 DEF_HELPER_1(nsa, i32, i32)
 DEF_HELPER_1(nsau, i32, i32)
 DEF_HELPER_1(wsr_windowbase, void, i32)
@@ -29,4 +31,7 @@ DEF_HELPER_2(itlb, void, i32, i32)
 DEF_HELPER_2(ptlb, i32, i32, i32)
 DEF_HELPER_3(wtlb, void, i32, i32, i32)
 
+DEF_HELPER_1(wsr_ibreakenable, void, i32)
+DEF_HELPER_2(wsr_ibreaka, void, i32, i32)
+
 #include "def-helper.h"
target-xtensa/op_helper.c +38 -0
index 0605611..1feaaee 100644
@@ -134,6 +134,19 @@ void HELPER(exception_cause_vaddr)(uint32_t pc, uint32_t cause, uint32_t vaddr)
     HELPER(exception_cause)(pc, cause);
 }
 
+void HELPER(debug_exception)(uint32_t pc, uint32_t cause)
+{
+    unsigned level = env->config->debug_level;
+
+    env->pc = pc;
+    env->sregs[DEBUGCAUSE] = cause;
+    env->sregs[EPC1 + level - 1] = pc;
+    env->sregs[EPS2 + level - 2] = env->sregs[PS];
+    env->sregs[PS] = (env->sregs[PS] & ~PS_INTLEVEL) | PS_EXCM |
+        (level << PS_INTLEVEL_SHIFT);
+    HELPER(exception)(EXC_DEBUG);
+}
+
 uint32_t HELPER(nsa)(uint32_t v)
 {
     if (v & 0x80000000) {
@@ -662,3 +675,28 @@ void HELPER(wtlb)(uint32_t p, uint32_t v, uint32_t dtlb)
     split_tlb_entry_spec(v, dtlb, &vpn, &wi, &ei);
     xtensa_tlb_set_entry(env, dtlb, wi, ei, vpn, p);
 }
+
+
+void HELPER(wsr_ibreakenable)(uint32_t v)
+{
+    uint32_t change = v ^ env->sregs[IBREAKENABLE];
+    unsigned i;
+
+    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);
+        }
+    }
+    env->sregs[IBREAKENABLE] = v & ((1 << env->config->nibreak) - 1);
+}
+
+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);
+    }
+    env->sregs[IBREAKA + i] = v;
+}
target-xtensa/translate.c +65 -3

128 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#7 lore raw

PATCH 6/12 target-xtensa: add ICOUNT SR and debug exception

In reply to Max Filippov

ICOUNT SR gets incremented on every instruction completion provided that CINTLEVEL at the beginning of the instruction execution is lower than ICOUNTLEVEL.

When ICOUNT would increment to 0 a debug exception is raised if CINTLEVEL is lower than DEBUGLEVEL.

See ISA, 4.7.7.5 for more details.

---
 target-xtensa/cpu.h       |    6 +++++
 target-xtensa/translate.c |   49 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 54 insertions(+), 1 deletions(-)
target-xtensa/cpu.h +6 -0
index a18072b..92441e3 100644
@@ -142,6 +142,8 @@ enum {
     DEBUGCAUSE = 233,
     CCOUNT = 234,
     PRID = 235,
+    ICOUNT = 236,
+    ICOUNTLEVEL = 237,
     EXCVADDR = 238,
     CCOMPARE = 240,
 };
@@ -429,6 +431,7 @@ static inline int cpu_mmu_index(CPUState *env)
 #define XTENSA_TBFLAG_EXCM 0x4
 #define XTENSA_TBFLAG_LITBASE 0x8
 #define XTENSA_TBFLAG_DEBUG 0x10
+#define XTENSA_TBFLAG_ICOUNT 0x20
 
 static inline void cpu_get_tb_cpu_state(CPUState *env, target_ulong *pc,
         target_ulong *cs_base, int *flags)
@@ -448,6 +451,9 @@ static inline void cpu_get_tb_cpu_state(CPUState *env, target_ulong *pc,
         if (xtensa_get_cintlevel(env) < env->config->debug_level) {
             *flags |= XTENSA_TBFLAG_DEBUG;
         }
+        if (xtensa_get_cintlevel(env) < env->sregs[ICOUNTLEVEL]) {
+            *flags |= XTENSA_TBFLAG_ICOUNT;
+        }
     }
 }
 
target-xtensa/translate.c +48 -1

110 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#8 lore raw

PATCH 7/12 exec: add missing breaks to the watch_mem_write

In reply to Max Filippov
---
 exec.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
exec.c +9 -3
index b81677a..f105b43 100644
@@ -3289,9 +3289,15 @@ static void watch_mem_write(void *opaque, target_phys_addr_t addr,
 {
     check_watchpoint(addr & ~TARGET_PAGE_MASK, ~(size - 1), BP_MEM_WRITE);
     switch (size) {
-    case 1: stb_phys(addr, val);
-    case 2: stw_phys(addr, val);
-    case 4: stl_phys(addr, val);
+    case 1:
+        stb_phys(addr, val);
+        break;
+    case 2:
+        stw_phys(addr, val);
+        break;
+    case 4:
+        stl_phys(addr, val);
+        break;
     default: abort();
     }
 }
Signature · 1 line
1.7.7.6
#9 lore raw

Re: [Qemu-devel] [PATCH 07/12] exec: add missing breaks to the watch_mem_write

Thanks, incidentally:

Am 18.02.2012 18:11, schrieb Max Filippov:

Quoted 1 line

Reviewed-by is missing. Care to fix on your branch?

I don't see any Rb/Ab on the others as well, please check.

Andreas

Quoted 27 lines
---
 exec.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
exec.c +9 -3
index b81677a..f105b43 100644
@@ -3289,9 +3289,15 @@ static void watch_mem_write(void *opaque, target_phys_addr_t addr,
 {
     check_watchpoint(addr & ~TARGET_PAGE_MASK, ~(size - 1), BP_MEM_WRITE);
     switch (size) {
-    case 1: stb_phys(addr, val);
-    case 2: stw_phys(addr, val);
-    case 4: stl_phys(addr, val);
+    case 1:
+        stb_phys(addr, val);
+        break;
+    case 2:
+        stw_phys(addr, val);
+        break;
+    case 4:
+        stl_phys(addr, val);
+        break;
     default: abort();
     }
 }
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#10 lore raw

Re: [Qemu-devel] [PATCH 07/12] exec: add missing breaks to the watch_mem_write

Quoted 6 lines

Thanks, incidentally:

Am 18.02.2012 18:11, schrieb Max Filippov:

Quoted 1 line

Reviewed-by is missing. Care to fix on your branch?

Done.

Quoted 1 line

I don't see any Rb/Ab on the others as well, please check.

A haven't got any other Rb/Ab.

Thanks.
-- Max

Reviewed-by on v1 7/12
#11 lore raw

Re: [Qemu-devel] [PATCH 07/12] exec: add missing breaks to the watch_mem_write

In reply to Max Filippov
Quoted 1 line · Max Filippov
Quoted 27 lines
---
 exec.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
exec.c +9 -3
index b81677a..f105b43 100644
@@ -3289,9 +3289,15 @@ static void watch_mem_write(void *opaque, target_phys_addr_t addr,
 {
     check_watchpoint(addr & ~TARGET_PAGE_MASK, ~(size - 1), BP_MEM_WRITE);
     switch (size) {
-    case 1: stb_phys(addr, val);
-    case 2: stw_phys(addr, val);
-    case 4: stl_phys(addr, val);
+    case 1:
+        stb_phys(addr, val);
+        break;
+    case 2:
+        stw_phys(addr, val);
+        break;
+    case 4:
+        stl_phys(addr, val);
+        break;
     default: abort();
     }
 }
Signature · 3 lines
Meador Inge
CodeSourcery / Mentor Embedded
http://www.mentor.com/embedded-software
#12 lore raw

PATCH 8/12 exec: fix check_watchpoint exiting cpu_loop

In reply to Max Filippov

In case of BP_STOP_BEFORE_ACCESS watchpoint check_watchpoint intends to signal EXCP_DEBUG exception on exit from cpu loop, but later overwrites exception code by the cpu_resume_from_signal call.

Use cpu_loop_exit with BP_STOP_BEFORE_ACCESS watchpoints.

---
 exec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
exec.c +2 -1
index f105b43..ed091f3 100644
@@ -3257,11 +3257,12 @@ static void check_watchpoint(int offset, int len_mask, int flags)
                 tb_phys_invalidate(tb, -1);
                 if (wp->flags & BP_STOP_BEFORE_ACCESS) {
                     env->exception_index = EXCP_DEBUG;
+                    cpu_loop_exit(env);
                 } else {
                     cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags);
                     tb_gen_code(env, pc, cs_base, cpu_flags, 1);
+                    cpu_resume_from_signal(env, NULL);
                 }
-                cpu_resume_from_signal(env, NULL);
             }
         } else {
             wp->flags &= ~BP_WATCHPOINT_HIT;
Signature · 1 line
1.7.7.6
#13 lore raw

PATCH 9/12 exec: let cpu_watchpoint_insert accept larger watchpoints

In reply to Max Filippov

Make cpu_watchpoint_insert accept watchpoints of any power-of-two size up to the target page size.

---
 exec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
exec.c +2 -1
index ed091f3..80560fa 100644
@@ -1443,7 +1443,8 @@ int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len,
     CPUWatchpoint *wp;
 
     /* sanity checks: allow power-of-2 lengths, deny unaligned watchpoints */
-    if ((len != 1 && len != 2 && len != 4 && len != 8) || (addr & ~len_mask)) {
+    if ((len & (len - 1)) || (addr & ~len_mask) ||
+            len == 0 || len > TARGET_PAGE_SIZE) {
         fprintf(stderr, "qemu: tried to set invalid watchpoint at "
                 TARGET_FMT_lx ", len=" TARGET_FMT_lu "\n", addr, len);
         return -EINVAL;
Signature · 1 line
1.7.7.6
#14 lore raw

PATCH 10/12 target-xtensa: add DBREAK data breakpoints

In reply to Max Filippov

Add DBREAKA/DBREAKC SRs and implement DBREAK breakpoints as debug watchpoints.

This implementation is not fully compliant to ISA: when a breakpoint is set to an unmapped/inaccessible memory address it generates TLB/memory protection exception instead of debug exception.

See ISA, 4.7.7.3, 4.7.7.6 for more details.

---
 target-xtensa/cpu.h       |   12 ++++++++
 target-xtensa/helper.c    |   41 +++++++++++++++++++++++++++++
 target-xtensa/helpers.h   |    2 +
 target-xtensa/op_helper.c |   62 +++++++++++++++++++++++++++++++++++++++++++++
 target-xtensa/translate.c |   30 +++++++++++++++++++++
 5 files changed, 147 insertions(+), 0 deletions(-)
target-xtensa/cpu.h +12 -0
index 92441e3..fb8a727 100644
@@ -128,6 +128,8 @@ enum {
     DTLBCFG = 92,
     IBREAKENABLE = 96,
     IBREAKA = 128,
+    DBREAKA = 144,
+    DBREAKC = 160,
     EPC1 = 177,
     DEPC = 192,
     EPS2 = 194,
@@ -175,12 +177,18 @@ enum {
 #define DEBUGCAUSE_DBNUM 0xf00
 #define DEBUGCAUSE_DBNUM_SHIFT 8
 
+#define DBREAKC_SB 0x80000000
+#define DBREAKC_LB 0x40000000
+#define DBREAKC_SB_LB (DBREAKC_SB | DBREAKC_LB)
+#define DBREAKC_MASK 0x3f
+
 #define MAX_NAREG 64
 #define MAX_NINTERRUPT 32
 #define MAX_NLEVEL 6
 #define MAX_NNMI 1
 #define MAX_NCCOMPARE 3
 #define MAX_TLB_WAY_SIZE 8
+#define MAX_NDBREAK 2
 
 #define REGION_PAGE_MASK 0xe0000000
 
@@ -330,6 +338,9 @@ typedef struct CPUXtensaState {
 
     int exception_taken;
 
+    /* Watchpoints for DBREAK registers */
+    CPUWatchpoint *cpu_watchpoint[MAX_NDBREAK];
+
     CPU_COMMON
 } CPUXtensaState;
 
@@ -365,6 +376,7 @@ int xtensa_get_physical_addr(CPUState *env,
         uint32_t vaddr, int is_write, int mmu_idx,
         uint32_t *paddr, uint32_t *page_size, unsigned *access);
 void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUState *env);
+void debug_exception_env(CPUState *new_env, uint32_t cause);
 
 
 #define XTENSA_OPTION_BIT(opt) (((uint64_t)1) << (opt))
target-xtensa/helper.c +41 -0

56 lines not on this page · raw message

target-xtensa/helpers.h +2 -0
index afe39d4..48a741e 100644
@@ -33,5 +33,7 @@ DEF_HELPER_3(wtlb, void, i32, i32, i32)
 
 DEF_HELPER_1(wsr_ibreakenable, void, i32)
 DEF_HELPER_2(wsr_ibreaka, void, i32, i32)
+DEF_HELPER_2(wsr_dbreaka, void, i32, i32)
+DEF_HELPER_2(wsr_dbreakc, void, i32, i32)
 
 #include "def-helper.h"
target-xtensa/op_helper.c +62 -0

71 lines not on this page · raw message

target-xtensa/translate.c +30 -0
index 3bf880f..9e8e20a 100644
@@ -98,6 +98,10 @@ static const char * const sregnames[256] = {
     [IBREAKENABLE] = "IBREAKENABLE",
     [IBREAKA] = "IBREAKA0",
     [IBREAKA + 1] = "IBREAKA1",
+    [DBREAKA] = "DBREAKA0",
+    [DBREAKA + 1] = "DBREAKA1",
+    [DBREAKC] = "DBREAKC0",
+    [DBREAKC + 1] = "DBREAKC1",
     [EPC1] = "EPC1",
     [EPC1 + 1] = "EPC2",
     [EPC1 + 2] = "EPC3",
@@ -536,6 +540,28 @@ static void gen_wsr_ibreaka(DisasContext *dc, uint32_t sr, TCGv_i32 v)
     }
 }
 
+static void gen_wsr_dbreaka(DisasContext *dc, uint32_t sr, TCGv_i32 v)
+{
+    unsigned id = sr - DBREAKA;
+
+    if (id < dc->config->ndbreak) {
+        TCGv_i32 tmp = tcg_const_i32(id);
+        gen_helper_wsr_dbreaka(tmp, v);
+        tcg_temp_free(tmp);
+    }
+}
+
+static void gen_wsr_dbreakc(DisasContext *dc, uint32_t sr, TCGv_i32 v)
+{
+    unsigned id = sr - DBREAKC;
+
+    if (id < dc->config->ndbreak) {
+        TCGv_i32 tmp = tcg_const_i32(id);
+        gen_helper_wsr_dbreakc(tmp, v);
+        tcg_temp_free(tmp);
+    }
+}
+
 static void gen_wsr_intset(DisasContext *dc, uint32_t sr, TCGv_i32 v)
 {
     tcg_gen_andi_i32(cpu_SR[sr], v,
@@ -634,6 +660,10 @@ static void gen_wsr(DisasContext *dc, uint32_t sr, TCGv_i32 s)
         [IBREAKENABLE] = gen_wsr_ibreakenable,
         [IBREAKA] = gen_wsr_ibreaka,
         [IBREAKA + 1] = gen_wsr_ibreaka,
+        [DBREAKA] = gen_wsr_dbreaka,
+        [DBREAKA + 1] = gen_wsr_dbreaka,
+        [DBREAKC] = gen_wsr_dbreakc,
+        [DBREAKC + 1] = gen_wsr_dbreakc,
         [INTSET] = gen_wsr_intset,
         [INTCLEAR] = gen_wsr_intclear,
         [INTENABLE] = gen_wsr_intenable,
Signature · 1 line
1.7.7.6
#15 lore raw

PATCH 11/12 target-xtensa: add DEBUG_SECTION to overlay tool

In reply to Max Filippov

Fill debug configuration from overlay definitions in the DEBUG_SECTION. Add DEBUG_SECTION to DC232B and FSF cores.

---
 target-xtensa/core-dc232b.c  |    1 +
 target-xtensa/core-fsf.c     |    1 +
 target-xtensa/overlay_tool.h |    5 +++++
 3 files changed, 7 insertions(+), 0 deletions(-)
target-xtensa/core-dc232b.c +1 -0
index 4d9bd55..b723c4c 100644
@@ -22,6 +22,7 @@ static const XtensaConfig dc232b = {
     EXCEPTIONS_SECTION,
     INTERRUPTS_SECTION,
     TLB_SECTION,
+    DEBUG_SECTION,
     .clock_freq_khz = 10000,
 };
 
target-xtensa/core-fsf.c +1 -0
index 7650462..88de4dd 100644
@@ -16,6 +16,7 @@ static const XtensaConfig fsf = {
     EXCEPTIONS_SECTION,
     INTERRUPTS_SECTION,
     TLB_SECTION,
+    DEBUG_SECTION,
     .clock_freq_khz = 10000,
 };
 
target-xtensa/overlay_tool.h +5 -0
index e7c4c3a..a3a5650 100644
@@ -114,6 +114,7 @@
         [EXC_KERNEL] = XCHAL_KERNEL_VECTOR_VADDR, \
         [EXC_USER] = XCHAL_USER_VECTOR_VADDR, \
         [EXC_DOUBLE] = XCHAL_DOUBLEEXC_VECTOR_VADDR, \
+        [EXC_DEBUG] = XCHAL_DEBUG_VECTOR_VADDR, \
     }
 
 #define INTERRUPT_VECTORS { \
@@ -302,6 +303,10 @@
 #define REGISTER_CORE(core)
 #endif
 
+#define DEBUG_SECTION \
+    .debug_level = XCHAL_DEBUGLEVEL, \
+    .nibreak = XCHAL_NUM_IBREAK, \
+    .ndbreak = XCHAL_NUM_DBREAK
 
 #if XCHAL_NUM_INTLEVELS + XCHAL_HAVE_NMI + 1 <= 2
 #define XCHAL_INTLEVEL2_VECTOR_VADDR 0
Signature · 1 line
1.7.7.6
#16 lore raw

PATCH 12/12 target-xtensa: add breakpoint tests

In reply to Max Filippov
---
 tests/tcg/xtensa/Makefile     |    1 +
 tests/tcg/xtensa/test_break.S |  223 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 224 insertions(+), 0 deletions(-)
 create mode 100644 tests/tcg/xtensa/test_break.S
tests/tcg/xtensa/Makefile +1 -0
index 8713af1..7e1e619 100644
@@ -23,6 +23,7 @@ CRT        = crt.o vectors.o
 TESTCASES += test_b.tst
 TESTCASES += test_bi.tst
 #TESTCASES += test_boolean.tst
+TESTCASES += test_break.tst
 TESTCASES += test_bz.tst
 TESTCASES += test_clamps.tst
 TESTCASES += test_fail.tst
tests/tcg/xtensa/test_break.S new file +223 -0

223 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#17 lore raw
In reply to Max Filippov
Quoted 7 lines

Hi.

This is a pull request for my current target-xtensa queue. Changes in the queue are:
- 'info tlb' monitor command;
- debug option implementation;
- a few minor fixes.

ping?

Quoted 48 lines

Debug option series has been posted to the list as an RFC, there were no changes in it since then.

Please pull.

Thanks.
-- Max

The following changes since commit 99c7f87826337fa81f2f0f9baa9ca0a44faf90e9:

 input: send kbd+mouse events only to running guests. (2012-02-17 11:02:55 -0600)

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

Max Filippov (12):
 target-xtensa: define TLB_TEMPLATE for MMU-less cores
 target-xtensa: implement info tlb monitor command
 target-xtensa: fetch 3rd opcode byte only when needed
 target-xtensa: add DEBUGCAUSE SR and configuration
 target-xtensa: implement instruction breakpoints
 target-xtensa: add ICOUNT SR and debug exception
 exec: add missing breaks to the watch_mem_write
 exec: fix check_watchpoint exiting cpu_loop
 exec: let cpu_watchpoint_insert accept larger watchpoints
 target-xtensa: add DBREAK data breakpoints
 target-xtensa: add DEBUG_SECTION to overlay tool
 target-xtensa: add breakpoint tests

 exec.c                        |   18 +++-
 hmp-commands.hx               |    2 +-
 monitor.c                     |    4 +- target-xtensa/core-dc232b.c   |    1 +
 target-xtensa/core-fsf.c      |    1 +
 target-xtensa/cpu.h           |   43 ++++++++ target-xtensa/helper.c        |  110 ++++++++++++++++++++ target-xtensa/helpers.h       |    7 ++
 target-xtensa/op_helper.c     |  100 ++++++++++++++++++ target-xtensa/overlay_tool.h  |   23 ++++- target-xtensa/translate.c     |  156 ++++++++++++++++++++++++++++- tests/tcg/xtensa/Makefile     |    1 + tests/tcg/xtensa/test_break.S |  223 +++++++++++++++++++++++++++++++++++++++++

 13 files changed, 674 insertions(+), 15 deletions(-)

 create mode 100644 tests/tcg/xtensa/test_break.S

--
1.7.7.6

Signature · 2 lines
Thanks.
-- Max
#18 lore raw
Quoted 9 lines · Max Filippov
Quoted 7 lines

Hi.

This is a pull request for my current target-xtensa queue. Changes in the queue are:
- 'info tlb' monitor command;
- debug option implementation;
- a few minor fixes.

ping?

Thanks, pulled.

Quoted 52 lines
Quoted 43 lines

Debug option series has been posted to the list as an RFC, there were no changes in it since then.

Please pull.

Thanks.
-- Max

The following changes since commit 99c7f87826337fa81f2f0f9baa9ca0a44faf90e9:

 input: send kbd+mouse events only to running guests. (2012-02-17 11:02:55 -0600)

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

Max Filippov (12):
 target-xtensa: define TLB_TEMPLATE for MMU-less cores
 target-xtensa: implement info tlb monitor command
 target-xtensa: fetch 3rd opcode byte only when needed
 target-xtensa: add DEBUGCAUSE SR and configuration
 target-xtensa: implement instruction breakpoints
 target-xtensa: add ICOUNT SR and debug exception
 exec: add missing breaks to the watch_mem_write
 exec: fix check_watchpoint exiting cpu_loop
 exec: let cpu_watchpoint_insert accept larger watchpoints
 target-xtensa: add DBREAK data breakpoints
 target-xtensa: add DEBUG_SECTION to overlay tool
 target-xtensa: add breakpoint tests

 exec.c                        |   18 +++-
 hmp-commands.hx               |    2 +-
 monitor.c                     |    4 +- target-xtensa/core-dc232b.c   |    1 +
 target-xtensa/core-fsf.c      |    1 +
 target-xtensa/cpu.h           |   43 ++++++++ target-xtensa/helper.c        |  110 ++++++++++++++++++++ target-xtensa/helpers.h       |    7 ++
 target-xtensa/op_helper.c     |  100 ++++++++++++++++++ target-xtensa/overlay_tool.h  |   23 ++++- target-xtensa/translate.c     |  156 ++++++++++++++++++++++++++++- tests/tcg/xtensa/Makefile     |    1 + tests/tcg/xtensa/test_break.S |  223 +++++++++++++++++++++++++++++++++++++++++

Quoted 5 lines
 13 files changed, 674 insertions(+), 15 deletions(-)

 create mode 100644 tests/tcg/xtensa/test_break.S

--
1.7.7.6

--
Thanks.
-- Max