limit passing around of cpu_user_regs
cover limit passing around of cpu_user_regs
Unlike (synchronous) exception handlers, interrupt handlers don't normally have a need to know the outer context's register state. Similarly, the vast majority of key handlers has no need for such.
1: keyhandler: don't pass cpu_user_regs around
2: IRQ: generalize [gs]et_irq_regs()
3: serial: drop serial_rx_fn's regs parameter
4: PV-shim: drop pv_console_rx()'s regs parameter
5: serial: drop serial_[rt]x_interrupt()'s regs parameter 6: IRQ: drop regs parameter from handler functions
7: x86/vPMU: drop regs parameter from interrupt functions 8: x86/APIC: drop regs parameter from direct vector handler functions
Jan
PATCH 1/8 keyhandler: don't pass cpu_user_regs around
There are exactly two handlers which care about the registers. Have handle_keypress() make the pointer available via a per-CPU variable, thus eliminating the need to pass it to all IRQ key handlers, making sure that a console-invoked key's handling can still nest inside a sysctl-invoked one's.
---
Subsequently we may want to eliminate the fn/irq_fn union as well, along with dropping the now redundant irq_keyhandler_fn_t.
xen/common/keyhandler.c +21 -15
@@ -80,6 +80,7 @@ static void cf_check keypress_action(voi } static DECLARE_TASKLET(keypress_tasklet, keypress_action, NULL); +static DEFINE_PER_CPU(struct cpu_user_regs *, keypress_regs);void handle_keypress (unsigned char key,struct cpu_user_regs *regs) {
@@ -91,7 +92,16 @@ void handle_keypress(unsigned char key,if ( !in_irq () || h->irq_callback ) {console_start_log_everything (); - h->irq_callback ? h->irq_fn (key, regs) : h->fn (key); +if ( h->irq_callback ) + { +struct cpu_user_regs *old =this_cpu (keypress_regs); + +this_cpu (keypress_regs) = regs; + h->irq_fn (key); +this_cpu (keypress_regs) = old; + } +else + h->fn (key);console_end_log_everything (); }else
@@ -171,8 +181,7 @@ void cf_check dump_execstate(struct cpu_watchdog_enable (); } -static void cf_check dump_registers( -unsigned char key,struct cpu_user_regs *regs) +static void cf_check dump_registers(unsigned char key) {unsigned int cpu;
@@ -185,8 +194,8 @@ static void cf_check dump_registers(cpumask_copy (&dump_execstate_mask, &cpu_online_map);/* Get local execution state out immediately, in case we get stuck. */ -if ( regs ) -dump_execstate (regs); +if (this_cpu (keypress_regs) ) +dump_execstate (this_cpu (keypress_regs));else run_in_exception_handler (dump_execstate);
@@ -248,8 +257,7 @@ static void cf_check dump_hwdom_register } } -static void cf_check reboot_machine( -unsigned char key,struct cpu_user_regs *regs) +static void cf_check reboot_machine(unsigned char key) {printk ("'%c' pressed -> rebooting machine\n" , key);machine_restart (0 );
@@ -477,8 +485,7 @@ static void cf_check run_all_nonirq_keyh static DECLARE_TASKLET(run_all_keyhandlers_tasklet, run_all_nonirq_keyhandlers, NULL); -static void cf_check run_all_keyhandlers( -unsigned char key,struct cpu_user_regs *regs) +static void cf_check run_all_keyhandlers(unsigned char key) {struct keyhandler *h;unsigned int k;
@@ -494,7 +501,7 @@ static void cf_check run_all_keyhandlersif ( !h->irq_fn || !h->diagnostic || !h->irq_callback )continue ;printk ("[%c: %s]\n" , k, h->desc); - h->irq_fn (k, regs); + h->irq_fn (k); }watchdog_enable ();
@@ -511,17 +518,16 @@ static void cf_check do_debugger_trap_fabarrier (); } -static void cf_check do_debug_key(unsigned char key, struct cpu_user_regs *regs) +static void cf_check do_debug_key(unsigned char key) {printk ("'%c' pressed -> trapping into debugger\n" , key); -if ( regs ) -do_debugger_trap_fatal (regs); +if (this_cpu (keypress_regs) ) +do_debugger_trap_fatal (this_cpu (keypress_regs));else run_in_exception_handler (do_debugger_trap_fatal); } -static void cf_check do_toggle_alt_key( -unsigned char key,struct cpu_user_regs *regs) +static void cf_check do_toggle_alt_key(unsigned char key) { alt_key_handling = !alt_key_handling; printk("'%c' pressed -> using %s key handling\n", key,
xen/drivers/char/console.c +3 -3
@@ -280,7 +280,7 @@ static int *__read_mostly upper_thresh_astatic int *__read_mostly lower_thresh_adj = &xenlog_lower_thresh;static const char *__read_mostly thresh_adj ="standard" ; -static void cf_check do_toggle_guest(unsigned char key, struct cpu_user_regs *regs) +static void cf_check do_toggle_guest(unsigned char key) {if ( upper_thresh_adj == &xenlog_upper_thresh ) {
@@ -307,13 +307,13 @@ static void do_adj_thresh(unsigned char loglvl_str(*upper_thresh_adj)); } -static void cf_check do_inc_thresh(unsigned char key, struct cpu_user_regs *regs) +static void cf_check do_inc_thresh(unsigned char key) { ++*lower_thresh_adj;do_adj_thresh (key); } -static void cf_check do_dec_thresh(unsigned char key, struct cpu_user_regs *regs) +static void cf_check do_dec_thresh(unsigned char key) {if ( *lower_thresh_adj ) --*lower_thresh_adj;
xen/include/xen/keyhandler.h +2 -3
@@ -24,9 +24,7 @@ typedef void (keyhandler_fn_t)(unsigned* * Called in hardirq context with interrupts disabled. */ -struct cpu_user_regs ; -typedef void (irq_keyhandler_fn_t )(unsigned char key, -struct cpu_user_regs *regs); +typedef void irq_keyhandler_fn_t (unsigned char key);/* Initialize keytable with default handlers. */ void initialize_keytable (void );
@@ -46,6 +44,7 @@ void register_irq_keyhandler(unsigned ch bool diagnostic);/* Inject a keypress into the key-handling subsystem. */ +struct cpu_user_regs ;extern void handle_keypress (unsigned char key,struct cpu_user_regs *regs);enum crash_reason {
Re: [PATCH 1/8] keyhandler: don't pass cpu_user_regs around
Quoted 1 line · Jan Beulich
There are exactly two handlers which care about the registers.
Which two? dump regs and trap to debugger?
[Edit, oh yes, this is clear in the patch, but IMO it would be helpful to state them here.]
Quoted 5 lines
Have
handle_keypress()make the pointer available via a per-CPU variable, thus eliminating the need to pass it to all IRQ key handlers, making sure that a console-invoked key's handling can still nest inside a sysctl-invoked one's.
I know this is the current behaviour, and I'm not suggesting altering it in this patch, but the sysctl was added so you had a way of using debug keys without necessarily having a working serial connection.
It was never expected or intended for both mechanisms to work concurrently, and I don't think we need to take any care to make/keep it working.
Quoted 1 line
Signed-off-by Jan Beulich <[email protected]>
tweaks, but see below.
Quoted 3 lines
---
Subsequently we may want to eliminate the fn/irq_fn union as well, along with dropping the now redundantirq_keyhandler_fn_t.
Yes - this simplification was one I was hoping to be able to make in due course. I suspect the split is only because some functionality wanted regs and others not.
Trap to debugger is an x86-ism for gdbstub only. I'm tempted to drop all the gdbstub code. I've never encountered it working in 13y, and the number of build fixes I've done personally, I don't believe the code can plausibly be in a non-bitrotten state.
Nevertheless, an explicit trap-to-debugger which isn't a manually inserted debugger_trap_{immediate,fatal}() is a weird construct in the first place, not least because an attached debugger can do this on its own anyway.
The more I think about this, the more I think we should just remove 'D', even if we don't go for dropping gdbstub. It's the only place where gdbstub really escapes out of x86 into common code. (I see there's a new one in bug.h but that is abstracted with a macro.)
Also, xl debug-keys D was clearly something that just got swept up with "make all debug keys usable via sysctl", not because it was a plausibly useful construct.
This just leaves dump regs, which I think can safely use get_irq_regs() || guest_cpu_user_regs(). All it wants is something to dump_execstate() to, which just wants to be the start of the path which led here.
With both of those sorted (albeit it with patch 2 needing to move ahead of 1), I don't think we need to keep keypress_regs.
Quoted 11 lines
xen/common/keyhandler.c +1
-0@@ -80,6 +80,7 @@ static void cf_check keypress_action(voi } static DECLARE_TASKLET(keypress_tasklet, keypress_action, NULL); +static DEFINE_PER_CPU(struct cpu_user_regs *, keypress_regs);void handle_keypress (unsigned char key,struct cpu_user_regs *regs) {
xen/common/keyhandler.c void handle_keypress(unsigned char key, · line 94
Quoted 4 lines
xen/common/keyhandler.c +0
-1@@ -91,7 +92,16 @@ void handle_keypress(unsigned char key,if ( !in_irq () || h->irq_callback ) {console_start_log_everything (); - h->irq_callback ? h->irq_fn (key, regs) : h->fn (key);
This would read better with a blank line here, and ...
xen/common/keyhandler.c void handle_keypress(unsigned char key, · line 104
Quoted 10 lines
xen/common/keyhandler.c +10
-0+if ( h->irq_callback ) + { +struct cpu_user_regs *old =this_cpu (keypress_regs); + +this_cpu (keypress_regs) = regs; + h->irq_fn (key); +this_cpu (keypress_regs) = old; + } +else + h->fn (key);
... here.
~Andrew
Re: [PATCH 1/8] keyhandler: don't pass cpu_user_regs around
Quoted 7 lines · Andrew Cooper
Quoted 1 line · Jan Beulich
There are exactly two handlers which care about the registers.
Which two? dump regs and trap to debugger?
[Edit, oh yes, this is clear in the patch, but IMO it would be helpful to state them here.]
Sure, added mention of 'd' and '%'.
Quoted 6 lines
Quoted 5 lines
Have
handle_keypress()make the pointer available via a per-CPU variable, thus eliminating the need to pass it to all IRQ key handlers, making sure that a console-invoked key's handling can still nest inside a sysctl-invoked one's.
Quoted 7 lines
I know this is the current behaviour, and I'm not suggesting altering it in this patch, but the sysctl was added so you had a way of using debug keys without necessarily having a working serial connection.
It was never expected or intended for both mechanisms to work concurrently, and I don't think we need to take any care to make/keep it working.
Well, all it takes is the saving and restoring of keypress_regs in handle_keypress(). You you really think it would be better to risk a cash, but not doing that tiny bit of extra work?
Quoted 4 lines
Quoted 1 line
Signed-off-by Jan Beulich <[email protected]>tweaks, but see below.
Thanks, and yes, I've inserted the two blank lines.
Quoted 7 lines
Quoted 3 lines
---
Subsequently we may want to eliminate the fn/irq_fn union as well, along with dropping the now redundantirq_keyhandler_fn_t.Yes - this simplification was one I was hoping to be able to make in due course. I suspect the split is only because some functionality wanted regs and others not.
That's my recollection, yes.
Quoted 9 lines
Trap to debugger is an x86-ism for gdbstub only. I'm tempted to drop all the gdbstub code. I've never encountered it working in 13y, and the number of build fixes I've done personally, I don't believe the code can plausibly be in a non-bitrotten state.
Nevertheless, an explicit trap-to-debugger which isn't a manually inserted debugger_trap_{immediate,fatal}() is a weird construct in the first place, not least because an attached debugger can do this on its own anyway.
Not sure here, and I'd hope purging of that (if so wanted) can be dealt with separately. I have a vague recollection of such "on its own" wasn't very reliable, when trying to use such elsewhere (in the distant past, before I started working on Xen). That's not to say that I have proof that our debug-key is any more reliable.
Quoted 8 lines
The more I think about this, the more I think we should just remove 'D', even if we don't go for dropping gdbstub. It's the only place where gdbstub really escapes out of x86 into common code. (I see there's a new one in
bug.hbut that is abstracted with a macro.)Also,
xl debug-keys Dwas clearly something that just got swept up with "make all debug keys usable via sysctl", not because it was a plausibly useful construct.
Did you really mean D (EPT table dump), not %? If the latter, then yes, that may better be filtered out of what can be done via sysctl.
Quoted 3 lines
This just leaves dump regs, which I think can safely use
get_irq_regs()|| guest_cpu_user_regs(). All it wants is something todump_execstate()to, which just wants to be the start of the path which led here.
I don't think so - consider the case of 'd' hitting while handling an interrupt (and, say, stuck there in an infinite loop with IRQs enabled). We'd then wrongly dump the context of what the earlier IRQ interrupted.
Jan
Re: [PATCH 1/8] keyhandler: don't pass cpu_user_regs around
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 5 lines
Have
handle_keypress()make the pointer available via a per-CPU variable, thus eliminating the need to pass it to all IRQ key handlers, making sure that a console-invoked key's handling can still nest inside a sysctl-invoked one's.I know this is the current behaviour, and I'm not suggesting altering it in this patch, but the sysctl was added so you had a way of using debug keys without necessarily having a working serial connection.
Quoted 6 lines
Quoted 3 lines
It was never expected or intended for both mechanisms to work concurrently, and I don't think we need to take any care to make/keep it working.
Well, all it takes is the saving and restoring of
keypress_regsinhandle_keypress(). You you really think it would be better to risk a cash, but not doing that tiny bit of extra work?
I presume you mean crash?
I'm not advocating for leaving something explicitly unsafe, but I'm also looking to see if we can avoid having keypress_regs to begin with. i.e. I think we've already got unnecessary complexity, and it would be good to reduce it.
Quoted 11 lines
Quoted 9 lines
Trap to debugger is an x86-ism for gdbstub only. I'm tempted to drop all the gdbstub code. I've never encountered it working in 13y, and the number of build fixes I've done personally, I don't believe the code can plausibly be in a non-bitrotten state.
Nevertheless, an explicit trap-to-debugger which isn't a manually inserted debugger_trap_{immediate,fatal}() is a weird construct in the first place, not least because an attached debugger can do this on its own anyway.
Not sure here, and I'd hope purging of that (if so wanted) can be dealt with separately.
It can, yes.
It was just if there was an easy way to avoid introducing keypress_regs then it would have been better to remove this first, than to refactor and then delete.
Quoted 4 lines
I have a vague recollection of such "on its own" wasn't very reliable, when trying to use such elsewhere (in the distant past, before I started working on Xen). That's not to say that I have proof that our debug-key is any more reliable.
This really comes back to whether gdbstub works or not.
Frankly, if you really do need to debug Xen these days, you'd be better off running it under Qemu and using the qemu gdbstub. If nothing else it's more likely to work, and it does not need an alive-enough Xen to have a working irq/serial subsystem.
Quoted 11 lines
Quoted 9 lines
The more I think about this, the more I think we should just remove 'D', even if we don't go for dropping gdbstub. It's the only place where gdbstub really escapes out of x86 into common code. (I see there's a new one in
bug.hbut that is abstracted with a macro.)Also,
xl debug-keys Dwas clearly something that just got swept up with "make all debug keys usable via sysctl", not because it was a plausibly useful construct.Did you really mean D (EPT table dump), not %? If the latter, then yes, that may better be filtered out of what can be done via sysctl.
I did mean %, yes.
Quoted 7 lines
Quoted 4 lines
This just leaves dump regs, which I think can safely use
get_irq_regs()|| guest_cpu_user_regs(). All it wants is something todump_execstate()to, which just wants to be the start of the path which led here.I don't think so - consider the case of 'd' hitting while handling an interrupt (and, say, stuck there in an infinite loop with IRQs enabled). We'd then wrongly dump the context of what the earlier IRQ interrupted.
The serial IRQ producing the 'd' keypress will push a irq frame, which is what will be returned by get_irq_regs().
It does occur to me that we're trying to accommodate for two behaviours here.
For a real keypress, we want to dump from the the point the interrupt hit because that's the interesting bit of stack to see. For a SYSCTL, there's nothing, and we're using BUGFRAME_run_fn to generate one.
So actually we just simply want "regs = get_irq_regs();" here and retain prior NULL check, don't we?
~Andrew
Re: [PATCH 1/8] keyhandler: don't pass cpu_user_regs around
Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 5 lines
Have
handle_keypress()make the pointer available via a per-CPU variable, thus eliminating the need to pass it to all IRQ key handlers, making sure that a console-invoked key's handling can still nest inside a sysctl-invoked one's.I know this is the current behaviour, and I'm not suggesting altering it in this patch, but the sysctl was added so you had a way of using debug keys without necessarily having a working serial connection.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
It was never expected or intended for both mechanisms to work concurrently, and I don't think we need to take any care to make/keep it working.
Well, all it takes is the saving and restoring of
keypress_regsinhandle_keypress(). You you really think it would be better to risk a cash, but not doing that tiny bit of extra work?I presume you mean crash?
Oops, yes, I do.
Quoted 8 lines
I'm not advocating for leaving something explicitly unsafe, but I'm also looking to see if we can avoid having
keypress_regsto begin with. i.e. I think we've already got unnecessary complexity, and it would be good to reduce it.
[...]Quoted 3 lines
Quoted 3 lines
This just leaves dump regs, which I think can safely use
get_irq_regs()|| guest_cpu_user_regs(). All it wants is something todump_execstate()to, which just wants to be the start of the path which led here.
Quoted 6 lines
Quoted 3 lines
I don't think so - consider the case of 'd' hitting while handling an interrupt (and, say, stuck there in an infinite loop with IRQs enabled). We'd then wrongly dump the context of what the earlier IRQ interrupted.
The serial IRQ producing the 'd' keypress will push a irq frame, which is what will be returned by
get_irq_regs().
Hmm, yes. I wonder what I was thinking ...
Quoted 6 lines
It does occur to me that we're trying to accommodate for two behaviours here.
For a real keypress, we want to dump from the the point the interrupt hit because that's the interesting bit of stack to see. For a SYSCTL, there's nothing, and we're using
BUGFRAME_run_fnto generate one.
There's three forms of handle_keypress() invocations really, and hence why (after having dropped the regs parameter already) I re-instated it.
As an aside - no, sysctl handling does not generate an exception frame. Is uses guest_cpu_user_regs() (and imo validly so).
Quoted 2 lines
So actually we just simply want "regs =
get_irq_regs();" here and retain prior NULL check, don't we?
As per above, after I had it that way first, I backed off to accommodate all present use forms of handle_keypress(). But dealing with that (in whichever way we may end up deeming workable) can be separate anyway, afaict.
Jan
Re: [PATCH 1/8] keyhandler: don't pass cpu_user_regs around
Quoted 10 lines · Jan Beulich
Quoted 7 lines · Andrew Cooper
On 11/01/2024 12:11 pm, Jan Beulich wrote:
It does occur to me that we're trying to accommodate for two behaviours here.For a real keypress, we want to dump from the the point the interrupt hit because that's the interesting bit of stack to see. For a SYSCTL, there's nothing, and we're using
BUGFRAME_run_fnto generate one.There's three forms of
handle_keypress()invocations really, and hence why (after having dropped the regs parameter already) I re-instated it.
Ok. As you've done this analysis work, can you list these 3 forms?
I've clearly missed one in my analysis.
Quoted 10 lines
As an aside - no, sysctl handling does not generate an exception frame. Is uses
guest_cpu_user_regs()(and imo validly so).Quoted 2 lines
So actually we just simply want "regs =
get_irq_regs();" here and retain prior NULL check, don't we?As per above, after I had it that way first, I backed off to accommodate all present use forms of
handle_keypress(). But dealing with that (in whichever way we may end up deeming workable) can be separate anyway, afaict.
When complexity is involved, I always prefer to make changes in smaller chunks.
~Andrew
Re: [PATCH 1/8] keyhandler: don't pass cpu_user_regs around
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Jan Beulich
Quoted 7 lines · Andrew Cooper
On 11/01/2024 12:11 pm, Jan Beulich wrote:
It does occur to me that we're trying to accommodate for two behaviours here.For a real keypress, we want to dump from the the point the interrupt hit because that's the interesting bit of stack to see. For a SYSCTL, there's nothing, and we're using
BUGFRAME_run_fnto generate one.
Quoted 6 lines
Quoted 2 lines
There's three forms of
handle_keypress()invocations really, and hence why (after having dropped the regs parameter already) I re-instated it.Ok. As you've done this analysis work, can you list these 3 forms?
I've clearly missed one in my analysis.
The console handler invocation is (now) using get_irq_regs(). The sysctl handling, as said, passes guest_cpu_user_regs(). And then there are two cases where NULL is passed, one from keypress_action() (a tasklet handler) and the other from keyhandler_crash_action(). I'm not convinced the latter is fully correct. The tasklet handler is used only for non-IRQ keys, and hence only in cases where regs wouldn't have been passed to the handler anyway.
IOW - leaving the keyhandler_crash_action() uncertainty aside, I think it ought to be possible to do as you did suggest.
Jan
Re: [PATCH 1/8] keyhandler: don't pass cpu_user_regs around
In reply to Jan BeulichHi Jan,
Quoted 7 lines · Jan Beulich
There are exactly two handlers which care about the registers. Have
handle_keypress()make the pointer available via a per-CPU variable, thus eliminating the need to pass it to all IRQ key handlers, making sure that a console-invoked key's handling can still nest inside a sysctl-invoked one's.Signed-off-by Jan Beulich <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 1/8] keyhandler: don't pass cpu_user_regs around
Quoted 10 lines · Julien Grall
Quoted 7 lines · Jan Beulich
There are exactly two handlers which care about the registers. Have
handle_keypress()make the pointer available via a per-CPU variable, thus eliminating the need to pass it to all IRQ key handlers, making sure that a console-invoked key's handling can still nest inside a sysctl-invoked one's.Signed-off-by Jan Beulich <[email protected]>Reviewed-by Julien Grall <[email protected]>
Thanks. I had to drop this patch though in v2, doing things differently to address a comment/request from Andrew.
Jan
PATCH 2/8 IRQ: generalize [gs]et_irq_regs()
In reply to Jan BeulichMove functions (and their data) to common code, and invoke the functions on Arm as well. This is in preparation of dropping the register parameters from handler functions.
---
To limit visibility of the per-CPU data item, we may want to consider making the functions out-of-line ones (in common/irq.c).
xen/arch/arm/irq.c +2 -0
@@ -221,6 +221,7 @@ void do_IRQ(struct cpu_user_regs *regs, {struct irq_desc *desc =irq_to_desc (irq);struct irqaction *action; +struct cpu_user_regs *old_regs =set_irq_regs (regs);perfc_incr (irqs);
@@ -288,6 +289,7 @@ out: out_no_end:spin_unlock (&desc->lock);irq_exit (); +set_irq_regs (old_regs); }void release_irq (unsigned int irq,const void *dev_id)
xen/arch/x86/include/asm/irq.h +0 -21
@@ -70,27 +70,6 @@ extern bool opt_noirqbalance;extern int opt_irq_vector_map; -/* -* Per-cpu current frame pointer - the location of the last exception frame on -* the stack -*/ -DECLARE_PER_CPU(struct cpu_user_regs *, __irq_regs); - -static inline struct cpu_user_regs *get_irq_regs (void ) -{ -return this_cpu (__irq_regs); -} - -static inline struct cpu_user_regs *set_irq_regs (struct cpu_user_regs *new_regs) -{ -struct cpu_user_regs *old_regs, **pp_regs = &this_cpu (__irq_regs); - - old_regs = *pp_regs; - *pp_regs = new_regs; -return old_regs; -} - -#define platform_legacy_irq (irq) ((irq) < 16) void cf_check event_check_interrupt(struct cpu_user_regs *regs);
xen/arch/x86/irq.c +0 -2
@@ -53,8 +53,6 @@ static DEFINE_SPINLOCK(vector_lock);DEFINE_PER_CPU (vector_irq_t, vector_irq); -DEFINE_PER_CPU(struct cpu_user_regs *, __irq_regs); -static LIST_HEAD (irq_ratelimit_list);static DEFINE_SPINLOCK (irq_ratelimit_lock);static struct timer irq_ratelimit_timer;
xen/common/irq.c +2 -0
@@ -1,6 +1,8 @@#include <xen/irq.h> #include <xen/errno.h> +DEFINE_PER_CPU(struct cpu_user_regs *, irq_regs); +int init_one_irq_desc (struct irq_desc *desc) {int err;
xen/include/xen/irq.h +20 -0
@@ -131,6 +131,26 @@ void cf_check irq_actor_none(struct irq_#define irq_disable_none irq_actor_none#define irq_enable_none irq_actor_none +/* +* Per-cpu interrupted context register state - the top-most interrupt frame +* on the stack. +*/ +DECLARE_PER_CPU(struct cpu_user_regs *, irq_regs); + +static inline struct cpu_user_regs *get_irq_regs (void ) +{ +return this_cpu (irq_regs); +} + +static inline struct cpu_user_regs *set_irq_regs (struct cpu_user_regs *new_regs) +{ +struct cpu_user_regs *old_regs, **pp_regs = &this_cpu (irq_regs); + + old_regs = *pp_regs; + *pp_regs = new_regs; +return old_regs; +} +struct domain ;struct vcpu ;
Re: [PATCH 2/8] IRQ: generalize [gs]et_irq_regs()
Quoted 5 lines · Jan Beulich
Move functions (and their data) to common code, and invoke the functions on Arm as well. This is in preparation of dropping the register parameters from handler functions.
Signed-off-by Jan Beulich <[email protected]>
suggestion.
Quoted 3 lines
---
To limit visibility of the per-CPU data item, we may want to consider making the functions out-of-line ones (incommon/irq.c).
If we had working LTO, then maybe. But we don't, and I think we can reasonably cover (not using) this with normal code review.
xen/include/xen/irq.h void cf_check irq_actor_none(struct irq_ · line 136
Quoted 9 lines
xen/include/xen/irq.h +3
-0@@ -131,6 +131,26 @@ void cf_check irq_actor_none(struct irq_#define irq_disable_none irq_actor_none#define irq_enable_none irq_actor_none +/* +* Per-cpu interrupted context register state - the top-most interrupt frame +* on the stack.
The prior wording "last" wasn't great either.
I'd suggest "inner-most". "top-most" comes with the usual confusions with stacks being upside down, and inner/outer is more common terminology with nesting.
~Andrew
Re: [PATCH 2/8] IRQ: generalize [gs]et_irq_regs()
In reply to Jan BeulichHi Jan,
Quoted 5 lines · Jan Beulich
Move functions (and their data) to common code, and invoke the functions on Arm as well. This is in preparation of dropping the register parameters from handler functions.
Signed-off-by Jan Beulich <[email protected]>
Quoted 20 lines
---
To limit visibility of the per-CPU data item, we may want to consider making the functions out-of-line ones (incommon/irq.c).xen/arch/arm/irq.c +2
-0@@ -221,6 +221,7 @@ void do_IRQ(struct cpu_user_regs *regs, {struct irq_desc *desc =irq_to_desc (irq);struct irqaction *action; +struct cpu_user_regs *old_regs =set_irq_regs (regs);perfc_incr (irqs);@@ -288,6 +289,7 @@ out: out_no_end:spin_unlock (&desc->lock);irq_exit (); +set_irq_regs (old_regs); }
[...]
Quoted 7 lines
xen/arch/arm/irq.c +7
-0+/* +* Per-cpu interrupted context register state - the top-most interrupt frame +* on the stack. +*/ +DECLARE_PER_CPU(struct cpu_user_regs *, irq_regs); + +static inline struct cpu_user_regs *get_irq_regs (void )
xen/arch/arm/irq.c
Quoted 10 lines
xen/arch/arm/irq.c +10
-0+{ +return this_cpu (irq_regs); +} + +static inline struct cpu_user_regs *set_irq_regs (struct cpu_user_regs *new_regs) +{ +struct cpu_user_regs *old_regs, **pp_regs = &this_cpu (irq_regs); + + old_regs = *pp_regs; + *pp_regs = new_regs;
NIT: As you move the code, can you add a newline before the return?
xen/arch/arm/irq.c
Quoted 5 lines
xen/arch/arm/irq.c +3
-0+return old_regs; +} +struct domain ;struct vcpu ;
Cheers,
Signature · 1 line
Julien Grall
PATCH 3/8 serial: drop serial_rx_fn's regs parameter
In reply to Jan BeulichIn the one place where it's needed, get_irq_regs() can be used instead. This is in preparation of dropping the register parameters from IRQ handler functions.
xen/drivers/char/console.c +5 -5
@@ -527,12 +527,12 @@ static void switch_serial_input(void)printk ("\n" ); } -static void __serial_rx (char c,struct cpu_user_regs *regs) +static void __serial_rx (char c) {switch ( console_rx ) {case 0 : -return handle_keypress (c, regs); +return handle_keypress (c,get_irq_regs ());case 1 :/*
@@ -579,7 +579,7 @@ static void __serial_rx(char c, struct c#endif } -static void cf_check serial_rx(char c, struct cpu_user_regs *regs) +static void cf_check serial_rx(char c) {static int switch_code_count =0 ;
@@ -595,10 +595,10 @@ static void cf_check serial_rx(char c, s }for ( ; switch_code_count !=0 ; switch_code_count-- ) -__serial_rx (switch_code, regs); +__serial_rx (switch_code);/* Finally process the just-received character. */ -__serial_rx (c, regs); +__serial_rx (c); } static void cf_check notify_dom0_con_ring(void *unused)
xen/drivers/char/serial.c +1 -1
@@ -68,7 +68,7 @@ void serial_rx_interrupt(struct serial_pspin_unlock_irqrestore (&port->rx_lock, flags);if ( fn !=NULL ) - (*fn)(c &0x7f , regs); +fn (c &0x7f ); }void serial_tx_interrupt (struct serial_port *port,struct cpu_user_regs *regs)
xen/drivers/char/xen_pv_console.c +1 -1
@@ -118,7 +118,7 @@ size_t pv_console_rx(struct cpu_user_reg { c = cons_ring->in[MASK_XENCONS_IDX (cons++, cons_ring->in)];if ( cons_rx_handler ) -cons_rx_handler (c, regs); +cons_rx_handler (c); recv++; }
xen/include/xen/serial.h +1 -1
@@ -15,7 +15,7 @@struct cpu_user_regs ;/* Register a character-receive hook on the specified COM port. */ -typedef void (*serial_rx_fn )(char c,struct cpu_user_regs *regs); +typedef void (*serial_rx_fn )(char c);void serial_set_rx_handler (int handle,serial_rx_fn fn);/* Number of characters we buffer for a polling receiver. */
Re: [PATCH 3/8] serial: drop serial_rx_fn's regs parameter
Quoted 5 lines · Jan Beulich
In the one place where it's needed,
get_irq_regs()can be used instead. This is in preparation of dropping the register parameters from IRQ handler functions.Signed-off-by Jan Beulich <[email protected]>
PATCH 4/8 PV-shim: drop pv_console_rx()'s regs parameter
In reply to Jan BeulichIt's not needed anymore. This is in preparation of dropping the register parameters from IRQ handler functions.
xen/arch/x86/guest/xen/xen.c +1 -1
@@ -181,7 +181,7 @@ static void cf_check xen_evtchn_upcall(s port += l1 *BITS_PER_LONG ;if ( pv_console && port ==pv_console_evtchn () ) -pv_console_rx (regs); +pv_console_rx ();else if ( pv_shim )pv_shim_inject_evtchn (port); }
xen/drivers/char/xen_pv_console.c +1 -1
@@ -94,7 +94,7 @@ evtchn_port_t pv_console_evtchn(void)return cons_evtchn; } -size_t pv_console_rx (struct cpu_user_regs *regs) +size_t pv_console_rx (void ) {char c;XENCONS_RING_IDX cons, prod;
xen/include/xen/pv_console.h +2 -2
@@ -9,7 +9,7 @@ void pv_console_init(void);void pv_console_set_rx_handler (serial_rx_fn fn);void pv_console_init_postirq (void );void pv_console_puts (const char *buf,size_t nr); -size_t pv_console_rx (struct cpu_user_regs *regs); +size_t pv_console_rx (void );evtchn_port_t pv_console_evtchn (void );#else
@@ -18,7 +18,7 @@ static inline void pv_console_init(void)static inline void pv_console_set_rx_handler (serial_rx_fn fn) { }static inline void pv_console_init_postirq (void ) { }static inline void pv_console_puts (const char *buf,size_t nr) { } -static inline size_t pv_console_rx (struct cpu_user_regs *regs) {return 0 ; } +static inline size_t pv_console_rx (void ) {return 0 ; }#endif /* !CONFIG_XEN_GUEST */ #endif /* __XEN_PV_CONSOLE_H__ */
Re: [PATCH 4/8] PV-shim: drop pv_console_rx()'s regs parameter
Quoted 4 lines · Jan Beulich
It's not needed anymore. This is in preparation of dropping the register parameters from IRQ handler functions.
Signed-off-by Jan Beulich <[email protected]>
PATCH 5/8 serial: drop serial_[rt]x_interrupt()'s regs parameter
In reply to Jan BeulichIn the the polling functions (ab)using set_irq_regs() is necessary to balance the change. This is in preparation of dropping the register parameters from IRQ handler functions.
xen/drivers/char/cadence-uart.c +1 -1
@@ -51,7 +51,7 @@ static void cuart_interrupt(int irq, voi/* ACK. */ if ( status &UART_SR_INTR_RTRIG ) { -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);cuart_write (uart,R_UART_CISR ,UART_SR_INTR_RTRIG ); } }while ( status &UART_SR_INTR_RTRIG );
xen/drivers/char/ehci-dbgp.c +8 -2
@@ -1253,6 +1253,7 @@ static void cf_check _ehci_dbgp_poll(strunsigned long flags;unsigned int timeout =MICROSECS (DBGP_CHECK_INTERVAL );bool empty = false; +struct cpu_user_regs *old_regs;if ( !dbgp->ehci_debug )return ;
@@ -1268,11 +1269,16 @@ static void cf_check _ehci_dbgp_poll(strspin_unlock_irqrestore (&port->tx_lock, flags); } +/* Mimic interrupt context. */ + old_regs =set_irq_regs (regs); +if ( dbgp->in.chunk ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);if ( empty ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port); + +set_irq_regs (old_regs);if (spin_trylock_irqsave (&port->tx_lock, flags) ) {
xen/drivers/char/exynos4210-uart.c +2 -2
@@ -81,7 +81,7 @@ static void exynos4210_uart_interrupt(inif ( status & (UINTM_RXD |UINTM_ERROR ) ) {/* uart->regs[UINTM] |= RXD|ERROR; */ -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);/* uart->regs[UINTM] &= ~(RXD|ERROR); */ exynos4210_write (uart,UINTP ,UINTM_RXD |UINTM_ERROR ); }
@@ -89,7 +89,7 @@ static void exynos4210_uart_interrupt(inif ( status & (UINTM_TXD |UINTM_MODEM ) ) {/* uart->regs[UINTM] |= TXD|MODEM; */ -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port);/* uart->regs[UINTM] &= ~(TXD|MODEM); */ exynos4210_write (uart,UINTP ,UINTM_TXD |UINTM_MODEM ); }
xen/drivers/char/imx-lpuart.c +2 -2
@@ -48,10 +48,10 @@ static void imx_lpuart_interrupt(int irq rxcnt =imx_lpuart_read (uart,UARTWATER ) >>UARTWATER_RXCNT_OFF ;if ( (sts &UARTSTAT_RDRF ) || (rxcnt >0 ) ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);if ( sts &UARTSTAT_TDRE ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port);imx_lpuart_write (uart,UARTSTAT , sts); }
xen/drivers/char/meson-uart.c +2 -2
@@ -69,10 +69,10 @@ static void meson_uart_interrupt(int irquint32_t st =readl (uart->regs +AML_UART_STATUS_REG );if ( !(st &AML_UART_RX_FIFO_EMPTY ) ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);if ( !(st &AML_UART_TX_FIFO_FULL ) ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port); }static void __init meson_uart_init_preirq (struct serial_port *port)
xen/drivers/char/mvebu-uart.c +2 -2
@@ -76,10 +76,10 @@ static void mvebu3700_uart_interrupt(intif ( st & (STATUS_RX_RDY |STATUS_OVR_ERR |STATUS_FRM_ERR |STATUS_BRK_DET ) ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);if ( st &STATUS_TX_RDY ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port); }static void __init mvebu3700_uart_init_preirq (struct serial_port *port)
xen/drivers/char/ns16550.c +9 -4
@@ -188,9 +188,9 @@ static void cf_check ns16550_interrupt(u8 lsr =ns_read_reg (uart,UART_LSR );if ( (lsr & uart->lsr_mask) == uart->lsr_mask ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port);if ( lsr &UART_LSR_DR ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);/* A "busy-detect" condition is observed on Allwinner/sunxi UART * after LCR is written during setup. It needs to be cleared at
@@ -211,22 +211,27 @@ static void cf_check __ns16550_poll(stru {struct serial_port *port =this_cpu (poll_port);struct ns16550 *uart = port->uart; +struct cpu_user_regs *old_regs;if ( uart->intr_works )return ;/* Interrupts work - no more polling */ +/* Mimic interrupt context. */ + old_regs =set_irq_regs (regs); +while (ns_read_reg (uart,UART_LSR ) &UART_LSR_DR ) {if (ns16550_ioport_invalid (uart) ) goto out; -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port); }if ( (ns_read_reg (uart,UART_LSR ) & uart->lsr_mask ) == uart->lsr_mask ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port); out: +set_irq_regs (old_regs);set_timer (&uart->timer,NOW () +MILLISECS (uart->timeout_ms)); }
xen/drivers/char/omap-uart.c +2 -2
@@ -70,9 +70,9 @@ static void omap_uart_interrupt(int irq, { lsr =omap_read (uart,UART_LSR ) &0xff ;if ( lsr &UART_LSR_THRE ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port);if ( lsr &UART_LSR_DR ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);if ( port->txbufc == port->txbufp ) { reg =omap_read (uart,UART_IER );
xen/drivers/char/pl011.c +2 -2
@@ -95,7 +95,7 @@ static void pl011_interrupt(int irq, voipl011_write (uart,ICR , status & ~(TXI |RTI |RXI ));if ( status & (RTI |RXI ) ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);/* TODO if ( status & (DSRMI|DCDMI|CTSMI|RIMI) )
@@ -103,7 +103,7 @@ static void pl011_interrupt(int irq, voi*/ if ( status & (TXI ) ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port); status =pl011_intr_status (uart); }while (status !=0 );
xen/drivers/char/scif-uart.c +2 -2
@@ -119,11 +119,11 @@ static void scif_uart_interrupt(int irq, {/* TX Interrupt */ if ( status &SCFSR_TDFE ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port);/* RX Interrupt */ if ( status & (SCFSR_RDF |SCFSR_DR ) ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);/* Error Interrupt */ if ( status & params->error_mask )
xen/drivers/char/serial.c +2 -2
@@ -45,7 +45,7 @@ static inline void serial_stop_tx(struct port->driver->stop_tx (port); } -void serial_rx_interrupt (struct serial_port *port,struct cpu_user_regs *regs) +void serial_rx_interrupt (struct serial_port *port) {char c;serial_rx_fn fn =NULL ;
@@ -71,7 +71,7 @@ void serial_rx_interrupt(struct serial_pfn (c &0x7f ); } -void serial_tx_interrupt (struct serial_port *port,struct cpu_user_regs *regs) +void serial_tx_interrupt (struct serial_port *port) {int i, n;unsigned long flags;
xen/drivers/char/xhci-dbc.c +8 -2
@@ -1164,6 +1164,7 @@ static void cf_check dbc_uart_poll(voidstruct dbc_uart *uart = port->uart;struct dbc *dbc = &uart->dbc;unsigned long flags =0 ; +struct cpu_user_regs *old_regs;if (spin_trylock_irqsave (&port->tx_lock, flags) ) {
@@ -1175,10 +1176,15 @@ static void cf_check dbc_uart_poll(voidspin_unlock_irqrestore (&port->tx_lock, flags); } +/* Mimic interrupt context. */ + old_regs =set_irq_regs (guest_cpu_user_regs ()); +while (dbc_work_ring_size (&dbc->dbc_iwork) ) -serial_rx_interrupt (port,guest_cpu_user_regs ()); +serial_rx_interrupt (port); + +serial_tx_interrupt (port); -serial_tx_interrupt (port,guest_cpu_user_regs ()); +set_irq_regs (old_regs);set_timer (&uart->timer,NOW () +MICROSECS (DBC_POLL_INTERVAL )); }
xen/include/xen/serial.h +2 -4
@@ -12,8 +12,6 @@#include <xen/init.h> #include <xen/spinlock.h> -struct cpu_user_regs ; -/* Register a character-receive hook on the specified COM port. */ typedef void (*serial_rx_fn )(char c);void serial_set_rx_handler (int handle,serial_rx_fn fn);
@@ -155,8 +153,8 @@ void serial_register_uart(int idx, struc/* Place the serial port into asynchronous transmit mode. */ void serial_async_transmit (struct serial_port *port);/* Process work in interrupt context. */ -void serial_rx_interrupt (struct serial_port *port,struct cpu_user_regs *regs); -void serial_tx_interrupt (struct serial_port *port,struct cpu_user_regs *regs); +void serial_rx_interrupt (struct serial_port *port); +void serial_tx_interrupt (struct serial_port *port);/* * Initialisers for individual uart drivers.
Re: [PATCH 5/8] serial: drop serial_[rt]x_interrupt()'s regs parameter
Quoted 2 lines · Jan Beulich
In the the polling functions (ab)using
set_irq_regs()is necessary to balance the change.
I have to admit that I don't know what "balance the change" is supposed to refer to in this context.
Quoted 8 lines
xen/drivers/char/ehci-dbgp.c +2
-0@@ -1268,11 +1269,16 @@ static void cf_check _ehci_dbgp_poll(strspin_unlock_irqrestore (&port->tx_lock, flags); } +/* Mimic interrupt context. */ + old_regs =set_irq_regs (regs);
xen/drivers/char/ehci-dbgp.c static void cf_check _ehci_dbgp_poll(str · line 1281
Quoted 10 lines
xen/drivers/char/ehci-dbgp.c +5
-2+if ( dbgp->in.chunk ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);if ( empty ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port); + +set_irq_regs (old_regs);
Looking at this logic, it has occured to me that patch 2 probably ought to have ASSERT(!local_irqs_enabled()) in set_irq_regs(). While the main arch irq dispatch can reasonably have it as an implicit expectation, uses like this could do with the check.
This construct is very nasty. What actually needs it?
If it's only handle_keypress(), isn't there a latent issue between patch 3 and 5, given that patch 3 uses set_irq_regs() before this patch sets it up?
Might it be better to do this in the main handling of BUGFRAME_run_fn, rather than at a few select users? We're already abusing BUGFRAME_run_fn to set up an IRQ-like context for these poll functions.
I suppose a different question is what it would take to get rid of this. Is it something a bit more cleanup would solve, or is there some more fundamental untangling required?
xen/drivers/char/xhci-dbc.c static void cf_check dbc_uart_poll(void · line 1180
Quoted 8 lines
xen/drivers/char/xhci-dbc.c +2
-0@@ -1175,10 +1176,15 @@ static void cf_check dbc_uart_poll(voidspin_unlock_irqrestore (&port->tx_lock, flags); } +/* Mimic interrupt context. */ + old_regs =set_irq_regs (guest_cpu_user_regs ());
This is not a bug in your patch, but...
The use of guest_cpu_user_regs() here is different to all the other poll functions. Is this actually correct?
If we're really in interrupt context and then we fake up a poll like this, then we don't have a total order of frames recorded in the irq_regs pointer. I can't see a specific issue, but it also doesn't feel as if it is something we should allow.
~Andrew
Re: [PATCH 5/8] serial: drop serial_[rt]x_interrupt()'s regs parameter
Quoted 6 lines · Andrew Cooper
Quoted 2 lines · Jan Beulich
In the the polling functions (ab)using
set_irq_regs()is necessary to balance the change.I have to admit that I don't know what "balance the change" is supposed to refer to in this context.
Maybe just a lack of proper English on my part. What I'm trying to say is that the removal of the function parameter comes with the need to make the pointer available via set_irq_regs() (which is, in a way at least, an abuse of the function).
Quoted 13 lines
Quoted 13 lines
xen/drivers/char/ehci-dbgp.c +4
-1@@ -1268,11 +1269,16 @@ static void cf_check _ehci_dbgp_poll(strspin_unlock_irqrestore (&port->tx_lock, flags); } +/* Mimic interrupt context. */ + old_regs =set_irq_regs (regs); +if ( dbgp->in.chunk ) -serial_rx_interrupt (port, regs); +serial_rx_interrupt (port);
Quoted 10 lines
xen/drivers/char/ehci-dbgp.c static void cf_check _ehci_dbgp_poll(str · line 1281
Quoted 5 lines
xen/drivers/char/ehci-dbgp.c +3
-1if ( empty ) -serial_tx_interrupt (port, regs); +serial_tx_interrupt (port); + +set_irq_regs (old_regs);Looking at this logic, it has occured to me that patch 2 probably ought to have ASSERT(!local_irqs_enabled()) in set_irq_regs(). While the main arch irq dispatch can reasonably have it as an implicit expectation, uses like this could do with the check.
Why would IRQs need to be off for set_irq_regs()? It's all a matter of proper nesting, and any IRQ (nested into here or nested inside another IRQ) would properly save/restore the outer context's pointer (irrespective of what kind of context that actually is).
Note also how __ns16550_poll() doesn't itself disable interrupts. While apparently not the case right now, I'm also of the opinion that IRQs could in principle be turned back on transiently while handling BUGFRAME_run_fn (and perhaps also BUGFRAME_warn).
Quoted 5 lines
This construct is very nasty. What actually needs it?
If it's only
handle_keypress(), isn't there a latent issue between patch 3 and 5, given that patch 3 usesset_irq_regs()before this patch sets it up?
I think you're right - looks like I need to re-order (or fold, in case there would then be a build issue).
Quoted 3 lines
Might it be better to do this in the main handling of
BUGFRAME_run_fn, rather than at a few select users? We're already abusingBUGFRAME_run_fnto set up an IRQ-like context for these poll functions.
Hmm. It would then look at least a little less abusive, I suppose. Otoh the handler function being passed registers is quite natural imo, for being exception (not interrupt) related. Or are you suggesting to "pass" registers both ways (i.e. keep the handler function parameter while additionally also using set_irq_regs())? That would feel a little odd, for being redundant.
Also I've never viewed use of BUGFRAME_run_fn here as having the purpose of setting up an IRQ-like context. I've always understood it as merely a means to get at a meaningful struct cpu_user_regs instance (i.e. covering the case of running in idle vCPU context; see below). Much like BUGFRAME_warn imo has only this as a purpose of involving generation of an exception.
Quoted 3 lines
I suppose a different question is what it would take to get rid of this. Is it something a bit more cleanup would solve, or is there some more fundamental untangling required?
Well, what exactly is "this" here? Something needs to set the pointer, even if I add a patch to switch handle_keypress() itself to not take a regs parameter anymore.
Quoted 6 lines
Quoted 6 lines
xen/drivers/char/xhci-dbc.c +0
-0@@ -1175,10 +1176,15 @@ static void cf_check dbc_uart_poll(voidspin_unlock_irqrestore (&port->tx_lock, flags); }
Quoted 7 lines
xen/drivers/char/xhci-dbc.c static void cf_check dbc_uart_poll(void · line 1180
Quoted 2 lines
xen/drivers/char/xhci-dbc.c +2
-0+/* Mimic interrupt context. */ + old_regs =set_irq_regs (guest_cpu_user_regs ());This is not a bug in your patch, but...
The use of
guest_cpu_user_regs()here is different to all the other poll functions. Is this actually correct?
I think it is okay-ish right now, but indeed I meant to have a post- commit-message remark about this. In particular, ...
Quoted 4 lines
If we're really in interrupt context and then we fake up a poll like this, then we don't have a total order of frames recorded in the
irq_regspointer. I can't see a specific issue, but it also doesn't feel as if it is something we should allow.
... I don't see any ordering constraint. dbc_uart_poll() is a timer handler, so will never itself run in interrupt context. And any IRQ would cleanly nest. Nevertheless register state will likely not be very meaningful when the timer ends up running in the context of an idle vCPU. Marek, what's the background of you having done this differently to other poll handlers?
Jan
PATCH 6/8 IRQ: drop register parameter from handler functions
In reply to Jan BeulichIt's simply not needed anymore. Note how Linux made this change many years ago already, in 2.6.19 (late 2006, see [1]).
xen/arch/arm/gic.c +1 -1
@@ -397,7 +397,7 @@ void gic_interrupt(struct cpu_user_regs }while (1 ); } -static void maintenance_interrupt (int irq,void *dev_id,struct cpu_user_regs *regs) +static void maintenance_interrupt (int irq,void *dev_id) {/* * This is a dummy interrupt handler.
xen/arch/arm/irq.c +2 -3
@@ -182,8 +182,7 @@ void irq_set_affinity(struct irq_desc *d }int request_irq (unsigned int irq,unsigned int irqflags, -void (*handler)(int irq,void *dev_id, -struct cpu_user_regs *regs), +void (*handler)(int irq,void *dev_id),const char *devname,void *dev_id) {struct irqaction *action;
@@ -276,7 +275,7 @@ void do_IRQ(struct cpu_user_regs *regs,do { - action->handler (irq, action->dev_id, regs); + action->handler (irq, action->dev_id); action = action->next; }while ( action );
xen/arch/arm/time.c +2 -2
@@ -241,7 +241,7 @@ int reprogram_timer(s_time_t timeout) }/* Handle the firing timer */ -static void htimer_interrupt (int irq,void *dev_id,struct cpu_user_regs *regs) +static void htimer_interrupt (int irq,void *dev_id) {if (unlikely (!(READ_SYSREG (CNTHP_CTL_EL2 ) & CNTx_CTL_PENDING)) )return ;
@@ -255,7 +255,7 @@ static void htimer_interrupt(int irq, voWRITE_SYSREG (0 ,CNTHP_CTL_EL2 ); } -static void vtimer_interrupt (int irq,void *dev_id,struct cpu_user_regs *regs) +static void vtimer_interrupt (int irq,void *dev_id) {/* * Edge-triggered interrupts can be used for the virtual timer. Even
xen/arch/x86/irq.c +2 -2
@@ -962,7 +962,7 @@ static int __init cf_check irq_ratelimit__initcall (irq_ratelimit_init);int __init request_irq (unsigned int irq,unsigned int irqflags, -void (*handler)(int irq,void *dev_id,struct cpu_user_regs *regs), +void (*handler)(int irq,void *dev_id),const char * devname,void *dev_id) {struct irqaction * action;
@@ -2009,7 +2009,7 @@ void do_IRQ(struct cpu_user_regs *regs)spin_unlock_irq (&desc->lock); tsc_in = tb_init_done ?get_cycles () :0 ; - action->handler (irq, action->dev_id, regs); + action->handler (irq, action->dev_id);TRACE_3D (TRC_HW_IRQ_HANDLED , irq, tsc_in,get_cycles ());spin_lock_irq (&desc->lock);
xen/arch/x86/hpet.c +1 -2
@@ -237,8 +237,7 @@ again: } } -static void cf_check hpet_interrupt_handler( -int irq,void *data,struct cpu_user_regs *regs) +static void cf_check hpet_interrupt_handler(int irq, void *data) {struct hpet_event_channel *ch = data;
xen/arch/x86/time.c +1 -2
@@ -198,8 +198,7 @@ static void smp_send_timer_broadcast_ipi } } -static void cf_check timer_interrupt( -int irq,void *dev_id,struct cpu_user_regs *regs) +static void cf_check timer_interrupt(int irq, void *dev_id) {ASSERT (local_irq_is_enabled ());
xen/common/irq.c +1 -1
@@ -29,7 +29,7 @@ int init_one_irq_desc(struct irq_desc *dreturn err; } -void cf_check no_action(int cpl, void *dev_id, struct cpu_user_regs *regs) +void cf_check no_action(int cpl, void *dev_id) { }
xen/drivers/char/cadence-uart.c +1 -1
@@ -40,7 +40,7 @@ static struct cuart {#define cuart_read (uart, off) readl((uart)->regs + (off))#define cuart_write (uart, off,val) writel((val), (uart)->regs + (off)) -static void cuart_interrupt (int irq,void *data,struct cpu_user_regs *regs) +static void cuart_interrupt (int irq,void *data) {struct serial_port *port = data;struct cuart *uart = port->uart;
xen/drivers/char/exynos4210-uart.c +1 -1
@@ -45,7 +45,7 @@ static struct exynos4210_uart {#define exynos4210_read (uart, off) readl((uart)->regs + off)#define exynos4210_write (uart, off, val) writel(val, (uart->regs) + off) -static void exynos4210_uart_interrupt (int irq,void *data,struct cpu_user_regs *regs) +static void exynos4210_uart_interrupt (int irq,void *data) {struct serial_port *port = data;struct exynos4210_uart *uart = port->uart;
xen/drivers/char/imx-lpuart.c +1 -2
@@ -37,8 +37,7 @@ static struct imx_lpuart {struct vuart_info vuart; } imx8_com; -static void imx_lpuart_interrupt (int irq,void *data, -struct cpu_user_regs *regs) +static void imx_lpuart_interrupt (int irq,void *data) {struct serial_port *port = data;struct imx_lpuart *uart = port->uart;
xen/drivers/char/meson-uart.c +1 -2
@@ -61,8 +61,7 @@ static struct meson_uart {struct vuart_info vuart; } meson_com; -static void meson_uart_interrupt (int irq,void *data, -struct cpu_user_regs *regs) +static void meson_uart_interrupt (int irq,void *data) {struct serial_port *port = data;struct meson_uart *uart = port->uart;
xen/drivers/char/mvebu-uart.c +1 -2
@@ -67,8 +67,7 @@ static struct mvebu3700_uart {#define mvebu3700_read (uart, off) readl((uart)->regs + (off))#define mvebu3700_write (uart, off, val) writel(val, (uart)->regs + (off)) -static void mvebu3700_uart_interrupt (int irq,void *data, -struct cpu_user_regs *regs) +static void mvebu3700_uart_interrupt (int irq,void *data) {struct serial_port *port = data;struct mvebu3700_uart *uart = port->uart;
xen/drivers/char/ns16550.c +1 -2
@@ -175,8 +175,7 @@ static void handle_dw_usr_busy_quirk(str } } -static void cf_check ns16550_interrupt( -int irq,void *dev_id,struct cpu_user_regs *regs) +static void cf_check ns16550_interrupt(int irq, void *dev_id) {struct serial_port *port = dev_id;struct ns16550 *uart = port->uart;
xen/drivers/char/omap-uart.c +1 -1
@@ -59,7 +59,7 @@ static struct omap_uart {struct vuart_info vuart; } omap_com = {0}; -static void omap_uart_interrupt (int irq,void *data,struct cpu_user_regs *regs) +static void omap_uart_interrupt (int irq,void *data) {struct serial_port *port = data;struct omap_uart *uart = port->uart;
xen/drivers/char/pl011.c +1 -1
@@ -82,7 +82,7 @@ static unsigned int pl011_intr_status(streturn (pl011_read (uart,RIS ) &pl011_read (uart,IMSC )); } -static void pl011_interrupt (int irq,void *data,struct cpu_user_regs *regs) +static void pl011_interrupt (int irq,void *data) {struct serial_port *port = data;struct pl011 *uart = port->uart;
xen/drivers/char/scif-uart.c +1 -1
@@ -102,7 +102,7 @@ static const struct port_params port_par }, }; -static void scif_uart_interrupt (int irq,void *data,struct cpu_user_regs *regs) +static void scif_uart_interrupt (int irq,void *data) {struct serial_port *port = data;struct scif_uart *uart = port->uart;
xen/drivers/passthrough/amd/iommu_init.c +1 -2
@@ -718,8 +718,7 @@ static void cf_check do_amd_iommu_irq(vo static DECLARE_SOFTIRQ_TASKLET(amd_iommu_irq_tasklet, do_amd_iommu_irq, NULL); -static void cf_check iommu_interrupt_handler( -int irq,void *dev_id,struct cpu_user_regs *regs) +static void cf_check iommu_interrupt_handler(int irq, void *dev_id) {unsigned long flags;struct amd_iommu *iommu = dev_id;
xen/drivers/passthrough/arm/smmu.c +2 -4
@@ -1097,16 +1097,14 @@ static irqreturn_t arm_smmu_global_fault }/* Xen: Interrupt handlers wrapper */ -static void arm_smmu_context_fault_xen (int irq,void *dev, -struct cpu_user_regs *regs) +static void arm_smmu_context_fault_xen (int irq,void *dev) {arm_smmu_context_fault (irq, dev); }#define arm_smmu_context_fault arm_smmu_context_fault_xen -static void arm_smmu_global_fault_xen (int irq,void *dev, -struct cpu_user_regs *regs) +static void arm_smmu_global_fault_xen (int irq,void *dev) {arm_smmu_global_fault (irq, dev); }
xen/drivers/passthrough/arm/smmu-v3.c +4 -8
@@ -880,8 +880,7 @@ static void arm_smmu_priq_tasklet(void *static int arm_smmu_device_disable (struct arm_smmu_device *smmu); -static void arm_smmu_gerror_handler (int irq,void *dev, -struct cpu_user_regs *regs) +static void arm_smmu_gerror_handler (int irq,void *dev) {u32 gerror, gerrorn, active;struct arm_smmu_device *smmu = dev;
@@ -926,8 +925,7 @@ static void arm_smmu_gerror_handler(intwritel (gerror, smmu->base +ARM_SMMU_GERRORN ); } -static void arm_smmu_combined_irq_handler (int irq,void *dev, -struct cpu_user_regs *regs) +static void arm_smmu_combined_irq_handler (int irq,void *dev) {struct arm_smmu_device *smmu = dev;
@@ -945,16 +943,14 @@ static void arm_smmu_combined_irq_tasklearm_smmu_priq_tasklet (dev); } -static void arm_smmu_evtq_irq_tasklet (int irq,void *dev, -struct cpu_user_regs *regs) +static void arm_smmu_evtq_irq_tasklet (int irq,void *dev) {struct arm_smmu_device *smmu = dev;tasklet_schedule (&(smmu->evtq_irq_tasklet)); } -static void arm_smmu_priq_irq_tasklet (int irq,void *dev, -struct cpu_user_regs *regs) +static void arm_smmu_priq_irq_tasklet (int irq,void *dev) {struct arm_smmu_device *smmu = dev;
xen/drivers/passthrough/vtd/iommu.c +1 -2
@@ -1119,8 +1119,7 @@ static void cf_check do_iommu_page_fault__do_iommu_page_fault (drhd->iommu); } -static void cf_check iommu_page_fault( -int irq,void *dev_id,struct cpu_user_regs *regs) +static void cf_check iommu_page_fault(int irq, void *dev_id) {/* * Just flag the tasklet as runnable. This is fine, according to VT-d
xen/include/xen/irq.h +3 -4
@@ -18,7 +18,7 @@ ASSERT(!in_irq() && (local_irq_is_enabled() || num_online_cpus() <= 1))struct irqaction { -void (*handler)(int irq,void *dev_id,struct cpu_user_regs *regs); +void (*handler)(int irq,void *dev_id);const char *name;void *dev_id;bool free_on_release;
@@ -119,12 +119,11 @@ extern int setup_irq(unsigned int irq, u struct irqaction *new);extern void release_irq (unsigned int irq,const void *dev_id);extern int request_irq (unsigned int irq,unsigned int irqflags, -void (*handler)(int irq,void *dev_id, -struct cpu_user_regs *regs), +void (*handler)(int irq,void *dev_id),const char *devname,void *dev_id);extern hw_irq_controller no_irq_type; -void cf_check no_action(int cpl, void *dev_id, struct cpu_user_regs *regs); +void cf_check no_action(int cpl, void *dev_id); unsigned int cf_check irq_startup_none(struct irq_desc *desc); void cf_check irq_actor_none(struct irq_desc *desc);#define irq_shutdown_none irq_actor_none
Re: [PATCH 6/8] IRQ: drop register parameter from handler functions
Quoted 6 lines · Jan Beulich
It's simply not needed anymore. Note how Linux made this change many years ago already, in 2.6.19 (late 2006, see [1]).
Signed-off-by Jan Beulich <[email protected]>
https://git.kernel.org/torvalds/c/7d12e780e003f93433d49ce78cfedf4b4c52adc5
See https://korg.docs.kernel.org/git-url-shorteners.html for full details, but this is a guaranteed-stable URL.
It's worth saying that despite that patch in Linux, they've still not yet managed to drop the regs parameter.
Re: [PATCH 6/8] IRQ: drop register parameter from handler functions
Quoted 4 lines · Andrew Cooper
Quoted 3 lines · Jan Beulich
It's simply not needed anymore. Note how Linux made this change many years ago already, in 2.6.19 (late 2006, see [1]).
Quoted 8 lines
Quoted 3 lines
Signed-off-by Jan Beulich <[email protected]>https://git.kernel.org/torvalds/c/7d12e780e003f93433d49ce78cfedf4b4c52adc5
See https://korg.docs.kernel.org/git-url-shorteners.html for full details, but this is a guaranteed-stable URL.
Okay, changed. I'll try to keep this in mind.
Quoted 2 lines
It's worth saying that despite that patch in Linux, they've still not yet managed to drop the regs parameter.
How that, when they have
typedef irqreturn_t (*irq_handler_t)(int, void *);
?
Quoted 1 line
Reviewed-by Andrew Cooper <[email protected]>
Thanks.
Jan
Re: [PATCH 6/8] IRQ: drop register parameter from handler functions
In reply to Jan BeulichHi Jan,
Quoted 4 lines · Jan Beulich
It's simply not needed anymore. Note how Linux made this change many years ago already, in 2.6.19 (late 2006, see [1]).
Signed-off-by Jan Beulich <[email protected]>
This patch will need to be adjusted to compile on Arm. If you incorporate the changes from Michal (see the reply to the cover letter), then:
Quoted 2 lines
NIT: I was under the impresion the tags would usually last in a commit. So this would go before [1].
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 6/8] IRQ: drop register parameter from handler functions
Quoted 11 lines · Julien Grall
Quoted 4 lines · Jan Beulich
It's simply not needed anymore. Note how Linux made this change many years ago already, in 2.6.19 (late 2006, see [1]).
Signed-off-by Jan Beulich <[email protected]>This patch will need to be adjusted to compile on Arm. If you incorporate the changes from Michal (see the reply to the cover letter), then:
Acked-by Julien Grall <[email protected]>
Thanks.
Quoted 4 lines
Quoted 1 line
NIT: I was under the impresion the tags would usually last in a commit. So this would go before [1].
Well, I'm not sure. Personally I think footnotes better are last. If you indeed dislike this arrangement, and since I dislike
"It's simply not needed anymore. Note how Linux made this change many
years ago already, in 2.6.19 (late 2006, see [1]).
[1] https://git.kernel.org/torvalds/c/7d12e780e003f93433d49ce78cfedf4b4c52adc5"
best I could think of would then be to go without footnote:
"It's simply not needed anymore. Note how Linux made this change many
years ago already, in 2.6.19 (late 2006, see
https://git.kernel.org/torvalds/c/7d12e780e003f93433d49ce78cfedf4b4c52adc5").
Thoughts?
Jan
PATCH 7/8 x86/vPMU: drop regs parameter from interrupt functions
In reply to Jan BeulichThe vendor functions don't use the respective parameters at all. In vpmu_do_interrupt() there's only a very limited area where the outer context's state would be needed, retrievable by get_irq_regs().
This is in preparation of dropping the register parameters from direct APIC vector handler functions.
xen/arch/x86/apic.c +1 -1
@@ -1412,7 +1412,7 @@ static void cf_check error_interrupt(str static void cf_check pmu_interrupt(struct cpu_user_regs *regs) {ack_APIC_irq (); -vpmu_do_interrupt (regs); +vpmu_do_interrupt (); }void __init apic_intr_init (void )
xen/arch/x86/cpu/vpmu.c +3 -2
@@ -158,7 +158,7 @@ static inline struct vcpu *choose_hwdom_return hardware_domain->vcpu[idx]; } -void vpmu_do_interrupt (struct cpu_user_regs *regs) +void vpmu_do_interrupt (void ) {struct vcpu *sampled = current, *sampling;struct vpmu_struct *vpmu;
@@ -239,6 +239,7 @@ void vpmu_do_interrupt(struct cpu_user_r else#endif { +const struct cpu_user_regs *regs =get_irq_regs ();struct xen_pmu_regs *r = &vpmu->xenpmu_data->pmu.r.regs;if ( (vpmu_mode &XENPMU_MODE_SELF ) )
@@ -301,7 +302,7 @@ void vpmu_do_interrupt(struct cpu_user_r/* We don't support (yet) HVM dom0 */ ASSERT (sampling == sampled); -if ( !alternative_call (vpmu_ops.do_interrupt, regs) || +if ( !alternative_call (vpmu_ops.do_interrupt) || !is_vlapic_lvtpc_enabled (vlapic) )return ;
xen/arch/x86/cpu/vpmu_amd.c +1 -1
@@ -175,7 +175,7 @@ static void amd_vpmu_unset_msr_bitmap(stmsr_bitmap_off (vpmu); } -static int cf_check amd_vpmu_do_interrupt(struct cpu_user_regs *regs) +static int cf_check amd_vpmu_do_interrupt(void) {return 1 ; }
xen/arch/x86/cpu/vpmu_intel.c +1 -1
@@ -772,7 +772,7 @@ static void cf_check core2_vpmu_dump(con } } -static int cf_check core2_vpmu_do_interrupt(struct cpu_user_regs *regs) +static int cf_check core2_vpmu_do_interrupt(void) {struct vcpu *v = current;u64 msr_content;
xen/arch/x86/include/asm/vpmu.h +2 -2
@@ -31,7 +31,7 @@ struct arch_vpmu_ops {int (*initialise)(struct vcpu *v);int (*do_wrmsr)(unsigned int msr,uint64_t msr_content);int (*do_rdmsr)(unsigned int msr,uint64_t *msr_content); -int (*do_interrupt)(struct cpu_user_regs *regs); +int (*do_interrupt)(void );void (*arch_vpmu_destroy)(struct vcpu *v);int (*arch_vpmu_save)(struct vcpu *v,bool to_guest);int (*arch_vpmu_load)(struct vcpu *v,bool from_guest);
@@ -99,7 +99,7 @@ static inline bool vpmu_are_all_set(consvoid vpmu_lvtpc_update (uint32_t val);int vpmu_do_msr (unsigned int msr,uint64_t *msr_content,bool is_write); -void vpmu_do_interrupt (struct cpu_user_regs *regs); +void vpmu_do_interrupt (void );void vpmu_initialise (struct vcpu *v);void vpmu_destroy (struct vcpu *v);void vpmu_save (struct vcpu *v);
Re: [PATCH 7/8] x86/vPMU: drop regs parameter from interrupt functions
Quoted 8 lines · Jan Beulich
The vendor functions don't use the respective parameters at all. In
vpmu_do_interrupt()there's only a very limited area where the outer context's state would be needed, retrievable byget_irq_regs().This is in preparation of dropping the register parameters from direct APIC vector handler functions.
Signed-off-by Jan Beulich <[email protected]>
PATCH 8/8 x86/APIC: drop regs parameter from direct vector handler functions
In reply to Jan BeulichThe only place it was needed is in the spurious handler, and there we can use get_irq_regs() instead.
xen/arch/x86/apic.c +5 -5
@@ -1324,7 +1324,7 @@ int reprogram_timer(s_time_t timeout)return apic_tmict || !timeout; } -static void cf_check apic_timer_interrupt(struct cpu_user_regs *regs) +static void cf_check apic_timer_interrupt(void) {ack_APIC_irq ();perfc_incr (apic_timer);
@@ -1343,7 +1343,7 @@ void smp_send_state_dump(unsigned int cp/* * Spurious interrupts should _never_ happen with our APIC/SMP architecture. */ -static void cf_check spurious_interrupt(struct cpu_user_regs *regs) +static void cf_check spurious_interrupt(void) {/* * Check if this is a vectored interrupt (most likely, as this is probably
@@ -1357,7 +1357,7 @@ static void cf_check spurious_interrupt( is_spurious = !nmi_check_continuation ();if (this_cpu (state_dump_pending)) {this_cpu (state_dump_pending) = false; -dump_execstate (regs); +dump_execstate (get_irq_regs ()); is_spurious = false; }
@@ -1374,7 +1374,7 @@ static void cf_check spurious_interrupt(* This interrupt should never happen with our APIC/SMP architecture */ -static void cf_check error_interrupt(struct cpu_user_regs *regs) +static void cf_check error_interrupt(void) {static const char *const esr_fields[] = {", Send CS error" ,
@@ -1409,7 +1409,7 @@ static void cf_check error_interrupt(str* This interrupt handles performance counters interrupt */ -static void cf_check pmu_interrupt(struct cpu_user_regs *regs) +static void cf_check pmu_interrupt(void) {ack_APIC_irq ();vpmu_do_interrupt ();
xen/arch/x86/cpu/mcheck/mce_intel.c +2 -2
@@ -58,7 +58,7 @@ bool __read_mostly lmce_support;#define MCE_RING 0x1 static DEFINE_PER_CPU(int, last_state); -static void cf_check intel_thermal_interrupt(struct cpu_user_regs *regs) +static void cf_check intel_thermal_interrupt(void) {uint64_t msr_content;unsigned int cpu =smp_processor_id ();
@@ -642,7 +642,7 @@ static void cpu_mcheck_disable(void)clear_cmci (); } -static void cf_check cmci_interrupt(struct cpu_user_regs *regs) +static void cf_check cmci_interrupt(void) {mctelem_cookie_t mctc;struct mca_summary bs;
xen/arch/x86/guest/xen/xen.c +1 -1
@@ -158,7 +158,7 @@ static void __init init_memmap(void) } } -static void cf_check xen_evtchn_upcall(struct cpu_user_regs *regs) +static void cf_check xen_evtchn_upcall(void) {struct vcpu_info *vcpu_info =this_cpu (vcpu_info);unsigned long pending;
xen/arch/x86/hvm/vmx/vmx.c +2 -2
@@ -2773,7 +2773,7 @@ static struct hvm_function_table __initd };/* Handle VT-d posted-interrupt when VCPU is blocked. */ -static void cf_check pi_wakeup_interrupt(struct cpu_user_regs *regs) +static void cf_check pi_wakeup_interrupt(void) {struct vmx_vcpu *vmx, *tmp;spinlock_t *lock = &per_cpu (vmx_pi_blocking,smp_processor_id ()).lock;
@@ -2805,7 +2805,7 @@ static void cf_check pi_wakeup_interrupt }/* Handle VT-d posted-interrupt when VCPU is running. */ -static void cf_check pi_notification_interrupt(struct cpu_user_regs *regs) +static void cf_check pi_notification_interrupt(void) {ack_APIC_irq ();this_cpu (irq_count)++;
xen/arch/x86/include/asm/irq.h +6 -8
@@ -72,17 +72,15 @@ extern int opt_irq_vector_map;#define platform_legacy_irq (irq) ((irq) < 16) -void cf_check event_check_interrupt(struct cpu_user_regs *regs); -void cf_check invalidate_interrupt(struct cpu_user_regs *regs); -void cf_check call_function_interrupt(struct cpu_user_regs *regs); -void cf_check irq_move_cleanup_interrupt(struct cpu_user_regs *regs); +void cf_check event_check_interrupt(void); +void cf_check invalidate_interrupt(void); +void cf_check call_function_interrupt(void); +void cf_check irq_move_cleanup_interrupt(void);uint8_t alloc_hipriority_vector (void ); -void set_direct_apic_vector ( -uint8_t vector,void (*handler)(struct cpu_user_regs *regs)); -void alloc_direct_apic_vector ( -uint8_t *vector,void (*handler)(struct cpu_user_regs *regs)); +void set_direct_apic_vector (uint8_t vector,void (*handler)(void )); +void alloc_direct_apic_vector (uint8_t *vector,void (*handler)(void ));void do_IRQ (struct cpu_user_regs *regs);
xen/arch/x86/irq.c +5 -7
@@ -743,7 +743,7 @@ void move_native_irq(struct irq_desc *de desc->handler->enable (desc); } -void cf_check irq_move_cleanup_interrupt(struct cpu_user_regs *regs) +void cf_check irq_move_cleanup_interrupt(void) {unsigned vector, me;
@@ -913,16 +913,14 @@ uint8_t alloc_hipriority_vector(void)return next++; } -static void (*direct_apic_vector[X86_NR_VECTORS ])(struct cpu_user_regs *regs); -void set_direct_apic_vector ( -uint8_t vector,void (*handler)(struct cpu_user_regs *regs)) +static void (*direct_apic_vector[X86_NR_VECTORS ])(void ); +void set_direct_apic_vector (uint8_t vector,void (*handler)(void )) {BUG_ON (direct_apic_vector[vector] !=NULL ); direct_apic_vector[vector] = handler; } -void alloc_direct_apic_vector ( -uint8_t *vector,void (*handler)(struct cpu_user_regs *regs)) +void alloc_direct_apic_vector (uint8_t *vector,void (*handler)(void )) {static DEFINE_SPINLOCK (lock);
@@ -1907,7 +1905,7 @@ void do_IRQ(struct cpu_user_regs *regs)if ( irq <0 ) {if ( direct_apic_vector[vector] ) - direct_apic_vector[vector](regs); + direct_apic_vector[vector]();else {const char *kind =", LAPIC" ;
xen/arch/x86/smp.c +3 -3
@@ -245,7 +245,7 @@ static cpumask_t flush_cpumask;static const void *flush_va;static unsigned int flush_flags; -void cf_check invalidate_interrupt(struct cpu_user_regs *regs) +void cf_check invalidate_interrupt(void) {unsigned int flags = flush_flags;ack_APIC_irq ();
@@ -387,14 +387,14 @@ void smp_send_nmi_allbutself(void)send_IPI_mask (&cpu_online_map,APIC_DM_NMI ); } -void cf_check event_check_interrupt(struct cpu_user_regs *regs) +void cf_check event_check_interrupt(void) {ack_APIC_irq ();perfc_incr (ipis);this_cpu (irq_count)++; } -void cf_check call_function_interrupt(struct cpu_user_regs *regs) +void cf_check call_function_interrupt(void) {ack_APIC_irq ();perfc_incr (ipis);
Re: [PATCH 8/8] x86/APIC: drop regs parameter from direct vector handler functions
Quoted 4 lines · Jan Beulich
The only place it was needed is in the spurious handler, and there we can use
get_irq_regs()instead.Signed-off-by Jan Beulich <[email protected]>
I'd forgotten that we'd abused SPIV like that, but oh well.
Quoted 6 lines · Jan Beulich
Unlike (synchronous) exception handlers, interrupt handlers don't normally have a need to know the outer context's register state. Similarly, the vast majority of key handlers has no need for such.
Quoted 6 lines
1: keyhandler: don't pass
cpu_user_regsaround 2: IRQ: generalize [gs]et_irq_regs()
3: serial: drop serial_rx_fn's regs parameter
4: PV-shim: drop pv_console_rx()'s regs parameter 5: serial: drop serial_[rt]x_interrupt()'s regs parameter 6: IRQ: drop regs parameter from handler functions
FYI, I did a build test on Arm and there were 2 build errors. Fix below:
xen/drivers/passthrough/arm/ipmmu-vmsa.c +1 -1
@@ -642,7 +642,7 @@ static void ipmmu_domain_irq(struct ipmmu_vmsa_domain *domain) domain->d, status, iova); } -static void ipmmu_irq (int irq,void *dev,struct cpu_user_regs *regs) +static void ipmmu_irq (int irq,void *dev) {struct ipmmu_vmsa_device *mmu = dev;unsigned int i;
xen/drivers/passthrough/arm/smmu-v3.c +1 -1
@@ -929,7 +929,7 @@ static void arm_smmu_combined_irq_handler(int irq, void *dev) {struct arm_smmu_device *smmu = dev; -arm_smmu_gerror_handler (irq, dev, regs); +arm_smmu_gerror_handler (irq, dev);tasklet_schedule (&(smmu->combined_irq_tasklet)); }
Quoted 5 lines
7: x86/vPMU: drop regs parameter from interrupt functions 8: x86/APIC: drop regs parameter from direct vector handler functions
Jan
~Michal
Quoted 5 lines · Michal Orzel
Quoted 4 lines · Jan Beulich
Unlike (synchronous) exception handlers, interrupt handlers don't normally have a need to know the outer context's register state. Similarly, the vast majority of key handlers has no need for such.
Quoted 7 lines
Quoted 6 lines
1: keyhandler: don't pass
cpu_user_regsaround 2: IRQ: generalize [gs]et_irq_regs()
3: serial: drop serial_rx_fn's regs parameter
4: PV-shim: drop pv_console_rx()'s regs parameter 5: serial: drop serial_[rt]x_interrupt()'s regs parameter 6: IRQ: drop regs parameter from handler functionsFYI, I did a build test on Arm and there were 2 build errors. Fix below:
Thanks for spotting. First of all I'll want to figure out why I didn't notice these; I certainly did do several Arm text builds.
Jan
Quoted 35 lines
xen/drivers/passthrough/arm/ipmmu-vmsa.c +1
-1@@ -642,7 +642,7 @@ static void ipmmu_domain_irq(struct ipmmu_vmsa_domain *domain) domain->d, status, iova); } -static void ipmmu_irq (int irq,void *dev,struct cpu_user_regs *regs) +static void ipmmu_irq (int irq,void *dev) {struct ipmmu_vmsa_device *mmu = dev;unsigned int i;xen/drivers/passthrough/arm/smmu-v3.c +1
-1@@ -929,7 +929,7 @@ static void arm_smmu_combined_irq_handler(int irq, void *dev) {struct arm_smmu_device *smmu = dev; -arm_smmu_gerror_handler (irq, dev, regs); +arm_smmu_gerror_handler (irq, dev);tasklet_schedule (&(smmu->combined_irq_tasklet)); }Quoted 7 lines
7: x86/vPMU: drop regs parameter from interrupt functions 8: x86/APIC: drop regs parameter from direct vector handler functions
Jan
~Michal