QOM CPUState patch queue 2013-07-22
Hello Anthony,
This is my current QOM CPU patch queue for 1.6. Please pull.
CPUArchState: 313 -> 287
Thanks,
Andreas
The following changes since commit 3464700f6aecb3e2aa9098839d90672d6b3fa974:
tests: Add test-bitops.c with some sextract tests (2013-07-22 15:41:49 -0500)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.git tags/qom-cpu-for-anthony
for you to fetch changes up to 6f152e9bc80aed81ea89aa8ad345cd71326b71fb:
linux-user: Use X86CPU property to retrieve CPUID family (2013-07-23 02:41:33 +0200)
----------------------------------------------------------------
QOM CPUState refactorings
* Fix NULL pointer dereference in gdbstub
* Introduce vaddr type
* Introduce CPUClass::set_pc()
* Introduce CPUClass::synchronize_from_tb()
* Introduce CPUClass::get_phys_page_debug()
* Introduce CPUClass::memory_rw_debug()
* Move singlestep_enabled and gdb_regs fields out of CPU_COMMON
* Adopt CPUState in more APIs
* Propagate CPUState in gdbstub
----------------------------------------------------------------
Andreas Färber (21):
gdbstub: Change GDBState::query_cpu to CPUState
cpu: Introduce vaddr type
cpu: Introduce CPUClass::set_pc() for gdb_set_cpu_pc()
target-m68k: Implement CPUClass::set_pc()
target-moxie: Implement CPUClass::set_pc()
target-unicore32: Implement CPUClass::set_pc()
cpu: Introduce CPUClass::synchronize_from_tb() for cpu_pc_from_tb()
cpu: Move singlestep_enabled field from CPU_COMMON to CPUState
gdbstub: Update gdb_handlesig() and gdb_signalled() Coding Style
cpu: Change cpu_single_step() argument to CPUState
kvm: Change kvm_{insert,remove}_breakpoint() argument to CPUState
gdbstub: Change syscall callback argument to CPUState
gdbstub: Change gdb_handlesig() argument to CPUState
gdbstub: Change gdb_{read,write}_register() argument to CPUState
cpu: Turn cpu_get_phys_page_debug() into a CPUClass hook
exec: Change cpu_memory_rw_debug() argument to CPUState
cpu: Introduce CPUClass::memory_rw_debug() for target_memory_rw_debug()
gdbstub: Change GDBState::{c,g}_cpu and find_cpu() to CPUState
cpu: Move gdb_regs field from CPU_COMMON to CPUState
gdbstub: Change gdb_register_coprocessor() argument to CPUState
linux-user: Use X86CPU property to retrieve CPUID family
Peter Maydell (1):
HACKING: Document vaddr type usage
Richard Henderson (2):
target-alpha: Copy singlestep_enabled to DisasContext
target-alpha: Copy implver to DisasContext
HACKING | 19 ++- bsd-user/main.c | 10 +- cpu-exec.c | 10 +- cpus.c | 6 +- disas.c | 4 +- exec.c | 36 +++--- gdbstub.c | 266 ++++++++++++++++++++---------------------- hw/i386/kvmvapic.c | 78 +++++++------ hw/xtensa/xtensa_lx60.c | 8 +- hw/xtensa/xtensa_sim.c | 10 +- include/exec/cpu-all.h | 14 +-- include/exec/cpu-defs.h | 3 - include/exec/gdbstub.h | 6 +- include/exec/softmmu-semi.h | 18 +-- include/qom/cpu.h | 113 +++++++++--------- include/sysemu/kvm.h | 4 +- kvm-all.c | 12 +- kvm-stub.c | 4 +- linux-user/cpu-uname.c | 10 +- linux-user/main.c | 35 +++--- linux-user/signal.c | 3 +- monitor.c | 2 +- target-alpha/cpu-qom.h | 1 + target-alpha/cpu.c | 15 ++- target-alpha/cpu.h | 5 - target-alpha/helper.c | 5 +- target-alpha/translate.c | 21 ++-- target-arm/arm-semi.c | 10 +- target-arm/cpu-qom.h | 2 + target-arm/cpu.c | 13 ++- target-arm/cpu.h | 5 - target-arm/helper.c | 15 ++- target-arm/translate.c | 7 +- target-cris/cpu-qom.h | 2 + target-cris/cpu.c | 11 ++ target-cris/cpu.h | 4 - target-cris/helper.c | 7 +- target-cris/translate.c | 7 +- target-i386/cpu-qom.h | 2 + target-i386/cpu.c | 19 ++- target-i386/cpu.h | 5 - target-i386/helper.c | 12 +- target-i386/kvm.c | 20 ++-- target-i386/translate.c | 5 +- target-lm32/cpu-qom.h | 1 + target-lm32/cpu.c | 13 ++- target-lm32/cpu.h | 5 - target-lm32/helper.c | 6 +- target-lm32/translate.c | 7 +- target-m68k/cpu-qom.h | 1 + target-m68k/cpu.c | 11 ++ target-m68k/cpu.h | 5 - target-m68k/helper.c | 5 +- target-m68k/m68k-semi.c | 5 +- target-m68k/translate.c | 7 +- target-microblaze/cpu-qom.h | 1 + target-microblaze/cpu.c | 13 ++- target-microblaze/cpu.h | 5 - target-microblaze/helper.c | 4 +- target-microblaze/translate.c | 8 +- target-mips/cpu-qom.h | 1 + target-mips/cpu.c | 30 ++++- target-mips/cpu.h | 7 -- target-mips/helper.c | 7 +- target-mips/translate.c | 11 +- target-moxie/cpu.c | 13 ++- target-moxie/cpu.h | 6 +- target-moxie/helper.c | 11 +- target-moxie/translate.c | 5 +- target-openrisc/cpu.c | 13 ++- target-openrisc/cpu.h | 6 +- target-openrisc/mmu.c | 5 +- target-openrisc/translate.c | 7 +- target-ppc/cpu-qom.h | 1 + target-ppc/cpu.h | 5 - target-ppc/mmu_helper.c | 4 +- target-ppc/translate.c | 8 +- target-ppc/translate_init.c | 26 +++-- target-s390x/cpu-qom.h | 1 + target-s390x/cpu.c | 11 ++ target-s390x/cpu.h | 5 - target-s390x/helper.c | 5 +- target-s390x/translate.c | 5 +- target-sh4/cpu-qom.h | 1 + target-sh4/cpu.c | 20 ++++ target-sh4/cpu.h | 6 - target-sh4/helper.c | 5 +- target-sh4/translate.c | 8 +- target-sparc/cpu-qom.h | 1 + target-sparc/cpu.c | 26 ++++- target-sparc/cpu.h | 11 +- target-sparc/mmu_helper.c | 22 ++-- target-sparc/translate.c | 3 +- target-unicore32/cpu-qom.h | 1 + target-unicore32/cpu.c | 11 ++ target-unicore32/cpu.h | 5 - target-unicore32/softmmu.c | 7 +- target-unicore32/translate.c | 7 +- target-xtensa/cpu-qom.h | 1 + target-xtensa/cpu.c | 11 ++ target-xtensa/cpu.h | 5 - target-xtensa/helper.c | 7 +- target-xtensa/translate.c | 7 +- target-xtensa/xtensa-semi.c | 14 +-- 104 files changed, 783 insertions(+), 550 deletions(-)
[Qemu-devel] [PULL 05/24] target-m68k: Implement CPUClass::set_pc()
This adds support for GDB's c addr (Continue) and s addr (Single Step).
Prepares for dropping cpu_pc_from_tb().
--- target-m68k/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target-m68k/cpu.c +8 -0
@@ -23,6 +23,13 @@#include "migration/vmstate.h" +static void m68k_cpu_set_pc (CPUState *cs,vaddr value) +{ +M68kCPU *cpu =M68K_CPU (cs); + + cpu->env.pc = value; +} +static void m68k_set_feature (CPUM68KState *env,int feature) { env->features |= (1u << feature);
@@ -182,6 +189,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = m68k_cpu_class_by_name; cc->do_interrupt = m68k_cpu_do_interrupt; cc->dump_state = m68k_cpu_dump_state; + cc->set_pc = m68k_cpu_set_pc; dc->vmsd = &vmstate_m68k_cpu; }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 01/24] gdbstub: Change GDBState::query_cpu to CPUState
In reply to Andreas FärberSince first_cpu/next_cpu are CPUState, CPUArchState is no longer needed.
This resolves a NULL pointer dereference of query_cpu, introduced with commit 182735efaf956ccab50b6d74a4fed163e0f35660 and reported by TeLeMan and Max Filippov.
--- gdbstub.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
gdbstub.c +4 -5
@@ -289,7 +289,7 @@ enum RSState { typedef struct GDBState { CPUArchState *c_cpu; /* current CPU for step/continue ops */ CPUArchState *g_cpu; /* current CPU for other ops */ - CPUArchState *query_cpu; /* for q{f|s}ThreadInfo */ + CPUState *query_cpu; /* for q{f|s}ThreadInfo */ enum RSState state; /* parsing state */ char line_buf[MAX_PACKET_LENGTH]; int line_buf_index;
@@ -2401,15 +2401,14 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)put_packet (s,"QC1" );break ; }else if (strcmp (p,"fThreadInfo" ) ==0 ) { - s->query_cpu = first_cpu->env_ptr; + s->query_cpu = first_cpu; goto report_cpuinfo; }else if (strcmp (p,"sThreadInfo" ) ==0 ) { report_cpuinfo:if (s->query_cpu) { -snprintf (buf,sizeof (buf),"m%x" , -cpu_index (ENV_GET_CPU (s->query_cpu))); +snprintf (buf,sizeof (buf),"m%x" ,cpu_index (s->query_cpu));put_packet (s, buf); - s->query_cpu =ENV_GET_CPU (s->query_cpu)->next_cpu->env_ptr; + s->query_cpu = s->query_cpu->next_cpu; }else put_packet (s,"l" );break ;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 03/24] HACKING: Document vaddr type usage
In reply to Andreas FärberFrom: Peter Maydell <[email protected]>
Also extend documentation of target_ulong and abi_ulong.
--- HACKING | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
HACKING +17 -2
@@ -40,8 +40,23 @@ speaking, the size of guest memory can always fit into ram_addr_t but it would not be correct to store an actual guest physical address in a ram_addr_t. -Use target_ulong (or abi_ulong) for CPU virtual addresses, however -devices should not need to use target_ulong. +For CPU virtual addresses there are several possible types. +vaddr is the best type to use to hold a CPU virtual address in +target-independent code. It is guaranteed to be large enough to hold a +virtual address for any target, and it does not change size from target +to target. It is always unsigned. +target_ulong is a type the size of a virtual address on the CPU; this means +it may be 32 or 64 bits depending on which target is being built. It should +therefore be used only in target-specific code, and in some +performance-critical built-per-target core code such as the TLB code. +There is also a signed version, target_long. +abi_ulong is for the *-user targets, and represents a type the size of +'void *' in that target's ABI. (This may not be the same as the size of a +full CPU virtual address in the case of target ABIs which use 32 bit pointers +on 64 bit CPUs, like sparc32plus.) Definitions of structures that must match +the target's ABI must use this type for anything that on the target is defined +to be an 'unsigned long' or a pointer type. +There is also a signed version, abi_long. Of course, take all of the above with a grain of salt. If you're about to use some system interface that requires a type like size_t, pid_t or
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 06/24] target-moxie: Implement CPUClass::set_pc()
In reply to Andreas FärberThis adds support for GDB's c addr (Continue) and s addr (Single Step).
Prepares for dropping cpu_pc_from_tb().
--- target-moxie/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target-moxie/cpu.c +8 -0
@@ -22,6 +22,13 @@#include "migration/vmstate.h" #include "machine.h" +static void moxie_cpu_set_pc (CPUState *cs,vaddr value) +{ +MoxieCPU *cpu =MOXIE_CPU (cs); + + cpu->env.pc = value; +} +static void moxie_cpu_reset (CPUState *s) {MoxieCPU *cpu =MOXIE_CPU (s);
@@ -93,6 +100,7 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = moxie_cpu_do_interrupt; cc->dump_state = moxie_cpu_dump_state; + cc->set_pc = moxie_cpu_set_pc;cpu_class_set_vmsd (cc, &vmstate_moxie_cpu); }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 02/24] cpu: Introduce vaddr type
In reply to Andreas Färbervaddr is to target_ulong what uintmax_t is to unsigned int.
Its purpose is to allow turning per-target functions with target_ulong arguments into CPUClass hooks.
--- include/qom/cpu.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/qom/cpu.h +12 -0
@@ -30,6 +30,18 @@typedef int (*WriteCoreDumpFunction )(void *buf,size_t size,void *opaque);/** +* vaddr: +* Type wide enough to contain any #target_ulong virtual address. +*/ +typedef uint64_t vaddr ; +#define VADDR_PRId PRId64 +#define VADDR_PRIu PRIu64 +#define VADDR_PRIo PRIo64 +#define VADDR_PRIx PRIx64 +#define VADDR_PRIX PRIX64 +#define VADDR_MAX UINT64_MAX + +/** * SECTION:cpu * @section_id: QEMU-cpu * @title: CPU Class
Signature · 1 line
1.8.1.4
[PULL 11/24] cpu: Move singlestep_enabled field from CPU_COMMON to CPUState
In reply to Andreas FärberPrepares for changing cpu_single_step() argument to CPUState.
--- cpu-exec.c | 2 +- cpus.c | 2 +- exec.c | 10 ++++++---- include/exec/cpu-defs.h | 1 - include/qom/cpu.h | 2 ++ kvm-all.c | 2 +- target-alpha/translate.c | 3 ++- target-arm/translate.c | 7 ++++--- target-cris/translate.c | 7 ++++--- target-i386/kvm.c | 6 ++++-- target-i386/translate.c | 5 +++-- target-lm32/translate.c | 7 ++++--- target-m68k/translate.c | 7 ++++--- target-microblaze/translate.c | 8 +++++--- target-mips/translate.c | 11 +++++++---- target-moxie/translate.c | 5 +++-- target-openrisc/translate.c | 7 ++++--- target-ppc/translate.c | 8 +++++--- target-s390x/translate.c | 5 +++-- target-sh4/translate.c | 8 +++++--- target-sparc/translate.c | 3 ++- target-unicore32/translate.c | 7 ++++--- target-xtensa/translate.c | 7 ++++--- 23 files changed, 78 insertions(+), 52 deletions(-)
cpu-exec.c +1 -1
@@ -297,7 +297,7 @@ int cpu_exec(CPUArchState *env)for (;;) { interrupt_request = cpu->interrupt_request;if (unlikely (interrupt_request)) { -if (unlikely (env->singlestep_enabled &SSTEP_NOIRQ )) { +if (unlikely (cpu->singlestep_enabled &SSTEP_NOIRQ )) {/* Mask out external interrupts for this step. */ interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK ; }
cpus.c +1 -1
@@ -1186,7 +1186,7 @@ static void tcg_exec_all(void)CPUArchState *env = cpu->env_ptr;qemu_clock_enable (vm_clock, - (env->singlestep_enabled &SSTEP_NOTIMER ) ==0 ); + (cpu->singlestep_enabled &SSTEP_NOTIMER ) ==0 );if (cpu_can_run (cpu)) { r =tcg_cpu_exec (env);
exec.c +6 -4
@@ -588,11 +588,13 @@ void cpu_breakpoint_remove_all(CPUArchState *env, int mask)void cpu_single_step (CPUArchState *env,int enabled) {#if defined(TARGET_HAS_ICE ) -if (env->singlestep_enabled != enabled) { - env->singlestep_enabled = enabled; -if (kvm_enabled ()) +CPUState *cpu =ENV_GET_CPU (env); + +if (cpu->singlestep_enabled != enabled) { + cpu->singlestep_enabled = enabled; +if (kvm_enabled ()) {kvm_update_guest_debug (env,0 ); -else { + }else {/* must flush all the translated code to avoid inconsistencies */ /* XXX: only flush what is necessary */ tb_flush (env);
include/exec/cpu-defs.h +0 -1
@@ -170,7 +170,6 @@ typedef struct CPUWatchpoint {/* from this point: preserved by CPU reset */ \/* ice debug support */ \ QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \ -int singlestep_enabled; \ \ QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \CPUWatchpoint *watchpoint_hit; \
include/qom/cpu.h +2 -0
@@ -133,6 +133,7 @@ struct kvm_run;* @stopped: Indicates the CPU has been artificially stopped. * @tcg_exit_req: Set to force TCG to stop executing linked TBs for this * CPU and return to its top level loop. +* @singlestep_enabled: Flags for single-stepping. * @env_ptr: Pointer to subclass-specific CPUArchState field. * @current_tb: Currently executing TB. * @next_cpu: Next CPU sharing TB cache.
@@ -165,6 +166,7 @@ struct CPUState {volatile sig_atomic_t exit_request;volatile sig_atomic_t tcg_exit_req;uint32_t interrupt_request; +int singlestep_enabled;void *env_ptr;/* CPUArchState */ struct TranslationBlock *current_tb;
kvm-all.c +1 -1
@@ -1890,7 +1890,7 @@ int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap) data.dbg.control = reinject_trap; -if (env->singlestep_enabled) { +if (cpu->singlestep_enabled) { data.dbg.control |=KVM_GUESTDBG_ENABLE |KVM_GUESTDBG_SINGLESTEP ; }kvm_arch_update_guest_debug (cpu, &data.dbg);
target-alpha/translate.c +2 -1
@@ -3388,6 +3388,7 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUAlphaState *env = &cpu->env;DisasContext ctx, *ctxp = &ctx;target_ulong pc_start;
@@ -3406,7 +3407,7 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu, ctx.pc = pc_start; ctx.mem_idx =cpu_mmu_index (env); ctx.implver = env->implver; - ctx.singlestep_enabled = env->singlestep_enabled; + ctx.singlestep_enabled = cs->singlestep_enabled;/* ??? Every TB begins with unset rounding mode, to be initialized on the first fp insn of the TB. Alternately we could define a proper
target-arm/translate.c +4 -3
@@ -9911,6 +9911,7 @@ static inline void gen_intermediate_code_internal(ARMCPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUARMState *env = &cpu->env;DisasContext dc1, *dc = &dc1;CPUBreakpoint *bp;
@@ -9930,7 +9931,7 @@ static inline void gen_intermediate_code_internal(ARMCPU *cpu, dc->is_jmp =DISAS_NEXT ; dc->pc = pc_start; - dc->singlestep_enabled = env->singlestep_enabled; + dc->singlestep_enabled = cs->singlestep_enabled; dc->condjmp =0 ; dc->thumb =ARM_TBFLAG_THUMB (tb->flags); dc->bswap_code =ARM_TBFLAG_BSWAP_CODE (tb->flags);
@@ -10080,7 +10081,7 @@ static inline void gen_intermediate_code_internal(ARMCPU *cpu,* ensures prefetch aborts occur at the right place. */ num_insns ++; }while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && - !env->singlestep_enabled && + !cs->singlestep_enabled && !singlestep && dc->pc < next_page_start && num_insns < max_insns);
@@ -10097,7 +10098,7 @@ static inline void gen_intermediate_code_internal(ARMCPU *cpu,/* At this stage dc->condjmp will only be set when the skipped instruction was a conditional branch or trap, and the PC has already been written. */ -if (unlikely (env->singlestep_enabled)) { +if (unlikely (cs->singlestep_enabled)) {/* Make sure the pc is updated, and raise a debug exception. */ if (dc->condjmp) {gen_set_condexec (dc);
target-cris/translate.c +4 -3
@@ -3165,6 +3165,7 @@ static inline voidgen_intermediate_code_internal (CRISCPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUCRISState *env = &cpu->env;uint16_t *gen_opc_end;uint32_t pc_start;
@@ -3197,7 +3198,7 @@ gen_intermediate_code_internal(CRISCPU *cpu, TranslationBlock *tb, dc->is_jmp =DISAS_NEXT ; dc->ppc = pc_start; dc->pc = pc_start; - dc->singlestep_enabled = env->singlestep_enabled; + dc->singlestep_enabled = cs->singlestep_enabled; dc->flags_uptodate =1 ; dc->flagx_known =1 ; dc->flags_x = tb->flags &X_FLAG ;
@@ -3337,7 +3338,7 @@ gen_intermediate_code_internal(CRISCPU *cpu, TranslationBlock *tb,/* If we are rexecuting a branch due to exceptions on delay slots dont break. */ -if (!(tb->pc &1 ) && env->singlestep_enabled) { +if (!(tb->pc &1 ) && cs->singlestep_enabled) {break ; } } while (!dc->is_jmp && !dc->cpustate_changed
@@ -3370,7 +3371,7 @@ gen_intermediate_code_internal(CRISCPU *cpu, TranslationBlock *tb,cris_evaluate_flags (dc); -if (unlikely (env->singlestep_enabled)) { +if (unlikely (cs->singlestep_enabled)) {if (dc->is_jmp ==DISAS_NEXT ) {tcg_gen_movi_tl (env_pc, npc); }
target-i386/kvm.c +4 -2
@@ -1594,6 +1594,7 @@ static int kvm_get_vcpu_events(X86CPU *cpu)static int kvm_guest_debug_workarounds (X86CPU *cpu) { +CPUState *cs =CPU (cpu);CPUX86State *env = &cpu->env;int ret =0 ;unsigned long reinject_trap =0 ;
@@ -1616,7 +1617,7 @@ static int kvm_guest_debug_workarounds(X86CPU *cpu)* reinject them via SET_GUEST_DEBUG. */ if (reinject_trap || - (!kvm_has_robust_singlestep () && env->singlestep_enabled)) { + (!kvm_has_robust_singlestep () && cs->singlestep_enabled)) { ret =kvm_update_guest_debug (env, reinject_trap); }return ret;
@@ -2042,13 +2043,14 @@ static CPUWatchpoint hw_watchpoint;static int kvm_handle_debug (X86CPU *cpu,struct kvm_debug_exit_arch *arch_info) { +CPUState *cs =CPU (cpu);CPUX86State *env = &cpu->env;int ret =0 ;int n;if (arch_info->exception ==1 ) {if (arch_info->dr6 & (1 <<14 )) { -if (env->singlestep_enabled) { +if (cs->singlestep_enabled) { ret =EXCP_DEBUG ; } }else {
target-i386/translate.c +3 -2
@@ -8255,6 +8255,7 @@ static inline void gen_intermediate_code_internal(X86CPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUX86State *env = &cpu->env;DisasContext dc1, *dc = &dc1;target_ulong pc_ptr;
@@ -8281,7 +8282,7 @@ static inline void gen_intermediate_code_internal(X86CPU *cpu, dc->cpl = (flags >>HF_CPL_SHIFT ) &3 ; dc->iopl = (flags >>IOPL_SHIFT ) &3 ; dc->tf = (flags >>TF_SHIFT ) &1 ; - dc->singlestep_enabled = env->singlestep_enabled; + dc->singlestep_enabled = cs->singlestep_enabled; dc->cc_op =CC_OP_DYNAMIC ; dc->cc_op_dirty = false; dc->cs_base = cs_base;
@@ -8302,7 +8303,7 @@ static inline void gen_intermediate_code_internal(X86CPU *cpu, dc->code64 = (flags >>HF_CS64_SHIFT ) &1 ;#endif dc->flags = flags; - dc->jmp_opt = !(dc->tf || env->singlestep_enabled || + dc->jmp_opt = !(dc->tf || cs->singlestep_enabled || (flags &HF_INHIBIT_IRQ_MASK ) #ifndef CONFIG_SOFTMMU || (flags & HF_SOFTMMU_MASK)
target-lm32/translate.c +4 -3
@@ -1015,6 +1015,7 @@ static inlinevoid gen_intermediate_code_internal (LM32CPU *cpu,TranslationBlock *tb,bool search_pc) { +CPUState *cs =CPU (cpu);CPULM32State *env = &cpu->env;struct DisasContext ctx, *dc = &ctx;uint16_t *gen_opc_end;
@@ -1032,7 +1033,7 @@ void gen_intermediate_code_internal(LM32CPU *cpu, dc->is_jmp =DISAS_NEXT ; dc->pc = pc_start; - dc->singlestep_enabled = env->singlestep_enabled; + dc->singlestep_enabled = cs->singlestep_enabled; dc->nr_nops =0 ;if (pc_start &3 ) {
@@ -1077,7 +1078,7 @@ void gen_intermediate_code_internal(LM32CPU *cpu, }while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end - && !env->singlestep_enabled + && !cs->singlestep_enabled && !singlestep && (dc->pc < next_page_start) && num_insns < max_insns);
@@ -1086,7 +1087,7 @@ void gen_intermediate_code_internal(LM32CPU *cpu,gen_io_end (); } -if (unlikely (env->singlestep_enabled)) { +if (unlikely (cs->singlestep_enabled)) {if (dc->is_jmp ==DISAS_NEXT ) {tcg_gen_movi_tl (cpu_pc, dc->pc); }
target-m68k/translate.c +4 -3
@@ -2974,6 +2974,7 @@ static inline voidgen_intermediate_code_internal (M68kCPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUM68KState *env = &cpu->env;DisasContext dc1, *dc = &dc1;uint16_t *gen_opc_end;
@@ -2995,7 +2996,7 @@ gen_intermediate_code_internal(M68kCPU *cpu, TranslationBlock *tb, dc->is_jmp =DISAS_NEXT ; dc->pc = pc_start; dc->cc_op =CC_OP_DYNAMIC ; - dc->singlestep_enabled = env->singlestep_enabled; + dc->singlestep_enabled = cs->singlestep_enabled; dc->fpcr = env->fpcr; dc->user = (env->sr &SR_S ) ==0 ; dc->is_mem =0 ;
@@ -3038,14 +3039,14 @@ gen_intermediate_code_internal(M68kCPU *cpu, TranslationBlock *tb,disas_m68k_insn (env, dc); num_insns++; }while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && - !env->singlestep_enabled && + !cs->singlestep_enabled && !singlestep && (pc_offset) < (TARGET_PAGE_SIZE -32 ) && num_insns < max_insns);if (tb->cflags &CF_LAST_IO )gen_io_end (); -if (unlikely (env->singlestep_enabled)) { +if (unlikely (cs->singlestep_enabled)) {/* Make sure the pc is updated, and raise a debug exception. */ if (!dc->is_jmp) {gen_flush_cc_op (dc);
target-microblaze/translate.c +5 -3
@@ -1741,6 +1741,7 @@ static inline voidgen_intermediate_code_internal (MicroBlazeCPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUMBState *env = &cpu->env;uint16_t *gen_opc_end;uint32_t pc_start;
@@ -1766,7 +1767,7 @@ gen_intermediate_code_internal(MicroBlazeCPU *cpu, TranslationBlock *tb, dc->jmp =JMP_INDIRECT ; } dc->pc = pc_start; - dc->singlestep_enabled = env->singlestep_enabled; + dc->singlestep_enabled = cs->singlestep_enabled; dc->cpustate_changed =0 ; dc->abort_at_next_insn =0 ; dc->nr_nops =0 ;
@@ -1859,8 +1860,9 @@ gen_intermediate_code_internal(MicroBlazeCPU *cpu, TranslationBlock *tb,break ; } } -if (env->singlestep_enabled) +if (cs->singlestep_enabled) {break ; + } }while (!dc->is_jmp && !dc->cpustate_changed && tcg_ctx.gen_opc_ptr < gen_opc_end && !singlestep
@@ -1887,7 +1889,7 @@ gen_intermediate_code_internal(MicroBlazeCPU *cpu, TranslationBlock *tb, }t_sync_flags (dc); -if (unlikely (env->singlestep_enabled)) { +if (unlikely (cs->singlestep_enabled)) {TCGv_i32 tmp =tcg_const_i32 (EXCP_DEBUG );if (dc->is_jmp !=DISAS_JUMP ) {
target-mips/translate.c +7 -4
@@ -15543,6 +15543,7 @@ static inline voidgen_intermediate_code_internal (MIPSCPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUMIPSState *env = &cpu->env;DisasContext ctx;target_ulong pc_start;
@@ -15561,7 +15562,7 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb, gen_opc_end = tcg_ctx.gen_opc_buf +OPC_MAX_SIZE ; ctx.pc = pc_start; ctx.saved_pc =-1 ; - ctx.singlestep_enabled = env->singlestep_enabled; + ctx.singlestep_enabled = cs->singlestep_enabled; ctx.insn_flags = env->insn_flags; ctx.tb = tb; ctx.bstate =BS_NONE ;
@@ -15637,8 +15638,9 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb,This is what GDB expects and is consistent with what the hardware does (e.g. if a delay slot instruction faults, the reported PC is the PC of the branch). */ -if (env->singlestep_enabled && (ctx.hflags &MIPS_HFLAG_BMASK ) ==0 ) +if (cs->singlestep_enabled && (ctx.hflags &MIPS_HFLAG_BMASK ) ==0 ) {break ; + }if ((ctx.pc & (TARGET_PAGE_SIZE -1 )) ==0 )break ;
@@ -15653,9 +15655,10 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb,if (singlestep)break ; } -if (tb->cflags &CF_LAST_IO ) +if (tb->cflags &CF_LAST_IO ) {gen_io_end (); -if (env->singlestep_enabled && ctx.bstate !=BS_BRANCH ) { + } +if (cs->singlestep_enabled && ctx.bstate !=BS_BRANCH ) {save_cpu_state (&ctx, ctx.bstate ==BS_NONE );gen_helper_0e0i (raise_exception,EXCP_DEBUG ); }else {
target-moxie/translate.c +3 -2
@@ -824,6 +824,7 @@ static inline voidgen_intermediate_code_internal (MoxieCPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);DisasContext ctx;target_ulong pc_start;uint16_t *gen_opc_end;
@@ -871,7 +872,7 @@ gen_intermediate_code_internal(MoxieCPU *cpu, TranslationBlock *tb, ctx.pc +=decode_opc (cpu, &ctx); num_insns++; -if (env->singlestep_enabled) { +if (cs->singlestep_enabled) {break ; }
@@ -880,7 +881,7 @@ gen_intermediate_code_internal(MoxieCPU *cpu, TranslationBlock *tb, } }while (ctx.bstate ==BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end); -if (env->singlestep_enabled) { +if (cs->singlestep_enabled) {tcg_gen_movi_tl (cpu_pc, ctx.pc);gen_helper_debug (cpu_env); }else {
target-openrisc/translate.c +4 -3
@@ -1662,6 +1662,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, TranslationBlock *tb, int search_pc) { +CPUState *cs =CPU (cpu);struct DisasContext ctx, *dc = &ctx;uint16_t *gen_opc_end;uint32_t pc_start;
@@ -1681,7 +1682,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, dc->mem_idx =cpu_mmu_index (&cpu->env); dc->synced_flags = dc->tb_flags = tb->flags; dc->delayed_branch = !!(dc->tb_flags &D_FLAG ); - dc->singlestep_enabled = cpu->env.singlestep_enabled; + dc->singlestep_enabled = cs->singlestep_enabled;if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM )) {qemu_log ("-----------------------------------------\n" );log_cpu_state (CPU (cpu),0 );
@@ -1743,7 +1744,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, } }while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end - && !cpu->env.singlestep_enabled + && !cs->singlestep_enabled && !singlestep && (dc->pc < next_page_start) && num_insns < max_insns);
@@ -1755,7 +1756,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu, dc->is_jmp =DISAS_UPDATE ;tcg_gen_movi_tl (cpu_pc, dc->pc); } -if (unlikely (cpu->env.singlestep_enabled)) { +if (unlikely (cs->singlestep_enabled)) {if (dc->is_jmp ==DISAS_NEXT ) {tcg_gen_movi_tl (cpu_pc, dc->pc); }
target-ppc/translate.c +5 -3
@@ -9730,6 +9730,7 @@ static inline void gen_intermediate_code_internal(PowerPCCPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;DisasContext ctx, *ctxp = &ctx;opc_handler_t **table, *handler;
@@ -9770,8 +9771,9 @@ static inline void gen_intermediate_code_internal(PowerPCCPU *cpu, ctx.singlestep_enabled =0 ;if ((env->flags &POWERPC_FLAG_BE ) && msr_be) ctx.singlestep_enabled |=CPU_BRANCH_STEP ; -if (unlikely (env->singlestep_enabled)) +if (unlikely (cs->singlestep_enabled)) { ctx.singlestep_enabled |=GDBSTUB_SINGLE_STEP ; + }#if defined (DO_SINGLE_STEP ) &&0 /* Single step trace mode */ msr_se =1 ;
@@ -9873,7 +9875,7 @@ static inline void gen_intermediate_code_internal(PowerPCCPU *cpu, ctx.exception != POWERPC_EXCP_BRANCH)) {gen_exception (ctxp,POWERPC_EXCP_TRACE ); } else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) || - (env->singlestep_enabled) || + (cs->singlestep_enabled) || singlestep || num_insns >= max_insns)) {/* if we reach a page boundary or are single stepping, stop
@@ -9887,7 +9889,7 @@ static inline void gen_intermediate_code_internal(PowerPCCPU *cpu,if (ctx.exception ==POWERPC_EXCP_NONE ) {gen_goto_tb (&ctx,0 , ctx.nip); }else if (ctx.exception !=POWERPC_EXCP_BRANCH ) { -if (unlikely (env->singlestep_enabled)) { +if (unlikely (cs->singlestep_enabled)) {gen_debug_exception (ctxp); }/* Generate the return instruction */
target-s390x/translate.c +3 -2
@@ -4740,6 +4740,7 @@ static inline void gen_intermediate_code_internal(S390CPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUS390XState *env = &cpu->env;DisasContext dc;target_ulong pc_start;
@@ -4761,7 +4762,7 @@ static inline void gen_intermediate_code_internal(S390CPU *cpu, dc.tb = tb; dc.pc = pc_start; dc.cc_op =CC_OP_DYNAMIC ; - do_debug = dc.singlestep_enabled = env->singlestep_enabled; + do_debug = dc.singlestep_enabled = cs->singlestep_enabled; gen_opc_end = tcg_ctx.gen_opc_buf +OPC_MAX_SIZE ;
@@ -4818,7 +4819,7 @@ static inline void gen_intermediate_code_internal(S390CPU *cpu, || tcg_ctx.gen_opc_ptr >= gen_opc_end || num_insns >= max_insns || singlestep - || env->singlestep_enabled)) { + || cs->singlestep_enabled)) { status =EXIT_PC_STALE ; } }while (status ==NO_EXIT );
target-sh4/translate.c +5 -3
@@ -1849,6 +1849,7 @@ static inline voidgen_intermediate_code_internal (SuperHCPU *cpu, TranslationBlock *tb, bool search_pc) { +CPUState *cs =CPU (cpu);CPUSH4State *env = &cpu->env;DisasContext ctx;target_ulong pc_start;
@@ -1868,7 +1869,7 @@ gen_intermediate_code_internal(SuperHCPU *cpu, TranslationBlock *tb,so assume it is a dynamic branch. */ ctx.delayed_pc =-1 ;/* use delayed pc from env pointer */ ctx.tb = tb; - ctx.singlestep_enabled = env->singlestep_enabled; + ctx.singlestep_enabled = cs->singlestep_enabled; ctx.features = env->features; ctx.has_movcal = (ctx.flags &TB_FLAG_PENDING_MOVCA );
@@ -1914,8 +1915,9 @@ gen_intermediate_code_internal(SuperHCPU *cpu, TranslationBlock *tb, ctx.pc +=2 ;if ((ctx.pc & (TARGET_PAGE_SIZE -1 )) ==0 )break ; -if (env->singlestep_enabled) +if (cs->singlestep_enabled) {break ; + }if (num_insns >= max_insns)break ;if (singlestep)
@@ -1923,7 +1925,7 @@ gen_intermediate_code_internal(SuperHCPU *cpu, TranslationBlock *tb, }if (tb->cflags &CF_LAST_IO )gen_io_end (); -if (env->singlestep_enabled) { +if (cs->singlestep_enabled) {tcg_gen_movi_i32 (cpu_pc, ctx.pc);gen_helper_debug (cpu_env); }else {
target-sparc/translate.c +2 -1
@@ -5223,6 +5223,7 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu, TranslationBlock *tb, bool spc) { +CPUState *cs =CPU (cpu);CPUSPARCState *env = &cpu->env;target_ulong pc_start, last_pc;uint16_t *gen_opc_end;
@@ -5244,7 +5245,7 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu, dc->def = env->def; dc->fpu_enabled =tb_fpu_enabled (tb->flags); dc->address_mask_32bit =tb_am_enabled (tb->flags); - dc->singlestep = (env->singlestep_enabled || singlestep); + dc->singlestep = (cs->singlestep_enabled || singlestep); gen_opc_end = tcg_ctx.gen_opc_buf +OPC_MAX_SIZE ; num_insns =0 ;
target-unicore32/translate.c +4 -3
@@ -1879,6 +1879,7 @@ static void disas_uc32_insn(CPUUniCore32State *env, DisasContext *s)static inline void gen_intermediate_code_internal (UniCore32CPU *cpu,TranslationBlock *tb,bool search_pc) { +CPUState *cs =CPU (cpu);CPUUniCore32State *env = &cpu->env;DisasContext dc1, *dc = &dc1;CPUBreakpoint *bp;
@@ -1900,7 +1901,7 @@ static inline void gen_intermediate_code_internal(UniCore32CPU *cpu, dc->is_jmp =DISAS_NEXT ; dc->pc = pc_start; - dc->singlestep_enabled = env->singlestep_enabled; + dc->singlestep_enabled = cs->singlestep_enabled; dc->condjmp =0 ; cpu_F0s =tcg_temp_new_i32 (); cpu_F1s =tcg_temp_new_i32 ();
@@ -1971,7 +1972,7 @@ static inline void gen_intermediate_code_internal(UniCore32CPU *cpu,* ensures prefetch aborts occur at the right place. */ num_insns++; }while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end && - !env->singlestep_enabled && + !cs->singlestep_enabled && !singlestep && dc->pc < next_page_start && num_insns < max_insns);
@@ -1988,7 +1989,7 @@ static inline void gen_intermediate_code_internal(UniCore32CPU *cpu,/* At this stage dc->condjmp will only be set when the skipped instruction was a conditional branch or trap, and the PC has already been written. */ -if (unlikely (env->singlestep_enabled)) { +if (unlikely (cs->singlestep_enabled)) {/* Make sure the pc is updated, and raise a debug exception. */ if (dc->condjmp) {if (dc->is_jmp ==DISAS_SYSCALL ) {
target-xtensa/translate.c +4 -3
@@ -2879,6 +2879,7 @@ static inlinevoid gen_intermediate_code_internal (XtensaCPU *cpu,TranslationBlock *tb,bool search_pc) { +CPUState *cs =CPU (cpu);CPUXtensaState *env = &cpu->env;DisasContext dc;int insn_count =0 ;
@@ -2894,7 +2895,7 @@ void gen_intermediate_code_internal(XtensaCPU *cpu, } dc.config = env->config; - dc.singlestep_enabled = env->singlestep_enabled; + dc.singlestep_enabled = cs->singlestep_enabled; dc.tb = tb; dc.pc = pc_start; dc.ring = tb->flags &XTENSA_TBFLAG_RING_MASK ;
@@ -2917,7 +2918,7 @@ void gen_intermediate_code_internal(XtensaCPU *cpu,gen_tb_start (); -if (env->singlestep_enabled && env->exception_taken) { +if (cs->singlestep_enabled && env->exception_taken) { env->exception_taken =0 ;tcg_gen_movi_i32 (cpu_pc, dc.pc);gen_exception (&dc,EXCP_DEBUG );
@@ -2970,7 +2971,7 @@ void gen_intermediate_code_internal(XtensaCPU *cpu,if (dc.icount) {tcg_gen_mov_i32 (cpu_SR[ICOUNT ], dc.next_icount); } -if (env->singlestep_enabled) { +if (cs->singlestep_enabled) {tcg_gen_movi_i32 (cpu_pc, dc.pc);gen_exception (&dc,EXCP_DEBUG );break ;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 04/24] cpu: Introduce CPUClass::set_pc() for gdb_set_cpu_pc()
In reply to Andreas FärberThis moves setting the Program Counter from gdbstub into target code. Use vaddr type as upper-bound replacement for target_ulong.
--- gdbstub.c | 39 ++++++--------------------------------- include/qom/cpu.h | 2 ++ target-alpha/cpu.c | 8 ++++++++ target-arm/cpu.c | 8 ++++++++ target-cris/cpu.c | 8 ++++++++ target-i386/cpu.c | 8 ++++++++ target-lm32/cpu.c | 8 ++++++++ target-microblaze/cpu.c | 8 ++++++++ target-mips/cpu.c | 14 ++++++++++++++ target-openrisc/cpu.c | 8 ++++++++ target-ppc/translate_init.c | 8 ++++++++ target-s390x/cpu.c | 8 ++++++++ target-sh4/cpu.c | 8 ++++++++ target-sparc/cpu.c | 9 +++++++++ target-xtensa/cpu.c | 8 ++++++++ 15 files changed, 119 insertions(+), 33 deletions(-)
gdbstub.c +6 -33
@@ -2042,40 +2042,13 @@ static void gdb_breakpoint_remove_all(void)static void gdb_set_cpu_pc (GDBState *s,target_ulong pc) { -cpu_synchronize_state (ENV_GET_CPU (s->c_cpu)); -#if defined(TARGET_I386 ) - s->c_cpu->eip = pc; -#elif defined (TARGET_PPC ) - s->c_cpu->nip = pc; -#elif defined (TARGET_SPARC ) - s->c_cpu->pc = pc; - s->c_cpu->npc = pc +4 ; -#elif defined (TARGET_ARM ) - s->c_cpu->regs[15 ] = pc; -#elif defined (TARGET_SH4 ) - s->c_cpu->pc = pc; -#elif defined (TARGET_MIPS ) - s->c_cpu->active_tc.PC = pc & ~(target_ulong )1 ; -if (pc &1 ) { - s->c_cpu->hflags |=MIPS_HFLAG_M16 ; - }else { - s->c_cpu->hflags &= ~(MIPS_HFLAG_M16 ); +CPUState *cpu =ENV_GET_CPU (s->c_cpu); +CPUClass *cc =CPU_GET_CLASS (cpu); + +cpu_synchronize_state (cpu); +if (cc->set_pc) { + cc->set_pc (cpu, pc); } -#elif defined (TARGET_MICROBLAZE ) - s->c_cpu->sregs[SR_PC ] = pc; -#elif defined(TARGET_OPENRISC ) - s->c_cpu->pc = pc; -#elif defined (TARGET_CRIS ) - s->c_cpu->pc = pc; -#elif defined (TARGET_ALPHA ) - s->c_cpu->pc = pc; -#elif defined (TARGET_S390X ) - s->c_cpu->psw.addr = pc; -#elif defined (TARGET_LM32 ) - s->c_cpu->pc = pc; -#elif defined(TARGET_XTENSA ) - s->c_cpu->pc = pc; -#endif }static CPUArchState *find_cpu (uint32_t thread_id)
include/qom/cpu.h +2 -0
@@ -73,6 +73,7 @@ typedef void (*CPUUnassignedAccess)(CPUState *cpu, hwaddr addr,* @get_arch_id: Callback for getting architecture-dependent CPU ID. * @get_paging_enabled: Callback for inquiring whether paging is enabled. * @get_memory_mapping: Callback for obtaining the memory mappings. +* @set_pc: Callback for setting the Program Counter register. * @vmsd: State description for migration. * * Represents a CPU family or model.
@@ -96,6 +97,7 @@ typedef struct CPUClass {bool (*get_paging_enabled)(const CPUState *cpu);void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp); +void (*set_pc)(CPUState *cpu,vaddr value);const struct VMStateDescription *vmsd; int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
target-alpha/cpu.c +8 -0
@@ -24,6 +24,13 @@#include "migration/vmstate.h" +static void alpha_cpu_set_pc (CPUState *cs,vaddr value) +{ +AlphaCPU *cpu =ALPHA_CPU (cs); + + cpu->env.pc = value; +} +static void alpha_cpu_realizefn (DeviceState *dev,Error **errp) {AlphaCPUClass *acc =ALPHA_CPU_GET_CLASS (dev);
@@ -264,6 +271,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = alpha_cpu_do_interrupt; cc->dump_state = alpha_cpu_dump_state;cpu_class_set_do_unassigned_access (cc, alpha_cpu_unassigned_access); + cc->set_pc = alpha_cpu_set_pc;device_class_set_vmsd (dc, &vmstate_alpha_cpu); }
target-arm/cpu.c +8 -0
@@ -25,6 +25,13 @@#endif #include "sysemu/sysemu.h" +static void arm_cpu_set_pc (CPUState *cs,vaddr value) +{ +ARMCPU *cpu =ARM_CPU (cs); + + cpu->env.regs[15 ] = value; +} +static void cp_reg_reset (gpointer key,gpointer value,gpointer opaque) {/* Reset a single ARMCPRegInfo register */
@@ -816,6 +823,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = arm_cpu_class_by_name; cc->do_interrupt = arm_cpu_do_interrupt; cc->dump_state = arm_cpu_dump_state; + cc->set_pc = arm_cpu_set_pc;cpu_class_set_vmsd (cc, &vmstate_arm_cpu); }
target-cris/cpu.c +8 -0
@@ -26,6 +26,13 @@#include "mmu.h" +static void cris_cpu_set_pc (CPUState *cs,vaddr value) +{ +CRISCPU *cpu =CRIS_CPU (cs); + + cpu->env.pc = value; +} +/* CPUClass::reset() */ static void cris_cpu_reset (CPUState *s) {
@@ -247,6 +254,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = cris_cpu_class_by_name; cc->do_interrupt = cris_cpu_do_interrupt; cc->dump_state = cris_cpu_dump_state; + cc->set_pc = cris_cpu_set_pc; }static const TypeInfo cris_cpu_type_info = {
target-i386/cpu.c +8 -0
@@ -2506,6 +2506,13 @@ static bool x86_cpu_get_paging_enabled(const CPUState *cs)return cpu->env.cr[0 ] &CR0_PG_MASK ; } +static void x86_cpu_set_pc (CPUState *cs,vaddr value) +{ +X86CPU *cpu =X86_CPU (cs); + + cpu->env.eip = value; +} +static void x86_cpu_common_class_init (ObjectClass *oc,void *data) {X86CPUClass *xcc =X86_CPU_CLASS (oc);
@@ -2522,6 +2529,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->do_interrupt = x86_cpu_do_interrupt; cc->dump_state = x86_cpu_dump_state; + cc->set_pc = x86_cpu_set_pc; cc->get_arch_id = x86_cpu_get_arch_id; cc->get_paging_enabled = x86_cpu_get_paging_enabled;#ifndef CONFIG_USER_ONLY
target-lm32/cpu.c +8 -0
@@ -22,6 +22,13 @@#include "qemu-common.h" +static void lm32_cpu_set_pc (CPUState *cs,vaddr value) +{ +LM32CPU *cpu =LM32_CPU (cs); + + cpu->env.pc = value; +} +/* CPUClass::reset() */ static void lm32_cpu_reset (CPUState *s) {
@@ -79,6 +86,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = lm32_cpu_do_interrupt; cc->dump_state = lm32_cpu_dump_state; + cc->set_pc = lm32_cpu_set_pc;cpu_class_set_vmsd (cc, &vmstate_lm32_cpu); }
target-microblaze/cpu.c +8 -0
@@ -26,6 +26,13 @@#include "migration/vmstate.h" +static void mb_cpu_set_pc (CPUState *cs,vaddr value) +{ +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); + + cpu->env.sregs[SR_PC ] = value; +} +/* CPUClass::reset() */ static void mb_cpu_reset (CPUState *s) {
@@ -134,6 +141,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = mb_cpu_do_interrupt; cc->dump_state = mb_cpu_dump_state;cpu_class_set_do_unassigned_access (cc, mb_cpu_unassigned_access); + cc->set_pc = mb_cpu_set_pc; dc->vmsd = &vmstate_mb_cpu; dc->props = mb_properties; }
target-mips/cpu.c +14 -0
@@ -22,6 +22,19 @@#include "qemu-common.h" +static void mips_cpu_set_pc (CPUState *cs,vaddr value) +{ +MIPSCPU *cpu =MIPS_CPU (cs); +CPUMIPSState *env = &cpu->env; + + env->active_tc.PC = value & ~(target_ulong )1 ; +if (value &1 ) { + env->hflags |=MIPS_HFLAG_M16 ; + }else { + env->hflags &= ~(MIPS_HFLAG_M16 ); + } +} +/* CPUClass::reset() */ static void mips_cpu_reset (CPUState *s) {
@@ -76,6 +89,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->do_interrupt = mips_cpu_do_interrupt; cc->dump_state = mips_cpu_dump_state;cpu_class_set_do_unassigned_access (cc, mips_cpu_unassigned_access); + cc->set_pc = mips_cpu_set_pc; }static const TypeInfo mips_cpu_type_info = {
target-openrisc/cpu.c +8 -0
@@ -20,6 +20,13 @@#include "cpu.h" #include "qemu-common.h" +static void openrisc_cpu_set_pc (CPUState *cs,vaddr value) +{ +OpenRISCCPU *cpu =OPENRISC_CPU (cs); + + cpu->env.pc = value; +} +/* CPUClass::reset() */ static void openrisc_cpu_reset (CPUState *s) {
@@ -146,6 +153,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = openrisc_cpu_class_by_name; cc->do_interrupt = openrisc_cpu_do_interrupt; cc->dump_state = openrisc_cpu_dump_state; + cc->set_pc = openrisc_cpu_set_pc;device_class_set_vmsd (dc, &vmstate_openrisc_cpu); }
target-ppc/translate_init.c +8 -0
@@ -8322,6 +8322,13 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)return cpu_list; } +static void ppc_cpu_set_pc (CPUState *cs,vaddr value) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); + + cpu->env.nip = value; +} +/* CPUClass::reset() */ static void ppc_cpu_reset (CPUState *s) {
@@ -8449,6 +8456,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = ppc_cpu_do_interrupt; cc->dump_state = ppc_cpu_dump_state; cc->dump_statistics = ppc_cpu_dump_statistics; + cc->set_pc = ppc_cpu_set_pc; }static const TypeInfo ppc_cpu_type_info = {
target-s390x/cpu.c +8 -0
@@ -58,6 +58,13 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) }#endif +static void s390_cpu_set_pc (CPUState *cs,vaddr value) +{ +S390CPU *cpu =S390_CPU (cs); + + cpu->env.psw.addr = value; +} +/* CPUClass::reset() */ static void s390_cpu_reset (CPUState *s) {
@@ -165,6 +172,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = s390_cpu_do_interrupt; cc->dump_state = s390_cpu_dump_state; + cc->set_pc = s390_cpu_set_pc; dc->vmsd = &vmstate_s390_cpu; }
target-sh4/cpu.c +8 -0
@@ -24,6 +24,13 @@#include "migration/vmstate.h" +static void superh_cpu_set_pc (CPUState *cs,vaddr value) +{ +SuperHCPU *cpu =SUPERH_CPU (cs); + + cpu->env.pc = value; +} +/* CPUClass::reset() */ static void superh_cpu_reset (CPUState *s) {
@@ -269,6 +276,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = superh_cpu_class_by_name; cc->do_interrupt = superh_cpu_do_interrupt; cc->dump_state = superh_cpu_dump_state; + cc->set_pc = superh_cpu_set_pc; dc->vmsd = &vmstate_sh_cpu; }
target-sparc/cpu.c +9 -0
@@ -723,6 +723,14 @@ void sparc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,cpu_fprintf (f,"\n" ); } +static void sparc_cpu_set_pc (CPUState *cs,vaddr value) +{ +SPARCCPU *cpu =SPARC_CPU (cs); + + cpu->env.pc = value; + cpu->env.npc = value +4 ; +} +static void sparc_cpu_realizefn (DeviceState *dev,Error **errp) {SPARCCPUClass *scc =SPARC_CPU_GET_CLASS (dev);
@@ -767,6 +775,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = sparc_cpu_do_interrupt; cc->dump_state = sparc_cpu_dump_state;cpu_class_set_do_unassigned_access (cc, sparc_cpu_unassigned_access); + cc->set_pc = sparc_cpu_set_pc; }static const TypeInfo sparc_cpu_type_info = {
target-xtensa/cpu.c +8 -0
@@ -33,6 +33,13 @@#include "migration/vmstate.h" +static void xtensa_cpu_set_pc (CPUState *cs,vaddr value) +{ +XtensaCPU *cpu =XTENSA_CPU (cs); + + cpu->env.pc = value; +} +/* CPUClass::reset() */ static void xtensa_cpu_reset (CPUState *s) {
@@ -100,6 +107,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = xtensa_cpu_do_interrupt; cc->dump_state = xtensa_cpu_dump_state; + cc->set_pc = xtensa_cpu_set_pc; dc->vmsd = &vmstate_xtensa_cpu; }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 07/24] target-unicore32: Implement CPUClass::set_pc()
In reply to Andreas FärberThis adds support for GDB's c addr (Continue) and s addr (Single Step).
Prepares for dropping cpu_pc_from_tb().
--- target-unicore32/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target-unicore32/cpu.c +8 -0
@@ -16,6 +16,13 @@#include "qemu-common.h" #include "migration/vmstate.h" +static void uc32_cpu_set_pc (CPUState *cs,vaddr value) +{ +UniCore32CPU *cpu =UNICORE32_CPU (cs); + + cpu->env.regs[31 ] = value; +} +static inline void set_feature (CPUUniCore32State *env,int feature) { env->features |= feature;
@@ -131,6 +138,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = uc32_cpu_class_by_name; cc->do_interrupt = uc32_cpu_do_interrupt; cc->dump_state = uc32_cpu_dump_state; + cc->set_pc = uc32_cpu_set_pc; dc->vmsd = &vmstate_uc32_cpu; }
Signature · 1 line
1.8.1.4
[PULL 14/24] kvm: Change kvm_{insert,remove}_breakpoint() argument to CPUState
In reply to Andreas FärberCPUArchState is no longer directly used since converting CPU loops to CPUState.
Prepares for changing GDBState::c_cpu to CPUState.
--- gdbstub.c | 12 ++++++++---- include/sysemu/kvm.h | 4 ++-- kvm-all.c | 10 ++++------ kvm-stub.c | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-)
gdbstub.c +8 -4
@@ -1954,8 +1954,10 @@ static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type)CPUArchState *env;int err =0 ; -if (kvm_enabled ()) -return kvm_insert_breakpoint (gdbserver_state->c_cpu, addr, len, type); +if (kvm_enabled ()) { +return kvm_insert_breakpoint (ENV_GET_CPU (gdbserver_state->c_cpu), + addr, len, type); + }switch (type) {case GDB_BREAKPOINT_SW :
@@ -1991,8 +1993,10 @@ static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type)CPUArchState *env;int err =0 ; -if (kvm_enabled ()) -return kvm_remove_breakpoint (gdbserver_state->c_cpu, addr, len, type); +if (kvm_enabled ()) { +return kvm_remove_breakpoint (ENV_GET_CPU (gdbserver_state->c_cpu), + addr, len, type); + }switch (type) {case GDB_BREAKPOINT_SW :
include/sysemu/kvm.h +2 -2
@@ -169,9 +169,9 @@ void *kvm_arch_ram_alloc(ram_addr_t size);void kvm_setup_guest_memory (void *start,size_t size);void kvm_flush_coalesced_mmio_buffer (void ); -int kvm_insert_breakpoint (CPUArchState *env,target_ulong addr, +int kvm_insert_breakpoint (CPUState *cpu,target_ulong addr,target_ulong len,int type); -int kvm_remove_breakpoint (CPUArchState *env,target_ulong addr, +int kvm_remove_breakpoint (CPUState *cpu,target_ulong addr,target_ulong len,int type);void kvm_remove_all_breakpoints (CPUState *cpu);int kvm_update_guest_debug (CPUArchState *env,unsigned long reinject_trap);
kvm-all.c +4 -6
@@ -1900,10 +1900,9 @@ int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap)return data.err; } -int kvm_insert_breakpoint (CPUArchState *env,target_ulong addr, +int kvm_insert_breakpoint (CPUState *cpu,target_ulong addr,target_ulong len,int type) { -CPUState *cpu =ENV_GET_CPU (env);struct kvm_sw_breakpoint *bp;int err;
@@ -1946,10 +1945,9 @@ int kvm_insert_breakpoint(CPUArchState *env, target_ulong addr,return 0 ; } -int kvm_remove_breakpoint (CPUArchState *env,target_ulong addr, +int kvm_remove_breakpoint (CPUState *cpu,target_ulong addr,target_ulong len,int type) { -CPUState *cpu =ENV_GET_CPU (env);struct kvm_sw_breakpoint *bp;int err;
@@ -2022,13 +2020,13 @@ int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap)return -EINVAL ; } -int kvm_insert_breakpoint (CPUArchState *env,target_ulong addr, +int kvm_insert_breakpoint (CPUState *cpu,target_ulong addr,target_ulong len,int type) {return -EINVAL ; } -int kvm_remove_breakpoint (CPUArchState *env,target_ulong addr, +int kvm_remove_breakpoint (CPUState *cpu,target_ulong addr,target_ulong len,int type) {return -EINVAL ;
kvm-stub.c +2 -2
@@ -83,13 +83,13 @@ int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap)return -ENOSYS ; } -int kvm_insert_breakpoint (CPUArchState *env,target_ulong addr, +int kvm_insert_breakpoint (CPUState *cpu,target_ulong addr,target_ulong len,int type) {return -EINVAL ; } -int kvm_remove_breakpoint (CPUArchState *env,target_ulong addr, +int kvm_remove_breakpoint (CPUState *cpu,target_ulong addr,target_ulong len,int type) {return -EINVAL ;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 09/24] target-alpha: Copy singlestep_enabled to DisasContext
In reply to Andreas FärberFrom: Richard Henderson <[email protected]>
Prepare for removing env from DisasContext.
--- target-alpha/translate.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
target-alpha/translate.c +6 -3
@@ -46,6 +46,8 @@ struct DisasContext {int tb_rm;/* Current flush-to-zero setting for this TB. */ int tb_ftz; + +bool singlestep_enabled; };/* Return values from translate_one, indicating the state of the TB.
@@ -380,7 +382,7 @@ static int use_goto_tb(DisasContext *ctx, uint64_t dest)/* Check for the dest on the same page as the start of the TB. We also want to suppress goto_tb in the case of single-steping and IO. */ return (((ctx->tb->pc ^ dest) &TARGET_PAGE_MASK ) ==0 - && !ctx->env->singlestep_enabled + && !ctx->singlestep_enabled && !(ctx->tb->cflags &CF_LAST_IO )); }
@@ -3401,6 +3403,7 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu, ctx.env = env; ctx.pc = pc_start; ctx.mem_idx =cpu_mmu_index (env); + ctx.singlestep_enabled = env->singlestep_enabled;/* ??? Every TB begins with unset rounding mode, to be initialized on the first fp insn of the TB. Alternately we could define a proper
@@ -3457,7 +3460,7 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu, || tcg_ctx.gen_opc_ptr >= gen_opc_end || num_insns >= max_insns || singlestep - || env->singlestep_enabled)) { + || ctx.singlestep_enabled)) { ret =EXIT_PC_STALE ; } }while (ret ==NO_EXIT );
@@ -3474,7 +3477,7 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu,tcg_gen_movi_i64 (cpu_pc, ctx.pc);/* FALLTHRU */ case EXIT_PC_UPDATED : -if (env->singlestep_enabled) { +if (ctx.singlestep_enabled) {gen_excp_1 (EXCP_DEBUG ,0 ); }else {tcg_gen_exit_tb (0 );
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 10/24] target-alpha: Copy implver to DisasContext
In reply to Andreas FärberFrom: Richard Henderson <[email protected]>
Which allows removing env from DisasContext.
--- target-alpha/translate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
target-alpha/translate.c +7 -4
@@ -38,7 +38,6 @@typedef struct DisasContext DisasContext ;struct DisasContext {struct TranslationBlock *tb; -CPUAlphaState *env;uint64_t pc;int mem_idx;
@@ -47,6 +46,9 @@ struct DisasContext {/* Current flush-to-zero setting for this TB. */ int tb_ftz; +/* implver value for this CPU. */ +int implver; +bool singlestep_enabled; };
@@ -2250,8 +2252,9 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn)break ;case 0x6C :/* IMPLVER */ -if (rc !=31 ) -tcg_gen_movi_i64 (cpu_ir[rc], ctx->env->implver); +if (rc !=31 ) { +tcg_gen_movi_i64 (cpu_ir[rc], ctx->implver); + }break ;default : goto invalid_opc;
@@ -3400,9 +3403,9 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu, gen_opc_end = tcg_ctx.gen_opc_buf +OPC_MAX_SIZE ; ctx.tb = tb; - ctx.env = env; ctx.pc = pc_start; ctx.mem_idx =cpu_mmu_index (env); + ctx.implver = env->implver; ctx.singlestep_enabled = env->singlestep_enabled;/* ??? Every TB begins with unset rounding mode, to be initialized on
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 12/24] gdbstub: Update gdb_handlesig() and gdb_signalled() Coding Style
In reply to Andreas FärberIn particular reindent to 4 instead of 2 spaces.
Prepares for changing cpu_single_step() argument in gdb_handlesig().
--- gdbstub.c | 94 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 47 insertions(+), 47 deletions(-)
gdbstub.c +47 -47
@@ -2761,66 +2761,66 @@ gdb_queuesig (void) }int -gdb_handlesig (CPUArchState *env,int sig) +gdb_handlesig (CPUArchState *env,int sig) { -GDBState *s; -char buf[256 ]; -int n; +GDBState *s; +char buf[256 ]; +int n; - s = gdbserver_state; -if (gdbserver_fd <0 || s->fd <0 ) -return sig; + s = gdbserver_state; +if (gdbserver_fd <0 || s->fd <0 ) { +return sig; + } -/* disable single step if it was enabled */ -cpu_single_step (env,0 ); -tb_flush (env); +/* disable single step if it was enabled */ +cpu_single_step (env,0 ); +tb_flush (env); -if (sig !=0 ) - { -snprintf (buf,sizeof (buf),"S%02x" ,target_signal_to_gdb (sig)); -put_packet (s, buf); - } -/* put_packet() might have detected that the peer terminated the -connection. */ -if (s->fd <0 ) -return sig; - - sig =0 ; - s->state =RS_IDLE ; - s->running_state =0 ; -while (s->running_state ==0 ) { - n =read (s->fd, buf,256 ); -if (n >0 ) - { -int i; +if (sig !=0 ) { +snprintf (buf,sizeof (buf),"S%02x" ,target_signal_to_gdb (sig)); +put_packet (s, buf); + } +/* put_packet() might have detected that the peer terminated the +connection. */ +if (s->fd <0 ) { +return sig; + } -for (i =0 ; i < n; i++) -gdb_read_byte (s, buf[i]); - } -else if (n ==0 || errno !=EAGAIN ) - { -/* XXX: Connection closed. Should probably wait for another -connection before continuing. */ -return sig; + sig =0 ; + s->state =RS_IDLE ; + s->running_state =0 ; +while (s->running_state ==0 ) { + n =read (s->fd, buf,256 ); +if (n >0 ) { +int i; + +for (i =0 ; i < n; i++) { +gdb_read_byte (s, buf[i]); + } + }else if (n ==0 || errno !=EAGAIN ) { +/* XXX: Connection closed. Should probably wait for another +connection before continuing. */ +return sig; } - } - sig = s->signal; - s->signal =0 ; -return sig; + } + sig = s->signal; + s->signal =0 ; +return sig; }/* Tell the remote gdb that the process has exited due to SIG. */ void gdb_signalled (CPUArchState *env,int sig) { -GDBState *s; -char buf[4 ]; +GDBState *s; +char buf[4 ]; - s = gdbserver_state; -if (gdbserver_fd <0 || s->fd <0 ) -return ; + s = gdbserver_state; +if (gdbserver_fd <0 || s->fd <0 ) { +return ; + } -snprintf (buf,sizeof (buf),"X%02x" ,target_signal_to_gdb (sig)); -put_packet (s, buf); +snprintf (buf,sizeof (buf),"X%02x" ,target_signal_to_gdb (sig)); +put_packet (s, buf); }static void gdb_accept (void )
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 13/24] cpu: Change cpu_single_step() argument to CPUState
In reply to Andreas FärberUse CPUState::env_ptr for now.
Needed for GdbState::c_cpu.
--- exec.c | 4 ++-- gdbstub.c | 9 +++++---- include/exec/cpu-all.h | 6 ------ include/qom/cpu.h | 13 +++++++++++++ 4 files changed, 20 insertions(+), 12 deletions(-)
exec.c +2 -2
@@ -585,10 +585,10 @@ void cpu_breakpoint_remove_all(CPUArchState *env, int mask)/* enable or disable single step mode. EXCP_DEBUG is returned by the CPU loop after each instruction */ -void cpu_single_step (CPUArchState *env,int enabled) +void cpu_single_step (CPUState *cpu,int enabled) {#if defined(TARGET_HAS_ICE ) -CPUState *cpu =ENV_GET_CPU (env); +CPUArchState *env = cpu->env_ptr;if (cpu->singlestep_enabled != enabled) { cpu->singlestep_enabled = enabled;
gdbstub.c +5 -4
@@ -2154,7 +2154,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) s->c_cpu = env; }if (res =='s' ) { -cpu_single_step (s->c_cpu, sstep_flags); +cpu_single_step (ENV_GET_CPU (s->c_cpu), sstep_flags); } s->signal = res_signal;gdb_continue (s);
@@ -2182,7 +2182,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) addr =strtoull (p, (char **)&p,16 );gdb_set_cpu_pc (s, addr); } -cpu_single_step (s->c_cpu, sstep_flags); +cpu_single_step (ENV_GET_CPU (s->c_cpu), sstep_flags);gdb_continue (s);return RS_IDLE ;case 'F' :
@@ -2570,7 +2570,7 @@ send_packet:put_packet (s, buf);/* disable single step if it was enabled */ - cpu_single_step(env, 0); + cpu_single_step(cpu, 0); }#endif
@@ -2763,6 +2763,7 @@ gdb_queuesig (void)int gdb_handlesig (CPUArchState *env,int sig) { +CPUState *cpu =ENV_GET_CPU (env);GDBState *s;char buf[256 ];int n;
@@ -2773,7 +2774,7 @@ gdb_handlesig(CPUArchState *env, int sig) }/* disable single step if it was enabled */ -cpu_single_step (env,0 ); +cpu_single_step (cpu,0 );tb_flush (env);if (sig !=0 ) {
include/exec/cpu-all.h +0 -6
@@ -428,12 +428,6 @@ int cpu_watchpoint_remove(CPUArchState *env, target_ulong addr,void cpu_watchpoint_remove_by_ref (CPUArchState *env,CPUWatchpoint *watchpoint);void cpu_watchpoint_remove_all (CPUArchState *env,int mask); -#define SSTEP_ENABLE 0x1/* Enable simulated HW single stepping */ -#define SSTEP_NOIRQ 0x2/* Do not use IRQ while single stepping */ -#define SSTEP_NOTIMER 0x4/* Do not Timers while single stepping */ - -void cpu_single_step (CPUArchState *env,int enabled); -#if !defined(CONFIG_USER_ONLY )/* Return the physical page corresponding to a virtual one. Use it
include/qom/cpu.h +13 -0
@@ -510,6 +510,19 @@ void cpu_resume(CPUState *cpu);*/ void qemu_init_vcpu (CPUState *cpu); +#define SSTEP_ENABLE 0x1/* Enable simulated HW single stepping */ +#define SSTEP_NOIRQ 0x2/* Do not use IRQ while single stepping */ +#define SSTEP_NOTIMER 0x4/* Do not Timers while single stepping */ + +/** +* cpu_single_step: +* @cpu: CPU to the flags for. +* @enabled: Flags to enable. +* +* Enables or disables single-stepping for @cpu. +*/ +void cpu_single_step (CPUState *cpu,int enabled); +#ifdef CONFIG_SOFTMMU extern const struct VMStateDescription vmstate_cpu_common;#else
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 08/24] cpu: Introduce CPUClass::synchronize_from_tb() for cpu_pc_from_tb()
In reply to Andreas FärberWhere no extra implementation is needed, fall back to CPUClass::set_pc().
--- cpu-exec.c | 8 +++++++- include/qom/cpu.h | 5 +++++ target-alpha/cpu.h | 5 ----- target-arm/cpu.h | 5 ----- target-cris/cpu.h | 4 ---- target-i386/cpu.c | 8 ++++++++ target-i386/cpu.h | 5 ----- target-lm32/cpu.h | 5 ----- target-m68k/cpu.h | 5 ----- target-microblaze/cpu.h | 5 ----- target-mips/cpu.c | 11 +++++++++++ target-mips/cpu.h | 7 ------- target-moxie/cpu.h | 5 ----- target-openrisc/cpu.h | 5 ----- target-ppc/cpu.h | 5 ----- target-s390x/cpu.h | 5 ----- target-sh4/cpu.c | 9 +++++++++ target-sh4/cpu.h | 6 ------ target-sparc/cpu.c | 9 +++++++++ target-sparc/cpu.h | 6 ------ target-unicore32/cpu.h | 5 ----- target-xtensa/cpu.h | 5 ----- 22 files changed, 49 insertions(+), 84 deletions(-)
cpu-exec.c +7 -1
@@ -59,8 +59,14 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr)* counter hit zero); we must restore the guest PC to the address * of the start of the TB. */ +CPUClass *cc =CPU_GET_CLASS (cpu);TranslationBlock *tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK ); -cpu_pc_from_tb (env, tb); +if (cc->synchronize_from_tb) { + cc->synchronize_from_tb (cpu, tb); + }else { +assert (cc->set_pc); + cc->set_pc (cpu, tb->pc); + } }if ((next_tb &TB_EXIT_MASK ) ==TB_EXIT_REQUESTED ) {/* We were asked to stop executing TBs (probably a pending
include/qom/cpu.h +5 -0
@@ -60,6 +60,8 @@ typedef void (*CPUUnassignedAccess)(CPUState *cpu, hwaddr addr, bool is_write, bool is_exec, int opaque, unsigned size); +struct TranslationBlock ; +/** * CPUClass: * @class_by_name: Callback to map -cpu command line model name to an
@@ -74,6 +76,8 @@ typedef void (*CPUUnassignedAccess)(CPUState *cpu, hwaddr addr,* @get_paging_enabled: Callback for inquiring whether paging is enabled. * @get_memory_mapping: Callback for obtaining the memory mappings. * @set_pc: Callback for setting the Program Counter register. +* @synchronize_from_tb: Callback for synchronizing state from a TCG +* #TranslationBlock. * @vmsd: State description for migration. * * Represents a CPU family or model.
@@ -98,6 +102,7 @@ typedef struct CPUClass {void (*get_memory_mapping)(CPUState *cpu,MemoryMappingList *list,Error **errp);void (*set_pc)(CPUState *cpu,vaddr value); +void (*synchronize_from_tb)(CPUState *cpu,struct TranslationBlock *tb);const struct VMStateDescription *vmsd; int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
target-alpha/cpu.h +0 -5
@@ -515,9 +515,4 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUAlphaState *env,TranslationBlock *tb) -{ - env->pc = tb->pc; -} -#endif /* !defined (__CPU_ALPHA_H__) */
target-arm/cpu.h +0 -5
@@ -797,11 +797,6 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUARMState *env,TranslationBlock *tb) -{ - env->regs[15 ] = tb->pc; -} -/* Load an instruction and return it in the standard little-endian order */ static inline uint32_t arm_ldl_code (CPUARMState *env,uint32_t addr,bool do_swap)
target-cris/cpu.h +0 -4
@@ -279,8 +279,4 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUCRISState *env,TranslationBlock *tb) -{ - env->pc = tb->pc; -}#endif
target-i386/cpu.c +8 -0
@@ -2513,6 +2513,13 @@ static void x86_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.eip = value; } +static void x86_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) +{ +X86CPU *cpu =X86_CPU (cs); + + cpu->env.eip = tb->pc - tb->cs_base; +} +static void x86_cpu_common_class_init (ObjectClass *oc,void *data) {X86CPUClass *xcc =X86_CPU_CLASS (oc);
@@ -2530,6 +2537,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->do_interrupt = x86_cpu_do_interrupt; cc->dump_state = x86_cpu_dump_state; cc->set_pc = x86_cpu_set_pc; + cc->synchronize_from_tb = x86_cpu_synchronize_from_tb; cc->get_arch_id = x86_cpu_get_arch_id; cc->get_paging_enabled = x86_cpu_get_paging_enabled;#ifndef CONFIG_USER_ONLY
target-i386/cpu.h +0 -5
@@ -1148,11 +1148,6 @@ static inline bool cpu_has_work(CPUState *cs)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUX86State *env,TranslationBlock *tb) -{ - env->eip = tb->pc - tb->cs_base; -} -static inline void cpu_get_tb_cpu_state (CPUX86State *env,target_ulong *pc,target_ulong *cs_base,int *flags) {
target-lm32/cpu.h +0 -5
@@ -232,9 +232,4 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPULM32State *env,TranslationBlock *tb) -{ - env->pc = tb->pc; -} -#endif
target-m68k/cpu.h +0 -5
@@ -260,9 +260,4 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUM68KState *env,TranslationBlock *tb) -{ - env->pc = tb->pc; -} -#endif
target-microblaze/cpu.h +0 -5
@@ -365,9 +365,4 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUMBState *env,TranslationBlock *tb) -{ - env->sregs[SR_PC ] = tb->pc; -} -#endif
target-mips/cpu.c +11 -0
@@ -35,6 +35,16 @@ static void mips_cpu_set_pc(CPUState *cs, vaddr value) } } +static void mips_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) +{ +MIPSCPU *cpu =MIPS_CPU (cs); +CPUMIPSState *env = &cpu->env; + + env->active_tc.PC = tb->pc; + env->hflags &= ~MIPS_HFLAG_BMASK ; + env->hflags |= tb->flags &MIPS_HFLAG_BMASK ; +} +/* CPUClass::reset() */ static void mips_cpu_reset (CPUState *s) {
@@ -90,6 +100,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->dump_state = mips_cpu_dump_state;cpu_class_set_do_unassigned_access (cc, mips_cpu_unassigned_access); cc->set_pc = mips_cpu_set_pc; + cc->synchronize_from_tb = mips_cpu_synchronize_from_tb; }static const TypeInfo mips_cpu_type_info = {
target-mips/cpu.h +0 -7
@@ -732,13 +732,6 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUMIPSState *env,TranslationBlock *tb) -{ - env->active_tc.PC = tb->pc; - env->hflags &= ~MIPS_HFLAG_BMASK ; - env->hflags |= tb->flags &MIPS_HFLAG_BMASK ; -} -static inline void compute_hflags (CPUMIPSState *env) { env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |
target-moxie/cpu.h +0 -5
@@ -143,11 +143,6 @@ static inline int cpu_mmu_index(CPUMoxieState *env)#include "exec/cpu-all.h" #include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUMoxieState *env,TranslationBlock *tb) -{ - env->pc = tb->pc; -} -static inline void cpu_get_tb_cpu_state (CPUMoxieState *env,target_ulong *pc,target_ulong *cs_base,int *flags) {
target-openrisc/cpu.h +0 -5
@@ -428,9 +428,4 @@ static inline target_ulong cpu_get_pc(CPUOpenRISCState *env) return env->pc; } -static inline void cpu_pc_from_tb (CPUOpenRISCState *env,TranslationBlock *tb) -{ - env->pc = tb->pc; -} -#endif /* CPU_OPENRISC_H */
target-ppc/cpu.h +0 -5
@@ -2144,11 +2144,6 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUPPCState *env,TranslationBlock *tb) -{ - env->nip = tb->pc; -} -void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUPPCState *env);#endif /* !defined (__CPU_PPC_H__) */
target-s390x/cpu.h +0 -5
@@ -1041,11 +1041,6 @@ static inline bool cpu_has_work(CPUState *cpu) (env->psw.mask &PSW_MASK_EXT ); } -static inline void cpu_pc_from_tb (CPUS390XState *env,TranslationBlock * tb) -{ - env->psw.addr = tb->pc; -} -/* fpu_helper.c */ uint32_t set_cc_nz_f32 (float32 v);uint32_t set_cc_nz_f64 (float64 v);
target-sh4/cpu.c +9 -0
@@ -31,6 +31,14 @@ static void superh_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.pc = value; } +static void superh_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) +{ +SuperHCPU *cpu =SUPERH_CPU (cs); + + cpu->env.pc = tb->pc; + cpu->env.flags = tb->flags; +} +/* CPUClass::reset() */ static void superh_cpu_reset (CPUState *s) {
@@ -277,6 +285,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = superh_cpu_do_interrupt; cc->dump_state = superh_cpu_dump_state; cc->set_pc = superh_cpu_set_pc; + cc->synchronize_from_tb = superh_cpu_synchronize_from_tb; dc->vmsd = &vmstate_sh_cpu; }
target-sh4/cpu.h +0 -6
@@ -359,10 +359,4 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUSH4State *env,TranslationBlock *tb) -{ - env->pc = tb->pc; - env->flags = tb->flags; -} -#endif /* _CPU_SH4_H */
target-sparc/cpu.c +9 -0
@@ -731,6 +731,14 @@ static void sparc_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.npc = value +4 ; } +static void sparc_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) +{ +SPARCCPU *cpu =SPARC_CPU (cs); + + cpu->env.pc = tb->pc; + cpu->env.npc = tb->cs_base; +} +static void sparc_cpu_realizefn (DeviceState *dev,Error **errp) {SPARCCPUClass *scc =SPARC_CPU_GET_CLASS (dev);
@@ -776,6 +784,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = sparc_cpu_dump_state;cpu_class_set_do_unassigned_access (cc, sparc_cpu_unassigned_access); cc->set_pc = sparc_cpu_set_pc; + cc->synchronize_from_tb = sparc_cpu_synchronize_from_tb; }static const TypeInfo sparc_cpu_type_info = {
target-sparc/cpu.h +0 -6
@@ -759,10 +759,4 @@ static inline bool cpu_has_work(CPUState *cpu)#include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUSPARCState *env,TranslationBlock *tb) -{ - env->pc = tb->pc; - env->npc = tb->cs_base; -} -#endif
target-unicore32/cpu.h +0 -5
@@ -146,11 +146,6 @@ static inline int cpu_mmu_index(CPUUniCore32State *env)#include "cpu-qom.h" #include "exec/exec-all.h" -static inline void cpu_pc_from_tb (CPUUniCore32State *env,TranslationBlock *tb) -{ - env->regs[31 ] = tb->pc; -} -static inline void cpu_get_tb_cpu_state (CPUUniCore32State *env,target_ulong *pc,target_ulong *cs_base,int *flags) {
target-xtensa/cpu.h +0 -5
@@ -522,9 +522,4 @@ static inline int cpu_has_work(CPUState *cpu) return env->pending_irq_level; } -static inline void cpu_pc_from_tb (CPUXtensaState *env,TranslationBlock *tb) -{ - env->pc = tb->pc; -} -#endif
Signature · 1 line
1.8.1.4
[PULL 19/24] exec: Change cpu_memory_rw_debug() argument to CPUState
In reply to Andreas FärberPropagate X86CPU in kvmvapic for simplicity.
--- cpus.c | 4 +-- disas.c | 4 +-- exec.c | 6 ++-- gdbstub.c | 2 +- hw/i386/kvmvapic.c | 72 +++++++++++++++++++++++---------------------- include/exec/cpu-all.h | 3 +- include/exec/softmmu-semi.h | 18 +++++++----- monitor.c | 2 +- target-arm/arm-semi.c | 2 +- target-i386/helper.c | 8 +++-- target-i386/kvm.c | 14 ++++----- target-sparc/mmu_helper.c | 5 ++-- target-xtensa/xtensa-semi.c | 10 +++---- 13 files changed, 77 insertions(+), 73 deletions(-)
cpus.c +1 -3
@@ -1285,7 +1285,6 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, {FILE *f;uint32_t l; -CPUArchState *env;CPUState *cpu;uint8_t buf[1024 ];
@@ -1299,7 +1298,6 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, "a CPU number");return ; } - env = cpu->env_ptr; f =fopen (filename,"wb" );if (!f) {
@@ -1311,7 +1309,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, l =sizeof (buf);if (l > size) l = size; -cpu_memory_rw_debug (env, addr, buf, l,0 ); +cpu_memory_rw_debug (cpu, addr, buf, l,0 );if (fwrite (buf,1 , l, f) != l) {error_set (errp,QERR_IO_ERROR ); goto exit;
disas.c +2 -2
@@ -39,7 +39,7 @@ target_read_memory (bfd_vma memaddr, {CPUDebug *s =container_of (info, CPUDebug, info); -cpu_memory_rw_debug (s->env, memaddr, myaddr, length,0 ); +cpu_memory_rw_debug (ENV_GET_CPU (s->env), memaddr, myaddr, length,0 );return 0 ; }
@@ -392,7 +392,7 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,if (monitor_disas_is_physical) {cpu_physical_memory_read (memaddr, myaddr, length); }else { -cpu_memory_rw_debug (s->env, memaddr,myaddr, length,0 ); +cpu_memory_rw_debug (ENV_GET_CPU (s->env), memaddr, myaddr, length,0 ); }return 0 ; }
exec.c +3 -3
@@ -1835,7 +1835,7 @@ MemoryRegion *get_system_io(void)/* physical memory access (slow version, mainly for debug) */ #if defined(CONFIG_USER_ONLY ) -int cpu_memory_rw_debug (CPUArchState *env,target_ulong addr, +int cpu_memory_rw_debug (CPUState *cpu,target_ulong addr,uint8_t *buf,int len,int is_write) {int l, flags;
@@ -2606,7 +2606,7 @@ void stq_be_phys(hwaddr addr, uint64_t val) }/* virtual memory access for debug (includes writing to ROM) */ -int cpu_memory_rw_debug (CPUArchState *env,target_ulong addr, +int cpu_memory_rw_debug (CPUState *cpu,target_ulong addr,uint8_t *buf,int len,int is_write) {int l;
@@ -2615,7 +2615,7 @@ int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr,while (len >0 ) { page = addr &TARGET_PAGE_MASK ; - phys_addr =cpu_get_phys_page_debug (ENV_GET_CPU (env), page); + phys_addr =cpu_get_phys_page_debug (cpu, page);/* if no physical page mapped, return an error */ if (phys_addr ==-1 )return -1 ;
gdbstub.c +1 -1
@@ -46,7 +46,7 @@static inline int target_memory_rw_debug (CPUArchState *env,target_ulong addr,uint8_t *buf,int len,int is_write) { -return cpu_memory_rw_debug (env, addr, buf, len, is_write); +return cpu_memory_rw_debug (ENV_GET_CPU (env), addr, buf, len, is_write); }#else /* target_memory_rw_debug() defined in cpu.h */
hw/i386/kvmvapic.c +37 -35
194 lines not on this page · raw message
include/exec/cpu-all.h +2 -1
@@ -22,6 +22,7 @@#include "qemu-common.h" #include "exec/cpu-common.h" #include "qemu/thread.h" +#include "qom/cpu.h" /* some important defines: *
@@ -483,7 +484,7 @@ void qemu_mutex_lock_ramlist(void);void qemu_mutex_unlock_ramlist (void );#endif /* !CONFIG_USER_ONLY */ -int cpu_memory_rw_debug (CPUArchState *env,target_ulong addr, +int cpu_memory_rw_debug (CPUState *cpu,target_ulong addr,uint8_t *buf,int len,int is_write);#endif /* CPU_ALL_H */
include/exec/softmmu-semi.h +10 -8
@@ -13,14 +13,14 @@ static inline uint32_t softmmu_tget32(CPUArchState *env, uint32_t addr) {uint32_t val; -cpu_memory_rw_debug (env, addr, (uint8_t *)&val,4 ,0 ); +cpu_memory_rw_debug (ENV_GET_CPU (env), addr, (uint8_t *)&val,4 ,0 );return tswap32 (val); }static inline uint32_t softmmu_tget8 (CPUArchState *env,uint32_t addr) {uint8_t val; -cpu_memory_rw_debug (env, addr, &val,1 ,0 ); +cpu_memory_rw_debug (ENV_GET_CPU (env), addr, &val,1 ,0 );return val; }
@@ -31,7 +31,7 @@ static inline uint32_t softmmu_tget8(CPUArchState *env, uint32_t addr)static inline void softmmu_tput32 (CPUArchState *env,uint32_t addr,uint32_t val) { val =tswap32 (val); -cpu_memory_rw_debug (env, addr, (uint8_t *)&val,4 ,1 ); +cpu_memory_rw_debug (ENV_GET_CPU (env), addr, (uint8_t *)&val,4 ,1 ); }#define put_user_u32 (arg, p) ({ softmmu_tput32(env, p, arg) ; 0; })#define put_user_ual (arg, p) put_user_u32(arg, p)
@@ -42,8 +42,9 @@ static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len,uint8_t *p;/* TODO: Make this something that isn't fixed size. */ p =malloc (len); -if (p && copy) -cpu_memory_rw_debug (env, addr, p, len,0 ); +if (p && copy) { +cpu_memory_rw_debug (ENV_GET_CPU (env), addr, p, len,0 ); + }return p; }#define lock_user (type, p, len, copy) softmmu_lock_user(env, p, len, copy)
@@ -58,7 +59,7 @@ static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr)return NULL ; }do { -cpu_memory_rw_debug (env, addr, &c,1 ,0 ); +cpu_memory_rw_debug (ENV_GET_CPU (env), addr, &c,1 ,0 ); addr++; *(p++) = c; }while (c);
@@ -68,8 +69,9 @@ static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr)static void softmmu_unlock_user (CPUArchState *env,void *p,target_ulong addr,target_ulong len) { -if (len) -cpu_memory_rw_debug (env, addr, p, len,1 ); +if (len) { +cpu_memory_rw_debug (ENV_GET_CPU (env), addr, p, len,1 ); + }free (p); }#define unlock_user (s, args, len) softmmu_unlock_user(env, s, args, len)
monitor.c +1 -1
@@ -1164,7 +1164,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,cpu_physical_memory_read (addr, buf, l); }else { env =mon_get_cpu (); -if (cpu_memory_rw_debug (env, addr, buf, l,0 ) <0 ) { +if (cpu_memory_rw_debug (ENV_GET_CPU (env), addr, buf, l,0 ) <0 ) {monitor_printf (mon," Cannot access memory\n" );break ; }
target-arm/arm-semi.c +1 -1
@@ -161,7 +161,7 @@ static void arm_semi_flen_cb(CPUState *cs, target_ulong ret, target_ulong err)/* The size is always stored in big-endian order, extract the value. We assume the size always fit in 32 bits. */ uint32_t size; -cpu_memory_rw_debug (env, env->regs[13 ]-64 +32 , (uint8_t *)&size,4 ,0 ); +cpu_memory_rw_debug (cs, env->regs[13 ]-64 +32 , (uint8_t *)&size,4 ,0 ); env->regs[0 ] =be32_to_cpu (size);#ifdef CONFIG_USER_ONLY ((TaskState *)env->opaque)->swi_errno = err;
target-i386/helper.c +5 -3
@@ -363,7 +363,7 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,cpu_fprintf (f,"Code=" );for (i =0 ; i <DUMP_CODE_BYTES_TOTAL ; i++) { -if (cpu_memory_rw_debug (env, base - offs + i, &code,1 ,0 ) ==0 ) { +if (cpu_memory_rw_debug (cs, base - offs + i, &code,1 ,0 ) ==0 ) {snprintf (codestr,sizeof (codestr),"%02x" , code); }else {snprintf (codestr,sizeof (codestr),"??" );
@@ -1260,6 +1260,8 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, target_ulong *base, unsigned int *limit, unsigned int *flags) { + X86CPU *cpu = x86_env_get_cpu(env); +CPUState *cs =CPU (cpu);SegmentCache *dt;target_ulong ptr;uint32_t e1, e2;
@@ -1272,8 +1274,8 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, index = selector & ~7 ; ptr = dt->base + index;if ((index +7 ) > dt->limit - ||cpu_memory_rw_debug (env, ptr, (uint8_t *)&e1,sizeof (e1),0 ) !=0 - ||cpu_memory_rw_debug (env, ptr+4 , (uint8_t *)&e2,sizeof (e2),0 ) !=0 ) + ||cpu_memory_rw_debug (cs, ptr, (uint8_t *)&e1,sizeof (e1),0 ) !=0 + ||cpu_memory_rw_debug (cs, ptr+4 , (uint8_t *)&e2,sizeof (e2),0 ) !=0 )return 0 ; *base = ((e1 >>16 ) | ((e2 &0xff ) <<16 ) | (e2 &0xff000000 ));
target-i386/kvm.c +6 -8
@@ -1932,25 +1932,23 @@ static int kvm_handle_tpr_access(X86CPU *cpu)return 1 ; } -int kvm_arch_insert_sw_breakpoint (CPUState *cpu,struct kvm_sw_breakpoint *bp) +int kvm_arch_insert_sw_breakpoint (CPUState *cs,struct kvm_sw_breakpoint *bp) { -CPUX86State *env = &X86_CPU (cpu)->env;static const uint8_t int3 =0xcc ; -if (cpu_memory_rw_debug (env, bp->pc, (uint8_t *)&bp->saved_insn,1 ,0 ) || -cpu_memory_rw_debug (env, bp->pc, (uint8_t *)&int3,1 ,1 )) { +if (cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,1 ,0 ) || +cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&int3,1 ,1 )) {return -EINVAL ; }return 0 ; } -int kvm_arch_remove_sw_breakpoint (CPUState *cpu,struct kvm_sw_breakpoint *bp) +int kvm_arch_remove_sw_breakpoint (CPUState *cs,struct kvm_sw_breakpoint *bp) { -CPUX86State *env = &X86_CPU (cpu)->env;uint8_t int3; -if (cpu_memory_rw_debug (env, bp->pc, &int3,1 ,0 ) || int3 !=0xcc || -cpu_memory_rw_debug (env, bp->pc, (uint8_t *)&bp->saved_insn,1 ,1 )) { +if (cpu_memory_rw_debug (cs, bp->pc, &int3,1 ,0 ) || int3 !=0xcc || +cpu_memory_rw_debug (cs, bp->pc, (uint8_t *)&bp->saved_insn,1 ,1 )) {return -EINVAL ; }return 0 ;
target-sparc/mmu_helper.c +3 -2
@@ -356,6 +356,7 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUSPARCState *env)int target_memory_rw_debug (CPUSPARCState *env,target_ulong addr,uint8_t *buf,int len,int is_write) { +CPUState *cs =CPU (sparc_env_get_cpu (env));int i;int len1;int cwp = env->cwp;
@@ -390,7 +391,7 @@ int target_memory_rw_debug(CPUSPARCState *env, target_ulong addr,/* Handle access before this window. */ if (addr < fp) { len1 = fp - addr; -if (cpu_memory_rw_debug (env, addr, buf, len1, is_write) !=0 ) { +if (cpu_memory_rw_debug (cs, addr, buf, len1, is_write) !=0 ) {return -1 ; } addr += len1;
@@ -426,7 +427,7 @@ int target_memory_rw_debug(CPUSPARCState *env, target_ulong addr, } } } -return cpu_memory_rw_debug (env, addr, buf, len, is_write); +return cpu_memory_rw_debug (cs, addr, buf, len, is_write); }#else /* !TARGET_SPARC64 */
target-xtensa/xtensa-semi.c +5 -5
@@ -204,8 +204,8 @@ void HELPER(simcall)(CPUXtensaState *env)int i;for (i =0 ; i <ARRAY_SIZE (name); ++i) { - rc =cpu_memory_rw_debug ( - env, regs[3 ] + i, (uint8_t *)name + i,1 ,0 ); + rc =cpu_memory_rw_debug (cs, regs[3 ] + i, + (uint8_t *)name + i,1 ,0 );if (rc !=0 || name[i] ==0 ) {break ; }
@@ -249,7 +249,7 @@ void HELPER(simcall)(CPUXtensaState *env)FD_SET (fd, &fdset);if (target_tv) { -cpu_memory_rw_debug (env, target_tv, +cpu_memory_rw_debug (cs, target_tv, (uint8_t *)target_tvv,sizeof (target_tvv),0 ); tv.tv_sec = (int32_t )tswap32 (target_tvv[0 ]); tv.tv_usec = (int32_t )tswap32 (target_tvv[1 ]);
@@ -284,8 +284,8 @@ void HELPER(simcall)(CPUXtensaState *env) }; argv.argptr[0 ] =tswap32 (regs[3 ] + offsetof(struct Argv , text)); -cpu_memory_rw_debug ( - env, regs[3 ], (uint8_t *)&argv,sizeof (argv),1 ); +cpu_memory_rw_debug (cs, + regs[3 ], (uint8_t *)&argv,sizeof (argv),1 ); }break ;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 15/24] gdbstub: Change syscall callback argument to CPUState
In reply to Andreas FärberCallback implementations were specific to arm and m68k, so can easily cast to ARMCPU and M68kCPU respectively.
Prepares for changing GDBState::c_cpu to CPUState.
--- gdbstub.c | 2 +- include/exec/gdbstub.h | 2 +- target-arm/arm-semi.c | 8 ++++++-- target-m68k/m68k-semi.c | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-)
gdbstub.c +1 -1
@@ -2205,7 +2205,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) p++; type = *p;if (s->current_syscall_cb) { - s->current_syscall_cb (s->c_cpu, ret, err); + s->current_syscall_cb (ENV_GET_CPU (s->c_cpu), ret, err); s->current_syscall_cb =NULL ; }if (type =='C' ) {
include/exec/gdbstub.h +1 -1
@@ -11,7 +11,7 @@#define GDB_WATCHPOINT_ACCESS 4#ifdef NEED_CPU_H -typedef void (*gdb_syscall_complete_cb )(CPUArchState *env, +typedef void (*gdb_syscall_complete_cb )(CPUState *cpu,target_ulong ret,target_ulong err);void gdb_do_syscall (gdb_syscall_complete_cb cb,const char *fmt, ...);
target-arm/arm-semi.c +6 -2
@@ -122,8 +122,10 @@ static target_ulong arm_semi_syscall_len;static target_ulong syscall_err;#endif -static void arm_semi_cb (CPUARMState *env,target_ulong ret,target_ulong err) +static void arm_semi_cb (CPUState *cs,target_ulong ret,target_ulong err) { +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env;#ifdef CONFIG_USER_ONLY TaskState *ts = env->opaque;#endif
@@ -152,8 +154,10 @@ static void arm_semi_cb(CPUARMState *env, target_ulong ret, target_ulong err) } } -static void arm_semi_flen_cb (CPUARMState *env,target_ulong ret,target_ulong err) +static void arm_semi_flen_cb (CPUState *cs,target_ulong ret,target_ulong err) { +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env;/* The size is always stored in big-endian order, extract the value. We assume the size always fit in 32 bits. */ uint32_t size;
target-m68k/m68k-semi.c +4 -1
@@ -161,8 +161,11 @@ static void m68k_semi_return_u64(CPUM68KState *env, uint64_t ret, uint32_t err)static int m68k_semi_is_fseek; -static void m68k_semi_cb (CPUM68KState *env,target_ulong ret,target_ulong err) +static void m68k_semi_cb (CPUState *cs,target_ulong ret,target_ulong err) { +M68kCPU *cpu =M68K_CPU (cs); +CPUM68KState *env = &cpu->env; +if (m68k_semi_is_fseek) {/* FIXME: We've already lost the high bits of the fseek return value. */
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 17/24] gdbstub: Change gdb_{read, write}_register() argument to CPUState
In reply to Andreas FärberUse CPUState::env_ptr for now.
Prepares for changing GDBState::g_cpu to CPUState.
--- gdbstub.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
gdbstub.c +10 -6
@@ -1866,8 +1866,9 @@ static const char *get_feature_xml(const char *p, const char **newp) }#endif -static int gdb_read_register (CPUArchState *env,uint8_t *mem_buf,int reg) +static int gdb_read_register (CPUState *cpu,uint8_t *mem_buf,int reg) { +CPUArchState *env = cpu->env_ptr;GDBRegisterState *r;if (reg <NUM_CORE_REGS )
@@ -1881,8 +1882,9 @@ static int gdb_read_register(CPUArchState *env, uint8_t *mem_buf, int reg)return 0 ; } -static int gdb_write_register (CPUArchState *env,uint8_t *mem_buf,int reg) +static int gdb_write_register (CPUState *cpu,uint8_t *mem_buf,int reg) { +CPUArchState *env = cpu->env_ptr;GDBRegisterState *r;if (reg <NUM_CORE_REGS )
@@ -2220,7 +2222,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) env = s->g_cpu; len =0 ;for (addr =0 ; addr < num_g_regs; addr++) { - reg_size =gdb_read_register (s->g_cpu, mem_buf + len, addr); + reg_size =gdb_read_register (ENV_GET_CPU (s->g_cpu), + mem_buf + len, addr); len += reg_size; }memtohex (buf, mem_buf, len);
@@ -2233,7 +2236,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) len =strlen (p) /2 ;hextomem ((uint8_t *)registers, p, len);for (addr =0 ; addr < num_g_regs && len >0 ; addr++) { - reg_size =gdb_write_register (s->g_cpu, registers, addr); + reg_size =gdb_write_register (ENV_GET_CPU (s->g_cpu), registers, + addr); len -= reg_size; registers += reg_size; }
@@ -2272,7 +2276,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)if (!gdb_has_xml) goto unknown_command; addr =strtoull (p, (char **)&p,16 ); - reg_size =gdb_read_register (s->g_cpu, mem_buf, addr); + reg_size =gdb_read_register (ENV_GET_CPU (s->g_cpu), mem_buf, addr);if (reg_size) {memtohex (buf, mem_buf, reg_size);put_packet (s, buf);
@@ -2288,7 +2292,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) p++; reg_size =strlen (p) /2 ;hextomem (mem_buf, p, reg_size); -gdb_write_register (s->g_cpu, mem_buf, addr); +gdb_write_register (ENV_GET_CPU (s->g_cpu), mem_buf, addr);put_packet (s,"OK" );break ;case 'Z' :
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 16/24] gdbstub: Change gdb_handlesig() argument to CPUState
In reply to Andreas FärberPrepares for changing GDBState::c_cpu to CPUState.
--- bsd-user/main.c | 10 ++++++---- gdbstub.c | 6 +++--- include/exec/gdbstub.h | 2 +- linux-user/main.c | 35 +++++++++++++++++++---------------- linux-user/signal.c | 3 ++- 5 files changed, 31 insertions(+), 25 deletions(-)
bsd-user/main.c +6 -4
@@ -643,7 +643,7 @@ void cpu_loop(CPUSPARCState *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );#if 0 if (sig) {
@@ -738,6 +738,7 @@ int main(int argc, char **argv)struct image_info info1, *info = &info1;TaskState ts1, *ts = &ts1;CPUArchState *env; +CPUState *cpu;int optind;const char *r;int gdbstub_port =0 ;
@@ -912,10 +913,11 @@ int main(int argc, char **argv)fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } + cpu =ENV_GET_CPU (env);#if defined(TARGET_SPARC ) || defined(TARGET_PPC ) -cpu_reset (ENV_GET_CPU (env)); +cpu_reset (cpu);#endif - thread_cpu =ENV_GET_CPU (env); + thread_cpu = cpu;if (getenv ("QEMU_STRACE" )) { do_strace =1 ;
@@ -1134,7 +1136,7 @@ int main(int argc, char **argv)if (gdbstub_port) {gdbserver_start (gdbstub_port); -gdb_handlesig (env,0 ); +gdb_handlesig (cpu,0 ); }cpu_loop (env);/* never exits */
gdbstub.c +3 -3
@@ -2636,7 +2636,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)va_end (va);#ifdef CONFIG_USER_ONLY put_packet (s, s->syscall_buf); -gdb_handlesig (s->c_cpu,0 ); +gdb_handlesig (ENV_GET_CPU (s->c_cpu),0 );#else /* In this case wait to send the syscall packet until notification that the CPU has stopped. This must be done because if the packet is sent
@@ -2765,9 +2765,9 @@ gdb_queuesig (void) }int -gdb_handlesig (CPUArchState *env,int sig) +gdb_handlesig (CPUState *cpu,int sig) { -CPUState *cpu =ENV_GET_CPU (env); +CPUArchState *env = cpu->env_ptr;GDBState *s;char buf[256 ];int n;
include/exec/gdbstub.h +1 -1
@@ -20,7 +20,7 @@ void gdb_set_stop_cpu(CPUState *cpu);void gdb_exit (CPUArchState *,int );#ifdef CONFIG_USER_ONLY int gdb_queuesig (void ); -int gdb_handlesig (CPUArchState *,int ); +int gdb_handlesig (CPUState *,int );void gdb_signalled (CPUArchState *,int );void gdbserver_fork (CPUArchState *);#endif
linux-user/main.c +19 -16
@@ -312,6 +312,7 @@ static void set_idt(int n, unsigned int dpl)void cpu_loop (CPUX86State *env) { +CPUState *cs =CPU (x86_env_get_cpu (env));int trapnr;abi_ulong pc;target_siginfo_t info;
@@ -443,7 +444,7 @@ void cpu_loop(CPUX86State *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig;
@@ -875,7 +876,7 @@ void cpu_loop(CPUARMState *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig;
@@ -966,7 +967,7 @@ void cpu_loop(CPUUniCore32State *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig; info.si_errno =0 ;
@@ -1233,7 +1234,7 @@ void cpu_loop (CPUSPARCState *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig;
@@ -1764,7 +1765,7 @@ void cpu_loop(CPUPPCState *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig; info.si_errno =0 ;
@@ -2315,7 +2316,7 @@ done_syscall: {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig;
@@ -2475,7 +2476,7 @@ void cpu_loop(CPUOpenRISCState *env)break ; }if (gdbsig) { -gdb_handlesig (env, gdbsig); +gdb_handlesig (cs, gdbsig);if (gdbsig !=TARGET_SIGTRAP ) {exit (1 ); }
@@ -2518,7 +2519,7 @@ void cpu_loop(CPUSH4State *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig;
@@ -2586,7 +2587,7 @@ void cpu_loop(CPUCRISState *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig;
@@ -2686,7 +2687,7 @@ void cpu_loop(CPUMBState *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig;
@@ -2779,7 +2780,7 @@ void cpu_loop(CPUM68KState *env) {int sig; - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { info.si_signo = sig;
@@ -3006,7 +3007,7 @@ void cpu_loop(CPUAlphaState *env) }break ;case EXCP_DEBUG : - info.si_signo =gdb_handlesig (env,TARGET_SIGTRAP ); + info.si_signo =gdb_handlesig (cs,TARGET_SIGTRAP );if (info.si_signo) { env->lock_addr =-1 ; info.si_errno =0 ;
@@ -3059,7 +3060,7 @@ void cpu_loop(CPUS390XState *env)break ;case EXCP_DEBUG : - sig =gdb_handlesig (env,TARGET_SIGTRAP ); + sig =gdb_handlesig (cs,TARGET_SIGTRAP );if (sig) { n =TARGET_TRAP_BRKPT ; goto do_signal_pc;
@@ -3541,6 +3542,7 @@ int main(int argc, char **argv, char **envp)struct linux_binprm bprm;TaskState *ts;CPUArchState *env; +CPUState *cpu;int optind;char **target_environ, **wrk;char **target_argv;
@@ -3637,11 +3639,12 @@ int main(int argc, char **argv, char **envp)fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } + cpu =ENV_GET_CPU (env);#if defined(TARGET_SPARC ) || defined(TARGET_PPC ) -cpu_reset (ENV_GET_CPU (env)); +cpu_reset (cpu);#endif - thread_cpu =ENV_GET_CPU (env); + thread_cpu = cpu;if (getenv ("QEMU_STRACE" )) { do_strace =1 ;
@@ -4076,7 +4079,7 @@ int main(int argc, char **argv, char **envp) gdbstub_port);exit (1 ); } -gdb_handlesig (env,0 ); +gdb_handlesig (cpu,0 ); }cpu_loop (env);/* never exits */
linux-user/signal.c +2 -1
@@ -5386,6 +5386,7 @@ long do_rt_sigreturn(CPUArchState *env)void process_pending_signals (CPUArchState *cpu_env) { +CPUState *cpu =ENV_GET_CPU (cpu_env);int sig;abi_ulong handler;sigset_t set, old_set;
@@ -5419,7 +5420,7 @@ void process_pending_signals(CPUArchState *cpu_env)if (!k->first) k->pending =0 ; - sig =gdb_handlesig (cpu_env, sig); + sig =gdb_handlesig (cpu, sig);if (!sig) { sa =NULL ; handler =TARGET_SIG_IGN ;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 20/24] cpu: Introduce CPUClass::memory_rw_debug() for target_memory_rw_debug()
In reply to Andreas FärberMake inline target_memory_rw_debug() always available and change its argument to CPUState. Let it check if CPUClass::memory_rw_debug provides a specialized callback and fall back to cpu_memory_rw_debug() otherwise.
The only overriding implementation is for 32-bit sparc.
This prepares for changing GDBState::g_cpu to CPUState.
--- gdbstub.c | 21 ++++++++++++--------- include/qom/cpu.h | 3 +++ target-sparc/cpu.c | 3 +++ target-sparc/cpu.h | 5 ++--- target-sparc/mmu_helper.c | 8 +++++--- 5 files changed, 25 insertions(+), 15 deletions(-)
gdbstub.c +12 -9
@@ -42,15 +42,16 @@#include "sysemu/kvm.h" #include "qemu/bitops.h" -#ifndef TARGET_CPU_MEMORY_RW_DEBUG -static inline int target_memory_rw_debug (CPUArchState *env,target_ulong addr, -uint8_t *buf,int len,int is_write) +static inline int target_memory_rw_debug (CPUState *cpu,target_ulong addr, +uint8_t *buf,int len,bool is_write) { -return cpu_memory_rw_debug (ENV_GET_CPU (env), addr, buf, len, is_write); +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (cc->memory_rw_debug) { +return cc->memory_rw_debug (cpu, addr, buf, len, is_write); + } +return cpu_memory_rw_debug (cpu, addr, buf, len, is_write); } -#else -/* target_memory_rw_debug() defined in cpu.h */ -#endif enum {GDB_SIGNAL_0 =0 ,
@@ -2248,7 +2249,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)if (*p ==',' ) p++; len =strtoull (p,NULL ,16 ); -if (target_memory_rw_debug (s->g_cpu, addr, mem_buf, len,0 ) !=0 ) { +if (target_memory_rw_debug (ENV_GET_CPU (s->g_cpu), addr, mem_buf, len, + false) !=0 ) {put_packet (s,"E14" ); }else {memtohex (buf, mem_buf, len);
@@ -2263,7 +2265,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)if (*p ==':' ) p++;hextomem (mem_buf, p, len); -if (target_memory_rw_debug (s->g_cpu, addr, mem_buf, len,1 ) !=0 ) { +if (target_memory_rw_debug (ENV_GET_CPU (s->g_cpu), addr, mem_buf, len, + true) !=0 ) {put_packet (s,"E14" ); }else {put_packet (s,"OK" );
include/qom/cpu.h +3 -0
@@ -70,6 +70,7 @@ struct TranslationBlock;* @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @do_interrupt: Callback for interrupt handling. * @do_unassigned_access: Callback for unassigned access handling. +* @memory_rw_debug: Callback for GDB memory access. * @dump_state: Callback for dumping state. * @dump_statistics: Callback for dumping statistics. * @get_arch_id: Callback for getting architecture-dependent CPU ID.
@@ -94,6 +95,8 @@ typedef struct CPUClass {int reset_dump_flags;void (*do_interrupt)(CPUState *cpu);CPUUnassignedAccess do_unassigned_access; +int (*memory_rw_debug)(CPUState *cpu,vaddr addr, +uint8_t *buf,int len,bool is_write);void (*dump_state)(CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); void (*dump_statistics)(CPUState *cpu, FILE *f,
target-sparc/cpu.c +3 -0
@@ -782,6 +782,9 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = sparc_cpu_do_interrupt; cc->dump_state = sparc_cpu_dump_state; +#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) + cc->memory_rw_debug = sparc_cpu_memory_rw_debug; +#endif cc->set_pc = sparc_cpu_set_pc; cc->synchronize_from_tb = sparc_cpu_synchronize_from_tb;#ifndef CONFIG_USER_ONLY
target-sparc/cpu.h +2 -3
@@ -526,9 +526,8 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev);void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUSPARCState *env);#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY ) -int target_memory_rw_debug (CPUSPARCState *env,target_ulong addr, -uint8_t *buf,int len,int is_write); -#define TARGET_CPU_MEMORY_RW_DEBUG +int sparc_cpu_memory_rw_debug (CPUState *cpu,vaddr addr, +uint8_t *buf,int len,bool is_write);#endif
target-sparc/mmu_helper.c +5 -3
@@ -353,10 +353,12 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUSPARCState *env)* reads (and only reads) in stack frames as if windows were flushed. We assume * that the sparc ABI is followed. */ -int target_memory_rw_debug (CPUSPARCState *env,target_ulong addr, -uint8_t *buf,int len,int is_write) +int sparc_cpu_memory_rw_debug (CPUState *cs,vaddr address, +uint8_t *buf,int len,bool is_write) { -CPUState *cs =CPU (sparc_env_get_cpu (env)); +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; +target_ulong addr = address;int i;int len1;int cwp = env->cwp;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 22/24] cpu: Move gdb_regs field from CPU_COMMON to CPUState
In reply to Andreas FärberPrepares for changing gdb_register_coprocessor() argument to CPUState.
--- gdbstub.c | 11 ++++++----- include/exec/cpu-defs.h | 2 -- include/qom/cpu.h | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-)
gdbstub.c +6 -5
@@ -1840,7 +1840,7 @@ static const char *get_feature_xml(const char *p, const char **newp)/* Generate the XML description for this CPU. */ if (!target_xml[0 ]) {GDBRegisterState *r; -CPUArchState *env = first_cpu->env_ptr; +CPUState *cpu = first_cpu;snprintf (target_xml,sizeof (target_xml), "<?xml version=\"1.0\"?>"
@@ -1849,7 +1849,7 @@ static const char *get_feature_xml(const char *p, const char **newp)"<xi:include href=\"%s\"/>" , GDB_CORE_XML); -for (r = env->gdb_regs; r; r = r->next) { +for (r = cpu->gdb_regs; r; r = r->next) {pstrcat (target_xml,sizeof (target_xml),"<xi:include href=\"" );pstrcat (target_xml,sizeof (target_xml), r->xml);pstrcat (target_xml,sizeof (target_xml),"\"/>" );
@@ -1875,7 +1875,7 @@ static int gdb_read_register(CPUState *cpu, uint8_t *mem_buf, int reg)if (reg <NUM_CORE_REGS )return cpu_gdb_read_register (env, mem_buf, reg); -for (r = env->gdb_regs; r; r = r->next) { +for (r = cpu->gdb_regs; r; r = r->next) {if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {return r->get_reg (env, mem_buf, reg - r->base_reg); }
@@ -1891,7 +1891,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg)if (reg <NUM_CORE_REGS )return cpu_gdb_write_register (env, mem_buf, reg); -for (r = env->gdb_regs; r; r = r->next) { +for (r = cpu->gdb_regs; r; r = r->next) {if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {return r->set_reg (env, mem_buf, reg - r->base_reg); }
@@ -1910,11 +1910,12 @@ void gdb_register_coprocessor(CPUArchState * env, gdb_reg_cb get_reg, gdb_reg_cb set_reg, int num_regs, const char *xml, int g_pos) { + CPUState *cpu = ENV_GET_CPU(env);GDBRegisterState *s;GDBRegisterState **p;static int last_reg =NUM_CORE_REGS ; - p = &env->gdb_regs; + p = &cpu->gdb_regs;while (*p) {/* Check for duplicates. */ if (strcmp ((*p)->xml, xml) ==0 )
include/exec/cpu-defs.h +0 -2
@@ -174,8 +174,6 @@ typedef struct CPUWatchpoint { QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \CPUWatchpoint *watchpoint_hit; \ \ -struct GDBRegisterState *gdb_regs; \ - \/* Core interrupt code */ \sigjmp_buf jmp_env; \int exception_index; \
include/qom/cpu.h +2 -0
@@ -141,6 +141,7 @@ struct kvm_run;* @singlestep_enabled: Flags for single-stepping. * @env_ptr: Pointer to subclass-specific CPUArchState field. * @current_tb: Currently executing TB. +* @gdb_regs: Additional GDB registers. * @next_cpu: Next CPU sharing TB cache. * @kvm_fd: vCPU file descriptor for KVM. *
@@ -175,6 +176,7 @@ struct CPUState {void *env_ptr;/* CPUArchState */ struct TranslationBlock *current_tb; +struct GDBRegisterState *gdb_regs;CPUState *next_cpu;int kvm_fd;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 24/24] linux-user: Use X86CPU property to retrieve CPUID family
In reply to Andreas FärberAvoids duplicating the calculation.
--- linux-user/cpu-uname.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
linux-user/cpu-uname.c +6 -4
@@ -55,12 +55,14 @@ const char *cpu_to_uname_machine(void *cpu_env)return "x86-64" ;#elif defined(TARGET_I386 )/* see arch/x86/kernel/cpu/bugs.c: check_bugs(), 386, 486, 586, 686 */ -uint32_t cpuid_version = ((CPUX86State *)cpu_env)->cpuid_version; -int family = ((cpuid_version >>8 ) &0x0f ) + ((cpuid_version >>20 ) &0xff ); -if (family ==4 ) +CPUState *cpu =ENV_GET_CPU ((CPUX86State *)cpu_env); +int family =object_property_get_int (OBJECT (cpu),"family" ,NULL ); +if (family ==4 ) {return "i486" ; -if (family ==5 ) + } +if (family ==5 ) {return "i586" ; + }return "i686" ;#else /* default is #define-d in each arch/ subdir */
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 23/24] gdbstub: Change gdb_register_coprocessor() argument to CPUState
In reply to Andreas Färber--- gdbstub.c | 7 +++---- include/exec/gdbstub.h | 2 +- target-arm/helper.c | 7 ++++--- target-m68k/helper.c | 3 ++- target-ppc/translate_init.c | 15 ++++++++------- 5 files changed, 18 insertions(+), 16 deletions(-)
gdbstub.c +3 -4
@@ -1906,11 +1906,10 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg)gdb reading a CPU register, and set_reg is gdb modifying a CPU register. */ -void gdb_register_coprocessor (CPUArchState * env, -gdb_reg_cb get_reg,gdb_reg_cb set_reg, -int num_regs,const char *xml,int g_pos) +void gdb_register_coprocessor (CPUState *cpu, +gdb_reg_cb get_reg,gdb_reg_cb set_reg, +int num_regs,const char *xml,int g_pos) { -CPUState *cpu =ENV_GET_CPU (env);GDBRegisterState *s;GDBRegisterState **p;static int last_reg =NUM_CORE_REGS ;
include/exec/gdbstub.h +1 -1
@@ -26,7 +26,7 @@ void gdbserver_fork(CPUArchState *);#endif /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_reg_cb )(CPUArchState *env,uint8_t *buf,int reg); -void gdb_register_coprocessor (CPUArchState *env, +void gdb_register_coprocessor (CPUState *cpu,gdb_reg_cb get_reg,gdb_reg_cb set_reg,int num_regs,const char *xml,int g_pos);
target-arm/helper.c +4 -3
@@ -1513,16 +1513,17 @@ ARMCPU *cpu_arm_init(const char *cpu_model)void arm_cpu_register_gdb_regs_for_features (ARMCPU *cpu) { +CPUState *cs =CPU (cpu);CPUARMState *env = &cpu->env;if (arm_feature (env,ARM_FEATURE_NEON )) { -gdb_register_coprocessor (env, vfp_gdb_get_reg, vfp_gdb_set_reg, +gdb_register_coprocessor (cs, vfp_gdb_get_reg, vfp_gdb_set_reg,51 ,"arm-neon.xml" ,0 ); }else if (arm_feature (env,ARM_FEATURE_VFP3 )) { -gdb_register_coprocessor (env, vfp_gdb_get_reg, vfp_gdb_set_reg, +gdb_register_coprocessor (cs, vfp_gdb_get_reg, vfp_gdb_set_reg,35 ,"arm-vfp3.xml" ,0 ); }else if (arm_feature (env,ARM_FEATURE_VFP )) { -gdb_register_coprocessor (env, vfp_gdb_get_reg, vfp_gdb_set_reg, +gdb_register_coprocessor (cs, vfp_gdb_get_reg, vfp_gdb_set_reg,19 ,"arm-vfp.xml" ,0 ); } }
target-m68k/helper.c +2 -1
@@ -121,10 +121,11 @@ M68kCPU *cpu_m68k_init(const char *cpu_model)void m68k_cpu_init_gdb (M68kCPU *cpu) { +CPUState *cs =CPU (cpu);CPUM68KState *env = &cpu->env;if (m68k_feature (env,M68K_FEATURE_CF_FPU )) { -gdb_register_coprocessor (env, fpu_gdb_get_reg, fpu_gdb_set_reg, +gdb_register_coprocessor (cs, fpu_gdb_get_reg, fpu_gdb_set_reg,11 ,"cf-fp.xml" ,18 ); }/* TODO: Add [E]MAC registers. */
target-ppc/translate_init.c +8 -7
@@ -7804,8 +7804,8 @@ static int ppc_fixup_cpu(PowerPCCPU *cpu)static void ppc_cpu_realizefn (DeviceState *dev,Error **errp) { +CPUState *cs =CPU (dev);PowerPCCPU *cpu =POWERPC_CPU (dev); -CPUPPCState *env = &cpu->env;PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu);Error *local_err =NULL ;#if !defined(CONFIG_USER_ONLY )
@@ -7849,15 +7849,15 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)init_ppc_proc (cpu);if (pcc->insns_flags &PPC_FLOAT ) { -gdb_register_coprocessor (env, gdb_get_float_reg, gdb_set_float_reg, +gdb_register_coprocessor (cs, gdb_get_float_reg, gdb_set_float_reg,33 ,"power-fpu.xml" ,0 ); }if (pcc->insns_flags &PPC_ALTIVEC ) { -gdb_register_coprocessor (env, gdb_get_avr_reg, gdb_set_avr_reg, +gdb_register_coprocessor (cs, gdb_get_avr_reg, gdb_set_avr_reg,34 ,"power-altivec.xml" ,0 ); }if (pcc->insns_flags &PPC_SPE ) { -gdb_register_coprocessor (env, gdb_get_spe_reg, gdb_set_spe_reg, +gdb_register_coprocessor (cs, gdb_get_spe_reg, gdb_set_spe_reg,34 ,"power-spe.xml" ,0 ); }
@@ -7865,6 +7865,7 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)#if defined(PPC_DUMP_CPU ) { +CPUPPCState *env = &cpu->env;const char *mmu_model, *excp_model, *bus_model;switch (env->mmu_model) {case POWERPC_MMU_32B :
@@ -8016,10 +8017,10 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)printf (" none\n" );printf (" Time-base/decrementer clock source: %s\n" , env->flags &POWERPC_FLAG_RTC_CLK ?"RTC clock" :"bus clock" ); +dump_ppc_insns (env); +dump_ppc_sprs (env); + fflush(stdout); } -dump_ppc_insns (env); -dump_ppc_sprs (env); -fflush (stdout);#endif }
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 21/24] gdbstub: Change GDBState::{c, g}_cpu and find_cpu() to CPUState
In reply to Andreas FärberUse CPUState::env_ptr where still needed.
--- gdbstub.c | 104 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 52 insertions(+), 52 deletions(-)
gdbstub.c +52 -52
@@ -288,8 +288,8 @@ enum RSState { RS_CHKSUM2, }; typedef struct GDBState { - CPUArchState *c_cpu; /* current CPU for step/continue ops */ - CPUArchState *g_cpu; /* current CPU for other ops */ + CPUState *c_cpu; /* current CPU for step/continue ops */ + CPUState *g_cpu; /* current CPU for other ops */ CPUState *query_cpu; /* for q{f|s}ThreadInfo */ enum RSState state; /* parsing state */ char line_buf[MAX_PACKET_LENGTH];
@@ -1958,8 +1958,7 @@ static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type)int err =0 ;if (kvm_enabled ()) { -return kvm_insert_breakpoint (ENV_GET_CPU (gdbserver_state->c_cpu), - addr, len, type); +return kvm_insert_breakpoint (gdbserver_state->c_cpu, addr, len, type); }switch (type) {
@@ -1997,8 +1996,7 @@ static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type)int err =0 ;if (kvm_enabled ()) { -return kvm_remove_breakpoint (ENV_GET_CPU (gdbserver_state->c_cpu), - addr, len, type); +return kvm_remove_breakpoint (gdbserver_state->c_cpu, addr, len, type); }switch (type) {
@@ -2034,7 +2032,7 @@ static void gdb_breakpoint_remove_all(void)CPUArchState *env;if (kvm_enabled ()) { -kvm_remove_all_breakpoints (ENV_GET_CPU (gdbserver_state->c_cpu)); +kvm_remove_all_breakpoints (gdbserver_state->c_cpu);return ; }
@@ -2049,7 +2047,7 @@ static void gdb_breakpoint_remove_all(void)static void gdb_set_cpu_pc (GDBState *s,target_ulong pc) { -CPUState *cpu =ENV_GET_CPU (s->c_cpu); +CPUState *cpu = s->c_cpu;CPUClass *cc =CPU_GET_CLASS (cpu);cpu_synchronize_state (cpu);
@@ -2058,13 +2056,13 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) } } -static CPUArchState *find_cpu (uint32_t thread_id) +static CPUState *find_cpu (uint32_t thread_id) {CPUState *cpu;for (cpu = first_cpu; cpu !=NULL ; cpu = cpu->next_cpu) {if (cpu_index (cpu) == thread_id) { -return cpu->env_ptr; +return cpu; } }
@@ -2073,7 +2071,10 @@ static CPUArchState *find_cpu(uint32_t thread_id)static int gdb_handle_packet (GDBState *s,const char *line_buf) { +#ifdef TARGET_XTENSA CPUArchState *env; +#endif +CPUState *cpu;const char *p;uint32_t thread;int ch, reg_size, type, res;
@@ -2091,7 +2092,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)case '?' :/* TODO: Make this return the correct value for user-mode. */ snprintf (buf,sizeof (buf),"T%02xthread:%02x;" ,GDB_SIGNAL_TRAP , -cpu_index (ENV_GET_CPU (s->c_cpu))); +cpu_index (s->c_cpu));put_packet (s, buf);/* Remove all the breakpoints when this query is issued, * because gdb is doing and initial connect and the state
@@ -2153,15 +2154,15 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) }if (res) {if (res_thread !=-1 && res_thread !=0 ) { - env =find_cpu (res_thread); -if (env ==NULL ) { + cpu =find_cpu (res_thread); +if (cpu ==NULL ) {put_packet (s,"E22" );break ; } - s->c_cpu = env; + s->c_cpu = cpu; }if (res =='s' ) { -cpu_single_step (ENV_GET_CPU (s->c_cpu), sstep_flags); +cpu_single_step (s->c_cpu, sstep_flags); } s->signal = res_signal;gdb_continue (s);
@@ -2189,7 +2190,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) addr =strtoull (p, (char **)&p,16 );gdb_set_cpu_pc (s, addr); } -cpu_single_step (ENV_GET_CPU (s->c_cpu), sstep_flags); +cpu_single_step (s->c_cpu, sstep_flags);gdb_continue (s);return RS_IDLE ;case 'F' :
@@ -2208,7 +2209,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) p++; type = *p;if (s->current_syscall_cb) { - s->current_syscall_cb (ENV_GET_CPU (s->c_cpu), ret, err); + s->current_syscall_cb (s->c_cpu, ret, err); s->current_syscall_cb =NULL ; }if (type =='C' ) {
@@ -2219,26 +2220,28 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) }break ;case 'g' : -cpu_synchronize_state (ENV_GET_CPU (s->g_cpu)); - env = s->g_cpu; +cpu_synchronize_state (s->g_cpu); +#ifdef TARGET_XTENSA + env = s->g_cpu->env_ptr; +#endif len =0 ;for (addr =0 ; addr < num_g_regs; addr++) { - reg_size =gdb_read_register (ENV_GET_CPU (s->g_cpu), - mem_buf + len, addr); + reg_size =gdb_read_register (s->g_cpu, mem_buf + len, addr); len += reg_size; }memtohex (buf, mem_buf, len);put_packet (s, buf);break ;case 'G' : -cpu_synchronize_state (ENV_GET_CPU (s->g_cpu)); - env = s->g_cpu; +cpu_synchronize_state (s->g_cpu); +#ifdef TARGET_XTENSA + env = s->g_cpu->env_ptr; +#endif registers = mem_buf; len =strlen (p) /2 ;hextomem ((uint8_t *)registers, p, len);for (addr =0 ; addr < num_g_regs && len >0 ; addr++) { - reg_size =gdb_write_register (ENV_GET_CPU (s->g_cpu), registers, - addr); + reg_size =gdb_write_register (s->g_cpu, registers, addr); len -= reg_size; registers += reg_size; }
@@ -2249,8 +2252,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)if (*p ==',' ) p++; len =strtoull (p,NULL ,16 ); -if (target_memory_rw_debug (ENV_GET_CPU (s->g_cpu), addr, mem_buf, len, - false) !=0 ) { +if (target_memory_rw_debug (s->g_cpu, addr, mem_buf, len, false) !=0 ) {put_packet (s,"E14" ); }else {memtohex (buf, mem_buf, len);
@@ -2265,7 +2267,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)if (*p ==':' ) p++;hextomem (mem_buf, p, len); -if (target_memory_rw_debug (ENV_GET_CPU (s->g_cpu), addr, mem_buf, len, +if (target_memory_rw_debug (s->g_cpu, addr, mem_buf, len, true) !=0 ) {put_packet (s,"E14" ); }else {
@@ -2279,7 +2281,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)if (!gdb_has_xml) goto unknown_command; addr =strtoull (p, (char **)&p,16 ); - reg_size =gdb_read_register (ENV_GET_CPU (s->g_cpu), mem_buf, addr); + reg_size =gdb_read_register (s->g_cpu, mem_buf, addr);if (reg_size) {memtohex (buf, mem_buf, reg_size);put_packet (s, buf);
@@ -2295,7 +2297,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) p++; reg_size =strlen (p) /2 ;hextomem (mem_buf, p, reg_size); -gdb_write_register (ENV_GET_CPU (s->g_cpu), mem_buf, addr); +gdb_write_register (s->g_cpu, mem_buf, addr);put_packet (s,"OK" );break ;case 'Z' :
@@ -2325,18 +2327,18 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)put_packet (s,"OK" );break ; } - env =find_cpu (thread); -if (env ==NULL ) { + cpu =find_cpu (thread); +if (cpu ==NULL ) {put_packet (s,"E22" );break ; }switch (type) {case 'c' : - s->c_cpu = env; + s->c_cpu = cpu;put_packet (s,"OK" );break ;case 'g' : - s->g_cpu = env; + s->g_cpu = cpu;put_packet (s,"OK" );break ;default :
@@ -2346,9 +2348,9 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)break ;case 'T' : thread =strtoull (p, (char **)&p,16 ); - env =find_cpu (thread); + cpu =find_cpu (thread); -if (env !=NULL ) { +if (cpu !=NULL ) {put_packet (s,"OK" ); }else {put_packet (s,"E22" );
@@ -2398,9 +2400,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)break ; }else if (strncmp (p,"ThreadExtraInfo," ,16 ) ==0 ) { thread =strtoull (p+16 , (char **)&p,16 ); - env =find_cpu (thread); -if (env !=NULL ) { -CPUState *cpu =ENV_GET_CPU (env); + cpu =find_cpu (thread); +if (cpu !=NULL ) {cpu_synchronize_state (cpu); len = snprintf((char *)mem_buf, sizeof(mem_buf), "CPU#%d [%s]", cpu->cpu_index,
@@ -2412,7 +2413,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } #ifdef CONFIG_USER_ONLY else if (strncmp(p, "Offsets", 7) == 0) { - TaskState *ts = s->c_cpu->opaque; + CPUArchState *env = s->c_cpu->env_ptr; + TaskState *ts = env->opaque; snprintf(buf, sizeof(buf), "Text=" TARGET_ABI_FMT_lx ";Data=" TARGET_ABI_FMT_lx
@@ -2502,18 +2504,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)void gdb_set_stop_cpu (CPUState *cpu) { -CPUArchState *env = cpu->env_ptr; - - gdbserver_state->c_cpu = env; - gdbserver_state->g_cpu = env; + gdbserver_state->c_cpu = cpu; + gdbserver_state->g_cpu = cpu; }#ifndef CONFIG_USER_ONLY static void gdb_vm_state_change (void *opaque,int running,RunState state) {GDBState *s = gdbserver_state; -CPUArchState *env = s->c_cpu; -CPUState *cpu =ENV_GET_CPU (env); +CPUArchState *env = s->c_cpu->env_ptr; +CPUState *cpu = s->c_cpu;char buf[256 ];const char *type;int ret;
@@ -2643,7 +2643,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)va_end (va);#ifdef CONFIG_USER_ONLY put_packet (s, s->syscall_buf); -gdb_handlesig (ENV_GET_CPU (s->c_cpu),0 ); +gdb_handlesig (s->c_cpu,0 );#else /* In this case wait to send the syscall packet until notification that the CPU has stopped. This must be done because if the packet is sent
@@ -2651,7 +2651,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)is still in the running state, which can cause packets to be dropped and state transition 'T' packets to be sent while the syscall is still being processed. */ -cpu_exit (ENV_GET_CPU (s->c_cpu)); +cpu_exit (s->c_cpu);#endif }
@@ -2860,8 +2860,8 @@ static void gdb_accept(void)socket_set_nodelay (fd); s =g_malloc0 (sizeof (GDBState)); - s->c_cpu = first_cpu->env_ptr; - s->g_cpu = first_cpu->env_ptr; + s->c_cpu = first_cpu; + s->g_cpu = first_cpu; s->fd = fd; gdb_has_xml =0 ;
@@ -3045,8 +3045,8 @@ int gdbserver_start(const char *device) mon_chr = s->mon_chr;memset (s,0 ,sizeof (GDBState)); } - s->c_cpu = first_cpu->env_ptr; - s->g_cpu = first_cpu->env_ptr; + s->c_cpu = first_cpu; + s->g_cpu = first_cpu; s->chr = chr; s->state = chr ?RS_IDLE :RS_INACTIVE ; s->mon_chr = mon_chr;
Signature · 1 line
1.8.1.4
[Qemu-devel] [PULL 18/24] cpu: Turn cpu_get_phys_page_debug() into a CPUClass hook
In reply to Andreas FärberChange breakpoint_invalidate() argument to CPUState alongside.
Since all targets now assign a softmmu-only field, we can drop helpers cpu_class_set_{do_unassigned_access,vmsd}() and device_class_set_vmsd().
Prepares for changing cpu_memory_rw_debug() argument to CPUState.
--- exec.c | 20 ++++++------ hw/i386/kvmvapic.c | 6 ++-- hw/xtensa/xtensa_lx60.c | 8 +++-- hw/xtensa/xtensa_sim.c | 10 +++--- include/exec/cpu-all.h | 5 --- include/qom/cpu.h | 74 +++++++++++++-------------------------------- target-alpha/cpu-qom.h | 1 + target-alpha/cpu.c | 7 +++-- target-alpha/helper.c | 5 +-- target-arm/cpu-qom.h | 2 ++ target-arm/cpu.c | 5 ++- target-arm/helper.c | 8 +++-- target-cris/cpu-qom.h | 2 ++ target-cris/cpu.c | 3 ++ target-cris/helper.c | 7 +++-- target-i386/cpu-qom.h | 2 ++ target-i386/cpu.c | 3 +- target-i386/helper.c | 4 ++- target-lm32/cpu-qom.h | 1 + target-lm32/cpu.c | 5 ++- target-lm32/helper.c | 6 ++-- target-m68k/cpu-qom.h | 1 + target-m68k/cpu.c | 3 ++ target-m68k/helper.c | 2 +- target-microblaze/cpu-qom.h | 1 + target-microblaze/cpu.c | 5 ++- target-microblaze/helper.c | 4 ++- target-mips/cpu-qom.h | 1 + target-mips/cpu.c | 5 ++- target-mips/helper.c | 7 +++-- target-moxie/cpu.c | 5 ++- target-moxie/cpu.h | 1 + target-moxie/helper.c | 11 +++---- target-openrisc/cpu.c | 5 ++- target-openrisc/cpu.h | 1 + target-openrisc/mmu.c | 5 ++- target-ppc/cpu-qom.h | 1 + target-ppc/mmu_helper.c | 4 ++- target-ppc/translate_init.c | 3 ++ target-s390x/cpu-qom.h | 1 + target-s390x/cpu.c | 3 ++ target-s390x/helper.c | 5 +-- target-sh4/cpu-qom.h | 1 + target-sh4/cpu.c | 3 ++ target-sh4/helper.c | 5 +-- target-sparc/cpu-qom.h | 1 + target-sparc/cpu.c | 5 ++- target-sparc/mmu_helper.c | 11 ++++--- target-unicore32/cpu-qom.h | 1 + target-unicore32/cpu.c | 3 ++ target-unicore32/softmmu.c | 7 +++-- target-xtensa/cpu-qom.h | 1 + target-xtensa/cpu.c | 3 ++ target-xtensa/helper.c | 7 +++-- target-xtensa/xtensa-semi.c | 4 +-- 55 files changed, 182 insertions(+), 128 deletions(-)
exec.c +11 -9
@@ -415,14 +415,14 @@ void cpu_exec_init(CPUArchState *env)#if defined(TARGET_HAS_ICE )#if defined(CONFIG_USER_ONLY ) -static void breakpoint_invalidate (CPUArchState *env,target_ulong pc) +static void breakpoint_invalidate (CPUState *cpu,target_ulong pc) {tb_invalidate_phys_page_range (pc, pc +1 ,0 ); }#else -static void breakpoint_invalidate (CPUArchState *env,target_ulong pc) +static void breakpoint_invalidate (CPUState *cpu,target_ulong pc) { -tb_invalidate_phys_addr (cpu_get_phys_page_debug (env, pc) | +tb_invalidate_phys_addr (cpu_get_phys_page_debug (cpu, pc) | (pc & ~TARGET_PAGE_MASK )); }#endif
@@ -525,15 +525,17 @@ int cpu_breakpoint_insert(CPUArchState *env, target_ulong pc, int flags, bp->flags = flags;/* keep all GDB-injected breakpoints in front */ -if (flags &BP_GDB ) +if (flags &BP_GDB ) {QTAILQ_INSERT_HEAD (&env->breakpoints, bp, entry); -else + }else {QTAILQ_INSERT_TAIL (&env->breakpoints, bp, entry); + } -breakpoint_invalidate (env, pc); +breakpoint_invalidate (ENV_GET_CPU (env), pc); -if (breakpoint) +if (breakpoint) { *breakpoint = bp; + }return 0 ;#else return -ENOSYS ;
@@ -564,7 +566,7 @@ void cpu_breakpoint_remove_by_ref(CPUArchState *env, CPUBreakpoint *breakpoint)#if defined(TARGET_HAS_ICE )QTAILQ_REMOVE (&env->breakpoints, breakpoint, entry); -breakpoint_invalidate (env, breakpoint->pc); +breakpoint_invalidate (ENV_GET_CPU (env), breakpoint->pc);g_free (breakpoint);#endif
@@ -2613,7 +2615,7 @@ int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr,while (len >0 ) { page = addr &TARGET_PAGE_MASK ; - phys_addr =cpu_get_phys_page_debug (env, page); + phys_addr =cpu_get_phys_page_debug (ENV_GET_CPU (env), page);/* if no physical page mapped, return an error */ if (phys_addr ==-1 )return -1 ;
hw/i386/kvmvapic.c +4 -2
@@ -146,6 +146,7 @@ static void update_guest_rom_state(VAPICROMState *s)static int find_real_tpr_addr (VAPICROMState *s,CPUX86State *env) { +CPUState *cs =CPU (x86_env_get_cpu (env));hwaddr paddr;target_ulong addr;
@@ -158,7 +159,7 @@ static int find_real_tpr_addr(VAPICROMState *s, CPUX86State *env)* virtual address space for the APIC mapping. */ for (addr =0xfffff000 ; addr >=0x80000000 ; addr -=TARGET_PAGE_SIZE ) { - paddr =cpu_get_phys_page_debug (env, addr); + paddr =cpu_get_phys_page_debug (cs, addr);if (paddr !=APIC_DEFAULT_ADDRESS ) {continue ; }
@@ -271,6 +272,7 @@ instruction_ok:static int update_rom_mapping (VAPICROMState *s,CPUX86State *env,target_ulong ip) { +CPUState *cs =CPU (x86_env_get_cpu (env));hwaddr paddr;uint32_t rom_state_vaddr;uint32_t pos, patch, offset;
@@ -287,7 +289,7 @@ static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong i/* find out virtual address of the ROM */ rom_state_vaddr = s->rom_state_paddr + (ip &0xf0000000 ); - paddr =cpu_get_phys_page_debug (env, rom_state_vaddr); + paddr =cpu_get_phys_page_debug (cs, rom_state_vaddr);if (paddr ==-1 ) {return -1 ; }
hw/xtensa/xtensa_lx60.c +5 -3
@@ -144,9 +144,11 @@ static void lx60_net_init(MemoryRegion *address_space,memory_region_add_subregion (address_space, buffers, ram); } -static uint64_t translate_phys_addr (void *env,uint64_t addr) +static uint64_t translate_phys_addr (void *opaque,uint64_t addr) { -return cpu_get_phys_page_debug (env, addr); +XtensaCPU *cpu = opaque; + +return cpu_get_phys_page_debug (CPU (cpu), addr); }static void lx60_reset (void *opaque)
@@ -252,7 +254,7 @@ static void lx_init(const LxBoardDesc *board, QEMUMachineInitArgs *args) }uint64_t elf_entry;uint64_t elf_lowaddr; -int success =load_elf (kernel_filename, translate_phys_addr, env, +int success =load_elf (kernel_filename, translate_phys_addr, cpu, &elf_entry, &elf_lowaddr,NULL , be,ELF_MACHINE ,0 );if (success >0 ) { env->pc = elf_entry;
hw/xtensa/xtensa_sim.c +6 -4
@@ -32,9 +32,11 @@#include "exec/memory.h" #include "exec/address-spaces.h" -static uint64_t translate_phys_addr (void *env,uint64_t addr) +static uint64_t translate_phys_addr (void *opaque,uint64_t addr) { -return cpu_get_phys_page_debug (env, addr); +XtensaCPU *cpu = opaque; + +return cpu_get_phys_page_debug (CPU (cpu), addr); }static void sim_reset (void *opaque)
@@ -88,10 +90,10 @@ static void xtensa_sim_init(QEMUMachineInitArgs *args)uint64_t elf_entry;uint64_t elf_lowaddr;#ifdef TARGET_WORDS_BIGENDIAN -int success =load_elf (kernel_filename, translate_phys_addr, env, +int success =load_elf (kernel_filename, translate_phys_addr, cpu, &elf_entry, &elf_lowaddr,NULL ,1 ,ELF_MACHINE ,0 );#else -int success =load_elf (kernel_filename, translate_phys_addr, env, +int success =load_elf (kernel_filename, translate_phys_addr, cpu, &elf_entry, &elf_lowaddr,NULL ,0 ,ELF_MACHINE ,0 );#endif if (success >0 ) {
include/exec/cpu-all.h +0 -5
@@ -430,11 +430,6 @@ void cpu_watchpoint_remove_all(CPUArchState *env, int mask);#if !defined(CONFIG_USER_ONLY ) -/* Return the physical page corresponding to a virtual one. Use it -only for debugging because no protection checks are done. Return -1 -if no page found. */ -hwaddr cpu_get_phys_page_debug (CPUArchState *env,target_ulong addr); -/* memory API */ extern ram_addr_t ram_size;
include/qom/cpu.h +21 -53
98 lines not on this page · raw message
target-alpha/cpu-qom.h +1 -0
@@ -81,5 +81,6 @@ extern const struct VMStateDescription vmstate_alpha_cpu;void alpha_cpu_do_interrupt (CPUState *cpu);void alpha_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr alpha_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-alpha/cpu.c +5 -2
@@ -270,9 +270,12 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = alpha_cpu_class_by_name; cc->do_interrupt = alpha_cpu_do_interrupt; cc->dump_state = alpha_cpu_dump_state; -cpu_class_set_do_unassigned_access (cc, alpha_cpu_unassigned_access); cc->set_pc = alpha_cpu_set_pc; -device_class_set_vmsd (dc, &vmstate_alpha_cpu); +#ifndef CONFIG_USER_ONLY + cc->do_unassigned_access = alpha_cpu_unassigned_access; + cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; + dc->vmsd = &vmstate_alpha_cpu; +#endif }static const TypeInfo alpha_cpu_type_info = {
target-alpha/helper.c +3 -2
@@ -315,12 +315,13 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,return ret; } -hwaddr cpu_get_phys_page_debug (CPUAlphaState *env,target_ulong addr) +hwaddr alpha_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +AlphaCPU *cpu =ALPHA_CPU (cs);target_ulong phys;int prot, fail; - fail =get_physical_address (env, addr,0 ,0 , &phys, &prot); + fail =get_physical_address (&cpu->env, addr,0 ,0 , &phys, &prot);return (fail >=0 ?-1 : phys); }
target-arm/cpu-qom.h +2 -0
@@ -147,4 +147,6 @@ void arm_v7m_cpu_do_interrupt(CPUState *cpu);void arm_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr arm_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); +#endif
target-arm/cpu.c +4 -1
@@ -824,7 +824,10 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = arm_cpu_do_interrupt; cc->dump_state = arm_cpu_dump_state; cc->set_pc = arm_cpu_set_pc; -cpu_class_set_vmsd (cc, &vmstate_arm_cpu); +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = arm_cpu_get_phys_page_debug; + cc->vmsd = &vmstate_arm_cpu; +#endif }static void cpu_register (const ARMCPUInfo *info)
target-arm/helper.c +5 -3
@@ -2762,17 +2762,19 @@ int cpu_arm_handle_mmu_fault (CPUARMState *env, target_ulong address,return 1 ; } -hwaddr cpu_get_phys_page_debug (CPUARMState *env,target_ulong addr) +hwaddr arm_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +ARMCPU *cpu =ARM_CPU (cs);hwaddr phys_addr;target_ulong page_size;int prot;int ret; - ret =get_phys_addr (env, addr,0 ,0 , &phys_addr, &prot, &page_size); + ret =get_phys_addr (&cpu->env, addr,0 ,0 , &phys_addr, &prot, &page_size); -if (ret !=0 ) +if (ret !=0 ) {return -1 ; + }return phys_addr; }
target-cris/cpu-qom.h +2 -0
@@ -79,4 +79,6 @@ void crisv10_cpu_do_interrupt(CPUState *cpu);void cris_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr cris_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); +#endif
target-cris/cpu.c +3 -0
@@ -255,6 +255,9 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = cris_cpu_do_interrupt; cc->dump_state = cris_cpu_dump_state; cc->set_pc = cris_cpu_set_pc; +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = cris_cpu_get_phys_page_debug; +#endif }static const TypeInfo cris_cpu_type_info = {
target-cris/helper.c +4 -3
@@ -255,16 +255,17 @@ void cris_cpu_do_interrupt(CPUState *cs) env->pregs[PR_ERP]); } -hwaddr cpu_get_phys_page_debug (CPUCRISState * env,target_ulong addr) +hwaddr cris_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +CRISCPU *cpu =CRIS_CPU (cs);uint32_t phy = addr;struct cris_mmu_result res;int miss; - miss =cris_mmu_translate (&res, env, addr,0 ,0 ,1 ); + miss =cris_mmu_translate (&res, &cpu->env, addr,0 ,0 ,1 );/* If D TLB misses, try I TLB. */ if (miss) { - miss =cris_mmu_translate (&res, env, addr,2 ,0 ,1 ); + miss =cris_mmu_translate (&res, &cpu->env, addr,2 ,0 ,1 ); }if (!miss) {
target-i386/cpu-qom.h +2 -0
@@ -104,4 +104,6 @@ void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,void x86_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr x86_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); +#endif
target-i386/cpu.c +2 -1
@@ -2542,12 +2542,13 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->get_paging_enabled = x86_cpu_get_paging_enabled;#ifndef CONFIG_USER_ONLY cc->get_memory_mapping = x86_cpu_get_memory_mapping; + cc->get_phys_page_debug = x86_cpu_get_phys_page_debug; cc->write_elf64_note = x86_cpu_write_elf64_note; cc->write_elf64_qemunote = x86_cpu_write_elf64_qemunote; cc->write_elf32_note = x86_cpu_write_elf32_note; cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote; + cc->vmsd = &vmstate_x86_cpu;#endif -cpu_class_set_vmsd (cc, &vmstate_x86_cpu); }static const TypeInfo x86_cpu_type_info = {
target-i386/helper.c +3 -1
@@ -884,8 +884,10 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,return 1 ; } -hwaddr cpu_get_phys_page_debug (CPUX86State *env,target_ulong addr) +hwaddr x86_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env;target_ulong pde_addr, pte_addr;uint64_t pte;hwaddr paddr;
target-lm32/cpu-qom.h +1 -0
@@ -78,5 +78,6 @@ extern const struct VMStateDescription vmstate_lm32_cpu;void lm32_cpu_do_interrupt (CPUState *cpu);void lm32_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr lm32_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-lm32/cpu.c +4 -1
@@ -87,7 +87,10 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = lm32_cpu_do_interrupt; cc->dump_state = lm32_cpu_dump_state; cc->set_pc = lm32_cpu_set_pc; -cpu_class_set_vmsd (cc, &vmstate_lm32_cpu); +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = lm32_cpu_get_phys_page_debug; + cc->vmsd = &vmstate_lm32_cpu; +#endif }static const TypeInfo lm32_cpu_type_info = {
target-lm32/helper.c +4 -2
@@ -37,10 +37,12 @@ int cpu_lm32_handle_mmu_fault(CPULM32State *env, target_ulong address, int rw,return 0 ; } -hwaddr cpu_get_phys_page_debug (CPULM32State *env,target_ulong addr) +hwaddr lm32_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +LM32CPU *cpu =LM32_CPU (cs); + addr &=TARGET_PAGE_MASK ; -if (env->flags &LM32_FLAG_IGNORE_MSB ) { +if (cpu->env.flags &LM32_FLAG_IGNORE_MSB ) {return addr &0x7fffffff ; }else {return addr;
target-m68k/cpu-qom.h +1 -0
@@ -73,5 +73,6 @@ static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env)void m68k_cpu_do_interrupt (CPUState *cpu);void m68k_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr m68k_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-m68k/cpu.c +3 -0
@@ -190,6 +190,9 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->do_interrupt = m68k_cpu_do_interrupt; cc->dump_state = m68k_cpu_dump_state; cc->set_pc = m68k_cpu_set_pc; +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug; +#endif dc->vmsd = &vmstate_m68k_cpu; }
target-m68k/helper.c +1 -1
@@ -290,7 +290,7 @@ int cpu_m68k_handle_mmu_fault (CPUM68KState *env, target_ulong address, int rw,/* MMU */ /* TODO: This will need fixing once the MMU is implemented. */ -hwaddr cpu_get_phys_page_debug (CPUM68KState *env,target_ulong addr) +hwaddr m68k_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) {return addr; }
target-microblaze/cpu-qom.h +1 -0
@@ -74,5 +74,6 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env)void mb_cpu_do_interrupt (CPUState *cs);void mb_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr mb_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-microblaze/cpu.c +4 -1
@@ -140,8 +140,11 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = mb_cpu_do_interrupt; cc->dump_state = mb_cpu_dump_state; -cpu_class_set_do_unassigned_access (cc, mb_cpu_unassigned_access); cc->set_pc = mb_cpu_set_pc; +#ifndef CONFIG_USER_ONLY + cc->do_unassigned_access = mb_cpu_unassigned_access; + cc->get_phys_page_debug = mb_cpu_get_phys_page_debug; +#endif dc->vmsd = &vmstate_mb_cpu; dc->props = mb_properties; }
target-microblaze/helper.c +3 -1
@@ -265,8 +265,10 @@ void mb_cpu_do_interrupt(CPUState *cs) } } -hwaddr cpu_get_phys_page_debug (CPUMBState * env,target_ulong addr) +hwaddr mb_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); +CPUMBState *env = &cpu->env;target_ulong vaddr, paddr =0 ;struct microblaze_mmu_lookup lu;unsigned int hit;
target-mips/cpu-qom.h +1 -0
@@ -77,5 +77,6 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env)void mips_cpu_do_interrupt (CPUState *cpu);void mips_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr mips_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-mips/cpu.c +4 -1
@@ -98,9 +98,12 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->do_interrupt = mips_cpu_do_interrupt; cc->dump_state = mips_cpu_dump_state; -cpu_class_set_do_unassigned_access (cc, mips_cpu_unassigned_access); cc->set_pc = mips_cpu_set_pc; cc->synchronize_from_tb = mips_cpu_synchronize_from_tb; +#ifndef CONFIG_USER_ONLY + cc->do_unassigned_access = mips_cpu_unassigned_access; + cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; +#endif }static const TypeInfo mips_cpu_type_info = {
target-mips/helper.c +5 -2
@@ -254,13 +254,16 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, }#if !defined(CONFIG_USER_ONLY ) -hwaddr cpu_get_phys_page_debug (CPUMIPSState *env,target_ulong addr) +hwaddr mips_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +MIPSCPU *cpu =MIPS_CPU (cs);hwaddr phys_addr;int prot; -if (get_physical_address (env, &phys_addr, &prot, addr,0 ,ACCESS_INT ) !=0 ) +if (get_physical_address (&cpu->env, &phys_addr, &prot, addr,0 , +ACCESS_INT ) !=0 ) {return -1 ; + }return phys_addr; }#endif
target-moxie/cpu.c +4 -1
@@ -101,7 +101,10 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = moxie_cpu_do_interrupt; cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc; -cpu_class_set_vmsd (cc, &vmstate_moxie_cpu); +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; + cc->vmsd = &vmstate_moxie_cpu; +#endif }static void moxielite_initfn (Object *obj)
target-moxie/cpu.h +1 -0
@@ -118,6 +118,7 @@ int cpu_moxie_exec(CPUMoxieState *s);void moxie_cpu_do_interrupt (CPUState *cs);void moxie_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr moxie_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void moxie_translate_init (void );int cpu_moxie_signal_handler (int host_signum,void *pinfo,void *puc);
target-moxie/helper.c +4 -7
@@ -118,11 +118,6 @@ int cpu_moxie_handle_mmu_fault(CPUMoxieState *env, target_ulong address,return 1 ; } -hwaddr cpu_get_phys_page_debug (CPUState *env,target_ulong addr) -{ -return addr; -} -#else /* !CONFIG_USER_ONLY */ int cpu_moxie_handle_mmu_fault(CPUMoxieState *env, target_ulong address,
@@ -162,12 +157,14 @@ void moxie_cpu_do_interrupt(CPUState *cs) } } -hwaddr cpu_get_phys_page_debug (CPUMoxieState *env,target_ulong addr) +hwaddr moxie_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +MoxieCPU *cpu =MOXIE_CPU (cs);uint32_t phy = addr;MoxieMMUResult res;int miss; - miss =moxie_mmu_translate (&res, env, addr,0 ,0 ); + + miss =moxie_mmu_translate (&res, &cpu->env, addr,0 ,0 );if (!miss) { phy = res.phy; }
target-openrisc/cpu.c +4 -1
@@ -154,7 +154,10 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = openrisc_cpu_do_interrupt; cc->dump_state = openrisc_cpu_dump_state; cc->set_pc = openrisc_cpu_set_pc; -device_class_set_vmsd (dc, &vmstate_openrisc_cpu); +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; + dc->vmsd = &vmstate_openrisc_cpu; +#endif }static void cpu_register (const OpenRISCCPUInfo *info)
target-openrisc/cpu.h +1 -0
@@ -349,6 +349,7 @@ int cpu_openrisc_exec(CPUOpenRISCState *s);void openrisc_cpu_do_interrupt (CPUState *cpu);void openrisc_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr openrisc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);void openrisc_translate_init (void ); int cpu_openrisc_handle_mmu_fault(CPUOpenRISCState *env, target_ulong address,
target-openrisc/mmu.c +2 -3
@@ -219,12 +219,11 @@ int cpu_openrisc_handle_mmu_fault(CPUOpenRISCState *env,#endif #ifndef CONFIG_USER_ONLY -hwaddr cpu_get_phys_page_debug (CPUOpenRISCState *env, -target_ulong addr) +hwaddr openrisc_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +OpenRISCCPU *cpu =OPENRISC_CPU (cs);hwaddr phys_addr;int prot; -OpenRISCCPU *cpu =openrisc_env_get_cpu (env);if (cpu_openrisc_get_phys_addr (cpu, &phys_addr, &prot, addr,0 )) {return -1 ;
target-ppc/cpu-qom.h +1 -0
@@ -105,5 +105,6 @@ void ppc_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags);void ppc_cpu_dump_statistics (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr ppc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-ppc/mmu_helper.c +3 -1
@@ -1409,8 +1409,10 @@ static int get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx,return ret; } -hwaddr cpu_get_phys_page_debug (CPUPPCState *env,target_ulong addr) +hwaddr ppc_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env;mmu_ctx_t ctx;switch (env->mmu_model) {
target-ppc/translate_init.c +3 -0
@@ -8457,6 +8457,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = ppc_cpu_dump_state; cc->dump_statistics = ppc_cpu_dump_statistics; cc->set_pc = ppc_cpu_set_pc; +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; +#endif }static const TypeInfo ppc_cpu_type_info = {
target-s390x/cpu-qom.h +1 -0
@@ -74,5 +74,6 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env)void s390_cpu_do_interrupt (CPUState *cpu);void s390_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr s390_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-s390x/cpu.c +3 -0
@@ -173,6 +173,9 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = s390_cpu_do_interrupt; cc->dump_state = s390_cpu_dump_state; cc->set_pc = s390_cpu_set_pc; +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; +#endif dc->vmsd = &vmstate_s390_cpu; }
target-s390x/helper.c +3 -2
@@ -417,9 +417,10 @@ int cpu_s390x_handle_mmu_fault(CPUS390XState *env, target_ulong orig_vaddr,return 0 ; } -hwaddr cpu_get_phys_page_debug (CPUS390XState *env, -target_ulong vaddr) +hwaddr s390_cpu_get_phys_page_debug (CPUState *cs,vaddr vaddr) { +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env;target_ulong raddr;int prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ;int old_exc = env->exception_index;
target-sh4/cpu-qom.h +1 -0
@@ -86,5 +86,6 @@ static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env)void superh_cpu_do_interrupt (CPUState *cpu);void superh_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr superh_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-sh4/cpu.c +3 -0
@@ -286,6 +286,9 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->dump_state = superh_cpu_dump_state; cc->set_pc = superh_cpu_set_pc; cc->synchronize_from_tb = superh_cpu_synchronize_from_tb; +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = superh_cpu_get_phys_page_debug; +#endif dc->vmsd = &vmstate_sh_cpu; }
target-sh4/helper.c +3 -2
@@ -508,12 +508,13 @@ int cpu_sh4_handle_mmu_fault(CPUSH4State * env, target_ulong address, int rw,return 0 ; } -hwaddr cpu_get_phys_page_debug (CPUSH4State * env,target_ulong addr) +hwaddr superh_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +SuperHCPU *cpu =SUPERH_CPU (cs);target_ulong physical;int prot; -get_physical_address (env, &physical, &prot, addr,0 ,0 ); +get_physical_address (&cpu->env, &physical, &prot, addr,0 ,0 );return physical; }
target-sparc/cpu-qom.h +1 -0
@@ -78,5 +78,6 @@ static inline SPARCCPU *sparc_env_get_cpu(CPUSPARCState *env)void sparc_cpu_do_interrupt (CPUState *cpu);void sparc_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr sparc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-sparc/cpu.c +4 -1
@@ -782,9 +782,12 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = sparc_cpu_do_interrupt; cc->dump_state = sparc_cpu_dump_state; -cpu_class_set_do_unassigned_access (cc, sparc_cpu_unassigned_access); cc->set_pc = sparc_cpu_set_pc; cc->synchronize_from_tb = sparc_cpu_synchronize_from_tb; +#ifndef CONFIG_USER_ONLY + cc->do_unassigned_access = sparc_cpu_unassigned_access; + cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug; +#endif }static const TypeInfo sparc_cpu_type_info = {
target-sparc/mmu_helper.c +7 -4
@@ -310,6 +310,7 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)void dump_mmu (FILE *f,fprintf_function cpu_fprintf,CPUSPARCState *env) { +CPUState *cs =CPU (sparc_env_get_cpu (env));target_ulong va, va1, va2;unsigned int n, m, o;hwaddr pde_ptr, pa;
@@ -322,20 +323,20 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUSPARCState *env)for (n =0 , va =0 ; n <256 ; n++, va +=16 *1024 *1024 ) { pde =mmu_probe (env, va,2 );if (pde) { - pa =cpu_get_phys_page_debug (env, va); + pa =cpu_get_phys_page_debug (cs, va); (*cpu_fprintf)(f,"VA: " TARGET_FMT_lx", PA: " TARGET_FMT_plx" PDE: " TARGET_FMT_lx"\n" , va, pa, pde);for (m =0 , va1 = va; m <64 ; m++, va1 +=256 *1024 ) { pde =mmu_probe (env, va1,1 );if (pde) { - pa =cpu_get_phys_page_debug (env, va1); + pa =cpu_get_phys_page_debug (cs, va1); (*cpu_fprintf)(f," VA: " TARGET_FMT_lx", PA: " TARGET_FMT_plx" PDE: " TARGET_FMT_lx"\n" , va1, pa, pde);for (o =0 , va2 = va1; o <64 ; o++, va2 +=4 *1024 ) { pde =mmu_probe (env, va2,0 );if (pde) { - pa =cpu_get_phys_page_debug (env, va2); + pa =cpu_get_phys_page_debug (cs, va2); (*cpu_fprintf)(f, " VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_plx " PTE: " TARGET_FMT_lx "\n",
@@ -833,8 +834,10 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr, }#endif -hwaddr cpu_get_phys_page_debug (CPUSPARCState *env,target_ulong addr) +hwaddr sparc_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env;hwaddr phys_addr;int mmu_idx =cpu_mmu_index (env);MemoryRegionSection section;
target-unicore32/cpu-qom.h +1 -0
@@ -63,5 +63,6 @@ static inline UniCore32CPU *uc32_env_get_cpu(CPUUniCore32State *env)void uc32_cpu_do_interrupt (CPUState *cpu);void uc32_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr uc32_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-unicore32/cpu.c +3 -0
@@ -139,6 +139,9 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = uc32_cpu_do_interrupt; cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc; +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug; +#endif dc->vmsd = &vmstate_uc32_cpu; }
target-unicore32/softmmu.c +4 -3
@@ -261,9 +261,10 @@ int uc32_cpu_handle_mmu_fault(CPUUniCore32State *env, target_ulong address,return ret; } -hwaddr cpu_get_phys_page_debug (CPUUniCore32State *env, -target_ulong addr) +hwaddr uc32_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { -cpu_abort (env,"%s not supported yet\n" , __func__); +UniCore32CPU *cpu =UNICORE32_CPU (cs); + +cpu_abort (&cpu->env,"%s not supported yet\n" , __func__);return addr; }
target-xtensa/cpu-qom.h +1 -0
@@ -83,5 +83,6 @@ static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env)void xtensa_cpu_do_interrupt (CPUState *cpu);void xtensa_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +hwaddr xtensa_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);#endif
target-xtensa/cpu.c +3 -0
@@ -108,6 +108,9 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = xtensa_cpu_do_interrupt; cc->dump_state = xtensa_cpu_dump_state; cc->set_pc = xtensa_cpu_set_pc; +#ifndef CONFIG_USER_ONLY + cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug; +#endif dc->vmsd = &vmstate_xtensa_cpu; }
target-xtensa/helper.c +4 -3
@@ -108,17 +108,18 @@ void xtensa_cpu_list(FILE *f, fprintf_function cpu_fprintf) } } -hwaddr cpu_get_phys_page_debug (CPUXtensaState *env,target_ulong addr) +hwaddr xtensa_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) { +XtensaCPU *cpu =XTENSA_CPU (cs);uint32_t paddr;uint32_t page_size;unsigned access; -if (xtensa_get_physical_addr (env, false, addr,0 ,0 , +if (xtensa_get_physical_addr (&cpu->env, false, addr,0 ,0 , &paddr, &page_size, &access) ==0 ) {return paddr; } -if (xtensa_get_physical_addr (env, false, addr,2 ,0 , +if (xtensa_get_physical_addr (&cpu->env, false, addr,2 ,0 , &paddr, &page_size, &access) ==0 ) {return paddr; }
target-xtensa/xtensa-semi.c +2 -2
@@ -152,6 +152,7 @@ static uint32_t errno_h2g(int host_errno)void HELPER (simcall )(CPUXtensaState *env) { +CPUState *cs =CPU (xtensa_env_get_cpu (env));uint32_t *regs = env->regs;switch (regs[2 ]) {
@@ -169,8 +170,7 @@ void HELPER(simcall)(CPUXtensaState *env)uint32_t len = regs[5 ];while (len >0 ) { -hwaddr paddr = -cpu_get_phys_page_debug (env, vaddr); +hwaddr paddr =cpu_get_phys_page_debug (cs, vaddr);uint32_t page_left =TARGET_PAGE_SIZE - (vaddr & (TARGET_PAGE_SIZE -1 ));uint32_t io_sz = page_left < len ? page_left : len;
Signature · 1 line
1.8.1.4