qom hooks to clean up cpu_exec
cover qom hooks to clean up cpu_exec
Prompted by trying to review Martin's ARM exception vs gdb problems, let's clean up cpu_exec so that it's almost readable.
After the 23 patches, there's one (interesting) ifdef left. That is, i386 redefining CPU_INTERRUPT_RESET as CPU_INTERRUPT_INIT for its own purposes. I'm not sure why all that couldn't be done under whatever hooks cpu_reset allows. Failing that, we might be able to redefine C_I_I as a new CPU_INTERRUPT_TGT_INT_3 bit.
I've done some smoke tests on i386, arm, xtensa, because I had images handy. But I've not done anything but compile the rest.
Comments appreciated.
r~
Richard Henderson (23):
qom: Add cpu_exec_enter and cpu_exec_exit hooks
cpu-exec: Remove do-nothing ifdef chains
target-i386: Use cpu_exec_enter/exit qom hooks
target-m68k: Use cpu_exec_enter/exit qom hooks
target-ppc: Use cpu_exec_enter qom hook
qom: Add cpu_exec_interrupt hook
target-xtensa: Use cpu_exec_interrupt qom hook
target-s390x: Use cpu_exec_interrupt qom hook
target-m68k: Use cpu_exec_interrupt qom hook
target-cris: Use cpu_exec_interrupt qom hook
target-alpha: Use cpu_exec_interrupt qom hook
target-sh4: Use cpu_exec_interrupt qom hook
target-unicore32: Use cpu_exec_interrupt qom hook
target-arm: Use cpu_exec_interrupt qom hook
target-sparc: Use cpu_exec_interrupt qom hook
target-openrisc: Use cpu_exec_interrupt qom hook
target-tricore: Remove the dummy interrupt boilerplate
target-mips: Use cpu_exec_interrupt qom hook
target-microblaze: Use cpu_exec_interrupt qom hook
target-lm32: Use cpu_exec_interrupt qom hook
target-ppc: Use cpu_exec_interrupt qom hook
target-i386: Use cpu_exec_interrupt qom hook
cpu-exec: Do CPU_INTERRUPT_HALT unconditionally
cpu-exec.c | 329 ++------------------------------------------ include/qom/cpu.h | 7 + qom/cpu.c | 12 +- target-alpha/cpu-qom.h | 1 + target-alpha/cpu.c | 1 + target-alpha/helper.c | 44 ++++++ target-arm/cpu-qom.h | 1 + target-arm/cpu.c | 34 +++++ target-arm/cpu64.c | 1 + target-cris/cpu-qom.h | 1 + target-cris/cpu.c | 1 + target-cris/helper.c | 31 +++++ target-i386/cpu-qom.h | 4 + target-i386/cpu.c | 3 + target-i386/helper.c | 21 +++ target-i386/seg_helper.c | 69 ++++++++++ target-lm32/cpu-qom.h | 1 + target-lm32/cpu.c | 1 + target-lm32/helper.c | 13 ++ target-m68k/cpu-qom.h | 4 + target-m68k/cpu.c | 4 + target-m68k/cpu.h | 1 - target-m68k/helper.c | 20 +++ target-m68k/op_helper.c | 22 ++- target-microblaze/cpu-qom.h | 1 + target-microblaze/cpu.c | 1 + target-microblaze/helper.c | 16 +++ target-mips/cpu-qom.h | 1 + target-mips/cpu.c | 1 + target-mips/helper.c | 17 +++ target-openrisc/cpu.c | 1 + target-openrisc/cpu.h | 1 + target-openrisc/interrupt.c | 20 +++ target-ppc/cpu-qom.h | 1 + target-ppc/cpu.h | 1 - target-ppc/excp_helper.c | 19 ++- target-ppc/translate_init.c | 10 ++ target-s390x/cpu-qom.h | 1 + target-s390x/cpu.c | 1 + target-s390x/helper.c | 13 ++ target-sh4/cpu-qom.h | 1 + target-sh4/cpu.c | 1 + target-sh4/helper.c | 9 ++ target-sparc/cpu.c | 21 +++ target-tricore/cpu-qom.h | 1 - target-tricore/cpu.c | 1 - target-tricore/cpu.h | 2 - target-tricore/helper.c | 4 - target-unicore32/cpu-qom.h | 1 + target-unicore32/cpu.c | 1 + target-unicore32/helper.c | 15 ++ target-xtensa/cpu-qom.h | 1 + target-xtensa/cpu.c | 1 + target-xtensa/helper.c | 10 ++ 54 files changed, 464 insertions(+), 336 deletions(-)
Signature · 1 line
1.9.3
PATCH 1/23 qom: Add cpu_exec_enter and cpu_exec_exit hooks
In preparation for removing a bunch of ifdefs from cpu_exec.
--- cpu-exec.c | 9 ++------- include/qom/cpu.h | 5 +++++ qom/cpu.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-)
cpu-exec.c +2 -7
@@ -317,10 +317,7 @@ volatile sig_atomic_t exit_request;int cpu_exec (CPUArchState *env) {CPUState *cpu =ENV_GET_CPU (env); -#if !(defined(CONFIG_USER_ONLY ) && \ - (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X )))CPUClass *cc =CPU_GET_CLASS (cpu); -#endif #ifdef TARGET_I386 X86CPU *x86_cpu =X86_CPU (cpu);#endif
@@ -382,9 +379,8 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_XTENSA )#elif defined(TARGET_TRICORE )/* XXXXX */ -#else -#error unsupported target CPU#endif + cc->cpu_exec_enter (cpu); cpu->exception_index =-1 ;/* Calculate difference between guest clock and host clock.
@@ -856,9 +852,8 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_S390X )#elif defined(TARGET_XTENSA )/* XXXXX */ -#else -#error unsupported target CPU#endif + cc->cpu_exec_exit (cpu);/* fail safe : never use current_cpu outside cpu_exec() */ current_cpu =NULL ;
include/qom/cpu.h +5 -0
@@ -99,6 +99,8 @@ struct TranslationBlock;* @vmsd: State description for migration. * @gdb_num_core_regs: Number of core registers accessible to GDB. * @gdb_core_xml_file: File name for core registers GDB XML description. +* @cpu_exec_enter: Callback for cpu_exec preparation. +* @cpu_exec_exit: Callback for cpu_exec cleanup. * * Represents a CPU family or model. */
@@ -149,6 +151,9 @@ typedef struct CPUClass {const struct VMStateDescription *vmsd;int gdb_num_core_regs;const char *gdb_core_xml_file; + +void (*cpu_exec_enter)(CPUState *cpu); +void (*cpu_exec_exit)(CPUState *cpu); } CPUClass;#ifdef HOST_WORDS_BIGENDIAN
qom/cpu.c +4 -2
@@ -202,7 +202,7 @@ static bool cpu_common_virtio_is_big_endian(CPUState *cpu)return target_words_bigendian (); } -static void cpu_common_debug_excp_handler (CPUState *cpu) +static void cpu_common_noop (CPUState *cpu) { }
@@ -344,7 +344,9 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register; k->virtio_is_big_endian = cpu_common_virtio_is_big_endian; - k->debug_excp_handler = cpu_common_debug_excp_handler; + k->debug_excp_handler = cpu_common_noop; + k->cpu_exec_enter = cpu_common_noop; + k->cpu_exec_exit = cpu_common_noop; dc->realize = cpu_common_realizefn;/* * Reason: CPUs still need special care by board code: wiring up
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 01/23] qom: Add cpu_exec_enter and cpu_exec_exit hooks
Quoted 10 lines · Richard Henderson
In preparation for removing a bunch of ifdefs from
cpu_exec.Cc Andreas Färber <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- cpu-exec.c | 9 ++------- include/qom/cpu.h | 5 +++++ qom/cpu.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-)
<snip>
I applaude this effort ;-)
Signature · 1 line
Alex Bennée
Re: [Qemu-devel] [PATCH 01/23] qom: Add cpu_exec_enter and cpu_exec_exit hooks
In reply to Richard HendersonAm 13.09.2014 um 18:45 schrieb Richard Henderson:
Quoted 61 lines
In preparation for removing a bunch of ifdefs from
cpu_exec.Cc Andreas Färber <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- cpu-exec.c | 9 ++------- include/qom/cpu.h | 5 +++++ qom/cpu.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-)cpu-exec.c +2
-7@@ -317,10 +317,7 @@ volatile sig_atomic_t exit_request;int cpu_exec (CPUArchState *env) {CPUState *cpu =ENV_GET_CPU (env); -#if !(defined(CONFIG_USER_ONLY ) && \ - (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X )))CPUClass *cc =CPU_GET_CLASS (cpu); -#endif #ifdef TARGET_I386 X86CPU *x86_cpu =X86_CPU (cpu);#endif @@ -382,9 +379,8 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_XTENSA )#elif defined(TARGET_TRICORE )/* XXXXX */ -#else -#error unsupported target CPU#endif + cc->cpu_exec_enter (cpu); cpu->exception_index =-1 ;/* Calculate difference between guest clock and host clock. @@ -856,9 +852,8 @@ int cpu_exec(CPUArchState *env)#elif defined(TARGET_S390X )#elif defined(TARGET_XTENSA )/* XXXXX */ -#else -#error unsupported target CPU#endif + cc->cpu_exec_exit (cpu);/* fail safe : never use current_cpu outside cpu_exec() */ current_cpu =NULL ;include/qom/cpu.h +2
-0@@ -99,6 +99,8 @@ struct TranslationBlock;* @vmsd: State description for migration. * @gdb_num_core_regs: Number of core registers accessible to GDB. * @gdb_core_xml_file: File name for core registers GDB XML description. +* @cpu_exec_enter: Callback for cpu_exec preparation. +* @cpu_exec_exit: Callback for cpu_exec cleanup. * * Represents a CPU family or model. */
include/qom/cpu.h typedef struct CPUClass { · line 156
Quoted 6 lines
include/qom/cpu.h +3
-0@@ -149,6 +151,9 @@ typedef struct CPUClass {const struct VMStateDescription *vmsd;int gdb_num_core_regs;const char *gdb_core_xml_file; + +void (*cpu_exec_enter)(CPUState *cpu); +void (*cpu_exec_exit)(CPUState *cpu);
I am fine with adding such hooks, but please let's use a better, active name. CPUClass is the struct name and cpu-exec is a file name; the hook should say what it's doing, not where the code (used to) live(s). Just exec_enter/exec_exit possibly?
Thanks,
Andreas
Quoted 28 lines
include/qom/cpu.h +0
-0} CPUClass;#ifdef HOST_WORDS_BIGENDIAN qom/cpu.c +4
-2@@ -202,7 +202,7 @@ static bool cpu_common_virtio_is_big_endian(CPUState *cpu)return target_words_bigendian (); } -static void cpu_common_debug_excp_handler (CPUState *cpu) +static void cpu_common_noop (CPUState *cpu) { }@@ -344,7 +344,9 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register; k->virtio_is_big_endian = cpu_common_virtio_is_big_endian; - k->debug_excp_handler = cpu_common_debug_excp_handler; + k->debug_excp_handler = cpu_common_noop; + k->cpu_exec_enter = cpu_common_noop; + k->cpu_exec_exit = cpu_common_noop; dc->realize = cpu_common_realizefn;/* * Reason: CPUs still need special care by board code: wiring up
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 01/23] qom: Add cpu_exec_enter and cpu_exec_exit hooks
Quoted 4 lines · Andreas Färber
I am fine with adding such hooks, but please let's use a better, active name. CPUClass is the struct name and cpu-exec is a file name; the hook should say what it's doing, not where the code (used to) live(s). Just exec_enter/exec_exit possibly?
cpu_exec is also the function name from which they're invoked, not just the file name.
I can make the name change if you really prefer, but (perhaps obviously) I kinda like the current naming.
r~
Re: [Qemu-devel] [PATCH 01/23] qom: Add cpu_exec_enter and cpu_exec_exit hooks
Quoted 11 lines · Richard Henderson
Quoted 4 lines · Andreas Färber
I am fine with adding such hooks, but please let's use a better, active name. CPUClass is the struct name and cpu-exec is a file name; the hook should say what it's doing, not where the code (used to) live(s). Just exec_enter/exec_exit possibly?
cpu_execis also the function name from which they're invoked, not just the file name.I can make the name change if you really prefer, but (perhaps obviously) I kinda like the current naming.
The current name doesn't seem particularly bad to me, and in the absence of further discussion here I assume you don't object that strongly, Andreas?
Since this patchset unavoidably touches a pile of the target-* code (and it will conflict with at least one patchset I want to fixup-and-queue for target-arm.next), I'd like to commit it direct to master so we don't end up having to respin it or fix up collisions. Or do you have a strong preference for taking it through the qom tree?
thanks
-- PMM
PATCH 2/23 cpu-exec: Remove do-nothing ifdef chains
In reply to Richard HendersonAround the cpu_exec_enter/exit hooks contain many empty ifdef blocks. Delete all of these to highlight those targets for which we actually need to do work.
--- cpu-exec.c | 32 -------------------------------- 1 file changed, 32 deletions(-)
cpu-exec.c +0 -32
@@ -358,27 +358,12 @@ int cpu_exec(CPUArchState *env) env->df =1 - (2 * ((env->eflags >>10 ) &1 ));CC_OP =CC_OP_EFLAGS ; env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); -#elif defined(TARGET_SPARC )#elif defined(TARGET_M68K ) env->cc_op =CC_OP_FLAGS ; env->cc_dest = env->sr &0xf ; env->cc_x = (env->sr >>4 ) &1 ; -#elif defined(TARGET_ALPHA ) -#elif defined(TARGET_ARM ) -#elif defined(TARGET_UNICORE32 )#elif defined(TARGET_PPC ) env->reserve_addr =-1 ; -#elif defined(TARGET_LM32 ) -#elif defined(TARGET_MICROBLAZE ) -#elif defined(TARGET_MIPS ) -#elif defined(TARGET_MOXIE ) -#elif defined(TARGET_OPENRISC ) -#elif defined(TARGET_SH4 ) -#elif defined(TARGET_CRIS ) -#elif defined(TARGET_S390X ) -#elif defined(TARGET_XTENSA ) -#elif defined(TARGET_TRICORE ) -/* XXXXX */ #endif cc->cpu_exec_enter (cpu); cpu->exception_index =-1 ;
@@ -830,28 +815,11 @@ int cpu_exec(CPUArchState *env)/* restore flags in standard format */ env->eflags = env->eflags |cpu_cc_compute_all (env,CC_OP ) | (env->df &DF_MASK ); -#elif defined(TARGET_ARM ) -/* XXX: Save/restore host fpu exception state?. */ -#elif defined(TARGET_UNICORE32 ) -#elif defined(TARGET_SPARC ) -#elif defined(TARGET_PPC ) -#elif defined(TARGET_LM32 )#elif defined(TARGET_M68K )cpu_m68k_flush_flags (env, env->cc_op); env->cc_op =CC_OP_FLAGS ; env->sr = (env->sr &0xffe0 ) | env->cc_dest | (env->cc_x <<4 ); -#elif defined(TARGET_MICROBLAZE ) -#elif defined(TARGET_MIPS ) -#elif defined(TARGET_TRICORE ) -#elif defined(TARGET_MOXIE ) -#elif defined(TARGET_OPENRISC ) -#elif defined(TARGET_SH4 ) -#elif defined(TARGET_ALPHA ) -#elif defined(TARGET_CRIS ) -#elif defined(TARGET_S390X ) -#elif defined(TARGET_XTENSA ) -/* XXXXX */ #endif cc->cpu_exec_exit (cpu);
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 02/23] cpu-exec: Remove do-nothing ifdef chains
Quoted 5 lines · Richard Henderson
Around the cpu_exec_enter/exit hooks contain many empty ifdef blocks. Delete all of these to highlight those targets for which we actually need to do work.
Signed-off-by Richard Henderson <[email protected]>
Quoted 64 lines
--- cpu-exec.c | 32 -------------------------------- 1 file changed, 32 deletions(-)cpu-exec.c +0
-32@@ -358,27 +358,12 @@ int cpu_exec(CPUArchState *env) env->df =1 - (2 * ((env->eflags >>10 ) &1 ));CC_OP =CC_OP_EFLAGS ; env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); -#elif defined(TARGET_SPARC )#elif defined(TARGET_M68K ) env->cc_op =CC_OP_FLAGS ; env->cc_dest = env->sr &0xf ; env->cc_x = (env->sr >>4 ) &1 ; -#elif defined(TARGET_ALPHA ) -#elif defined(TARGET_ARM ) -#elif defined(TARGET_UNICORE32 )#elif defined(TARGET_PPC ) env->reserve_addr =-1 ; -#elif defined(TARGET_LM32 ) -#elif defined(TARGET_MICROBLAZE ) -#elif defined(TARGET_MIPS ) -#elif defined(TARGET_MOXIE ) -#elif defined(TARGET_OPENRISC ) -#elif defined(TARGET_SH4 ) -#elif defined(TARGET_CRIS ) -#elif defined(TARGET_S390X ) -#elif defined(TARGET_XTENSA ) -#elif defined(TARGET_TRICORE ) -/* XXXXX */ #endif cc->cpu_exec_enter (cpu); cpu->exception_index =-1 ;@@ -830,28 +815,11 @@ int cpu_exec(CPUArchState *env)/* restore flags in standard format */ env->eflags = env->eflags |cpu_cc_compute_all (env,CC_OP ) | (env->df &DF_MASK ); -#elif defined(TARGET_ARM ) -/* XXX: Save/restore host fpu exception state?. */ -#elif defined(TARGET_UNICORE32 ) -#elif defined(TARGET_SPARC ) -#elif defined(TARGET_PPC ) -#elif defined(TARGET_LM32 )#elif defined(TARGET_M68K )cpu_m68k_flush_flags (env, env->cc_op); env->cc_op =CC_OP_FLAGS ; env->sr = (env->sr &0xffe0 ) | env->cc_dest | (env->cc_x <<4 ); -#elif defined(TARGET_MICROBLAZE ) -#elif defined(TARGET_MIPS ) -#elif defined(TARGET_TRICORE ) -#elif defined(TARGET_MOXIE ) -#elif defined(TARGET_OPENRISC ) -#elif defined(TARGET_SH4 ) -#elif defined(TARGET_ALPHA ) -#elif defined(TARGET_CRIS ) -#elif defined(TARGET_S390X ) -#elif defined(TARGET_XTENSA ) -/* XXXXX */ #endif cc->cpu_exec_exit (cpu);
Signature · 1 line
Alex Bennée
PATCH 3/23 target-i386: Use cpu_exec_enter/exit qom hooks
In reply to Richard HendersonNote that the code that was within the "exit" ifdef block was identical to the cpu_compute_eflags inline, so make that simplification at the same time.
--- cpu-exec.c | 14 ++------------ target-i386/cpu-qom.h | 3 +++ target-i386/cpu.c | 2 ++ target-i386/helper.c | 21 +++++++++++++++++++++ 4 files changed, 28 insertions(+), 12 deletions(-)
cpu-exec.c +2 -12
@@ -352,13 +352,7 @@ int cpu_exec(CPUArchState *env) cpu->exit_request =1 ; } -#if defined(TARGET_I386 ) -/* put eflags in CPU temporary format */ -CC_SRC = env->eflags & (CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); - env->df =1 - (2 * ((env->eflags >>10 ) &1 )); -CC_OP =CC_OP_EFLAGS ; - env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); -#elif defined(TARGET_M68K ) +#if defined(TARGET_M68K ) env->cc_op =CC_OP_FLAGS ; env->cc_dest = env->sr &0xf ; env->cc_x = (env->sr >>4 ) &1 ;
@@ -811,11 +805,7 @@ int cpu_exec(CPUArchState *env) }/* for(;;) */ -#if defined(TARGET_I386 ) -/* restore flags in standard format */ - env->eflags = env->eflags |cpu_cc_compute_all (env,CC_OP ) - | (env->df &DF_MASK ); -#elif defined(TARGET_M68K ) +#if defined(TARGET_M68K )cpu_m68k_flush_flags (env, env->cc_op); env->cc_op =CC_OP_FLAGS ; env->sr = (env->sr &0xffe0 )
target-i386/cpu-qom.h +3 -0
@@ -151,4 +151,7 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);int x86_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int x86_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +void x86_cpu_exec_enter (CPUState *cpu); +void x86_cpu_exec_exit (CPUState *cpu); +#endif
target-i386/cpu.c +2 -0
@@ -2942,6 +2942,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->debug_excp_handler = breakpoint_handler;#endif + cc->cpu_exec_enter = x86_cpu_exec_enter; + cc->cpu_exec_exit = x86_cpu_exec_exit; }static const TypeInfo x86_cpu_type_info = {
target-i386/helper.c +21 -0
@@ -1262,3 +1262,24 @@ void do_cpu_sipi(X86CPU *cpu) { }#endif + +/* Frob eflags into and out of the CPU temporary format. */ + +void x86_cpu_exec_enter (CPUState *cs) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + +CC_SRC = env->eflags & (CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); + env->df =1 - (2 * ((env->eflags >>10 ) &1 )); +CC_OP =CC_OP_EFLAGS ; + env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); +} + +void x86_cpu_exec_exit (CPUState *cs) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + + env->eflags =cpu_compute_eflags (env); +}
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 03/23] target-i386: Use cpu_exec_enter/exit qom hooks
Quoted 5 lines · Richard Henderson
Note that the code that was within the "exit" ifdef block was identical to the
cpu_compute_eflagsinline, so make that simplification at the same time.Signed-off-by Richard Henderson <[email protected]>
Quoted 93 lines
--- cpu-exec.c | 14 ++------------ target-i386/cpu-qom.h | 3 +++ target-i386/cpu.c | 2 ++ target-i386/helper.c | 21 +++++++++++++++++++++ 4 files changed, 28 insertions(+), 12 deletions(-)cpu-exec.c +2
-12@@ -352,13 +352,7 @@ int cpu_exec(CPUArchState *env) cpu->exit_request =1 ; } -#if defined(TARGET_I386 ) -/* put eflags in CPU temporary format */ -CC_SRC = env->eflags & (CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); - env->df =1 - (2 * ((env->eflags >>10 ) &1 )); -CC_OP =CC_OP_EFLAGS ; - env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); -#elif defined(TARGET_M68K ) +#if defined(TARGET_M68K ) env->cc_op =CC_OP_FLAGS ; env->cc_dest = env->sr &0xf ; env->cc_x = (env->sr >>4 ) &1 ;@@ -811,11 +805,7 @@ int cpu_exec(CPUArchState *env) }/* for(;;) */ -#if defined(TARGET_I386 ) -/* restore flags in standard format */ - env->eflags = env->eflags |cpu_cc_compute_all (env,CC_OP ) - | (env->df &DF_MASK ); -#elif defined(TARGET_M68K ) +#if defined(TARGET_M68K )cpu_m68k_flush_flags (env, env->cc_op); env->cc_op =CC_OP_FLAGS ; env->sr = (env->sr &0xffe0 )target-i386/cpu-qom.h +3
-0@@ -151,4 +151,7 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);int x86_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int x86_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +void x86_cpu_exec_enter (CPUState *cpu); +void x86_cpu_exec_exit (CPUState *cpu); +#endif target-i386/cpu.c +2
-0@@ -2942,6 +2942,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)#ifndef CONFIG_USER_ONLY cc->debug_excp_handler = breakpoint_handler;#endif + cc->cpu_exec_enter = x86_cpu_exec_enter; + cc->cpu_exec_exit = x86_cpu_exec_exit; }static const TypeInfo x86_cpu_type_info = {target-i386/helper.c +21
-0@@ -1262,3 +1262,24 @@ void do_cpu_sipi(X86CPU *cpu) { }#endif + +/* Frob eflags into and out of the CPU temporary format. */ + +void x86_cpu_exec_enter (CPUState *cs) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + +CC_SRC = env->eflags & (CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); + env->df =1 - (2 * ((env->eflags >>10 ) &1 )); +CC_OP =CC_OP_EFLAGS ; + env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); +} + +void x86_cpu_exec_exit (CPUState *cs) +{ +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env; + + env->eflags =cpu_compute_eflags (env); +}
Signature · 1 line
Alex Bennée
PATCH 4/23 target-m68k: Use cpu_exec_enter/exit qom hooks
In reply to Richard Henderson--- cpu-exec.c | 13 +------------ target-m68k/cpu-qom.h | 3 +++ target-m68k/cpu.c | 3 +++ target-m68k/helper.c | 20 ++++++++++++++++++++ 4 files changed, 27 insertions(+), 12 deletions(-)
cpu-exec.c +1 -12
@@ -352,11 +352,7 @@ int cpu_exec(CPUArchState *env) cpu->exit_request =1 ; } -#if defined(TARGET_M68K ) - env->cc_op =CC_OP_FLAGS ; - env->cc_dest = env->sr &0xf ; - env->cc_x = (env->sr >>4 ) &1 ; -#elif defined(TARGET_PPC ) +#if defined(TARGET_PPC ) env->reserve_addr =-1 ;#endif cc->cpu_exec_enter (cpu);
@@ -804,13 +800,6 @@ int cpu_exec(CPUArchState *env) } }/* for(;;) */ - -#if defined(TARGET_M68K ) -cpu_m68k_flush_flags (env, env->cc_op); - env->cc_op =CC_OP_FLAGS ; - env->sr = (env->sr &0xffe0 ) - | env->cc_dest | (env->cc_x <<4 ); -#endif cc->cpu_exec_exit (cpu);/* fail safe : never use current_cpu outside cpu_exec() */
target-m68k/cpu-qom.h +3 -0
@@ -77,4 +77,7 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);int m68k_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int m68k_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +void m68k_cpu_exec_enter (CPUState *cs); +void m68k_cpu_exec_exit (CPUState *cs); +#endif
target-m68k/cpu.c +3 -0
@@ -205,6 +205,9 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data)#else cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug;#endif + cc->cpu_exec_enter = m68k_cpu_exec_enter; + cc->cpu_exec_exit = m68k_cpu_exec_exit; + dc->vmsd = &vmstate_m68k_cpu; cc->gdb_num_core_regs =18 ; cc->gdb_core_xml_file ="cf-core.xml" ;
target-m68k/helper.c +20 -0
@@ -864,3 +864,23 @@ void HELPER(set_mac_extu)(CPUM68KState *env, uint32_t val, uint32_t acc) res |= (uint64_t )(val &0xffff0000 ) <<16 ; env->macc[acc +1 ] = res; } + +void m68k_cpu_exec_enter (CPUState *cs) +{ +M68kCPU *cpu =M68K_CPU (cs); +CPUM68KState *env = &cpu->env; + + env->cc_op =CC_OP_FLAGS ; + env->cc_dest = env->sr &0xf ; + env->cc_x = (env->sr >>4 ) &1 ; +} + +void m68k_cpu_exec_exit (CPUState *cs) +{ +M68kCPU *cpu =M68K_CPU (cs); +CPUM68KState *env = &cpu->env; + +cpu_m68k_flush_flags (env, env->cc_op); + env->cc_op =CC_OP_FLAGS ; + env->sr = (env->sr &0xffe0 ) | env->cc_dest | (env->cc_x <<4 ); +}
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 04/23] target-m68k: Use cpu_exec_enter/exit qom hooks
Quoted 2 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>---
<snip>
Quoted 9 lines
target-m68k/helper.c +9
-0+void m68k_cpu_exec_enter (CPUState *cs) +{ +M68kCPU *cpu =M68K_CPU (cs); +CPUM68KState *env = &cpu->env; + + env->cc_op =CC_OP_FLAGS ; + env->cc_dest = env->sr &0xf ; + env->cc_x = (env->sr >>4 ) &1 ; +}
target-m68k/helper.c void HELPER(set_mac_extu)(CPUM68KState *env, uint32_t val, uint32_t acc) · line 886
Quoted 10 lines
target-m68k/helper.c +10
-0+ +void m68k_cpu_exec_exit (CPUState *cs) +{ +M68kCPU *cpu =M68K_CPU (cs); +CPUM68KState *env = &cpu->env; + +cpu_m68k_flush_flags (env, env->cc_op); + env->cc_op =CC_OP_FLAGS ; + env->sr = (env->sr &0xffe0 ) | env->cc_dest | (env->cc_x <<4 ); +}
It would have been nice to replace the magic numbers with some define's but seeing as the changes are mechanical so far best not get too fancy in this series ;-)
Signature · 1 line
Alex Bennée
PATCH 5/23 target-ppc: Use cpu_exec_enter qom hook
In reply to Richard Henderson--- cpu-exec.c | 3 --- target-ppc/translate_init.c | 9 +++++++++ 2 files changed, 9 insertions(+), 3 deletions(-)
cpu-exec.c +0 -3
@@ -352,9 +352,6 @@ int cpu_exec(CPUArchState *env) cpu->exit_request =1 ; } -#if defined(TARGET_PPC ) - env->reserve_addr =-1 ; -#endif cc->cpu_exec_enter (cpu); cpu->exception_index =-1 ;
target-ppc/translate_init.c +9 -0
@@ -9456,6 +9456,14 @@ static bool ppc_cpu_has_work(CPUState *cs)return msr_ee && (cs->interrupt_request &CPU_INTERRUPT_HARD ); } +static void ppc_cpu_exec_enter (CPUState *cs) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env; + + env->reserve_addr =-1 ; +} +/* CPUClass::reset() */ static void ppc_cpu_reset (CPUState *s) {
@@ -9638,6 +9646,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->write_elf64_qemunote = ppc64_cpu_write_elf64_qemunote;#endif #endif + cc->cpu_exec_enter = ppc_cpu_exec_enter; cc->gdb_num_core_regs =71 ;
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 05/23] target-ppc: Use cpu_exec_enter qom hook
Quoted 2 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>
<snip>
target-ppc/translate_init.c static bool ppc_cpu_has_work(CPUState *cs) · line 9463
Quoted 5 lines
target-ppc/translate_init.c +5
-0+static void ppc_cpu_exec_enter (CPUState *cs) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env; +
Ok the naming of those structures and the order to traverse them gets confusing - is it really CPUState -> ${ARCH}CPU -> ${ARCH}CPUState?
Anyway...
Quoted 13 lines
target-ppc/translate_init.c +4
-0+ env->reserve_addr =-1 ; +} +/* CPUClass::reset() */ static void ppc_cpu_reset (CPUState *s) {@@ -9638,6 +9646,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->write_elf64_qemunote = ppc64_cpu_write_elf64_qemunote;#endif #endif + cc->cpu_exec_enter = ppc_cpu_exec_enter; cc->gdb_num_core_regs =71 ;
Signature · 1 line
Alex Bennée
Re: [Qemu-devel] [PATCH 05/23] target-ppc: Use cpu_exec_enter qom hook
Quoted 6 lines · Alex Bennée
Quoted 2 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]><snip>
Quoted 8 lines
target-ppc/translate_init.c static bool ppc_cpu_has_work(CPUState *cs) · line 9463
Quoted 5 lines
target-ppc/translate_init.c +5
-0+static void ppc_cpu_exec_enter (CPUState *cs) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env; +Ok the naming of those structures and the order to traverse them gets confusing - is it really CPUState -> ${ARCH}CPU -> ${ARCH}CPUState?
CPUState is the QOM base class name. The
subclass names are ${ARCH}CPU. CPU${ARCH}State
is the name of the "env struct" which is embedded within the ${ARCH}CPU struct (but not at the start of it).
The available conversions are:
${ARCH}CPU to CPUState : CPU(x)
CPUState to ${ARCH}CPU : ${ARCH}_CPU(cs)
(these are just the stock QOM casting macros)
${ARCH}CPU to env: &cpu->env
env to ${ARCH}CPU: ${arch}_env_get_cpu(env)
(the latter is just a container_of operation)
env to CPUState: ENV_GET_CPU(env) CPUState to env: convert via ${ARCH}_CPU
(and actually ENV_GET_CPU is just sugar for a conversion via ${ARCH}_CPU)
As a method on the base QOM CPU class, this family of functions is correctly taking CPUState* as the argument.
-- PMM
PATCH 6/23 qom: Add cpu_exec_interrupt hook
In reply to Richard HendersonContinuing the removal of ifdefs from cpu_exec.
--- cpu-exec.c | 14 +++++++++----- include/qom/cpu.h | 2 ++ qom/cpu.c | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-)
cpu-exec.c +9 -5
@@ -676,8 +676,15 @@ int cpu_exec(CPUArchState *env) next_tb = 0; }#endif -/* Don't use the cached interrupt_request value, -do_interrupt may have updated the EXITTB flag. */ +/* The target hook has 3 exit conditions: +False when the interrupt isn't processed, +True when it is, and we should restart on a new TB, +and via longjmp via cpu_loop_exit. */ +if (cc->cpu_exec_interrupt (cpu, interrupt_request)) { + next_tb =0 ; + } +/* Don't use the cached interrupt_request value, +do_interrupt may have updated the EXITTB flag. */ if (cpu->interrupt_request &CPU_INTERRUPT_EXITTB ) { cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB ;/* ensure that no TB jump will be modified as
@@ -783,10 +790,7 @@ int cpu_exec(CPUArchState *env)* local variables as longjmp is marked 'noreturn'. */ cpu = current_cpu; env = cpu->env_ptr; -#if !(defined(CONFIG_USER_ONLY ) && \ - (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X ))) cc =CPU_GET_CLASS (cpu); -#endif #ifdef TARGET_I386 x86_cpu =X86_CPU (cpu);#endif
include/qom/cpu.h +2 -0
@@ -101,6 +101,7 @@ struct TranslationBlock;* @gdb_core_xml_file: File name for core registers GDB XML description. * @cpu_exec_enter: Callback for cpu_exec preparation. * @cpu_exec_exit: Callback for cpu_exec cleanup. +* @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec. * * Represents a CPU family or model. */
@@ -154,6 +155,7 @@ typedef struct CPUClass {void (*cpu_exec_enter)(CPUState *cpu);void (*cpu_exec_exit)(CPUState *cpu); +bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); } CPUClass;#ifdef HOST_WORDS_BIGENDIAN
qom/cpu.c +6 -0
@@ -206,6 +206,11 @@ static void cpu_common_noop(CPUState *cpu) { } +static bool cpu_common_exec_interrupt (CPUState *cpu,int int_req) +{ +return false; +} +void cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags) {
@@ -347,6 +352,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->debug_excp_handler = cpu_common_noop; k->cpu_exec_enter = cpu_common_noop; k->cpu_exec_exit = cpu_common_noop; + k->cpu_exec_interrupt = cpu_common_exec_interrupt; dc->realize = cpu_common_realizefn;/* * Reason: CPUs still need special care by board code: wiring up
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 06/23] qom: Add cpu_exec_interrupt hook
Quoted 9 lines · Richard Henderson
Continuing the removal of ifdefs from
cpu_exec.Cc Andreas Färber <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- cpu-exec.c | 14 +++++++++----- include/qom/cpu.h | 2 ++ qom/cpu.c | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-)
Signature · 2 lines
Thanks. -- Max
Re: [Qemu-devel] [PATCH 06/23] qom: Add cpu_exec_interrupt hook
In reply to Richard HendersonQuoted 4 lines · Richard Henderson
Continuing the removal of ifdefs from
cpu_exec.Cc Andreas Färber <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Quoted 83 lines
--- cpu-exec.c | 14 +++++++++----- include/qom/cpu.h | 2 ++ qom/cpu.c | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-)cpu-exec.c +9
-5@@ -676,8 +676,15 @@ int cpu_exec(CPUArchState *env) next_tb = 0; }#endif -/* Don't use the cached interrupt_request value, -do_interrupt may have updated the EXITTB flag. */ +/* The target hook has 3 exit conditions: +False when the interrupt isn't processed, +True when it is, and we should restart on a new TB, +and via longjmp via cpu_loop_exit. */ +if (cc->cpu_exec_interrupt (cpu, interrupt_request)) { + next_tb =0 ; + } +/* Don't use the cached interrupt_request value, +do_interrupt may have updated the EXITTB flag. */ if (cpu->interrupt_request &CPU_INTERRUPT_EXITTB ) { cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB ;/* ensure that no TB jump will be modified as @@ -783,10 +790,7 @@ int cpu_exec(CPUArchState *env)* local variables as longjmp is marked 'noreturn'. */ cpu = current_cpu; env = cpu->env_ptr; -#if !(defined(CONFIG_USER_ONLY ) && \ - (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X ))) cc =CPU_GET_CLASS (cpu); -#endif #ifdef TARGET_I386 x86_cpu =X86_CPU (cpu);#endif include/qom/cpu.h +2
-0@@ -101,6 +101,7 @@ struct TranslationBlock;* @gdb_core_xml_file: File name for core registers GDB XML description. * @cpu_exec_enter: Callback for cpu_exec preparation. * @cpu_exec_exit: Callback for cpu_exec cleanup. +* @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec. * * Represents a CPU family or model. */ @@ -154,6 +155,7 @@ typedef struct CPUClass {void (*cpu_exec_enter)(CPUState *cpu);void (*cpu_exec_exit)(CPUState *cpu); +bool (*cpu_exec_interrupt)(CPUState *cpu,int interrupt_request); } CPUClass;#ifdef HOST_WORDS_BIGENDIAN qom/cpu.c +6
-0@@ -206,6 +206,11 @@ static void cpu_common_noop(CPUState *cpu) { } +static bool cpu_common_exec_interrupt (CPUState *cpu,int int_req) +{ +return false; +} +void cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags) {@@ -347,6 +352,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->debug_excp_handler = cpu_common_noop; k->cpu_exec_enter = cpu_common_noop; k->cpu_exec_exit = cpu_common_noop; + k->cpu_exec_interrupt = cpu_common_exec_interrupt; dc->realize = cpu_common_realizefn;/* * Reason: CPUs still need special care by board code: wiring up
Signature · 1 line
Alex Bennée
PATCH 7/23 target-xtensa: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 6 ------ target-xtensa/cpu-qom.h | 1 + target-xtensa/cpu.c | 1 + target-xtensa/helper.c | 10 ++++++++++ 4 files changed, 12 insertions(+), 6 deletions(-)
cpu-exec.c +0 -6
@@ -669,12 +669,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } -#elif defined(TARGET_XTENSA) -if (interrupt_request &CPU_INTERRUPT_HARD ) { - cpu->exception_index =EXC_IRQ ; - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-xtensa/cpu-qom.h +1 -0
@@ -84,6 +84,7 @@ static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env)#define ENV_OFFSET offsetof(XtensaCPU, env)void xtensa_cpu_do_interrupt (CPUState *cpu); +bool xtensa_cpu_exec_interrupt (CPUState *cpu,int interrupt_request);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);
target-xtensa/cpu.c +1 -0
@@ -142,6 +142,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = xtensa_cpu_class_by_name; cc->has_work = xtensa_cpu_has_work; cc->do_interrupt = xtensa_cpu_do_interrupt; + cc->cpu_exec_interrupt = xtensa_cpu_exec_interrupt; cc->dump_state = xtensa_cpu_dump_state; cc->set_pc = xtensa_cpu_set_pc; cc->gdb_read_register = xtensa_cpu_gdb_read_register;
target-xtensa/helper.c +10 -0
@@ -256,6 +256,16 @@ void xtensa_cpu_do_interrupt(CPUState *cs)check_interrupts (env); } +bool xtensa_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +if (interrupt_request &CPU_INTERRUPT_HARD ) { + cs->exception_index =EXC_IRQ ; +xtensa_cpu_do_interrupt (cs); +return true; + } +return false; +} +static void reset_tlb_mmu_all_ways (CPUXtensaState *env,const xtensa_tlb *tlb,xtensa_tlb_entry entry[][MAX_TLB_WAY_SIZE ]) {
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 07/23] target-xtensa: Use cpu_exec_interrupt qom hook
Quoted 8 lines · Richard Henderson
Cc Max Filippov <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- cpu-exec.c | 6 ------ target-xtensa/cpu-qom.h | 1 + target-xtensa/cpu.c | 1 + target-xtensa/helper.c | 10 ++++++++++ 4 files changed, 12 insertions(+), 6 deletions(-)
Signature · 2 lines
Thanks. -- Max
Re: [Qemu-devel] [PATCH 07/23] target-xtensa: Use cpu_exec_interrupt qom hook
In reply to Richard HendersonQuoted 2 lines · Richard Henderson
Cc Max Filippov <[email protected]>Signed-off-by Richard Henderson <[email protected]>
<snip>
Quoted 11 lines
cpu-exec.c +0
-6@@ -669,12 +669,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } -#elif defined(TARGET_XTENSA) -if (interrupt_request &CPU_INTERRUPT_HARD ) { - cpu->exception_index =EXC_IRQ ; - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif
<snip>
Quoted 3 lines
void
xtensa_cpu_do_interrupt(CPUState *cpu);
+boolxtensa_cpu_exec_interrupt(CPUState *cpu, int interrupt_request);
<snip>
Quoted 2 lines
cc->do_interrupt = xtensa_cpu_do_interrupt;+
cc->cpu_exec_interrupt=xtensa_cpu_exec_interrupt;
<snip>
target-xtensa/helper.c void xtensa_cpu_do_interrupt(CPUState *cs) · line 266
Quoted 9 lines
target-xtensa/helper.c +8
-0+bool xtensa_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +if (interrupt_request &CPU_INTERRUPT_HARD ) { + cs->exception_index =EXC_IRQ ; +xtensa_cpu_do_interrupt (cs); +return true; + } +return false;
<snip>
Do this mean when all this unwinding has occured cc->do_interrupt will no longer be needed at all entries will go in via $ARCH_cpu_exec_interrupt?
Signature · 1 line
Alex Bennée
Re: [Qemu-devel] [PATCH 07/23] target-xtensa: Use cpu_exec_interrupt qom hook
Quoted 3 lines · Alex Bennée
Do this mean when all this unwinding has occured
cc->do_interruptwill no longer be needed at all entries will go in via $ARCH_cpu_exec_interrupt?
No.
Don't forget the call to do_interrupt in the block immediately following the sigsetjmp. And even ignoring that, some targets (like arm) have several different settings for do_interrupt, while they share a cpu_exec_interrupt hook.
r~
PATCH 8/23 target-s390x: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 6 ------ target-s390x/cpu-qom.h | 1 + target-s390x/cpu.c | 1 + target-s390x/helper.c | 13 +++++++++++++ 4 files changed, 15 insertions(+), 6 deletions(-)
cpu-exec.c +0 -6
@@ -663,12 +663,6 @@ int cpu_exec(CPUArchState *env)do_interrupt_m68k_hardirq (env); next_tb = 0; } -#elif defined(TARGET_S390X) && !defined(CONFIG_USER_ONLY) -if ((interrupt_request &CPU_INTERRUPT_HARD ) && - (env->psw.mask &PSW_MASK_EXT )) { - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-s390x/cpu-qom.h +1 -0
@@ -78,6 +78,7 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env)#define ENV_OFFSET offsetof(S390CPU, env)void s390_cpu_do_interrupt (CPUState *cpu); +bool s390_cpu_exec_interrupt (CPUState *cpu,int int_req);void s390_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
target-s390x/cpu.c +1 -0
@@ -262,6 +262,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->write_elf64_note = s390_cpu_write_elf64_note; cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote; + cc->cpu_exec_interrupt = s390_cpu_exec_interrupt;#endif dc->vmsd = &vmstate_s390_cpu; cc->gdb_num_core_regs =S390_NUM_CORE_REGS ;
target-s390x/helper.c +13 -0
@@ -876,4 +876,17 @@ void s390_cpu_do_interrupt(CPUState *cs) } } +bool s390_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +if (interrupt_request &CPU_INTERRUPT_HARD ) { +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env; + +if (env->psw.mask &PSW_MASK_EXT ) { +s390_cpu_do_interrupt (cs); +return true; + } + } +return false; +}#endif /* CONFIG_USER_ONLY */
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 08/23] target-s390x: Use cpu_exec_interrupt qom hook
Quoted 2 lines · Richard Henderson
Cc Alexander Graf <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Quoted 70 lines
--- cpu-exec.c | 6 ------ target-s390x/cpu-qom.h | 1 + target-s390x/cpu.c | 1 + target-s390x/helper.c | 13 +++++++++++++ 4 files changed, 15 insertions(+), 6 deletions(-)cpu-exec.c +0
-6@@ -663,12 +663,6 @@ int cpu_exec(CPUArchState *env)do_interrupt_m68k_hardirq (env); next_tb = 0; } -#elif defined(TARGET_S390X) && !defined(CONFIG_USER_ONLY) -if ((interrupt_request &CPU_INTERRUPT_HARD ) && - (env->psw.mask &PSW_MASK_EXT )) { - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed, target-s390x/cpu-qom.h +1
-0@@ -78,6 +78,7 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env)#define ENV_OFFSET offsetof(S390CPU, env)void s390_cpu_do_interrupt (CPUState *cpu); +bool s390_cpu_exec_interrupt (CPUState *cpu,int int_req);void s390_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,target-s390x/cpu.c +1
-0@@ -262,6 +262,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->write_elf64_note = s390_cpu_write_elf64_note; cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote; + cc->cpu_exec_interrupt = s390_cpu_exec_interrupt;#endif dc->vmsd = &vmstate_s390_cpu; cc->gdb_num_core_regs =S390_NUM_CORE_REGS ;target-s390x/helper.c +13
-0@@ -876,4 +876,17 @@ void s390_cpu_do_interrupt(CPUState *cs) } } +bool s390_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +if (interrupt_request &CPU_INTERRUPT_HARD ) { +S390CPU *cpu =S390_CPU (cs); +CPUS390XState *env = &cpu->env; + +if (env->psw.mask &PSW_MASK_EXT ) { +s390_cpu_do_interrupt (cs); +return true; + } + } +return false; +}#endif /* CONFIG_USER_ONLY */
Signature · 1 line
Alex Bennée
PATCH 9/23 target-m68k: Use cpu_exec_interrupt qom hook
In reply to Richard HendersonSince do_interrupt_m68k_hardirq is no longer used outside op_helper.c, make it static.
--- cpu-exec.c | 13 ------------- target-m68k/cpu-qom.h | 1 + target-m68k/cpu.c | 1 + target-m68k/cpu.h | 1 - target-m68k/op_helper.c | 22 ++++++++++++++++++++-- 5 files changed, 22 insertions(+), 16 deletions(-)
cpu-exec.c +0 -13
@@ -650,19 +650,6 @@ int cpu_exec(CPUArchState *env) next_tb = 0; } } -#elif defined(TARGET_M68K) -if (interrupt_request &CPU_INTERRUPT_HARD - && ((env->sr &SR_I ) >>SR_I_SHIFT ) - < env->pending_level) { -/* Real hardware gets the interrupt vector via an -IACK cycle at this point. Current emulated -hardware doesn't rely on this, so we -provide/save the vector when the interrupt is -first signalled. */ - cpu->exception_index = env->pending_vector; -do_interrupt_m68k_hardirq (env); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-m68k/cpu-qom.h +1 -0
@@ -71,6 +71,7 @@ static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env)#define ENV_OFFSET offsetof(M68kCPU, env)void m68k_cpu_do_interrupt (CPUState *cpu); +bool m68k_cpu_exec_interrupt (CPUState *cpu,int int_req);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);
target-m68k/cpu.c +1 -0
@@ -196,6 +196,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = m68k_cpu_class_by_name; cc->has_work = m68k_cpu_has_work; cc->do_interrupt = m68k_cpu_do_interrupt; + cc->cpu_exec_interrupt = m68k_cpu_exec_interrupt; cc->dump_state = m68k_cpu_dump_state; cc->set_pc = m68k_cpu_set_pc; cc->gdb_read_register = m68k_cpu_gdb_read_register;
target-m68k/cpu.h +0 -1
@@ -120,7 +120,6 @@ void m68k_tcg_init(void);void m68k_cpu_init_gdb (M68kCPU *cpu);M68kCPU *cpu_m68k_init (const char *cpu_model);int cpu_m68k_exec (CPUM68KState *s); -void do_interrupt_m68k_hardirq (CPUM68KState *env1);/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */
target-m68k/op_helper.c +20 -2
@@ -27,7 +27,7 @@ void m68k_cpu_do_interrupt(CPUState *cs) cs->exception_index =-1 ; } -void do_interrupt_m68k_hardirq (CPUM68KState *env) +static inline void do_interrupt_m68k_hardirq (CPUM68KState *env) { }
@@ -141,12 +141,30 @@ void m68k_cpu_do_interrupt(CPUState *cs) do_interrupt_all(env, 0); } -void do_interrupt_m68k_hardirq (CPUM68KState *env) +static inline void do_interrupt_m68k_hardirq (CPUM68KState *env) {do_interrupt_all (env,1 ); }#endif +bool m68k_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +M68kCPU *cpu =M68K_CPU (cs); +CPUM68KState *env = &cpu->env; + +if (interrupt_request &CPU_INTERRUPT_HARD + && ((env->sr &SR_I ) >>SR_I_SHIFT ) < env->pending_level) { +/* Real hardware gets the interrupt vector via an IACK cycle +at this point. Current emulated hardware doesn't rely on +this, so we provide/save the vector when the interrupt is +first signalled. */ + cs->exception_index = env->pending_vector; +do_interrupt_m68k_hardirq (env); +return true; + } +return false; +} +static void raise_exception (CPUM68KState *env,int tt) {CPUState *cs =CPU (m68k_env_get_cpu (env));
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 09/23] target-m68k: Use cpu_exec_interrupt qom hook
Quoted 4 lines · Richard Henderson
Since
do_interrupt_m68k_hardirqis no longer used outsideop_helper.c, make it static.Signed-off-by Richard Henderson <[email protected]>
Quoted 113 lines
--- cpu-exec.c | 13 ------------- target-m68k/cpu-qom.h | 1 + target-m68k/cpu.c | 1 + target-m68k/cpu.h | 1 - target-m68k/op_helper.c | 22 ++++++++++++++++++++-- 5 files changed, 22 insertions(+), 16 deletions(-)cpu-exec.c +0
-13@@ -650,19 +650,6 @@ int cpu_exec(CPUArchState *env) next_tb = 0; } } -#elif defined(TARGET_M68K) -if (interrupt_request &CPU_INTERRUPT_HARD - && ((env->sr &SR_I ) >>SR_I_SHIFT ) - < env->pending_level) { -/* Real hardware gets the interrupt vector via an -IACK cycle at this point. Current emulated -hardware doesn't rely on this, so we -provide/save the vector when the interrupt is -first signalled. */ - cpu->exception_index = env->pending_vector; -do_interrupt_m68k_hardirq (env); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed, target-m68k/cpu-qom.h +1
-0@@ -71,6 +71,7 @@ static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env)#define ENV_OFFSET offsetof(M68kCPU, env)void m68k_cpu_do_interrupt (CPUState *cpu); +bool m68k_cpu_exec_interrupt (CPUState *cpu,int int_req);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);target-m68k/cpu.c +1
-0@@ -196,6 +196,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = m68k_cpu_class_by_name; cc->has_work = m68k_cpu_has_work; cc->do_interrupt = m68k_cpu_do_interrupt; + cc->cpu_exec_interrupt = m68k_cpu_exec_interrupt; cc->dump_state = m68k_cpu_dump_state; cc->set_pc = m68k_cpu_set_pc; cc->gdb_read_register = m68k_cpu_gdb_read_register;target-m68k/cpu.h +0
-1@@ -120,7 +120,6 @@ void m68k_tcg_init(void);void m68k_cpu_init_gdb (M68kCPU *cpu);M68kCPU *cpu_m68k_init (const char *cpu_model);int cpu_m68k_exec (CPUM68KState *s); -void do_interrupt_m68k_hardirq (CPUM68KState *env1);/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */ target-m68k/op_helper.c +20
-2@@ -27,7 +27,7 @@ void m68k_cpu_do_interrupt(CPUState *cs) cs->exception_index =-1 ; } -void do_interrupt_m68k_hardirq (CPUM68KState *env) +static inline void do_interrupt_m68k_hardirq (CPUM68KState *env) { }@@ -141,12 +141,30 @@ void m68k_cpu_do_interrupt(CPUState *cs) do_interrupt_all(env, 0); } -void do_interrupt_m68k_hardirq (CPUM68KState *env) +static inline void do_interrupt_m68k_hardirq (CPUM68KState *env) {do_interrupt_all (env,1 ); }#endif +bool m68k_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +M68kCPU *cpu =M68K_CPU (cs); +CPUM68KState *env = &cpu->env; + +if (interrupt_request &CPU_INTERRUPT_HARD + && ((env->sr &SR_I ) >>SR_I_SHIFT ) < env->pending_level) { +/* Real hardware gets the interrupt vector via an IACK cycle +at this point. Current emulated hardware doesn't rely on +this, so we provide/save the vector when the interrupt is +first signalled. */ + cs->exception_index = env->pending_vector; +do_interrupt_m68k_hardirq (env); +return true; + } +return false; +} +static void raise_exception (CPUM68KState *env,int tt) {CPUState *cs =CPU (m68k_env_get_cpu (env));
Signature · 1 line
Alex Bennée
PATCH 10/23 target-cris: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 21 --------------------- target-cris/cpu-qom.h | 1 + target-cris/cpu.c | 1 + target-cris/helper.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 21 deletions(-)
cpu-exec.c +0 -21
@@ -629,27 +629,6 @@ int cpu_exec(CPUArchState *env) next_tb = 0; } } -#elif defined(TARGET_CRIS) -if (interrupt_request &CPU_INTERRUPT_HARD - && (env->pregs[PR_CCS ] &I_FLAG ) - && !env->locked_irq) { - cpu->exception_index =EXCP_IRQ ; - cc->do_interrupt (cpu); - next_tb =0 ; - } -if (interrupt_request &CPU_INTERRUPT_NMI ) { -unsigned int m_flag_archval; -if (env->pregs[PR_VR ] <32 ) { - m_flag_archval =M_FLAG_V10 ; - }else { - m_flag_archval =M_FLAG_V32 ; - } -if ((env->pregs[PR_CCS ] & m_flag_archval)) { - cpu->exception_index =EXCP_NMI ; - cc->do_interrupt (cpu); - next_tb =0 ; - } - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-cris/cpu-qom.h +1 -0
@@ -75,6 +75,7 @@ static inline CRISCPU *cris_env_get_cpu(CPUCRISState *env)void cris_cpu_do_interrupt (CPUState *cpu);void crisv10_cpu_do_interrupt (CPUState *cpu); +bool cris_cpu_exec_interrupt (CPUState *cpu,int int_req);void cris_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf,int flags);
target-cris/cpu.c +1 -0
@@ -279,6 +279,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = cris_cpu_class_by_name; cc->has_work = cris_cpu_has_work; cc->do_interrupt = cris_cpu_do_interrupt; + cc->cpu_exec_interrupt = cris_cpu_exec_interrupt; cc->dump_state = cris_cpu_dump_state; cc->set_pc = cris_cpu_set_pc; cc->gdb_read_register = cris_cpu_gdb_read_register;
target-cris/helper.c +31 -0
@@ -283,3 +283,34 @@ hwaddr cris_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return phy; }#endif + +bool cris_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +CPUClass *cc =CPU_GET_CLASS (cs); +CRISCPU *cpu =CRIS_CPU (cs); +CPUCRISState *env = &cpu->env; +bool ret = false; + +if (interrupt_request &CPU_INTERRUPT_HARD + && (env->pregs[PR_CCS ] &I_FLAG ) + && !env->locked_irq) { + cs->exception_index =EXCP_IRQ ; + cc->do_interrupt (cs); + ret = true; + } +if (interrupt_request &CPU_INTERRUPT_NMI ) { +unsigned int m_flag_archval; +if (env->pregs[PR_VR ] <32 ) { + m_flag_archval =M_FLAG_V10 ; + }else { + m_flag_archval =M_FLAG_V32 ; + } +if ((env->pregs[PR_CCS ] & m_flag_archval)) { + cs->exception_index =EXCP_NMI ; + cc->do_interrupt (cs); + ret = true; + } + } + +return ret; +}
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 10/23] target-cris: Use cpu_exec_interrupt qom hook
Quoted 2 lines · Richard Henderson
Cc Edgar E. Iglesias <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Both CRIS and MicroBlaze look good, thanks.
Quoted 105 lines
--- cpu-exec.c | 21 --------------------- target-cris/cpu-qom.h | 1 + target-cris/cpu.c | 1 + target-cris/helper.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 21 deletions(-)cpu-exec.c +0
-21@@ -629,27 +629,6 @@ int cpu_exec(CPUArchState *env) next_tb = 0; } } -#elif defined(TARGET_CRIS) -if (interrupt_request &CPU_INTERRUPT_HARD - && (env->pregs[PR_CCS ] &I_FLAG ) - && !env->locked_irq) { - cpu->exception_index =EXCP_IRQ ; - cc->do_interrupt (cpu); - next_tb =0 ; - } -if (interrupt_request &CPU_INTERRUPT_NMI ) { -unsigned int m_flag_archval; -if (env->pregs[PR_VR ] <32 ) { - m_flag_archval =M_FLAG_V10 ; - }else { - m_flag_archval =M_FLAG_V32 ; - } -if ((env->pregs[PR_CCS ] & m_flag_archval)) { - cpu->exception_index =EXCP_NMI ; - cc->do_interrupt (cpu); - next_tb =0 ; - } - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed, target-cris/cpu-qom.h +1
-0@@ -75,6 +75,7 @@ static inline CRISCPU *cris_env_get_cpu(CPUCRISState *env)void cris_cpu_do_interrupt (CPUState *cpu);void crisv10_cpu_do_interrupt (CPUState *cpu); +bool cris_cpu_exec_interrupt (CPUState *cpu,int int_req);void cris_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf,int flags);target-cris/cpu.c +1
-0@@ -279,6 +279,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = cris_cpu_class_by_name; cc->has_work = cris_cpu_has_work; cc->do_interrupt = cris_cpu_do_interrupt; + cc->cpu_exec_interrupt = cris_cpu_exec_interrupt; cc->dump_state = cris_cpu_dump_state; cc->set_pc = cris_cpu_set_pc; cc->gdb_read_register = cris_cpu_gdb_read_register;target-cris/helper.c +31
-0@@ -283,3 +283,34 @@ hwaddr cris_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)return phy; }#endif + +bool cris_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +CPUClass *cc =CPU_GET_CLASS (cs); +CRISCPU *cpu =CRIS_CPU (cs); +CPUCRISState *env = &cpu->env; +bool ret = false; + +if (interrupt_request &CPU_INTERRUPT_HARD + && (env->pregs[PR_CCS ] &I_FLAG ) + && !env->locked_irq) { + cs->exception_index =EXCP_IRQ ; + cc->do_interrupt (cs); + ret = true; + } +if (interrupt_request &CPU_INTERRUPT_NMI ) { +unsigned int m_flag_archval; +if (env->pregs[PR_VR ] <32 ) { + m_flag_archval =M_FLAG_V10 ; + }else { + m_flag_archval =M_FLAG_V32 ; + } +if ((env->pregs[PR_CCS ] & m_flag_archval)) { + cs->exception_index =EXCP_NMI ; + cc->do_interrupt (cs); + ret = true; + } + } + +return ret; +}Signature · 1 line
1.9.3
PATCH 11/23 target-alpha: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 32 -------------------------------- target-alpha/cpu-qom.h | 1 + target-alpha/cpu.c | 1 + target-alpha/helper.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 32 deletions(-)
cpu-exec.c +0 -32
@@ -597,38 +597,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } -#elif defined(TARGET_ALPHA ) - { -int idx =-1 ; -/* ??? This hard-codes the OSF/1 interrupt levels. */ -switch (env->pal_mode ?7 : env->ps &PS_INT_MASK ) { - case 0 ... 3: -if (interrupt_request &CPU_INTERRUPT_HARD ) { - idx =EXCP_DEV_INTERRUPT ; - } -/* FALLTHRU */ -case 4 : -if (interrupt_request &CPU_INTERRUPT_TIMER ) { - idx =EXCP_CLK_INTERRUPT ; - } -/* FALLTHRU */ -case 5 : -if (interrupt_request &CPU_INTERRUPT_SMP ) { - idx =EXCP_SMP_INTERRUPT ; - } -/* FALLTHRU */ -case 6 : -if (interrupt_request &CPU_INTERRUPT_MCHK ) { - idx =EXCP_MCHK ; - } - } -if (idx >=0 ) { - cpu->exception_index = idx; - env->error_code =0 ; - cc->do_interrupt (cpu); - next_tb =0 ; - } - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-alpha/cpu-qom.h +1 -0
@@ -79,6 +79,7 @@ extern const struct VMStateDescription vmstate_alpha_cpu;#endif void alpha_cpu_do_interrupt (CPUState *cpu); +bool alpha_cpu_exec_interrupt (CPUState *cpu,int int_req);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);
target-alpha/cpu.c +1 -0
@@ -284,6 +284,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = alpha_cpu_class_by_name; cc->has_work = alpha_cpu_has_work; cc->do_interrupt = alpha_cpu_do_interrupt; + cc->cpu_exec_interrupt = alpha_cpu_exec_interrupt; cc->dump_state = alpha_cpu_dump_state; cc->set_pc = alpha_cpu_set_pc; cc->gdb_read_register = alpha_cpu_gdb_read_register;
target-alpha/helper.c +44 -0
50 lines not on this page · raw message
Signature · 1 line
1.9.3
PATCH 12/23 target-sh4: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 5 ----- target-sh4/cpu-qom.h | 1 + target-sh4/cpu.c | 1 + target-sh4/helper.c | 9 +++++++++ 4 files changed, 11 insertions(+), 5 deletions(-)
cpu-exec.c +0 -5
@@ -592,11 +592,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } -#elif defined(TARGET_SH4) -if (interrupt_request &CPU_INTERRUPT_HARD ) { - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-sh4/cpu-qom.h +1 -0
@@ -84,6 +84,7 @@ static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env)#define ENV_OFFSET offsetof(SuperHCPU, env)void superh_cpu_do_interrupt (CPUState *cpu); +bool superh_cpu_exec_interrupt (CPUState *cpu,int int_req);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);
target-sh4/cpu.c +1 -0
@@ -276,6 +276,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = superh_cpu_class_by_name; cc->has_work = superh_cpu_has_work; cc->do_interrupt = superh_cpu_do_interrupt; + cc->cpu_exec_interrupt = superh_cpu_exec_interrupt; cc->dump_state = superh_cpu_dump_state; cc->set_pc = superh_cpu_set_pc; cc->synchronize_from_tb = superh_cpu_synchronize_from_tb;
target-sh4/helper.c +9 -0
@@ -863,3 +863,12 @@ int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr) }#endif + +bool superh_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +if (interrupt_request &CPU_INTERRUPT_HARD ) { +superh_cpu_do_interrupt (cs); +return true; + } +return false; +}
Signature · 1 line
1.9.3
PATCH 13/23 target-unicore32: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 7 ------- target-unicore32/cpu-qom.h | 1 + target-unicore32/cpu.c | 1 + target-unicore32/helper.c | 15 +++++++++++++++ 4 files changed, 17 insertions(+), 7 deletions(-)
cpu-exec.c +0 -7
@@ -585,13 +585,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } -#elif defined(TARGET_UNICORE32) -if (interrupt_request &CPU_INTERRUPT_HARD - && !(env->uncached_asr &ASR_I )) { - cpu->exception_index =UC32_EXCP_INTR ; - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-unicore32/cpu-qom.h +1 -0
@@ -61,6 +61,7 @@ static inline UniCore32CPU *uc32_env_get_cpu(CPUUniCore32State *env)#define ENV_OFFSET offsetof(UniCore32CPU, env)void uc32_cpu_do_interrupt (CPUState *cpu); +bool uc32_cpu_exec_interrupt (CPUState *cpu,int int_req);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);
target-unicore32/cpu.c +1 -0
@@ -146,6 +146,7 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = uc32_cpu_class_by_name; cc->has_work = uc32_cpu_has_work; cc->do_interrupt = uc32_cpu_do_interrupt; + cc->cpu_exec_interrupt = uc32_cpu_exec_interrupt; cc->dump_state = uc32_cpu_dump_state; cc->set_pc = uc32_cpu_set_pc;#ifdef CONFIG_USER_ONLY
target-unicore32/helper.c +15 -0
@@ -250,3 +250,18 @@ int uc32_cpu_handle_mmu_fault(CPUState *cs, vaddr address, return 1; }#endif + +bool uc32_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +if (interrupt_request &CPU_INTERRUPT_HARD ) { +UniCore32CPU *cpu =UNICORE32_CPU (cs); +CPUUniCore32State *env = &cpu->env; + +if (!(env->uncached_asr &ASR_I )) { + cs->exception_index =UC32_EXCP_INTR ; +uc32_cpu_do_interrupt (cs); +return true; + } + } +return false; +}
Signature · 1 line
1.9.3
PATCH 14/23 target-arm: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 23 ----------------------- target-arm/cpu-qom.h | 1 + target-arm/cpu.c | 34 ++++++++++++++++++++++++++++++++++ target-arm/cpu64.c | 1 + 4 files changed, 36 insertions(+), 23 deletions(-)
cpu-exec.c +0 -23
@@ -562,29 +562,6 @@ int cpu_exec(CPUArchState *env) } } } -#elif defined(TARGET_ARM) -if (interrupt_request &CPU_INTERRUPT_FIQ - && !(env->daif &PSTATE_F )) { - cpu->exception_index =EXCP_FIQ ; - cc->do_interrupt (cpu); - next_tb =0 ; - } -/* ARMv7-M interrupt return works by loading a magic value -into the PC. On real hardware the load causes the -return to occur. The qemu implementation performs the -jump normally, then does the exception return when the -CPU tries to execute code at the magic address. -This will cause the magic PC value to be pushed to -the stack if an interrupt occurred at the wrong time. -We avoid this by disabling interrupts when -pc contains a magic address. */ -if (interrupt_request &CPU_INTERRUPT_HARD - && !(env->daif &PSTATE_I ) - && (!IS_M (env) || env->regs[15 ] <0xfffffff0 )) { - cpu->exception_index =EXCP_IRQ ; - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-arm/cpu-qom.h +1 -0
@@ -192,6 +192,7 @@ void init_cpreg_list(ARMCPU *cpu);void arm_cpu_do_interrupt (CPUState *cpu);void arm_v7m_cpu_do_interrupt (CPUState *cpu); +bool arm_cpu_exec_interrupt (CPUState *cpu,int int_req);void arm_cpu_dump_state (CPUState *cs,FILE *f,fprintf_function cpu_fprintf,int flags);
target-arm/cpu.c +34 -0
@@ -188,6 +188,39 @@ static void arm_cpu_reset(CPUState *s)hw_watchpoint_update_all (cpu); } +bool arm_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +CPUClass *cc =CPU_GET_CLASS (cs); +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; +bool ret = false; + +if (interrupt_request &CPU_INTERRUPT_FIQ + && !(env->daif &PSTATE_F )) { + cs->exception_index =EXCP_FIQ ; + cc->do_interrupt (cs); + ret = true; + } +/* ARMv7-M interrupt return works by loading a magic value +into the PC. On real hardware the load causes the +return to occur. The qemu implementation performs the +jump normally, then does the exception return when the +CPU tries to execute code at the magic address. +This will cause the magic PC value to be pushed to +the stack if an interrupt occurred at the wrong time. +We avoid this by disabling interrupts when +pc contains a magic address. */ +if (interrupt_request &CPU_INTERRUPT_HARD + && !(env->daif &PSTATE_I ) + && (!IS_M (env) || env->regs[15 ] <0xfffffff0 )) { + cs->exception_index =EXCP_IRQ ; + cc->do_interrupt (cs); + ret = true; + } + +return ret; +} +#ifndef CONFIG_USER_ONLY static void arm_cpu_set_irq (void *opaque,int irq,int level) {
@@ -1053,6 +1086,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = arm_cpu_class_by_name; cc->has_work = arm_cpu_has_work; cc->do_interrupt = arm_cpu_do_interrupt; + cc->cpu_exec_interrupt = arm_cpu_exec_interrupt; cc->dump_state = arm_cpu_dump_state; cc->set_pc = arm_cpu_set_pc; cc->gdb_read_register = arm_cpu_gdb_read_register;
target-arm/cpu64.c +1 -0
@@ -197,6 +197,7 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data)CPUClass *cc =CPU_CLASS (oc); cc->do_interrupt = aarch64_cpu_do_interrupt; + cc->cpu_exec_interrupt = arm_cpu_exec_interrupt; cc->set_pc = aarch64_cpu_set_pc; cc->gdb_read_register = aarch64_cpu_gdb_read_register; cc->gdb_write_register = aarch64_cpu_gdb_write_register;
Signature · 1 line
1.9.3
PATCH 15/23 target-sparc: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 16 ---------------- target-sparc/cpu.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-)
cpu-exec.c +0 -16
@@ -546,22 +546,6 @@ int cpu_exec(CPUArchState *env) next_tb = 0; } } -#elif defined(TARGET_SPARC) -if (interrupt_request &CPU_INTERRUPT_HARD ) { -if (cpu_interrupts_enabled (env) && - env->interrupt_index >0 ) { -int pil = env->interrupt_index &0xf ; -int type = env->interrupt_index &0xf0 ; - -if (((type ==TT_EXTINT ) && -cpu_pil_allowed (env, pil)) || - type !=TT_EXTINT ) { - cpu->exception_index = env->interrupt_index; - cc->do_interrupt (cpu); - next_tb =0 ; - } - } - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-sparc/cpu.c +21 -0
@@ -70,6 +70,26 @@ static void sparc_cpu_reset(CPUState *s) env->cache_control =0 ; } +static bool sparc_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +if (interrupt_request &CPU_INTERRUPT_HARD ) { +SPARCCPU *cpu =SPARC_CPU (cs); +CPUSPARCState *env = &cpu->env; + +if (cpu_interrupts_enabled (env) && env->interrupt_index >0 ) { +int pil = env->interrupt_index &0xf ; +int type = env->interrupt_index &0xf0 ; + +if (type !=TT_EXTINT ||cpu_pil_allowed (env, pil)) { + cs->exception_index = env->interrupt_index; +sparc_cpu_do_interrupt (cs); +return true; + } + } + } +return false; +} +static int cpu_sparc_register (SPARCCPU *cpu,const char *cpu_model) {CPUClass *cc =CPU_GET_CLASS (cpu);
@@ -813,6 +833,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data) cc->parse_features = sparc_cpu_parse_features; cc->has_work = sparc_cpu_has_work; cc->do_interrupt = sparc_cpu_do_interrupt; + cc->cpu_exec_interrupt = sparc_cpu_exec_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;
Signature · 1 line
1.9.3
PATCH 16/23 target-openrisc: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 18 ------------------ target-openrisc/cpu.c | 1 + target-openrisc/cpu.h | 1 + target-openrisc/interrupt.c | 20 ++++++++++++++++++++ 4 files changed, 22 insertions(+), 18 deletions(-)
cpu-exec.c +0 -18
@@ -528,24 +528,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } - -#elif defined(TARGET_OPENRISC) - { -int idx =-1 ; -if ((interrupt_request &CPU_INTERRUPT_HARD ) - && (env->sr &SR_IEE )) { - idx =EXCP_INT ; - } -if ((interrupt_request &CPU_INTERRUPT_TIMER ) - && (env->sr &SR_TEE )) { - idx =EXCP_TICK ; - } -if (idx >=0 ) { - cpu->exception_index = idx; - cc->do_interrupt (cpu); - next_tb =0 ; - } - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-openrisc/cpu.c +1 -0
@@ -165,6 +165,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = openrisc_cpu_class_by_name; cc->has_work = openrisc_cpu_has_work; cc->do_interrupt = openrisc_cpu_do_interrupt; + cc->cpu_exec_interrupt = openrisc_cpu_exec_interrupt; cc->dump_state = openrisc_cpu_dump_state; cc->set_pc = openrisc_cpu_set_pc; cc->gdb_read_register = openrisc_cpu_gdb_read_register;
target-openrisc/cpu.h +1 -0
@@ -348,6 +348,7 @@ OpenRISCCPU *cpu_openrisc_init(const char *cpu_model);void cpu_openrisc_list (FILE *f,fprintf_function cpu_fprintf);int cpu_openrisc_exec (CPUOpenRISCState *s);void openrisc_cpu_do_interrupt (CPUState *cpu); +bool openrisc_cpu_exec_interrupt (CPUState *cpu,int int_req);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);
target-openrisc/interrupt.c +20 -0
@@ -63,3 +63,23 @@ void openrisc_cpu_do_interrupt(CPUState *cs) cs->exception_index =-1 ; } + +bool openrisc_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +OpenRISCCPU *cpu =OPENRISC_CPU (cs); +CPUOpenRISCState *env = &cpu->env; +int idx =-1 ; + +if ((interrupt_request &CPU_INTERRUPT_HARD ) && (env->sr &SR_IEE )) { + idx =EXCP_INT ; + } +if ((interrupt_request &CPU_INTERRUPT_TIMER ) && (env->sr &SR_TEE )) { + idx =EXCP_TICK ; + } +if (idx >=0 ) { + cs->exception_index = idx; +openrisc_cpu_do_interrupt (cs); +return true; + } +return false; +}
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 16/23] target-openrisc: Use cpu_exec_interrupt qom hook
Hi Richard,
Thank you!
Quoted 91 lines · Richard Henderson
Cc Jia Liu <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- cpu-exec.c | 18 ------------------ target-openrisc/cpu.c | 1 + target-openrisc/cpu.h | 1 + target-openrisc/interrupt.c | 20 ++++++++++++++++++++ 4 files changed, 22 insertions(+), 18 deletions(-)cpu-exec.c +0
-18@@ -528,24 +528,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } - -#elif defined(TARGET_OPENRISC) - { -int idx =-1 ; -if ((interrupt_request &CPU_INTERRUPT_HARD ) - && (env->sr &SR_IEE )) { - idx =EXCP_INT ; - } -if ((interrupt_request &CPU_INTERRUPT_TIMER ) - && (env->sr &SR_TEE )) { - idx =EXCP_TICK ; - } -if (idx >=0 ) { - cpu->exception_index = idx; - cc->do_interrupt (cpu); - next_tb =0 ; - } - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed, target-openrisc/cpu.c +1
-0@@ -165,6 +165,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = openrisc_cpu_class_by_name; cc->has_work = openrisc_cpu_has_work; cc->do_interrupt = openrisc_cpu_do_interrupt; + cc->cpu_exec_interrupt = openrisc_cpu_exec_interrupt; cc->dump_state = openrisc_cpu_dump_state; cc->set_pc = openrisc_cpu_set_pc; cc->gdb_read_register = openrisc_cpu_gdb_read_register;target-openrisc/cpu.h +1
-0@@ -348,6 +348,7 @@ OpenRISCCPU *cpu_openrisc_init(const char *cpu_model);void cpu_openrisc_list (FILE *f,fprintf_function cpu_fprintf);int cpu_openrisc_exec (CPUOpenRISCState *s);void openrisc_cpu_do_interrupt (CPUState *cpu); +bool openrisc_cpu_exec_interrupt (CPUState *cpu,int int_req);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);target-openrisc/interrupt.c +20
-1@@ -63,3 +63,23 @@ void openrisc_cpu_do_interrupt(CPUState *cs) cs->exception_index =-1 ; } + +bool openrisc_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +OpenRISCCPU *cpu =OPENRISC_CPU (cs); +CPUOpenRISCState *env = &cpu->env; +int idx =-1 ; + +if ((interrupt_request &CPU_INTERRUPT_HARD ) && (env->sr &SR_IEE )) { + idx =EXCP_INT ; + } +if ((interrupt_request &CPU_INTERRUPT_TIMER ) && (env->sr &SR_TEE )) { + idx =EXCP_TICK ; + } +if (idx >=0 ) { + cs->exception_index = idx; +openrisc_cpu_do_interrupt (cs); +return true; + } +return false; +} --
Quoted 2 lines
1.9.3
Regards,
Jia
PATCH 17/23 target-tricore: Remove the dummy interrupt boilerplate
In reply to Richard HendersonIt can go back in when it actually does something.
--- cpu-exec.c | 5 ----- target-tricore/cpu-qom.h | 1 - target-tricore/cpu.c | 1 - target-tricore/cpu.h | 2 -- target-tricore/helper.c | 4 ---- 5 files changed, 13 deletions(-)
cpu-exec.c +0 -5
@@ -523,11 +523,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } -#elif defined(TARGET_TRICORE) -if ((interrupt_request &CPU_INTERRUPT_HARD )) { - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-tricore/cpu-qom.h +0 -1
@@ -63,7 +63,6 @@ static inline TriCoreCPU *tricore_env_get_cpu(CPUTriCoreState *env)#define ENV_OFFSET offsetof(TriCoreCPU, env)hwaddr tricore_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); -void tricore_cpu_do_interrupt (CPUState *cpu);void tricore_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags);
target-tricore/cpu.c +0 -1
@@ -145,7 +145,6 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = tricore_cpu_class_by_name; cc->has_work = tricore_cpu_has_work; - cc->do_interrupt = tricore_cpu_do_interrupt; cc->dump_state = tricore_cpu_dump_state; cc->set_pc = tricore_cpu_set_pc; cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;
target-tricore/cpu.h +0 -2
@@ -400,6 +400,4 @@ static inline void cpu_pc_from_tb(CPUTriCoreState *env, TranslationBlock *tb) env->PC = tb->pc; } -void do_interrupt (CPUTriCoreState *env); -#endif /*__TRICORE_CPU_H__ */
target-tricore/helper.c +0 -4
@@ -82,10 +82,6 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address,return ret; } -void tricore_cpu_do_interrupt (CPUState *cs) -{ -} -TriCoreCPU *cpu_tricore_init (const char *cpu_model) {return TRICORE_CPU (cpu_generic_init (TYPE_TRICORE_CPU , cpu_model));
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 17/23] target-tricore: Remove the dummy interrupt boilerplate
Thanks for the effort cleaning up the cpu-exec file. This looks good to me. I'll add it again, in the next TriCore patchset.
Quoted 78 lines · Richard Henderson
It can go back in when it actually does something.
Cc Bastian Koppelmann <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- cpu-exec.c | 5 ----- target-tricore/cpu-qom.h | 1 - target-tricore/cpu.c | 1 - target-tricore/cpu.h | 2 -- target-tricore/helper.c | 4 ---- 5 files changed, 13 deletions(-)cpu-exec.c +0
-5@@ -523,11 +523,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } -#elif defined(TARGET_TRICORE) -if ((interrupt_request &CPU_INTERRUPT_HARD )) { - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed, target-tricore/cpu-qom.h +0
-1@@ -63,7 +63,6 @@ static inline TriCoreCPU *tricore_env_get_cpu(CPUTriCoreState *env)#define ENV_OFFSET offsetof(TriCoreCPU, env)hwaddr tricore_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); -void tricore_cpu_do_interrupt (CPUState *cpu);void tricore_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags);target-tricore/cpu.c +0
-1@@ -145,7 +145,6 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->class_by_name = tricore_cpu_class_by_name; cc->has_work = tricore_cpu_has_work; - cc->do_interrupt = tricore_cpu_do_interrupt; cc->dump_state = tricore_cpu_dump_state; cc->set_pc = tricore_cpu_set_pc; cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;target-tricore/cpu.h +0
-2@@ -400,6 +400,4 @@ static inline void cpu_pc_from_tb(CPUTriCoreState *env, TranslationBlock *tb) env->PC = tb->pc; } -void do_interrupt (CPUTriCoreState *env); -#endif /*__TRICORE_CPU_H__ */ target-tricore/helper.c +0
-4@@ -82,10 +82,6 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address,return ret; } -void tricore_cpu_do_interrupt (CPUState *cs) -{ -} -TriCoreCPU *cpu_tricore_init (const char *cpu_model) {return TRICORE_CPU (cpu_generic_init (TYPE_TRICORE_CPU , cpu_model));
PATCH 18/23 target-mips: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 9 --------- target-mips/cpu-qom.h | 1 + target-mips/cpu.c | 1 + target-mips/helper.c | 17 +++++++++++++++++ 4 files changed, 19 insertions(+), 9 deletions(-)
cpu-exec.c +0 -9
@@ -514,15 +514,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } -#elif defined(TARGET_MIPS) -if ((interrupt_request &CPU_INTERRUPT_HARD ) && -cpu_mips_hw_interrupts_pending (env)) { -/* Raise it */ - cpu->exception_index =EXCP_EXT_INTERRUPT ; - env->error_code =0 ; - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-mips/cpu-qom.h +1 -0
@@ -75,6 +75,7 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env)#define ENV_OFFSET offsetof(MIPSCPU, env)void mips_cpu_do_interrupt (CPUState *cpu); +bool mips_cpu_exec_interrupt (CPUState *cpu,int int_req);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);
target-mips/cpu.c +1 -0
@@ -136,6 +136,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->has_work = mips_cpu_has_work; cc->do_interrupt = mips_cpu_do_interrupt; + cc->cpu_exec_interrupt = mips_cpu_exec_interrupt; cc->dump_state = mips_cpu_dump_state; cc->set_pc = mips_cpu_set_pc; cc->synchronize_from_tb = mips_cpu_synchronize_from_tb;
target-mips/helper.c +17 -0
@@ -675,6 +675,23 @@ void mips_cpu_do_interrupt(CPUState *cs) cs->exception_index =EXCP_NONE ; } +bool mips_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +if (interrupt_request &CPU_INTERRUPT_HARD ) { +MIPSCPU *cpu =MIPS_CPU (cs); +CPUMIPSState *env = &cpu->env; + +if (cpu_mips_hw_interrupts_pending (env)) { +/* Raise it */ + cs->exception_index =EXCP_EXT_INTERRUPT ; + env->error_code =0 ; +mips_cpu_do_interrupt (cs); +return true; + } + } +return false; +} +#if !defined(CONFIG_USER_ONLY )void r4k_invalidate_tlb (CPUMIPSState *env,int idx,int use_extra) {
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 18/23] target-mips: Use cpu_exec_interrupt qom hook
Quoted 8 lines · Richard Henderson
Cc Aurelien Jarno <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- cpu-exec.c | 9 --------- target-mips/cpu-qom.h | 1 + target-mips/cpu.c | 1 + target-mips/helper.c | 17 +++++++++++++++++ 4 files changed, 19 insertions(+), 9 deletions(-)
Images I've got for mips still work:
Leon
PATCH 19/23 target-microblaze: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 9 --------- target-microblaze/cpu-qom.h | 1 + target-microblaze/cpu.c | 1 + target-microblaze/helper.c | 16 ++++++++++++++++ 4 files changed, 18 insertions(+), 9 deletions(-)
cpu-exec.c +0 -9
@@ -505,15 +505,6 @@ int cpu_exec(CPUArchState *env) cc->do_interrupt (cpu); next_tb = 0; } -#elif defined(TARGET_MICROBLAZE) -if ((interrupt_request &CPU_INTERRUPT_HARD ) - && (env->sregs[SR_MSR ] &MSR_IE ) - && !(env->sregs[SR_MSR ] & (MSR_EIP |MSR_BIP )) - && !(env->iflags & (D_FLAG |IMM_FLAG ))) { - cpu->exception_index =EXCP_IRQ ; - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-microblaze/cpu-qom.h +1 -0
@@ -72,6 +72,7 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env)#define ENV_OFFSET offsetof(MicroBlazeCPU, env)void mb_cpu_do_interrupt (CPUState *cs); +bool mb_cpu_exec_interrupt (CPUState *cs,int int_req);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);
target-microblaze/cpu.c +1 -0
@@ -169,6 +169,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->has_work = mb_cpu_has_work; cc->do_interrupt = mb_cpu_do_interrupt; + cc->cpu_exec_interrupt = mb_cpu_exec_interrupt; cc->dump_state = mb_cpu_dump_state; cc->set_pc = mb_cpu_set_pc; cc->gdb_read_register = mb_cpu_gdb_read_register;
target-microblaze/helper.c +16 -0
@@ -286,3 +286,19 @@ hwaddr mb_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) return paddr; }#endif + +bool mb_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +MicroBlazeCPU *cpu =MICROBLAZE_CPU (cs); +CPUMBState *env = &cpu->env; + +if ((interrupt_request &CPU_INTERRUPT_HARD ) + && (env->sregs[SR_MSR ] &MSR_IE ) + && !(env->sregs[SR_MSR ] & (MSR_EIP |MSR_BIP )) + && !(env->iflags & (D_FLAG |IMM_FLAG ))) { + cs->exception_index =EXCP_IRQ ; +mb_cpu_do_interrupt (cs); +return true; + } +return false; +}
Signature · 1 line
1.9.3
PATCH 20/23 target-lm32: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 7 ------- target-lm32/cpu-qom.h | 1 + target-lm32/cpu.c | 1 + target-lm32/helper.c | 13 +++++++++++++ 4 files changed, 15 insertions(+), 7 deletions(-)
cpu-exec.c +0 -7
@@ -498,13 +498,6 @@ int cpu_exec(CPUArchState *env) } next_tb =0 ; } -#elif defined(TARGET_LM32) -if ((interrupt_request &CPU_INTERRUPT_HARD ) - && (env->ie &IE_IE )) { - cpu->exception_index =EXCP_IRQ ; - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-lm32/cpu-qom.h +1 -0
@@ -82,6 +82,7 @@ extern const struct VMStateDescription vmstate_lm32_cpu;#endif void lm32_cpu_do_interrupt (CPUState *cpu); +bool lm32_cpu_exec_interrupt (CPUState *cs,int int_req);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);
target-lm32/cpu.c +1 -0
@@ -261,6 +261,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = lm32_cpu_class_by_name; cc->has_work = lm32_cpu_has_work; cc->do_interrupt = lm32_cpu_do_interrupt; + cc->cpu_exec_interrupt = lm32_cpu_exec_interrupt; cc->dump_state = lm32_cpu_dump_state; cc->set_pc = lm32_cpu_set_pc; cc->gdb_read_register = lm32_cpu_gdb_read_register;
target-lm32/helper.c +13 -0
@@ -202,6 +202,19 @@ void lm32_cpu_do_interrupt(CPUState *cs) } } +bool lm32_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +LM32CPU *cpu =LM32_CPU (cs); +CPULM32State *env = &cpu->env; + +if ((interrupt_request &CPU_INTERRUPT_HARD ) && (env->ie &IE_IE )) { + cs->exception_index =EXCP_IRQ ; +lm32_cpu_do_interrupt (cs); +return true; + } +return false; +} +LM32CPU *cpu_lm32_init (const char *cpu_model) {return LM32_CPU (cpu_generic_init (TYPE_LM32_CPU , cpu_model));
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 20/23] target-lm32: Use cpu_exec_interrupt qom hook
Am Samstag, 13. September 2014, 09:45:31 schrieb Richard Henderson:
Quoted 2 lines
Cc Michael Walle <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Quoted 73 lines
--- cpu-exec.c | 7 ------- target-lm32/cpu-qom.h | 1 + target-lm32/cpu.c | 1 + target-lm32/helper.c | 13 +++++++++++++ 4 files changed, 15 insertions(+), 7 deletions(-)cpu-exec.c +0
-7@@ -498,13 +498,6 @@ int cpu_exec(CPUArchState *env) } next_tb =0 ; } -#elif defined(TARGET_LM32) -if ((interrupt_request &CPU_INTERRUPT_HARD ) - && (env->ie &IE_IE )) { - cpu->exception_index =EXCP_IRQ ; - cc->do_interrupt (cpu); - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed, target-lm32/cpu-qom.h +1
-0@@ -82,6 +82,7 @@ extern const struct VMStateDescription vmstate_lm32_cpu;#endif void lm32_cpu_do_interrupt (CPUState *cpu); +bool lm32_cpu_exec_interrupt (CPUState *cs,int int_req);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);target-lm32/cpu.c +1
-0@@ -261,6 +261,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = lm32_cpu_class_by_name; cc->has_work = lm32_cpu_has_work; cc->do_interrupt = lm32_cpu_do_interrupt; + cc->cpu_exec_interrupt = lm32_cpu_exec_interrupt; cc->dump_state = lm32_cpu_dump_state; cc->set_pc = lm32_cpu_set_pc; cc->gdb_read_register = lm32_cpu_gdb_read_register;target-lm32/helper.c +13
-0@@ -202,6 +202,19 @@ void lm32_cpu_do_interrupt(CPUState *cs) } } +bool lm32_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +LM32CPU *cpu =LM32_CPU (cs); +CPULM32State *env = &cpu->env; + +if ((interrupt_request &CPU_INTERRUPT_HARD ) && (env->ie &IE_IE )) { + cs->exception_index =EXCP_IRQ ; +lm32_cpu_do_interrupt (cs); +return true; + } +return false; +} +LM32CPU *cpu_lm32_init (const char *cpu_model) {return LM32_CPU (cpu_generic_init (TYPE_LM32_CPU , cpu_model));
PATCH 21/23 target-ppc: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 8 -------- target-ppc/cpu-qom.h | 1 + target-ppc/cpu.h | 1 - target-ppc/excp_helper.c | 19 +++++++++++++++++-- target-ppc/translate_init.c | 1 + 5 files changed, 19 insertions(+), 11 deletions(-)
cpu-exec.c +0 -8
@@ -490,14 +490,6 @@ int cpu_exec(CPUArchState *env) #endif } } -#elif defined(TARGET_PPC) -if (interrupt_request &CPU_INTERRUPT_HARD ) { -ppc_hw_interrupt (env); -if (env->pending_interrupts ==0 ) { - cpu->interrupt_request &= ~CPU_INTERRUPT_HARD ; - } - next_tb =0 ; - }#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed,
target-ppc/cpu-qom.h +1 -0
@@ -113,6 +113,7 @@ PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr);PowerPCCPUClass *ppc_cpu_class_by_pvr_mask (uint32_t pvr);void ppc_cpu_do_interrupt (CPUState *cpu); +bool ppc_cpu_exec_interrupt (CPUState *cpu,int int_req);void ppc_cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); void ppc_cpu_dump_statistics(CPUState *cpu, FILE *f,
target-ppc/cpu.h +0 -1
@@ -1147,7 +1147,6 @@ int cpu_ppc_exec (CPUPPCState *s);is returned if the signal was handled by the virtual CPU. */ int cpu_ppc_signal_handler (int host_signum,void *pinfo,void *puc); -void ppc_hw_interrupt (CPUPPCState *env);#if defined(CONFIG_USER_ONLY )int ppc_cpu_handle_mmu_fault (CPUState *cpu,vaddr address,int rw,int mmu_idx);
target-ppc/excp_helper.c +17 -2
@@ -48,7 +48,7 @@ void ppc_cpu_do_interrupt(CPUState *cs) env->error_code =0 ; } -void ppc_hw_interrupt (CPUPPCState *env) +static void ppc_hw_interrupt (CPUPPCState *env) {CPUState *cs =CPU (ppc_env_get_cpu (env));
@@ -692,7 +692,7 @@ void ppc_cpu_do_interrupt(CPUState *cs)powerpc_excp (cpu, env->excp_model, cs->exception_index); } -void ppc_hw_interrupt (CPUPPCState *env) +static void ppc_hw_interrupt (CPUPPCState *env) {PowerPCCPU *cpu =ppc_env_get_cpu (env);int hdice;
@@ -820,6 +820,21 @@ void ppc_cpu_do_system_reset(CPUState *cs) }#endif /* !CONFIG_USER_ONLY */ +bool ppc_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +PowerPCCPU *cpu =POWERPC_CPU (cs); +CPUPPCState *env = &cpu->env; + +if (interrupt_request &CPU_INTERRUPT_HARD ) { +ppc_hw_interrupt (env); +if (env->pending_interrupts ==0 ) { + cs->interrupt_request &= ~CPU_INTERRUPT_HARD ; + } +return true; + } +return false; +} +#if defined(DEBUG_OP )static void cpu_dump_rfi (target_ulong RA ,target_ulong msr) {
target-ppc/translate_init.c +1 -0
@@ -9631,6 +9631,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->class_by_name = ppc_cpu_class_by_name; cc->has_work = ppc_cpu_has_work; cc->do_interrupt = ppc_cpu_do_interrupt; + cc->cpu_exec_interrupt = ppc_cpu_exec_interrupt; cc->dump_state = ppc_cpu_dump_state; cc->dump_statistics = ppc_cpu_dump_statistics; cc->set_pc = ppc_cpu_set_pc;
Signature · 1 line
1.9.3
PATCH 22/23 target-i386: Use cpu_exec_interrupt qom hook
In reply to Richard Henderson--- cpu-exec.c | 64 -------------------------------------------- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 1 + target-i386/seg_helper.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 64 deletions(-)
cpu-exec.c +0 -64
@@ -427,70 +427,6 @@ int cpu_exec(CPUArchState *env) cpu_reset(cpu); }#endif -#if defined(TARGET_I386 ) -#if !defined(CONFIG_USER_ONLY ) -if (interrupt_request &CPU_INTERRUPT_POLL ) { - cpu->interrupt_request &= ~CPU_INTERRUPT_POLL ; -apic_poll_irq (x86_cpu->apic_state); - } -#endif -if (interrupt_request &CPU_INTERRUPT_SIPI ) { -do_cpu_sipi (x86_cpu); - }else if (env->hflags2 &HF2_GIF_MASK ) { -if ((interrupt_request &CPU_INTERRUPT_SMI ) && - !(env->hflags &HF_SMM_MASK )) { -cpu_svm_check_intercept_param (env,SVM_EXIT_SMI , -0 ); - cpu->interrupt_request &= ~CPU_INTERRUPT_SMI ; -do_smm_enter (x86_cpu); - next_tb =0 ; - }else if ((interrupt_request &CPU_INTERRUPT_NMI ) && - !(env->hflags2 &HF2_NMI_MASK )) { - cpu->interrupt_request &= ~CPU_INTERRUPT_NMI ; - env->hflags2 |=HF2_NMI_MASK ; -do_interrupt_x86_hardirq (env,EXCP02_NMI ,1 ); - next_tb =0 ; - }else if (interrupt_request &CPU_INTERRUPT_MCE ) { - cpu->interrupt_request &= ~CPU_INTERRUPT_MCE ; -do_interrupt_x86_hardirq (env,EXCP12_MCHK ,0 ); - next_tb =0 ; - }else if ((interrupt_request &CPU_INTERRUPT_HARD ) && - (((env->hflags2 &HF2_VINTR_MASK ) && - (env->hflags2 &HF2_HIF_MASK )) || - (!(env->hflags2 &HF2_VINTR_MASK ) && - (env->eflags &IF_MASK && - !(env->hflags &HF_INHIBIT_IRQ_MASK ))))) { -int intno; -cpu_svm_check_intercept_param (env,SVM_EXIT_INTR , -0 ); - cpu->interrupt_request &= ~(CPU_INTERRUPT_HARD | -CPU_INTERRUPT_VIRQ ); - intno =cpu_get_pic_interrupt (env); -qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Servicing hardware INT=0x%02x\n" , intno); -do_interrupt_x86_hardirq (env, intno,1 ); -/* ensure that no TB jump will be modified as -the program flow was changed */ - next_tb =0 ; -#if !defined(CONFIG_USER_ONLY ) - } else if ((interrupt_request & CPU_INTERRUPT_VIRQ) && - (env->eflags &IF_MASK ) && - !(env->hflags &HF_INHIBIT_IRQ_MASK )) { -int intno; -/* FIXME: this should respect TPR */ -cpu_svm_check_intercept_param (env,SVM_EXIT_VINTR , -0 ); - intno =ldl_phys (cpu->as, - env->vm_vmcb - + offsetof(struct vmcb , - control.int_vector)); -qemu_log_mask (CPU_LOG_TB_IN_ASM ,"Servicing virtual hardware INT=0x%02x\n" , intno); -do_interrupt_x86_hardirq (env, intno,1 ); - cpu->interrupt_request &= ~CPU_INTERRUPT_VIRQ ; - next_tb =0 ; -#endif - } - } -#endif /* The target hook has 3 exit conditions: False when the interrupt isn't processed, True when it is, and we should restart on a new TB,
target-i386/cpu-qom.h +1 -0
@@ -130,6 +130,7 @@ extern struct VMStateDescription vmstate_x86_cpu;* @cpu: vCPU the interrupt is to be handled by. */ void x86_cpu_do_interrupt (CPUState *cpu); +bool x86_cpu_exec_interrupt (CPUState *cpu,int int_req);int x86_cpu_write_elf64_note (WriteCoreDumpFunction f,CPUState *cpu,int cpuid,void *opaque);
target-i386/cpu.c +1 -0
@@ -2920,6 +2920,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->parse_features = x86_cpu_parse_featurestr; cc->has_work = x86_cpu_has_work; cc->do_interrupt = x86_cpu_do_interrupt; + cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; cc->dump_state = x86_cpu_dump_state; cc->set_pc = x86_cpu_set_pc; cc->synchronize_from_tb = x86_cpu_synchronize_from_tb;
target-i386/seg_helper.c +69 -0
75 lines not on this page · raw message
Signature · 1 line
1.9.3
PATCH 23/23 cpu-exec: Do CPU_INTERRUPT_HALT unconditionally
In reply to Richard HendersonThe signal is currently checked by 10 targets, but only actually raised by Sparc and ARM. For the sake of one test-and-branch, we can handle this generic bit generically.
--- cpu-exec.c | 5 ----- 1 file changed, 5 deletions(-)
cpu-exec.c +0 -5
@@ -404,17 +404,12 @@ int cpu_exec(CPUArchState *env) cpu->exception_index =EXCP_DEBUG ;cpu_loop_exit (cpu); } -#if defined(TARGET_ARM ) || defined(TARGET_SPARC ) || defined(TARGET_MIPS ) || \ - defined(TARGET_PPC ) || defined(TARGET_ALPHA ) || defined(TARGET_CRIS ) || \ - defined(TARGET_MICROBLAZE ) || defined(TARGET_LM32 ) || \ - defined(TARGET_UNICORE32 ) || defined(TARGET_TRICORE )if (interrupt_request &CPU_INTERRUPT_HALT ) { cpu->interrupt_request &= ~CPU_INTERRUPT_HALT ; cpu->halted =1 ; cpu->exception_index =EXCP_HLT ;cpu_loop_exit (cpu); } -#endif #if defined(TARGET_I386 )if (interrupt_request &CPU_INTERRUPT_INIT ) {cpu_svm_check_intercept_param (env,SVM_EXIT_INIT ,0 );
Signature · 1 line
1.9.3
Peter Maydell
AppliedQuoted 9 lines · Richard Henderson
Prompted by trying to review Martin's ARM exception vs gdb problems, let's clean up
cpu_execso that it's almost readable.After the 23 patches, there's one (interesting) ifdef left. That is, i386 redefining
CPU_INTERRUPT_RESETasCPU_INTERRUPT_INITfor its own purposes. I'm not sure why all that couldn't be done under whatever hookscpu_resetallows. Failing that, we might be able to redefineC_I_Ias a newCPU_INTERRUPT_TGT_INT_3bit.
Quoted 4 lines
I've done some smoke tests on i386, arm, xtensa, because I had images handy. But I've not done anything but compile the rest.
Comments appreciated.
Applied to master, thanks.
-- PMM