cpu interrupt cleanup
cover cpu interrupt cleanup
Blue Swirl pointed out that CPU_INTERRUPT_TIMER was unused, and should therefore be remove. This is a logical extension of that, making all target specific cpu interrupts really be private to the target.
This will allow new ports to define external cpu interrupts as needed without having to modify generic code.
r~
Richard Henderson (8):
irq: Introduce CPU_INTERRUPT_TGT_* defines.
irq: Introduce and use CPU_INTERRUPT_SSTEP_MASK.
target-mips: Do not check CPU_INTERRUPT_TIMER.
target-sparc: Do not check CPU_INTERRUPT_TIMER.
irq: Remove CPU_INTERRUPT_TIMER.
target-arm: Privatize CPU_INTERRUPT_FIQ.
target-i386: Privatize some i386-specific interrupt names.
irq: Privatize CPU_INTERRUPT_NMI.
cpu-all.h | 60 +++++++++++++++++++++++++++++++++++++--------- cpu-exec.c | 8 +----- poison.h | 13 ++++++---- target-arm/cpu.h | 4 +++ target-cris/cpu.h | 3 ++ target-i386/cpu.h | 9 +++++++ target-microblaze/cpu.h | 3 ++ target-mips/exec.h | 4 --- 8 files changed, 76 insertions(+), 28 deletions(-)
Signature · 1 line
1.7.4.4
PATCH 1/8 irq: Introduce CPU_INTERRUPT_TGT_* defines.
These defines will be place-holders for cpu-specific functionality. Generic code will, at the end of the patch series, no longer have to concern itself about how SMI, NMI, etc should be handled. Instead, generic code will know only that the interrupt is internal or external.
--- cpu-all.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++----------- poison.h | 8 +++++++ 2 files changed, 59 insertions(+), 12 deletions(-)
cpu-all.h +51 -12
@@ -786,18 +786,57 @@ void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...)extern CPUState *first_cpu;extern CPUState *cpu_single_env; -#define CPU_INTERRUPT_HARD 0x02/* hardware interrupt pending */ -#define CPU_INTERRUPT_EXITTB 0x04/* exit the current TB (use for x86 a20 case) */ -#define CPU_INTERRUPT_TIMER 0x08/* internal timer exception pending */ -#define CPU_INTERRUPT_FIQ 0x10/* Fast interrupt pending. */ -#define CPU_INTERRUPT_HALT 0x20/* CPU halt wanted */ -#define CPU_INTERRUPT_SMI 0x40/* (x86 only) SMI interrupt pending */ -#define CPU_INTERRUPT_DEBUG 0x80/* Debug event occured. */ -#define CPU_INTERRUPT_VIRQ 0x100/* virtual interrupt pending. */ -#define CPU_INTERRUPT_NMI 0x200/* NMI pending. */ -#define CPU_INTERRUPT_INIT 0x400/* INIT pending. */ -#define CPU_INTERRUPT_SIPI 0x800/* SIPI pending. */ -#define CPU_INTERRUPT_MCE 0x1000/* (x86 only) MCE pending. */ +/* Flags for use in ENV->INTERRUPT_PENDING. + +The numbers assigned here are non-sequential in order to preserve +binary compatibility with the vmstate dump. Bit 0 (0x0001) was +previously used for CPU_INTERRUPT_EXIT, and is cleared when loading +the vmstate dump. */ + +/* External hardware interrupt pending. This is typically used for +interrupts from devices. */ +#define CPU_INTERRUPT_HARD 0x0002 + +/* Exit the current TB. This is typically used when some system-level device +makes some change to the memory mapping. E.g. the a20 line change. */ +#define CPU_INTERRUPT_EXITTB 0x0004 + +/* Halt the CPU. */ +#define CPU_INTERRUPT_HALT 0x0020 + +/* Debug event pending. */ +#define CPU_INTERRUPT_DEBUG 0x0080 + +/* Several target-specific external hardware interrupts. Each target/cpu.h +should define proper names based on these defines. */ +#define CPU_INTERRUPT_TGT_EXT_0 0x0008 +#define CPU_INTERRUPT_TGT_EXT_1 0x0010 +#define CPU_INTERRUPT_TGT_EXT_2 0x0040 +#define CPU_INTERRUPT_TGT_EXT_3 0x0200 +#define CPU_INTERRUPT_TGT_EXT_4 0x1000 + +/* Several target-specific internal interrupts. These differ from the +preceeding target-specific interrupts in that they are intended to +originate from within the cpu itself, typically in response to some +instruction being executed. These, therefore, are not masked while +single-stepping within the debugger. */ +#define CPU_INTERRUPT_TGT_INT_0 0x0100 +#define CPU_INTERRUPT_TGT_INT_1 0x0400 +#define CPU_INTERRUPT_TGT_INT_2 0x0800 + +/* First unused bit: 0x2000. */ + +/* Temporary remapping from the generic names back to the previous +cpu-specific names. These will be moved to target-foo/cpu.h next. */ +#define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_EXT_0 +#define CPU_INTERRUPT_FIQ CPU_INTERRUPT_TGT_EXT_1 +#define CPU_INTERRUPT_SMI CPU_INTERRUPT_TGT_EXT_2 +#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_INT_0 +#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3 +#define CPU_INTERRUPT_INIT CPU_INTERRUPT_TGT_INT_1 +#define CPU_INTERRUPT_SIPI CPU_INTERRUPT_TGT_INT_2 +#define CPU_INTERRUPT_MCE CPU_INTERRUPT_TGT_EXT_4 +void cpu_interrupt (CPUState *s,int mask);void cpu_reset_interrupt (CPUState *env,int mask);
poison.h +8 -0
@@ -46,6 +46,14 @@#pragma GCC poison CPU_INTERRUPT_DEBUG#pragma GCC poison CPU_INTERRUPT_VIRQ#pragma GCC poison CPU_INTERRUPT_NMI +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_0 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_1 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_2 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_3 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_4 +#pragma GCC poison CPU_INTERRUPT_TGT_INT_0 +#pragma GCC poison CPU_INTERRUPT_TGT_INT_1 +#pragma GCC poison CPU_INTERRUPT_TGT_INT_2#endif #endif
Signature · 1 line
1.7.4.4
PATCH 2/8 irq: Introduce and use CPU_INTERRUPT_SSTEP_MASK.
In reply to Richard HendersonThis mask contains all of the bits that should be ignored while single stepping in the debugger. The mask contains 2 bits that are not currently cleared, but are also never set. The bits are included in the mask for consistency in handling of the CPU_INTERRUPT_TGT_EXT_N bits.
--- cpu-all.h | 8 ++++++++ cpu-exec.c | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-)
cpu-all.h +8 -0
@@ -837,6 +837,14 @@ extern CPUState *cpu_single_env;#define CPU_INTERRUPT_SIPI CPU_INTERRUPT_TGT_INT_2#define CPU_INTERRUPT_MCE CPU_INTERRUPT_TGT_EXT_4 +/* The set of all bits that should be masked when single-stepping. */ +#define CPU_INTERRUPT_SSTEP_MASK \ + (CPU_INTERRUPT_HARD \ + | CPU_INTERRUPT_TGT_EXT_0 \ + | CPU_INTERRUPT_TGT_EXT_1 \ + | CPU_INTERRUPT_TGT_EXT_2 \ + | CPU_INTERRUPT_TGT_EXT_3 \ + | CPU_INTERRUPT_TGT_EXT_4)void cpu_interrupt (CPUState *s,int mask);void cpu_reset_interrupt (CPUState *env,int mask);
cpu-exec.c +1 -4
@@ -360,10 +360,7 @@ int cpu_exec(CPUState *env1)if (unlikely (interrupt_request)) {if (unlikely (env->singlestep_enabled &SSTEP_NOIRQ )) {/* Mask out external interrupts for this step. */ - interrupt_request &= ~(CPU_INTERRUPT_HARD | -CPU_INTERRUPT_FIQ | -CPU_INTERRUPT_SMI | -CPU_INTERRUPT_NMI ); + interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK ; }if (interrupt_request &CPU_INTERRUPT_DEBUG ) { env->interrupt_request &= ~CPU_INTERRUPT_DEBUG ;
Signature · 1 line
1.7.4.4
PATCH 3/8 target-mips: Do not check CPU_INTERRUPT_TIMER.
In reply to Richard HendersonThis bit is never set, therefore we should not read it either.
--- target-mips/exec.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
target-mips/exec.h +0 -4
@@ -29,10 +29,6 @@ static inline int cpu_has_work(CPUState *env) has_work =1 ; } -if (env->interrupt_request &CPU_INTERRUPT_TIMER ) { - has_work =1 ; - } -return has_work; }
Signature · 1 line
1.7.4.4
PATCH 4/8 target-sparc: Do not check CPU_INTERRUPT_TIMER.
In reply to Richard HendersonThis bit is never set, therefore we should not read it either.
--- cpu-exec.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
cpu-exec.c +0 -3
@@ -489,9 +489,6 @@ int cpu_exec(CPUState *env1) next_tb = 0; } } - }else if (interrupt_request &CPU_INTERRUPT_TIMER ) { -//do_interrupt(0, 0, 0, 0, 0); - env->interrupt_request &= ~CPU_INTERRUPT_TIMER ; }#elif defined(TARGET_ARM) if (interrupt_request & CPU_INTERRUPT_FIQ
Signature · 1 line
1.7.4.4
PATCH 5/8 irq: Remove CPU_INTERRUPT_TIMER.
In reply to Richard HendersonIt is no longer used anywhere.
--- cpu-all.h | 1 - poison.h | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)
cpu-all.h +0 -1
@@ -828,7 +828,6 @@ extern CPUState *cpu_single_env;/* Temporary remapping from the generic names back to the previous cpu-specific names. These will be moved to target-foo/cpu.h next. */ -#define CPU_INTERRUPT_TIMER CPU_INTERRUPT_TGT_EXT_0#define CPU_INTERRUPT_FIQ CPU_INTERRUPT_TGT_EXT_1#define CPU_INTERRUPT_SMI CPU_INTERRUPT_TGT_EXT_2#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_INT_0
poison.h +0 -1
@@ -39,7 +39,6 @@#pragma GCC poison CPU_INTERRUPT_HARD#pragma GCC poison CPU_INTERRUPT_EXITTB -#pragma GCC poison CPU_INTERRUPT_TIMER#pragma GCC poison CPU_INTERRUPT_FIQ#pragma GCC poison CPU_INTERRUPT_HALT#pragma GCC poison CPU_INTERRUPT_SMI
Signature · 1 line
1.7.4.4
PATCH 6/8 target-arm: Privatize CPU_INTERRUPT_FIQ.
In reply to Richard HendersonThis interrupt name was only used by the ARM port.
--- cpu-all.h | 1 - poison.h | 1 - target-arm/cpu.h | 4 ++++ 3 files changed, 4 insertions(+), 2 deletions(-)
cpu-all.h +0 -1
@@ -828,7 +828,6 @@ extern CPUState *cpu_single_env;/* Temporary remapping from the generic names back to the previous cpu-specific names. These will be moved to target-foo/cpu.h next. */ -#define CPU_INTERRUPT_FIQ CPU_INTERRUPT_TGT_EXT_1#define CPU_INTERRUPT_SMI CPU_INTERRUPT_TGT_EXT_2#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_INT_0#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3
poison.h +0 -1
@@ -39,7 +39,6 @@#pragma GCC poison CPU_INTERRUPT_HARD#pragma GCC poison CPU_INTERRUPT_EXITTB -#pragma GCC poison CPU_INTERRUPT_FIQ#pragma GCC poison CPU_INTERRUPT_HALT#pragma GCC poison CPU_INTERRUPT_SMI#pragma GCC poison CPU_INTERRUPT_DEBUG
target-arm/cpu.h +4 -0
@@ -55,6 +55,10 @@#define ARMV7M_EXCP_PENDSV 14#define ARMV7M_EXCP_SYSTICK 15 +/* ARM-specific interrupt pending bits. */ +#define CPU_INTERRUPT_FIQ CPU_INTERRUPT_TGT_EXT_1 + +typedef void ARMWriteCPFunc (void *opaque,int cp_info,int srcreg,int operand,uint32_t value); typedef uint32_t ARMReadCPFunc(void *opaque, int cp_info,
Signature · 1 line
1.7.4.4
PATCH 7/8 target-i386: Privatize some i386-specific interrupt names.
In reply to Richard HendersonSMI, VIRQ, INIT, SIPI, and MCE are all only used by the i386 port.
--- cpu-all.h | 5 ----- poison.h | 2 -- target-i386/cpu.h | 8 ++++++++ 3 files changed, 8 insertions(+), 7 deletions(-)
cpu-all.h +0 -5
@@ -828,12 +828,7 @@ extern CPUState *cpu_single_env;/* Temporary remapping from the generic names back to the previous cpu-specific names. These will be moved to target-foo/cpu.h next. */ -#define CPU_INTERRUPT_SMI CPU_INTERRUPT_TGT_EXT_2 -#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_INT_0#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3 -#define CPU_INTERRUPT_INIT CPU_INTERRUPT_TGT_INT_1 -#define CPU_INTERRUPT_SIPI CPU_INTERRUPT_TGT_INT_2 -#define CPU_INTERRUPT_MCE CPU_INTERRUPT_TGT_EXT_4/* The set of all bits that should be masked when single-stepping. */ #define CPU_INTERRUPT_SSTEP_MASK \
poison.h +0 -2
@@ -40,9 +40,7 @@#pragma GCC poison CPU_INTERRUPT_HARD#pragma GCC poison CPU_INTERRUPT_EXITTB#pragma GCC poison CPU_INTERRUPT_HALT -#pragma GCC poison CPU_INTERRUPT_SMI#pragma GCC poison CPU_INTERRUPT_DEBUG -#pragma GCC poison CPU_INTERRUPT_VIRQ#pragma GCC poison CPU_INTERRUPT_NMI#pragma GCC poison CPU_INTERRUPT_TGT_EXT_0#pragma GCC poison CPU_INTERRUPT_TGT_EXT_1
target-i386/cpu.h +8 -0
@@ -466,6 +466,14 @@#define EXCP_SYSCALL 0x100/* only happens in user only emulation for syscall instruction */ +/* i386-specific interrupt pending bits. */ +#define CPU_INTERRUPT_SMI CPU_INTERRUPT_TGT_EXT_2 +#define CPU_INTERRUPT_MCE CPU_INTERRUPT_TGT_EXT_4 +#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_INT_0 +#define CPU_INTERRUPT_INIT CPU_INTERRUPT_TGT_INT_1 +#define CPU_INTERRUPT_SIPI CPU_INTERRUPT_TGT_INT_2 + +enum {CC_OP_DYNAMIC ,/* must use dynamic code to get cc_op */ CC_OP_EFLAGS ,/* all cc are explicitly computed, CC_SRC = flags */
Signature · 1 line
1.7.4.4
PATCH 8/8 irq: Privatize CPU_INTERRUPT_NMI.
In reply to Richard HendersonThis interrupt name is used by i386, CRIS, and MicroBlaze. Copy the name into each target.
--- cpu-all.h | 4 ---- poison.h | 1 - target-cris/cpu.h | 3 +++ target-i386/cpu.h | 1 + target-microblaze/cpu.h | 3 +++ 5 files changed, 7 insertions(+), 5 deletions(-)
cpu-all.h +0 -4
@@ -826,10 +826,6 @@ extern CPUState *cpu_single_env;/* First unused bit: 0x2000. */ -/* Temporary remapping from the generic names back to the previous -cpu-specific names. These will be moved to target-foo/cpu.h next. */ -#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3 -/* The set of all bits that should be masked when single-stepping. */ #define CPU_INTERRUPT_SSTEP_MASK \ (CPU_INTERRUPT_HARD \
poison.h +0 -1
@@ -41,7 +41,6 @@#pragma GCC poison CPU_INTERRUPT_EXITTB#pragma GCC poison CPU_INTERRUPT_HALT#pragma GCC poison CPU_INTERRUPT_DEBUG -#pragma GCC poison CPU_INTERRUPT_NMI#pragma GCC poison CPU_INTERRUPT_TGT_EXT_0#pragma GCC poison CPU_INTERRUPT_TGT_EXT_1#pragma GCC poison CPU_INTERRUPT_TGT_EXT_2
target-cris/cpu.h +3 -0
@@ -36,6 +36,9 @@#define EXCP_IRQ 4#define EXCP_BREAK 5 +/* CRIS-specific interrupt pending bits. */ +#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3 +/* Register aliases. R0 - R15 */ #define R_FP 8#define R_SP 14
target-i386/cpu.h +1 -0
@@ -468,6 +468,7 @@/* i386-specific interrupt pending bits. */ #define CPU_INTERRUPT_SMI CPU_INTERRUPT_TGT_EXT_2 +#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3#define CPU_INTERRUPT_MCE CPU_INTERRUPT_TGT_EXT_4#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_INT_0#define CPU_INTERRUPT_INIT CPU_INTERRUPT_TGT_INT_1
target-microblaze/cpu.h +3 -0
@@ -41,6 +41,9 @@ struct CPUMBState;#define EXCP_HW_BREAK 5#define EXCP_HW_EXCP 6 +/* MicroBlaze-specific interrupt pending bits. */ +#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_3 +/* Register aliases. R0 - R15 */ #define R_SP 1#define SR_PC 0
Signature · 1 line
1.7.4.4
I forgot to mention: the patch series is at
git://repo.or.cz/qemu/rth.git rth/irq-1
Also, the i386 port defines a CPU_TARGET_MCE, checked by the kvm code, but as far as I can tell that bit is never set. I've left that alone for now.
r~
Quoted 3 lines · Richard Henderson
Also, the i386 port defines a
CPU_TARGET_MCE, checked by the kvm code, but as far as I can tell that bit is never set. I've left that alone for now.
That rather looks like a ghost. Can you name some hashes, files, and lines that should contain this?
Jan
Quoted 7 lines · Jan Kiszka
Quoted 3 lines · Richard Henderson
Also, the i386 port defines a
CPU_TARGET_MCE, checked by the kvm code, but as far as I can tell that bit is never set. I've left that alone for now.That rather looks like a ghost. Can you name some hashes, files, and lines that should contain this?
Gah, sorry, CPU_INTERRUPT_MCE. Dunno what my fingers were thinking.
r~
Quoted 11 lines · Richard Henderson
Quoted 7 lines · Jan Kiszka
Quoted 3 lines · Richard Henderson
Also, the i386 port defines a
CPU_TARGET_MCE, checked by the kvm code, but as far as I can tell that bit is never set. I've left that alone for now.That rather looks like a ghost. Can you name some hashes, files, and lines that should contain this?
Gah, sorry,
CPU_INTERRUPT_MCE. Dunno what my fingers were thinking.
Check target-i386/helper.c, do_inject_x86_mce. It really does what its name says. :)
Jan
Quoted 7 lines · Richard Henderson
Blue Swirl pointed out that
CPU_INTERRUPT_TIMERwas unused, and should therefore be remove. This is a logical extension of that, making all target specific cpu interrupts really be private to the target.This will allow new ports to define external cpu interrupts as needed without having to modify generic code.
The patches don't apply, please rebase. Please also fix the tab and trailing whitespace problems spotted by scripts/checkpatch.pl while at it.