[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/2] xen: Identify panic and reboot/halt functions as noreturn
On an x86 build (GCC Debian 4.7.2-5), this reduces the .text size by exactly 4K, and .init.text by 1751 bytes. Even in a non-debug build, the generated code uses `call` rather than `jmp` so there should be no impact on any stack trace generation. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CC: Keir Fraser <keir@xxxxxxx> CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Ian Campbell <ian.campbell@xxxxxxxxxx> CC: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx> CC: Tim Deegan <tim@xxxxxxx> --- I believe I have identified each reasonable ARM function which could be tagged as noreturn, but am not overly familiar with the codebase. I have compile tested arm32 and arm64 --- xen/arch/arm/shutdown.c | 6 +++--- xen/arch/arm/smpboot.c | 2 +- xen/arch/x86/cpu/mcheck/mce.c | 2 +- xen/arch/x86/cpu/mcheck/mce.h | 2 +- xen/arch/x86/shutdown.c | 6 +++--- xen/common/shutdown.c | 4 ++-- xen/drivers/char/console.c | 2 +- xen/include/asm-arm/smp.h | 2 +- xen/include/xen/lib.h | 2 +- xen/include/xen/shutdown.h | 10 ++++++---- 10 files changed, 20 insertions(+), 18 deletions(-) diff --git a/xen/arch/arm/shutdown.c b/xen/arch/arm/shutdown.c index 767cc12..58f1cf1 100644 --- a/xen/arch/arm/shutdown.c +++ b/xen/arch/arm/shutdown.c @@ -11,12 +11,12 @@ static void raw_machine_reset(void) platform_reset(); } -static void halt_this_cpu(void *arg) +static void noreturn halt_this_cpu(void *arg) { stop_cpu(); } -void machine_halt(void) +void noreturn machine_halt(void) { watchdog_disable(); console_start_sync(); @@ -25,7 +25,7 @@ void machine_halt(void) halt_this_cpu(NULL); } -void machine_restart(unsigned int delay_millisecs) +void noreturn machine_restart(unsigned int delay_millisecs) { int timeout = 10; diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 6c90fa6..7242331 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -310,7 +310,7 @@ void __cpu_disable(void) * scheduler will drop to the idle loop, which will call stop_cpu(). */ } -void stop_cpu(void) +void noreturn stop_cpu(void) { local_irq_disable(); cpu_is_dead = 1; diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index 93d7ae1..8a226ca 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -1534,7 +1534,7 @@ static void mc_panic_dump(void) dprintk(XENLOG_ERR, "End dump mc_info, %x mcinfo dumped\n", mcinfo_dumpped); } -void mc_panic(char *s) +void noreturn mc_panic(char *s) { is_mc_panic = 1; console_force_unlock(); diff --git a/xen/arch/x86/cpu/mcheck/mce.h b/xen/arch/x86/cpu/mcheck/mce.h index cbd123d..db791ff 100644 --- a/xen/arch/x86/cpu/mcheck/mce.h +++ b/xen/arch/x86/cpu/mcheck/mce.h @@ -57,7 +57,7 @@ int mce_available(struct cpuinfo_x86 *c); unsigned int mce_firstbank(struct cpuinfo_x86 *c); /* Helper functions used for collecting error telemetry */ struct mc_info *x86_mcinfo_getptr(void); -void mc_panic(char *s); +void mc_panic(char *s) noreturn; void x86_mc_get_cpu_info(unsigned, uint32_t *, uint16_t *, uint16_t *, uint32_t *, uint32_t *, uint32_t *, uint32_t *); diff --git a/xen/arch/x86/shutdown.c b/xen/arch/x86/shutdown.c index 6143c40..a99a599 100644 --- a/xen/arch/x86/shutdown.c +++ b/xen/arch/x86/shutdown.c @@ -92,7 +92,7 @@ static void noreturn __machine_halt(void *unused) halt(); } -void machine_halt(void) +void noreturn machine_halt(void) { watchdog_disable(); console_start_sync(); @@ -452,12 +452,12 @@ static int __init reboot_init(void) } __initcall(reboot_init); -static void __machine_restart(void *pdelay) +static void noreturn __machine_restart(void *pdelay) { machine_restart(*(unsigned int *)pdelay); } -void machine_restart(unsigned int delay_millisecs) +void noreturn machine_restart(unsigned int delay_millisecs) { unsigned int i, attempt; enum reboot_type orig_reboot_type = reboot_type; diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c index 9bccd34..87424b1 100644 --- a/xen/common/shutdown.c +++ b/xen/common/shutdown.c @@ -17,7 +17,7 @@ bool_t __read_mostly opt_noreboot; boolean_param("noreboot", opt_noreboot); -static void maybe_reboot(void) +static void noreturn maybe_reboot(void) { if ( opt_noreboot ) { @@ -32,7 +32,7 @@ static void maybe_reboot(void) } } -void dom0_shutdown(u8 reason) +void noreturn dom0_shutdown(u8 reason) { switch ( reason ) { diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 508f845..7347f96 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -1038,7 +1038,7 @@ __initcall(debugtrace_init); * ************************************************************** */ -void panic(const char *fmt, ...) +void noreturn panic(const char *fmt, ...) { va_list args; unsigned long flags; diff --git a/xen/include/asm-arm/smp.h b/xen/include/asm-arm/smp.h index 1485cc6..0f57c68 100644 --- a/xen/include/asm-arm/smp.h +++ b/xen/include/asm-arm/smp.h @@ -15,7 +15,7 @@ DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask); #define raw_smp_processor_id() (get_processor_id()) -extern void stop_cpu(void); +extern void stop_cpu(void) noreturn; extern int arch_smp_init(void); extern int arch_cpu_init(int cpu, struct dt_device_node *dn); diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 814fcb4..c8b35f1 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -87,7 +87,7 @@ extern void printk(const char *format, ...) __attribute__ ((format (printf, 1, 2))); extern void guest_printk(const struct domain *d, const char *format, ...) __attribute__ ((format (printf, 2, 3))); -extern void panic(const char *format, ...) +extern void panic(const char *format, ...) noreturn __attribute__ ((format (printf, 1, 2))); extern long vm_assist(struct domain *, unsigned int, unsigned int); extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst); diff --git a/xen/include/xen/shutdown.h b/xen/include/xen/shutdown.h index 2bee748..dfe80d0 100644 --- a/xen/include/xen/shutdown.h +++ b/xen/include/xen/shutdown.h @@ -1,13 +1,15 @@ #ifndef __XEN_SHUTDOWN_H__ #define __XEN_SHUTDOWN_H__ +#include <xen/compiler.h> + /* opt_noreboot: If true, machine will need manual reset on error. */ extern bool_t opt_noreboot; -void dom0_shutdown(u8 reason); +void dom0_shutdown(u8 reason) noreturn; -void machine_restart(unsigned int delay_millisecs); -void machine_halt(void); -void machine_power_off(void); +void machine_restart(unsigned int delay_millisecs) noreturn; +void machine_halt(void) noreturn; +void machine_power_off(void) noreturn; #endif /* __XEN_SHUTDOWN_H__ */ -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |