From: "Jan Beulich" Subject: [PATCH] x86: eliminate (unused) return value from exception handling routines Date: Mon, 10 Dec 2007 09:29:20 +0000 Message-ID: <475D1500.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org (Hunk 4 will only apply cleanly on top of the previously sent gdprintk() cleanup patch.) Signed-off-by: Jan Beulich Index: 2007-12-10/xen/arch/x86/traps.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-12-10.orig/xen/arch/x86/traps.c 2007-12-10 09:24:04.0000000= 00 +0100 +++ 2007-12-10/xen/arch/x86/traps.c 2007-12-10 09:25:55.000000000 = +0100 @@ -86,12 +86,11 @@ idt_entry_t *idt_tables[NR_CPUS] __read_ =20 #define DECLARE_TRAP_HANDLER(_name) \ asmlinkage void _name(void); \ -asmlinkage int do_ ## _name(struct cpu_user_regs *regs) +asmlinkage void do_ ## _name(struct cpu_user_regs *regs) =20 -asmlinkage void nmi(void); -asmlinkage void machine_check(void); DECLARE_TRAP_HANDLER(divide_error); DECLARE_TRAP_HANDLER(debug); +DECLARE_TRAP_HANDLER(nmi); DECLARE_TRAP_HANDLER(int3); DECLARE_TRAP_HANDLER(overflow); DECLARE_TRAP_HANDLER(bounds); @@ -105,6 +104,7 @@ DECLARE_TRAP_HANDLER(general_protection) DECLARE_TRAP_HANDLER(page_fault); DECLARE_TRAP_HANDLER(coprocessor_error); DECLARE_TRAP_HANDLER(simd_coprocessor_error); +DECLARE_TRAP_HANDLER(machine_check); DECLARE_TRAP_HANDLER(alignment_check); DECLARE_TRAP_HANDLER(spurious_interrupt_bug); =20 @@ -382,7 +382,7 @@ asmlinkage void fatal_trap(int trapnr, s (regs->eflags & X86_EFLAGS_IF) ? "" : ", IN INTERRUPT CONTEXT");= } =20 -static int do_guest_trap( +static void do_guest_trap( int trapnr, const struct cpu_user_regs *regs, int use_error_code) { struct vcpu *v =3D current; @@ -411,8 +411,6 @@ static int do_guest_trap( gdprintk(XENLOG_WARNING, "Unhandled %s fault/trap [#%d] " "on VCPU %d [ec=3D%04x]\n", trapstr(trapnr), trapnr, v->vcpu_id, regs->error_code); - - return 0; } =20 static void instruction_done( @@ -477,7 +475,7 @@ asmlinkage int set_guest_nmi_trapbounce( return !null_trap_bounce(v, tb); } =20 -static inline int do_trap( +static inline void do_trap( int trapnr, struct cpu_user_regs *regs, int use_error_code) { unsigned long fixup; @@ -485,14 +483,17 @@ static inline int do_trap( DEBUGGER_trap_entry(trapnr, regs); =20 if ( guest_mode(regs) ) - return do_guest_trap(trapnr, regs, use_error_code); + { + do_guest_trap(trapnr, regs, use_error_code); + return; + } =20 if ( likely((fixup =3D search_exception_table(regs->eip)) !=3D 0) ) { dprintk(XENLOG_ERR, "Trap %d: %p -> %p\n", trapnr, _p(regs->eip), _p(fixup)); regs->eip =3D fixup; - return 0; + return; } =20 DEBUGGER_trap_fatal(trapnr, regs); @@ -501,19 +502,18 @@ static inline int do_trap( panic("FATAL TRAP: vector =3D %d (%s)\n" "[error_code=3D%04x]\n", trapnr, trapstr(trapnr), regs->error_code); - return 0; } =20 #define DO_ERROR_NOCODE(trapnr, name) \ -asmlinkage int do_##name(struct cpu_user_regs *regs) \ +asmlinkage void do_##name(struct cpu_user_regs *regs) \ { \ - return do_trap(trapnr, regs, 0); \ + do_trap(trapnr, regs, 0); \ } =20 #define DO_ERROR(trapnr, name) \ -asmlinkage int do_##name(struct cpu_user_regs *regs) \ +asmlinkage void do_##name(struct cpu_user_regs *regs) \ { \ - return do_trap(trapnr, regs, 1); \ + do_trap(trapnr, regs, 1); \ } =20 DO_ERROR_NOCODE(TRAP_divide_error, divide_error) @@ -714,20 +714,20 @@ static int emulate_forced_invalid_op(str return EXCRET_fault_fixed; } =20 -asmlinkage int do_invalid_op(struct cpu_user_regs *regs) +asmlinkage void do_invalid_op(struct cpu_user_regs *regs) { struct bug_frame bug; struct bug_frame_str bug_str; char *filename, *predicate, *eip =3D (char *)regs->eip; - int rc, id, lineno; + int id, lineno; =20 DEBUGGER_trap_entry(TRAP_invalid_op, regs); =20 if ( likely(guest_mode(regs)) ) { - if ( (rc =3D emulate_forced_invalid_op(regs)) !=3D 0 ) - return rc; - return do_guest_trap(TRAP_invalid_op, regs, 0); + if ( !emulate_forced_invalid_op(regs) ) + do_guest_trap(TRAP_invalid_op, regs, 0); + return; } =20 if ( !is_kernel(eip) || @@ -743,7 +743,7 @@ asmlinkage int do_invalid_op(struct cpu_ { show_execution_state(regs); regs->eip =3D (unsigned long)eip; - return EXCRET_fault_fixed; + return; } =20 /* WARN, BUG or ASSERT: decode the filename pointer and line number. = */ @@ -761,7 +761,7 @@ asmlinkage int do_invalid_op(struct cpu_ printk("Xen WARN at %.50s:%d\n", filename, lineno); show_execution_state(regs); regs->eip =3D (unsigned long)eip; - return EXCRET_fault_fixed; + return; } =20 if ( id =3D=3D BUGFRAME_bug ) @@ -792,10 +792,9 @@ asmlinkage int do_invalid_op(struct cpu_ DEBUGGER_trap_fatal(TRAP_invalid_op, regs); show_execution_state(regs); panic("FATAL TRAP: vector =3D %d (invalid opcode)\n", TRAP_invalid_op)= ; - return 0; } =20 -asmlinkage int do_int3(struct cpu_user_regs *regs) +asmlinkage void do_int3(struct cpu_user_regs *regs) { DEBUGGER_trap_entry(TRAP_int3, regs); =20 @@ -806,7 +805,7 @@ asmlinkage int do_int3(struct cpu_user_r panic("FATAL TRAP: vector =3D 3 (Int3)\n"); }=20 =20 - return do_guest_trap(TRAP_int3, regs, 0); + do_guest_trap(TRAP_int3, regs, 0); } =20 asmlinkage void do_machine_check(struct cpu_user_regs *regs) @@ -1065,10 +1064,9 @@ static int fixup_page_fault(unsigned lon * Bit 3: Reserved bit violation * Bit 4: Instruction fetch */ -asmlinkage int do_page_fault(struct cpu_user_regs *regs) +asmlinkage void do_page_fault(struct cpu_user_regs *regs) { unsigned long addr, fixup; - int rc; =20 addr =3D read_cr2(); =20 @@ -1076,19 +1074,19 @@ asmlinkage int do_page_fault(struct cpu_ =20 perfc_incr(page_faults); =20 - if ( unlikely((rc =3D fixup_page_fault(addr, regs)) !=3D 0) ) - return rc; + if ( unlikely(fixup_page_fault(addr, regs) !=3D 0) ) + return; =20 if ( unlikely(!guest_mode(regs)) ) { if ( spurious_page_fault(addr, regs) ) - return EXCRET_not_a_fault; + return; =20 if ( likely((fixup =3D search_exception_table(regs->eip)) !=3D 0) = ) { perfc_incr(copy_user_faults); regs->eip =3D fixup; - return 0; + return; } =20 DEBUGGER_trap_fatal(TRAP_page_fault, regs); @@ -1102,7 +1100,6 @@ asmlinkage int do_page_fault(struct cpu_ } =20 propagate_page_fault(addr, regs->error_code); - return 0; } =20 /* @@ -1351,7 +1348,7 @@ void (*pv_post_outb_hook)(unsigned int p if ( (_rc =3D copy_from_user(&_x, (type *)_ptr, sizeof(_x))) !=3D 0 ) = \ { = \ propagate_page_fault(_ptr + sizeof(_x) - _rc, 0); = \ - return EXCRET_fault_fixed; = \ + goto skip; = \ } = \ (eip) +=3D sizeof(_x); _x; }) =20 @@ -2010,6 +2007,7 @@ static int emulate_privileged_op(struct=20 =20 done: instruction_done(regs, eip, bpmatch); + skip: return EXCRET_fault_fixed; =20 fail: @@ -2023,7 +2021,7 @@ static inline int check_stack_limit(unsi (!(ar & _SEGMENT_EC) ? (esp - 1) <=3D limit : (esp - decr) > = limit)); } =20 -static int emulate_gate_op(struct cpu_user_regs *regs) +static void emulate_gate_op(struct cpu_user_regs *regs) { #ifdef __x86_64__ struct vcpu *v =3D current; @@ -2036,9 +2034,15 @@ static int emulate_gate_op(struct cpu_us if ( !read_gate_descriptor(regs->error_code, v, &sel, &off, &ar) || ((ar >> 13) & 3) < (regs->cs & 3) || (ar & _SEGMENT_TYPE) !=3D 0xc00 ) - return do_guest_trap(TRAP_gp_fault, regs, 1); + { + do_guest_trap(TRAP_gp_fault, regs, 1); + return; + } if ( !(ar & _SEGMENT_P) ) - return do_guest_trap(TRAP_no_segment, regs, 1); + { + do_guest_trap(TRAP_no_segment, regs, 1); + return; + } dpl =3D (ar >> 13) & 3; nparm =3D ar & 0x1f; =20 @@ -2050,7 +2054,10 @@ static int emulate_gate_op(struct cpu_us !(ar & _SEGMENT_S) || !(ar & _SEGMENT_P) || !(ar & _SEGMENT_CODE) ) - return do_guest_trap(TRAP_gp_fault, regs, 1); + { + do_guest_trap(TRAP_gp_fault, regs, 1); + return; + } =20 op_bytes =3D op_default =3D ar & _SEGMENT_DB ? 4 : 2; ad_default =3D ad_bytes =3D op_default; @@ -2199,7 +2206,9 @@ static int emulate_gate_op(struct cpu_us if ( jump < 0 ) { fail: - return do_guest_trap(TRAP_gp_fault, regs, 1); + do_guest_trap(TRAP_gp_fault, regs, 1); + skip: + return; } =20 if ( (opnd_sel !=3D regs->cs && @@ -2207,7 +2216,10 @@ static int emulate_gate_op(struct cpu_us !(ar & _SEGMENT_S) || !(ar & _SEGMENT_P) || ((ar & _SEGMENT_CODE) && !(ar & _SEGMENT_WR)) ) - return do_guest_trap(TRAP_gp_fault, regs, 1); + { + do_guest_trap(TRAP_gp_fault, regs, 1); + return; + } =20 opnd_off +=3D op_bytes; #define ad_default ad_bytes @@ -2215,7 +2227,10 @@ static int emulate_gate_op(struct cpu_us #undef ad_default ASSERT((opnd_sel & ~3) =3D=3D regs->error_code); if ( dpl < (opnd_sel & 3) ) - return do_guest_trap(TRAP_gp_fault, regs, 1); + { + do_guest_trap(TRAP_gp_fault, regs, 1); + return; + } =20 if ( !read_descriptor(sel, v, regs, &base, &limit, &ar, 0) || !(ar & _SEGMENT_S) || @@ -2225,17 +2240,20 @@ static int emulate_gate_op(struct cpu_us ((ar >> 13) & 3) !=3D (regs->cs & 3)) ) { regs->error_code =3D sel; - return do_guest_trap(TRAP_gp_fault, regs, 1); + do_guest_trap(TRAP_gp_fault, regs, 1); + return; } if ( !(ar & _SEGMENT_P) ) { regs->error_code =3D sel; - return do_guest_trap(TRAP_no_segment, regs, 1); + do_guest_trap(TRAP_no_segment, regs, 1); + return; } if ( off > limit ) { regs->error_code =3D 0; - return do_guest_trap(TRAP_gp_fault, regs, 1); + do_guest_trap(TRAP_gp_fault, regs, 1); + return; } =20 if ( !jump ) @@ -2251,7 +2269,7 @@ static int emulate_gate_op(struct cpu_us { \ propagate_page_fault((unsigned long)(stkp + 1) - rc, \ PFEC_write_access); \ - return 0; \ + return; \ } \ } while ( 0 ) =20 @@ -2260,7 +2278,10 @@ static int emulate_gate_op(struct cpu_us sel |=3D (ar >> 13) & 3; /* Inner stack known only for kernel ring. */ if ( (sel & 3) !=3D GUEST_KERNEL_RPL(v->domain) ) - return do_guest_trap(TRAP_gp_fault, regs, 1); + { + do_guest_trap(TRAP_gp_fault, regs, 1); + return; + } esp =3D v->arch.guest_context.kernel_sp; ss =3D v->arch.guest_context.kernel_ss; if ( (ss & 3) !=3D (sel & 3) || @@ -2271,17 +2292,22 @@ static int emulate_gate_op(struct cpu_us !(ar & _SEGMENT_WR) ) { regs->error_code =3D ss & ~3; - return do_guest_trap(TRAP_invalid_tss, regs, 1); + do_guest_trap(TRAP_invalid_tss, regs, 1); + return; } if ( !(ar & _SEGMENT_P) || !check_stack_limit(ar, limit, esp, (4 + nparm) * 4) ) { regs->error_code =3D ss & ~3; - return do_guest_trap(TRAP_stack_error, regs, 1); + do_guest_trap(TRAP_stack_error, regs, 1); + return; } stkp =3D (unsigned int *)(unsigned long)((unsigned int)base + = esp); if ( !compat_access_ok(stkp - 4 - nparm, (4 + nparm) * 4) ) - return do_guest_trap(TRAP_gp_fault, regs, 1); + { + do_guest_trap(TRAP_gp_fault, regs, 1); + return; + } push(regs->ss); push(regs->esp); if ( nparm ) @@ -2297,7 +2323,10 @@ static int emulate_gate_op(struct cpu_us return do_guest_trap(TRAP_gp_fault, regs, 1); ustkp =3D (unsigned int *)(unsigned long)((unsigned = int)base + regs->_esp + nparm * 4); if ( !compat_access_ok(ustkp - nparm, nparm * 4) ) - return do_guest_trap(TRAP_gp_fault, regs, 1); + { + do_guest_trap(TRAP_gp_fault, regs, 1); + return; + } do { unsigned int parm; @@ -2307,7 +2336,7 @@ static int emulate_gate_op(struct cpu_us if ( rc ) { propagate_page_fault((unsigned long)(ustkp + 1) - = rc, 0); - return 0; + return; } push(parm); } while ( --nparm ); @@ -2320,15 +2349,22 @@ static int emulate_gate_op(struct cpu_us ss =3D regs->ss; if ( !read_descriptor(ss, v, regs, &base, &limit, &ar, 0) || ((ar >> 13) & 3) !=3D (sel & 3) ) - return do_guest_trap(TRAP_gp_fault, regs, 1); + { + do_guest_trap(TRAP_gp_fault, regs, 1); + return; + } if ( !check_stack_limit(ar, limit, esp, 2 * 4) ) { regs->error_code =3D 0; - return do_guest_trap(TRAP_stack_error, regs, 1); + do_guest_trap(TRAP_stack_error, regs, 1); + return; } stkp =3D (unsigned int *)(unsigned long)((unsigned int)base + = esp); if ( !compat_access_ok(stkp - 2, 2 * 4) ) - return do_guest_trap(TRAP_gp_fault, regs, 1); + { + do_guest_trap(TRAP_gp_fault, regs, 1); + return; + } } push(regs->cs); push(eip); @@ -2342,11 +2378,9 @@ static int emulate_gate_op(struct cpu_us regs->cs =3D sel; instruction_done(regs, off, 0); #endif - - return 0; } =20 -asmlinkage int do_general_protection(struct cpu_user_regs *regs) +asmlinkage void do_general_protection(struct cpu_user_regs *regs) { struct vcpu *v =3D current; unsigned long fixup; @@ -2388,18 +2422,22 @@ asmlinkage int do_general_protection(str if ( permit_softint(TI_GET_DPL(ti), v, regs) ) { regs->eip +=3D 2; - return do_guest_trap(vector, regs, 0); + do_guest_trap(vector, regs, 0); + return; } } else if ( is_pv_32on64_vcpu(v) && regs->error_code ) - return emulate_gate_op(regs); + { + emulate_gate_op(regs); + return; + } =20 /* Emulate some simple privileged and I/O instructions. */ if ( (regs->error_code =3D=3D 0) && emulate_privileged_op(regs) ) { trace_trap_one_addr(TRC_PV_EMULATE_PRIVOP, regs->eip); - return 0; + return; } =20 #if defined(__i386__) @@ -2408,12 +2446,13 @@ asmlinkage int do_general_protection(str gpf_emulate_4gb(regs) ) { TRACE_1D(TRC_PV_EMULATE_4GB, regs->eip); - return 0; + return; } #endif =20 /* Pass on GPF as is. */ - return do_guest_trap(TRAP_gp_fault, regs, 1); + do_guest_trap(TRAP_gp_fault, regs, 1); + return; =20 gp_in_kernel: =20 @@ -2422,7 +2461,7 @@ asmlinkage int do_general_protection(str dprintk(XENLOG_INFO, "GPF (%04x): %p -> %p\n", regs->error_code, _p(regs->eip), _p(fixup)); regs->eip =3D fixup; - return 0; + return; } =20 DEBUGGER_trap_fatal(TRAP_gp_fault, regs); @@ -2430,7 +2469,6 @@ asmlinkage int do_general_protection(str hardware_gp: show_execution_state(regs); panic("GENERAL PROTECTION FAULT\n[error_code=3D%04x]\n", regs->error_c= ode); - return 0; } =20 static void nmi_softirq(void) @@ -2550,7 +2588,7 @@ void unset_nmi_callback(void) nmi_callback =3D dummy_nmi_callback; } =20 -asmlinkage int do_device_not_available(struct cpu_user_regs *regs) +asmlinkage void do_device_not_available(struct cpu_user_regs *regs) { struct vcpu *curr =3D current; =20 @@ -2566,10 +2604,10 @@ asmlinkage int do_device_not_available(s else TRACE_0D(TRC_PV_MATH_STATE_RESTORE); =20 - return EXCRET_fault_fixed; + return; } =20 -asmlinkage int do_debug(struct cpu_user_regs *regs) +asmlinkage void do_debug(struct cpu_user_regs *regs) { struct vcpu *v =3D current; =20 @@ -2609,16 +2647,16 @@ asmlinkage int do_debug(struct cpu_user_ v->arch.guest_context.debugreg[6] =3D read_debugreg(6); =20 ler_enable(); - return do_guest_trap(TRAP_debug, regs, 0); + do_guest_trap(TRAP_debug, regs, 0); + return; =20 out: ler_enable(); - return EXCRET_not_a_fault; + return; } =20 -asmlinkage int do_spurious_interrupt_bug(struct cpu_user_regs *regs) +asmlinkage void do_spurious_interrupt_bug(struct cpu_user_regs *regs) { - return EXCRET_not_a_fault; } =20 void set_intr_gate(unsigned int n, void *addr) Index: 2007-12-10/xen/include/asm-x86/debugger.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2007-12-10.orig/xen/include/asm-x86/debugger.h 2007-04-02 = 12:16:26.000000000 +0200 +++ 2007-12-10/xen/include/asm-x86/debugger.h 2007-12-10 09:25:07.0000000= 00 +0100 @@ -35,9 +35,9 @@ =20 /* The main trap handlers use these helper macros which include early = bail. */ #define DEBUGGER_trap_entry(_v, _r) \ - if ( debugger_trap_entry(_v, _r) ) return EXCRET_fault_fixed; + if ( debugger_trap_entry(_v, _r) ) return; #define DEBUGGER_trap_fatal(_v, _r) \ - if ( debugger_trap_fatal(_v, _r) ) return EXCRET_fault_fixed; + if ( debugger_trap_fatal(_v, _r) ) return; =20 #if defined(CRASH_DEBUG) =20