Commit d79acba420196a07f94b8d789972de7ff776f548

Authored by balrog
1 parent 88fe8a41

Fix writes to pages containing watchpoints for the RAM not at 0x0 cases.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3025 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 7 additions and 7 deletions
cpu-defs.h
@@ -141,7 +141,7 @@ typedef struct CPUTLBEntry { @@ -141,7 +141,7 @@ typedef struct CPUTLBEntry {
141 \ 141 \
142 struct { \ 142 struct { \
143 target_ulong vaddr; \ 143 target_ulong vaddr; \
144 - int is_ram; \ 144 + target_phys_addr_t addend; \
145 } watchpoint[MAX_WATCHPOINTS]; \ 145 } watchpoint[MAX_WATCHPOINTS]; \
146 int nb_watchpoints; \ 146 int nb_watchpoints; \
147 int watchpoint_hit; \ 147 int watchpoint_hit; \
@@ -1626,17 +1626,18 @@ int tlb_set_page_exec(CPUState *env, target_ulong vaddr, @@ -1626,17 +1626,18 @@ int tlb_set_page_exec(CPUState *env, target_ulong vaddr,
1626 for (i = 0; i < env->nb_watchpoints; i++) { 1626 for (i = 0; i < env->nb_watchpoints; i++) {
1627 if (vaddr == (env->watchpoint[i].vaddr & TARGET_PAGE_MASK)) { 1627 if (vaddr == (env->watchpoint[i].vaddr & TARGET_PAGE_MASK)) {
1628 if (address & ~TARGET_PAGE_MASK) { 1628 if (address & ~TARGET_PAGE_MASK) {
1629 - env->watchpoint[i].is_ram = 0; 1629 + env->watchpoint[i].addend = 0;
1630 address = vaddr | io_mem_watch; 1630 address = vaddr | io_mem_watch;
1631 } else { 1631 } else {
1632 - env->watchpoint[i].is_ram = 1; 1632 + env->watchpoint[i].addend = pd - paddr +
  1633 + (unsigned long) phys_ram_base;
1633 /* TODO: Figure out how to make read watchpoints coexist 1634 /* TODO: Figure out how to make read watchpoints coexist
1634 with code. */ 1635 with code. */
1635 pd = (pd & TARGET_PAGE_MASK) | io_mem_watch | IO_MEM_ROMD; 1636 pd = (pd & TARGET_PAGE_MASK) | io_mem_watch | IO_MEM_ROMD;
1636 } 1637 }
1637 } 1638 }
1638 } 1639 }
1639 - 1640 +
1640 index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); 1641 index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
1641 addend -= vaddr; 1642 addend -= vaddr;
1642 te = &env->tlb_table[is_user][index]; 1643 te = &env->tlb_table[is_user][index];
@@ -2178,7 +2179,7 @@ static uint32_t watch_mem_readl(void *opaque, target_phys_addr_t addr) @@ -2178,7 +2179,7 @@ static uint32_t watch_mem_readl(void *opaque, target_phys_addr_t addr)
2178 2179
2179 /* Generate a debug exception if a watchpoint has been hit. 2180 /* Generate a debug exception if a watchpoint has been hit.
2180 Returns the real physical address of the access. addr will be a host 2181 Returns the real physical address of the access. addr will be a host
2181 - address in the is_ram case. */ 2182 + address in case of a RAM location. */
2182 static target_ulong check_watchpoint(target_phys_addr_t addr) 2183 static target_ulong check_watchpoint(target_phys_addr_t addr)
2183 { 2184 {
2184 CPUState *env = cpu_single_env; 2185 CPUState *env = cpu_single_env;
@@ -2190,8 +2191,7 @@ static target_ulong check_watchpoint(target_phys_addr_t addr) @@ -2190,8 +2191,7 @@ static target_ulong check_watchpoint(target_phys_addr_t addr)
2190 for (i = 0; i < env->nb_watchpoints; i++) { 2191 for (i = 0; i < env->nb_watchpoints; i++) {
2191 watch = env->watchpoint[i].vaddr; 2192 watch = env->watchpoint[i].vaddr;
2192 if (((env->mem_write_vaddr ^ watch) & TARGET_PAGE_MASK) == 0) { 2193 if (((env->mem_write_vaddr ^ watch) & TARGET_PAGE_MASK) == 0) {
2193 - if (env->watchpoint[i].is_ram)  
2194 - retaddr = addr - (unsigned long)phys_ram_base; 2194 + retaddr = addr - env->watchpoint[i].addend;
2195 if (((addr ^ watch) & ~TARGET_PAGE_MASK) == 0) { 2195 if (((addr ^ watch) & ~TARGET_PAGE_MASK) == 0) {
2196 cpu_single_env->watchpoint_hit = i + 1; 2196 cpu_single_env->watchpoint_hit = i + 1;
2197 cpu_interrupt(cpu_single_env, CPU_INTERRUPT_DEBUG); 2197 cpu_interrupt(cpu_single_env, CPU_INTERRUPT_DEBUG);