From ceff76a5be3caaca028ea8a6cbce5744eaf2b2db Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 4 Mar 2014 11:19:20 +0100 Subject: [PATCH] x86: identify reset_stack_and_jump() as noreturn reset_stack_and_jump() is actually a macro, but can effectivly become noreturn by giving it an unreachable() declaration. Propagate the 'noreturn-ness' up through the direct and indirect callers. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Reviewed-by: Tim Deegan Acked-by: Keir Fraser --- xen/arch/x86/domain.c | 6 ++---- xen/arch/x86/hvm/svm/svm.c | 2 +- xen/arch/x86/setup.c | 2 +- xen/include/asm-x86/current.h | 11 +++++++---- xen/include/asm-x86/domain.h | 2 +- xen/include/asm-x86/hvm/vmx/vmx.h | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 6618ae6604f1..c42a079f1da4 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -133,12 +133,12 @@ void startup_cpu_idle_loop(void) reset_stack_and_jump(idle_loop); } -static void continue_idle_domain(struct vcpu *v) +static void noreturn continue_idle_domain(struct vcpu *v) { reset_stack_and_jump(idle_loop); } -static void continue_nonidle_domain(struct vcpu *v) +static void noreturn continue_nonidle_domain(struct vcpu *v) { check_wakeup_from_wait(); mark_regs_dirty(guest_cpu_user_regs()); @@ -1521,13 +1521,11 @@ void context_switch(struct vcpu *prev, struct vcpu *next) update_vcpu_system_time(next); schedule_tail(next); - BUG(); } void continue_running(struct vcpu *same) { schedule_tail(same); - BUG(); } int __sync_local_execstate(void) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 61b1ec81a7d1..4fd53761eb65 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -911,7 +911,7 @@ static void svm_ctxt_switch_to(struct vcpu *v) wrmsrl(MSR_TSC_AUX, hvm_msr_tsc_aux(v)); } -static void svm_do_resume(struct vcpu *v) +static void noreturn svm_do_resume(struct vcpu *v) { struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; bool_t debug_state = v->domain->debugger_attached; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c743606c385f..4dbf2b7e5f21 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -537,7 +537,7 @@ static char * __init cmdline_cook(char *p, char *loader_name) return p; } -void __init __start_xen(unsigned long mbi_p) +void __init noreturn __start_xen(unsigned long mbi_p) { char *memmap_type = NULL; char *cmdline, *kextra, *loader; diff --git a/xen/include/asm-x86/current.h b/xen/include/asm-x86/current.h index c2792ce139a5..4d1f20e16d39 100644 --- a/xen/include/asm-x86/current.h +++ b/xen/include/asm-x86/current.h @@ -59,10 +59,13 @@ static inline struct cpu_info *get_cpu_info(void) ((sp & (~(STACK_SIZE-1))) + \ (STACK_SIZE - sizeof(struct cpu_info) - sizeof(unsigned long))) -#define reset_stack_and_jump(__fn) \ - __asm__ __volatile__ ( \ - "mov %0,%%"__OP"sp; jmp %c1" \ - : : "r" (guest_cpu_user_regs()), "i" (__fn) : "memory" ) +#define reset_stack_and_jump(__fn) \ + ({ \ + __asm__ __volatile__ ( \ + "mov %0,%%"__OP"sp; jmp %c1" \ + : : "r" (guest_cpu_user_regs()), "i" (__fn) : "memory" ); \ + unreachable(); \ + }) #define schedule_tail(vcpu) (((vcpu)->arch.schedule_tail)(vcpu)) diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 4ff89f01eac5..49f7c0c23112 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -395,7 +395,7 @@ struct arch_vcpu unsigned long flags; /* TF_ */ - void (*schedule_tail) (struct vcpu *); + void noreturn (*schedule_tail) (struct vcpu *); void (*ctxt_switch_from) (struct vcpu *); void (*ctxt_switch_to) (struct vcpu *); diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h index 6f6b6728dfba..827c97e7eeed 100644 --- a/xen/include/asm-x86/hvm/vmx/vmx.h +++ b/xen/include/asm-x86/hvm/vmx/vmx.h @@ -91,7 +91,7 @@ typedef enum { void vmx_asm_vmexit_handler(struct cpu_user_regs); void vmx_asm_do_vmentry(void); void vmx_intr_assist(void); -void vmx_do_resume(struct vcpu *); +void noreturn vmx_do_resume(struct vcpu *); void vmx_vlapic_msr_changed(struct vcpu *v); void vmx_realmode(struct cpu_user_regs *regs); void vmx_update_debug_state(struct vcpu *v);