Skip to content

Commit

Permalink
x86: identify reset_stack_and_jump() as noreturn
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Jan Beulich <[email protected]>
Reviewed-by: Tim Deegan <[email protected]>
Acked-by: Keir Fraser <[email protected]>
  • Loading branch information
andyhhp authored and jbeulich committed Mar 4, 2014
1 parent f600b32 commit ceff76a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
6 changes: 2 additions & 4 deletions xen/arch/x86/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion xen/arch/x86/hvm/svm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion xen/arch/x86/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions xen/include/asm-x86/current.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion xen/include/asm-x86/domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
2 changes: 1 addition & 1 deletion xen/include/asm-x86/hvm/vmx/vmx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ceff76a

Please sign in to comment.