[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] consolidate do_bug_frame() / bug_fn_t
commit 8c5e4ce14509ca85b3f5faa298a766b8ffdd4f85 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Thu Feb 22 12:16:55 2024 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Feb 22 12:16:55 2024 +0100 consolidate do_bug_frame() / bug_fn_t The type not being used in do_bug_frame() is suspicious. Apparently that's solely because the type uses a pointer-to-const parameter, when so far run_in_exception_handler() wanted functions taking pointer- to-non-const. Expand use of const, in turn requiring common code's do_bug_frame() as well as [gs]et_irq_regs() to also gain const. This then brings the former function also closer to the common one, with Arm's use of vaddr_t remaining as a difference. While there also replace the bogus use of hard tabs in [gs]et_irq_regs() (I clearly didn't mean to put it in like this). Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Julien Grall <jgrall@xxxxxxxxxx> --- xen/arch/arm/irq.c | 2 +- xen/arch/x86/include/asm/processor.h | 3 +-- xen/arch/x86/irq.c | 2 +- xen/arch/x86/traps.c | 7 +------ xen/common/bug.c | 8 ++------ xen/common/irq.c | 2 +- xen/common/keyhandler.c | 2 +- xen/drivers/char/ehci-dbgp.c | 4 ++-- xen/drivers/char/ns16550.c | 4 ++-- xen/include/xen/bug.h | 5 ++--- xen/include/xen/irq.h | 17 +++++++++-------- xen/include/xen/kernel.h | 3 +-- xen/include/xen/lib.h | 2 +- 13 files changed, 25 insertions(+), 36 deletions(-) diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 6ac952f43b..bcce80a4d6 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -220,7 +220,7 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq) { struct irq_desc *desc = irq_to_desc(irq); struct irqaction *action; - struct cpu_user_regs *old_regs = set_irq_regs(regs); + const struct cpu_user_regs *old_regs = set_irq_regs(regs); perfc_incr(irqs); diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/asm/processor.h index b227cdee8e..c26ef9090c 100644 --- a/xen/arch/x86/include/asm/processor.h +++ b/xen/arch/x86/include/asm/processor.h @@ -409,8 +409,7 @@ static always_inline void rep_nop(void) void show_code(const struct cpu_user_regs *regs); void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs); void show_registers(const struct cpu_user_regs *regs); -#define dump_execution_state() \ - run_in_exception_handler(show_execution_state_nonconst) +#define dump_execution_state() run_in_exception_handler(show_execution_state) void show_page_walk(unsigned long addr); void noreturn fatal_trap(const struct cpu_user_regs *regs, bool show_remote); diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index 810de06fd3..7458b89ab3 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1896,7 +1896,7 @@ void do_IRQ(struct cpu_user_regs *regs) struct irq_desc *desc; unsigned int vector = (uint8_t)regs->entry_vector; int irq = this_cpu(vector_irq)[vector]; - struct cpu_user_regs *old_regs = set_irq_regs(regs); + const struct cpu_user_regs *old_regs = set_irq_regs(regs); perfc_incr(irqs); this_cpu(irq_count)++; diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 5f4bcc0537..ff37d97133 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -643,7 +643,7 @@ void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs) printk("\n"); } -void show_execution_state(const struct cpu_user_regs *regs) +void cf_check show_execution_state(const struct cpu_user_regs *regs) { /* Prevent interleaving of output. */ unsigned long flags = console_lock_recursive_irqsave(); @@ -655,11 +655,6 @@ void show_execution_state(const struct cpu_user_regs *regs) console_unlock_recursive_irqrestore(flags); } -void cf_check show_execution_state_nonconst(struct cpu_user_regs *regs) -{ - show_execution_state(regs); -} - void vcpu_show_execution_state(struct vcpu *v) { unsigned long flags = 0; diff --git a/xen/common/bug.c b/xen/common/bug.c index 5fbe703a81..c43e7c4397 100644 --- a/xen/common/bug.c +++ b/xen/common/bug.c @@ -10,7 +10,7 @@ * Returns a negative value in case of an error otherwise * BUGFRAME_{run_fn, warn, bug, assert} */ -int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc) +int do_bug_frame(const struct cpu_user_regs *regs, unsigned long pc) { const struct bug_frame *bug = NULL; const struct virtual_region *region; @@ -44,14 +44,10 @@ int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc) if ( id == BUGFRAME_run_fn ) { - void (*fn)(struct cpu_user_regs *) = bug_ptr(bug); + bug_fn_t *fn = bug_ptr(bug); fn(regs); - /* Re-enforce consistent types, because of the casts involved. */ - if ( false ) - run_in_exception_handler(fn); - return id; } diff --git a/xen/common/irq.c b/xen/common/irq.c index 04f14f7d1a..7225b46374 100644 --- a/xen/common/irq.c +++ b/xen/common/irq.c @@ -1,7 +1,7 @@ #include <xen/irq.h> #include <xen/errno.h> -DEFINE_PER_CPU(struct cpu_user_regs *, irq_regs); +DEFINE_PER_CPU(const struct cpu_user_regs *, irq_regs); int init_one_irq_desc(struct irq_desc *desc) { diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index 9c23a540e5..127ca50696 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -135,7 +135,7 @@ static void cf_check show_handlers(unsigned char key) static cpumask_t dump_execstate_mask; -void cf_check dump_execstate(struct cpu_user_regs *regs) +void cf_check dump_execstate(const struct cpu_user_regs *regs) { unsigned int cpu = smp_processor_id(); diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c index 2bb55418a7..1ad3c6bebf 100644 --- a/xen/drivers/char/ehci-dbgp.c +++ b/xen/drivers/char/ehci-dbgp.c @@ -1246,14 +1246,14 @@ static int cf_check ehci_dbgp_getc(struct serial_port *port, char *pc) /* Safe: ehci_dbgp_poll() runs as timer handler, so not reentrant. */ static struct serial_port *poll_port; -static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs) +static void cf_check _ehci_dbgp_poll(const struct cpu_user_regs *regs) { struct serial_port *port = poll_port; struct ehci_dbgp *dbgp = port->uart; unsigned long flags; unsigned int timeout = MICROSECS(DBGP_CHECK_INTERVAL); bool empty = false; - struct cpu_user_regs *old_regs; + const struct cpu_user_regs *old_regs; if ( !dbgp->ehci_debug ) return; diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index a126e4a808..8f76bbe676 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -206,11 +206,11 @@ static void cf_check ns16550_interrupt(int irq, void *dev_id) /* Safe: ns16550_poll() runs as softirq so not reentrant on a given CPU. */ static DEFINE_PER_CPU(struct serial_port *, poll_port); -static void cf_check __ns16550_poll(struct cpu_user_regs *regs) +static void cf_check __ns16550_poll(const struct cpu_user_regs *regs) { struct serial_port *port = this_cpu(poll_port); struct ns16550 *uart = port->uart; - struct cpu_user_regs *old_regs; + const struct cpu_user_regs *old_regs; if ( uart->intr_works ) return; /* Interrupts work - no more polling */ diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h index 4bd0be5088..a11d4239f8 100644 --- a/xen/include/xen/bug.h +++ b/xen/include/xen/bug.h @@ -101,8 +101,7 @@ typedef void bug_fn_t(const struct cpu_user_regs *regs); #ifndef run_in_exception_handler -static void always_inline run_in_exception_handler( - void (*fn)(struct cpu_user_regs *regs)) +static void always_inline run_in_exception_handler(bug_fn_t *fn) { BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL); } @@ -133,7 +132,7 @@ static void always_inline run_in_exception_handler( * Returns a negative value in case of an error otherwise * BUGFRAME_{run_fn, warn, bug, assert} */ -int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc); +int do_bug_frame(const struct cpu_user_regs *regs, unsigned long pc); #endif /* CONFIG_GENERIC_BUG_FRAME */ diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h index 72c24c6f04..89f7a8317a 100644 --- a/xen/include/xen/irq.h +++ b/xen/include/xen/irq.h @@ -134,21 +134,22 @@ void cf_check irq_actor_none(struct irq_desc *desc); * Per-cpu interrupted context register state - the inner-most interrupt frame * on the stack. */ -DECLARE_PER_CPU(struct cpu_user_regs *, irq_regs); +DECLARE_PER_CPU(const struct cpu_user_regs *, irq_regs); -static inline struct cpu_user_regs *get_irq_regs(void) +static inline const struct cpu_user_regs *get_irq_regs(void) { - return this_cpu(irq_regs); + return this_cpu(irq_regs); } -static inline struct cpu_user_regs *set_irq_regs(struct cpu_user_regs *new_regs) +static inline const struct cpu_user_regs *set_irq_regs( + const struct cpu_user_regs *new_regs) { - struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(irq_regs); + const struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(irq_regs); - old_regs = *pp_regs; - *pp_regs = new_regs; + old_regs = *pp_regs; + *pp_regs = new_regs; - return old_regs; + return old_regs; } struct domain; diff --git a/xen/include/xen/kernel.h b/xen/include/xen/kernel.h index 6bbd4a2827..bb6b0f3891 100644 --- a/xen/include/xen/kernel.h +++ b/xen/include/xen/kernel.h @@ -110,8 +110,7 @@ extern const unsigned int xen_config_data_size; struct cpu_user_regs; struct vcpu; -void show_execution_state(const struct cpu_user_regs *regs); -void cf_check show_execution_state_nonconst(struct cpu_user_regs *regs); +void cf_check show_execution_state(const struct cpu_user_regs *regs); void vcpu_show_execution_state(struct vcpu *v); #endif /* _LINUX_KERNEL_H */ diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 1793be5b6b..abee6c20d7 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -173,7 +173,7 @@ extern char *print_tainted(char *str); extern void add_taint(unsigned int taint); struct cpu_user_regs; -void cf_check dump_execstate(struct cpu_user_regs *regs); +void cf_check dump_execstate(const struct cpu_user_regs *regs); void init_constructors(void); -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |