From 3b8e6a2db1946b5f21e69fde31b39f43367f1928 Mon Sep 17 00:00:00 2001 From: "Edgar E. Iglesias" Date: Tue, 5 Apr 2011 13:00:36 +0200 Subject: exec: Handle registrations of the entire address space Signed-off-by: Edgar E. Iglesias --- exec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 964ce318fb..983c0db3f7 100644 --- a/exec.c +++ b/exec.c @@ -2611,6 +2611,7 @@ void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, ram_addr_t orig_size = size; subpage_t *subpage; + assert(size); cpu_notify_set_memory(start_addr, size, phys_offset); if (phys_offset == IO_MEM_UNASSIGNED) { @@ -2619,7 +2620,9 @@ void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, region_offset &= TARGET_PAGE_MASK; size = (size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK; end_addr = start_addr + (target_phys_addr_t)size; - for(addr = start_addr; addr != end_addr; addr += TARGET_PAGE_SIZE) { + + addr = start_addr; + do { p = phys_page_find(addr >> TARGET_PAGE_BITS); if (p && p->phys_offset != IO_MEM_UNASSIGNED) { ram_addr_t orig_memory = p->phys_offset; @@ -2671,7 +2674,8 @@ void cpu_register_physical_memory_offset(target_phys_addr_t start_addr, } } region_offset += TARGET_PAGE_SIZE; - } + addr += TARGET_PAGE_SIZE; + } while (addr != end_addr); /* since each CPU stores ram addresses in its TLB cache, we must reset the modified entries */ -- cgit v1.2.3 From 71d2b725e1f38162872b198992a61fa460978d77 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 26 Mar 2011 21:06:56 +0100 Subject: exec: Remove a type cast which is no longer needed All other type casts in calls of cpu_physical_memory_write are used by hardware emulations and will be fixed by separate patches. Cc: Blue Swirl Signed-off-by: Stefan Weil Signed-off-by: Aurelien Jarno --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index 983c0db3f7..e8f1eeb750 100644 --- a/exec.c +++ b/exec.c @@ -4253,7 +4253,7 @@ void stw_phys(target_phys_addr_t addr, uint32_t val) void stq_phys(target_phys_addr_t addr, uint64_t val) { val = tswap64(val); - cpu_physical_memory_write(addr, (const uint8_t *)&val, 8); + cpu_physical_memory_write(addr, &val, 8); } /* virtual memory access for debug (includes writing to ROM) */ -- cgit v1.2.3 From 54f7b4a396d00522d99c685562a54725a1b52e40 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 10 Apr 2011 18:23:39 +0200 Subject: Replace cpu_physical_memory_rw were possible Using cpu_physical_memory_read, cpu_physical_memory_write and ldub_phys improves readability and allows removing some type casts. lduw_phys and ldl_phys were not used because both require aligned addresses. Therefore it is not possible to simply replace existing calls by one of these functions. Signed-off-by: Stefan Weil Signed-off-by: Aurelien Jarno --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index e8f1eeb750..b1ee52a4d0 100644 --- a/exec.c +++ b/exec.c @@ -3932,7 +3932,7 @@ void *cpu_physical_memory_map(target_phys_addr_t addr, bounce.addr = addr; bounce.len = l; if (!is_write) { - cpu_physical_memory_rw(addr, bounce.buffer, l, 0); + cpu_physical_memory_read(addr, bounce.buffer, l); } ptr = bounce.buffer; } else { -- cgit v1.2.3 From 618ba8e6a1313df6a8366ac8ffee47e3f885ac90 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 18 Apr 2011 06:39:53 +0000 Subject: Remove unused function parameter from cpu_restore_state The previous patch removed the need for parameter puc. Is is now unused, so remove it. Cc: Aurelien Jarno Reviewed-by: Peter Maydell Signed-off-by: Stefan Weil --- exec.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index b1ee52a4d0..c3dc68ae09 100644 --- a/exec.c +++ b/exec.c @@ -1070,8 +1070,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, restore the CPU state */ current_tb_modified = 1; - cpu_restore_state(current_tb, env, - env->mem_io_pc, NULL); + cpu_restore_state(current_tb, env, env->mem_io_pc); cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base, ¤t_flags); } @@ -1179,7 +1178,7 @@ static void tb_invalidate_phys_page(tb_page_addr_t addr, restore the CPU state */ current_tb_modified = 1; - cpu_restore_state(current_tb, env, pc, puc); + cpu_restore_state(current_tb, env, pc); cpu_get_tb_cpu_state(env, ¤t_pc, ¤t_cs_base, ¤t_flags); } @@ -3266,7 +3265,7 @@ static void check_watchpoint(int offset, int len_mask, int flags) cpu_abort(env, "check_watchpoint: could not find TB for " "pc=%p", (void *)env->mem_io_pc); } - cpu_restore_state(tb, env, env->mem_io_pc, NULL); + cpu_restore_state(tb, env, env->mem_io_pc); tb_phys_invalidate(tb, -1); if (wp->flags & BP_STOP_BEFORE_ACCESS) { env->exception_index = EXCP_DEBUG; @@ -4301,7 +4300,7 @@ void cpu_io_recompile(CPUState *env, void *retaddr) retaddr); } n = env->icount_decr.u16.low + tb->icount; - cpu_restore_state(tb, env, (unsigned long)retaddr, NULL); + cpu_restore_state(tb, env, (unsigned long)retaddr); /* Calculate how many instructions had been executed before the fault occurred. */ n = n - env->icount_decr.u16.low; -- cgit v1.2.3 From 97ffbd8d9d54736dd73227e5330c7f5cdc2d7a96 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 13 Apr 2011 01:32:56 +0200 Subject: Break up user and system cpu_interrupt implementations Both have only two lines in common, and we will convert the system service into a callback which is of no use for user mode operation. Signed-off-by: Jan Kiszka CC: Riku Voipio Signed-off-by: Marcelo Tosatti --- exec.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index c3dc68ae09..d6d8a89110 100644 --- a/exec.c +++ b/exec.c @@ -1629,6 +1629,7 @@ static void cpu_unlink_tb(CPUState *env) spin_unlock(&interrupt_lock); } +#ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */ void cpu_interrupt(CPUState *env, int mask) { @@ -1637,7 +1638,6 @@ void cpu_interrupt(CPUState *env, int mask) old_mask = env->interrupt_request; env->interrupt_request |= mask; -#ifndef CONFIG_USER_ONLY /* * If called from iothread context, wake the target cpu in * case its halted. @@ -1646,21 +1646,27 @@ void cpu_interrupt(CPUState *env, int mask) qemu_cpu_kick(env); return; } -#endif if (use_icount) { env->icount_decr.u16.high = 0xffff; -#ifndef CONFIG_USER_ONLY if (!can_do_io(env) && (mask & ~old_mask) != 0) { cpu_abort(env, "Raised interrupt while not in I/O function"); } -#endif } else { cpu_unlink_tb(env); } } +#else /* CONFIG_USER_ONLY */ + +void cpu_interrupt(CPUState *env, int mask) +{ + env->interrupt_request |= mask; + cpu_unlink_tb(env); +} +#endif /* CONFIG_USER_ONLY */ + void cpu_reset_interrupt(CPUState *env, int mask) { env->interrupt_request &= ~mask; -- cgit v1.2.3 From ec6959d0466fb240fe4d94d5f525eebf9ba18b84 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 13 Apr 2011 01:32:56 +0200 Subject: Redirect cpu_interrupt to callback handler This allows to override the interrupt handling of QEMU in system mode. KVM will make use of it to set a specialized handler. Signed-off-by: Jan Kiszka Signed-off-by: Marcelo Tosatti --- exec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'exec.c') diff --git a/exec.c b/exec.c index d6d8a89110..a718d747e7 100644 --- a/exec.c +++ b/exec.c @@ -1631,7 +1631,7 @@ static void cpu_unlink_tb(CPUState *env) #ifndef CONFIG_USER_ONLY /* mask must never be zero, except for A20 change call */ -void cpu_interrupt(CPUState *env, int mask) +static void tcg_handle_interrupt(CPUState *env, int mask) { int old_mask; @@ -1658,6 +1658,8 @@ void cpu_interrupt(CPUState *env, int mask) } } +CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt; + #else /* CONFIG_USER_ONLY */ void cpu_interrupt(CPUState *env, int mask) -- cgit v1.2.3