From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KAn9a-0005Lo-0M for qemu-devel@nongnu.org; Mon, 23 Jun 2008 10:36:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KAn9X-0005Ka-GQ for qemu-devel@nongnu.org; Mon, 23 Jun 2008 10:36:21 -0400 Received: from [199.232.76.173] (port=33374 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KAn9W-0005KH-6S for qemu-devel@nongnu.org; Mon, 23 Jun 2008 10:36:18 -0400 Received: from gecko.sbs.de ([194.138.37.40]:19925) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KAn9V-0004ss-TG for qemu-devel@nongnu.org; Mon, 23 Jun 2008 10:36:18 -0400 Received: from mail1.sbs.de (localhost [127.0.0.1]) by gecko.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m5NEZnHN002125 for ; Mon, 23 Jun 2008 16:35:49 +0200 Received: from [139.25.109.167] (mchn012c.ww002.siemens.net [139.25.109.167] (may be forged)) by mail1.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m5NEZnpk017931 for ; Mon, 23 Jun 2008 16:35:49 +0200 Resent-To: qemu-devel@nongnu.org Resent-Message-Id: <485FB4C4.2030301@siemens.com> Message-ID: <485FB2D4.5050601@siemens.com> Date: Mon, 23 Jun 2008 16:27:32 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <485FB18E.1090801@siemens.com> In-Reply-To: <485FB18E.1090801@siemens.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 7/15] Extend mem_write_* to mem_access_* Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org For full read-watchpoint support, it is required to keep track of the accessed vaddr as well as the accessing pc also for read operations. This patch extends the use of mem_write_pc/vaddr to mem_access_pc/vaddr therefore. Signed-off-by: Jan Kiszka --- cpu-defs.h | 8 ++++---- exec.c | 18 +++++++++--------- softmmu_template.h | 15 ++++++++++----- 3 files changed, 23 insertions(+), 18 deletions(-) Index: b/cpu-defs.h =================================================================== --- a/cpu-defs.h +++ b/cpu-defs.h @@ -148,10 +148,10 @@ typedef struct CPUWatchpoint { /* in order to avoid passing too many arguments to the memory \ write helpers, we store some rarely used information in the CPU \ context) */ \ - unsigned long mem_write_pc; /* host pc at which the memory was \ - written */ \ - target_ulong mem_write_vaddr; /* target virtual addr at which the \ - memory was written */ \ + unsigned long mem_access_pc; /* host pc at which the memory was \ + accessed */ \ + target_ulong mem_access_vaddr; /* target virtual addr at which the \ + memory was accessed */ \ int halted; /* TRUE if the CPU is in suspend state */ \ /* The meaning of the MMU modes is defined in the target code. */ \ CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \ Index: b/exec.c =================================================================== --- a/exec.c +++ b/exec.c @@ -794,9 +794,9 @@ void tb_invalidate_phys_page_range(targe if (current_tb_not_found) { current_tb_not_found = 0; current_tb = NULL; - if (env->mem_write_pc) { + if (env->mem_access_pc) { /* now we have a real cpu fault */ - current_tb = tb_find_pc(env->mem_write_pc); + current_tb = tb_find_pc(env->mem_access_pc); } } if (current_tb == tb && @@ -809,7 +809,7 @@ void tb_invalidate_phys_page_range(targe current_tb_modified = 1; cpu_restore_state(current_tb, env, - env->mem_write_pc, NULL); + env->mem_access_pc, NULL); } #endif /* TARGET_HAS_PRECISE_SMC */ /* we need to do that to handle the case where a signal @@ -833,7 +833,7 @@ void tb_invalidate_phys_page_range(targe if (!p->first_tb) { invalidate_page_bitmap(p); if (is_cpu_write_access) { - tlb_unprotect_code_phys(env, start, env->mem_write_vaddr); + tlb_unprotect_code_phys(env, start, env->mem_access_vaddr); } } #endif @@ -858,7 +858,7 @@ static inline void tb_invalidate_phys_pa if (1) { if (loglevel) { fprintf(logfile, "modifying code at 0x%x size=%d EIP=%x PC=%08x\n", - cpu_single_env->mem_write_vaddr, len, + cpu_single_env->mem_access_vaddr, len, cpu_single_env->eip, cpu_single_env->eip + (long)cpu_single_env->segs[R_CS].base); } @@ -2207,7 +2207,7 @@ static void notdirty_mem_writeb(void *op /* we remove the notdirty callback only if the code has been flushed */ if (dirty_flags == 0xff) - tlb_set_dirty(cpu_single_env, cpu_single_env->mem_write_vaddr); + tlb_set_dirty(cpu_single_env, cpu_single_env->mem_access_vaddr); } static void notdirty_mem_writew(void *opaque, target_phys_addr_t ram_addr, @@ -2232,7 +2232,7 @@ static void notdirty_mem_writew(void *op /* we remove the notdirty callback only if the code has been flushed */ if (dirty_flags == 0xff) - tlb_set_dirty(cpu_single_env, cpu_single_env->mem_write_vaddr); + tlb_set_dirty(cpu_single_env, cpu_single_env->mem_access_vaddr); } static void notdirty_mem_writel(void *opaque, target_phys_addr_t ram_addr, @@ -2257,7 +2257,7 @@ static void notdirty_mem_writel(void *op /* we remove the notdirty callback only if the code has been flushed */ if (dirty_flags == 0xff) - tlb_set_dirty(cpu_single_env, cpu_single_env->mem_write_vaddr); + tlb_set_dirty(cpu_single_env, cpu_single_env->mem_access_vaddr); } static CPUReadMemoryFunc *error_mem_read[3] = { @@ -2279,7 +2279,7 @@ static void check_watchpoint(int offset, target_ulong vaddr; CPUWatchpoint *wp; - vaddr = (env->mem_write_vaddr & TARGET_PAGE_MASK) + offset; + vaddr = (env->mem_access_vaddr & TARGET_PAGE_MASK) + offset; for (wp = env->watchpoints; wp != NULL; wp = wp->next) { if (vaddr == wp->vaddr && (wp->flags & flags)) { env->watchpoint_hit = wp; Index: b/softmmu_template.h =================================================================== --- a/softmmu_template.h +++ b/softmmu_template.h @@ -51,13 +51,16 @@ static DATA_TYPE glue(glue(slow_ld, SUFF int mmu_idx, void *retaddr); static inline DATA_TYPE glue(io_read, SUFFIX)(target_phys_addr_t physaddr, - target_ulong addr) + target_ulong addr, + void *retaddr) { DATA_TYPE res; int index; index = (physaddr >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1); physaddr = (physaddr & TARGET_PAGE_MASK) + addr; + env->mem_access_vaddr = addr; + env->mem_access_pc = (unsigned long)retaddr; #if SHIFT <= 2 res = io_mem_read[index][SHIFT](io_mem_opaque[index], physaddr); #else @@ -96,7 +99,8 @@ DATA_TYPE REGPARM glue(glue(__ld, SUFFIX if ((addr & (DATA_SIZE - 1)) != 0) goto do_unaligned_access; addend = env->iotlb[mmu_idx][index]; - res = glue(io_read, SUFFIX)(addend, addr); + retaddr = GETPC(); + res = glue(io_read, SUFFIX)(addend, addr, retaddr); } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { /* slow unaligned access (it spans two pages or IO) */ do_unaligned_access: @@ -149,7 +153,8 @@ static DATA_TYPE glue(glue(slow_ld, SUFF if ((addr & (DATA_SIZE - 1)) != 0) goto do_unaligned_access; addend = env->iotlb[mmu_idx][index]; - res = glue(io_read, SUFFIX)(addend, addr); + retaddr = GETPC(); + res = glue(io_read, SUFFIX)(addend, addr, retaddr); } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { do_unaligned_access: /* slow unaligned access (it spans two pages) */ @@ -195,8 +200,8 @@ static inline void glue(io_write, SUFFIX index = (physaddr >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1); physaddr = (physaddr & TARGET_PAGE_MASK) + addr; - env->mem_write_vaddr = addr; - env->mem_write_pc = (unsigned long)retaddr; + env->mem_access_vaddr = addr; + env->mem_access_pc = (unsigned long)retaddr; #if SHIFT <= 2 io_mem_write[index][SHIFT](io_mem_opaque[index], physaddr, val); #else