From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMnt6-0000ku-Gx for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMnsz-000586-SB for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:12 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42215 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMnsz-00057z-Hz for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:05 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 10 Mar 2014 01:15:19 +0100 Message-Id: <1394410549-13751-11-git-send-email-afaerber@suse.de> In-Reply-To: <1394410549-13751-1-git-send-email-afaerber@suse.de> References: <1394410549-13751-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v2 10/40] cpu: Move mem_io_{pc, vaddr} fields from CPU_COMMON to CPUState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori , "Michael S. Tsirkin" Reset them. Signed-off-by: Andreas F=C3=A4rber --- exec.c | 9 +++++---- hw/i386/kvmvapic.c | 2 +- include/exec/cpu-defs.h | 7 ------- include/exec/softmmu_template.h | 8 ++++---- include/qom/cpu.h | 8 ++++++++ qom/cpu.c | 2 ++ target-i386/helper.c | 5 +++-- translate-all.c | 15 ++++++++------- 8 files changed, 31 insertions(+), 25 deletions(-) diff --git a/exec.c b/exec.c index 680268a..5c36cdc 100644 --- a/exec.c +++ b/exec.c @@ -1547,7 +1547,7 @@ static void notdirty_mem_write(void *opaque, hwaddr= ram_addr, flushed */ if (!cpu_physical_memory_is_clean(ram_addr)) { CPUArchState *env =3D current_cpu->env_ptr; - tlb_set_dirty(env, env->mem_io_vaddr); + tlb_set_dirty(env, current_cpu->mem_io_vaddr); } } =20 @@ -1566,7 +1566,8 @@ static const MemoryRegionOps notdirty_mem_ops =3D { /* Generate a debug exception if a watchpoint has been hit. */ static void check_watchpoint(int offset, int len_mask, int flags) { - CPUArchState *env =3D current_cpu->env_ptr; + CPUState *cpu =3D current_cpu; + CPUArchState *env =3D cpu->env_ptr; target_ulong pc, cs_base; target_ulong vaddr; CPUWatchpoint *wp; @@ -1576,10 +1577,10 @@ static void check_watchpoint(int offset, int len_= mask, int flags) /* We re-entered the check after replacing the TB. Now raise * the debug interrupt so that is will trigger after the * current instruction. */ - cpu_interrupt(ENV_GET_CPU(env), CPU_INTERRUPT_DEBUG); + cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); return; } - vaddr =3D (env->mem_io_vaddr & TARGET_PAGE_MASK) + offset; + vaddr =3D (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if ((vaddr =3D=3D (wp->vaddr & len_mask) || (vaddr & wp->len_mask) =3D=3D wp->vaddr) && (wp->flags & fl= ags)) { diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index 72025d0..6cf5d41 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -406,7 +406,7 @@ static void patch_instruction(VAPICROMState *s, X86CP= U *cpu, target_ulong ip) } =20 if (!kvm_enabled()) { - cpu_restore_state(env, env->mem_io_pc); + cpu_restore_state(env, cs->mem_io_pc); cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base, ¤t_flags); } diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 01cd8c7..f228d8c 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -145,13 +145,6 @@ typedef struct CPUWatchpoint { #define CPU_TEMP_BUF_NLONGS 128 #define CPU_COMMON = \ /* soft mmu support */ = \ - /* in order to avoid passing too many arguments to the MMIO = \ - helpers, we store some rarely used information in the CPU = \ - context) */ = \ - uintptr_t mem_io_pc; /* host pc at which the memory was = \ - accessed */ = \ - target_ulong mem_io_vaddr; /* target virtual addr at which the = \ - memory was accessed */ = \ CPU_COMMON_TLB = \ struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; = \ = \ diff --git a/include/exec/softmmu_template.h b/include/exec/softmmu_templ= ate.h index c14a04d..c7cd937 100644 --- a/include/exec/softmmu_template.h +++ b/include/exec/softmmu_template.h @@ -126,12 +126,12 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(CPUAr= chState *env, MemoryRegion *mr =3D iotlb_to_region(cpu->as, physaddr); =20 physaddr =3D (physaddr & TARGET_PAGE_MASK) + addr; - env->mem_io_pc =3D retaddr; + cpu->mem_io_pc =3D retaddr; if (mr !=3D &io_mem_rom && mr !=3D &io_mem_notdirty && !can_do_io(en= v)) { cpu_io_recompile(env, retaddr); } =20 - env->mem_io_vaddr =3D addr; + cpu->mem_io_vaddr =3D addr; io_mem_read(mr, physaddr, &val, 1 << SHIFT); return val; } @@ -337,8 +337,8 @@ static inline void glue(io_write, SUFFIX)(CPUArchStat= e *env, cpu_io_recompile(env, retaddr); } =20 - env->mem_io_vaddr =3D addr; - env->mem_io_pc =3D retaddr; + cpu->mem_io_vaddr =3D addr; + cpu->mem_io_pc =3D retaddr; io_mem_write(mr, physaddr, val, 1 << SHIFT); } =20 diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 5af434d..9d52cf3 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -163,6 +163,8 @@ struct kvm_run; * @gdb_num_regs: Number of total registers accessible to GDB. * @gdb_num_g_regs: Number of registers in GDB 'g' packets. * @next_cpu: Next CPU sharing TB cache. + * @mem_io_pc: Host Program Counter at which the memory was accessed. + * @mem_io_vaddr: Target virtual address at which the memory was accesse= d. * @kvm_fd: vCPU file descriptor for KVM. * * State of one CPU core or thread. @@ -204,6 +206,12 @@ struct CPUState { int gdb_num_g_regs; QTAILQ_ENTRY(CPUState) node; =20 + /* In order to avoid passing too many arguments to the MMIO helpers, + * we store some rarely used information in the CPU context. + */ + uintptr_t mem_io_pc; + vaddr mem_io_vaddr; + int kvm_fd; bool kvm_vcpu_dirty; struct KVMState *kvm_state; diff --git a/qom/cpu.c b/qom/cpu.c index 4e5446a..c59e8b1 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -240,6 +240,8 @@ static void cpu_common_reset(CPUState *cpu) cpu->interrupt_request =3D 0; cpu->current_tb =3D NULL; cpu->halted =3D 0; + cpu->mem_io_pc =3D 0; + cpu->mem_io_vaddr =3D 0; } =20 static bool cpu_common_has_work(CPUState *cs) diff --git a/target-i386/helper.c b/target-i386/helper.c index 696bbf5..4910e40 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1254,13 +1254,14 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu= , int bank, void cpu_report_tpr_access(CPUX86State *env, TPRAccess access) { X86CPU *cpu =3D x86_env_get_cpu(env); + CPUState *cs =3D CPU(cpu); =20 if (kvm_enabled()) { env->tpr_access_type =3D access; =20 - cpu_interrupt(CPU(cpu), CPU_INTERRUPT_TPR); + cpu_interrupt(cs, CPU_INTERRUPT_TPR); } else { - cpu_restore_state(env, env->mem_io_pc); + cpu_restore_state(env, cs->mem_io_pc); =20 apic_handle_tpr_access_report(cpu->apic_state, env->eip, access)= ; } diff --git a/translate-all.c b/translate-all.c index 1ac0246..dc35caa 100644 --- a/translate-all.c +++ b/translate-all.c @@ -1063,9 +1063,9 @@ void tb_invalidate_phys_page_range(tb_page_addr_t s= tart, tb_page_addr_t end, if (current_tb_not_found) { current_tb_not_found =3D 0; current_tb =3D NULL; - if (env->mem_io_pc) { + if (cpu->mem_io_pc) { /* now we have a real cpu fault */ - current_tb =3D tb_find_pc(env->mem_io_pc); + current_tb =3D tb_find_pc(cpu->mem_io_pc); } } if (current_tb =3D=3D tb && @@ -1077,7 +1077,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t s= tart, tb_page_addr_t end, restore the CPU state */ =20 current_tb_modified =3D 1; - cpu_restore_state_from_tb(current_tb, env, env->mem_io_p= c); + cpu_restore_state_from_tb(current_tb, env, cpu->mem_io_p= c); cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base, ¤t_flags); } @@ -1104,7 +1104,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t s= tart, tb_page_addr_t end, if (!p->first_tb) { invalidate_page_bitmap(p); if (is_cpu_write_access) { - tlb_unprotect_code_phys(env, start, env->mem_io_vaddr); + tlb_unprotect_code_phys(env, start, cpu->mem_io_vaddr); } } #endif @@ -1376,14 +1376,15 @@ void tb_invalidate_phys_addr(AddressSpace *as, hw= addr addr) =20 void tb_check_watchpoint(CPUArchState *env) { + CPUState *cpu =3D ENV_GET_CPU(env); TranslationBlock *tb; =20 - tb =3D tb_find_pc(env->mem_io_pc); + tb =3D tb_find_pc(cpu->mem_io_pc); if (!tb) { cpu_abort(env, "check_watchpoint: could not find TB for pc=3D%p"= , - (void *)env->mem_io_pc); + (void *)cpu->mem_io_pc); } - cpu_restore_state_from_tb(tb, env, env->mem_io_pc); + cpu_restore_state_from_tb(tb, env, cpu->mem_io_pc); tb_phys_invalidate(tb, -1); } =20 --=20 1.8.4.5