diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2012-09-24 15:05:52 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2012-09-26 09:47:06 -0400 |
commit | ef3f628872c838933a279d0d7e63e707783c9710 (patch) | |
tree | 2274330a797077630527238e10161c1678e6e5a2 | |
parent | bf5a3c13b939813d28ce26c01425054c740d6731 (diff) |
x86: Unspaghettize do_general_protection()
There is some unnatural label based layout in this function.
Convert the unnecessary goto to readable conditional blocks.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/kernel/traps.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index b481341c9369..74850e559449 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -258,13 +258,25 @@ do_general_protection(struct pt_regs *regs, long error_code) | |||
258 | conditional_sti(regs); | 258 | conditional_sti(regs); |
259 | 259 | ||
260 | #ifdef CONFIG_X86_32 | 260 | #ifdef CONFIG_X86_32 |
261 | if (regs->flags & X86_VM_MASK) | 261 | if (regs->flags & X86_VM_MASK) { |
262 | goto gp_in_vm86; | 262 | local_irq_enable(); |
263 | handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code); | ||
264 | return; | ||
265 | } | ||
263 | #endif | 266 | #endif |
264 | 267 | ||
265 | tsk = current; | 268 | tsk = current; |
266 | if (!user_mode(regs)) | 269 | if (!user_mode(regs)) { |
267 | goto gp_in_kernel; | 270 | if (fixup_exception(regs)) |
271 | return; | ||
272 | |||
273 | tsk->thread.error_code = error_code; | ||
274 | tsk->thread.trap_nr = X86_TRAP_GP; | ||
275 | if (!notify_die(DIE_GPF, "general protection fault", regs, error_code, | ||
276 | X86_TRAP_GP, SIGSEGV) == NOTIFY_STOP) | ||
277 | die("general protection fault", regs, error_code); | ||
278 | return; | ||
279 | } | ||
268 | 280 | ||
269 | tsk->thread.error_code = error_code; | 281 | tsk->thread.error_code = error_code; |
270 | tsk->thread.trap_nr = X86_TRAP_GP; | 282 | tsk->thread.trap_nr = X86_TRAP_GP; |
@@ -280,24 +292,6 @@ do_general_protection(struct pt_regs *regs, long error_code) | |||
280 | 292 | ||
281 | force_sig(SIGSEGV, tsk); | 293 | force_sig(SIGSEGV, tsk); |
282 | return; | 294 | return; |
283 | |||
284 | #ifdef CONFIG_X86_32 | ||
285 | gp_in_vm86: | ||
286 | local_irq_enable(); | ||
287 | handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code); | ||
288 | return; | ||
289 | #endif | ||
290 | |||
291 | gp_in_kernel: | ||
292 | if (fixup_exception(regs)) | ||
293 | return; | ||
294 | |||
295 | tsk->thread.error_code = error_code; | ||
296 | tsk->thread.trap_nr = X86_TRAP_GP; | ||
297 | if (notify_die(DIE_GPF, "general protection fault", regs, error_code, | ||
298 | X86_TRAP_GP, SIGSEGV) == NOTIFY_STOP) | ||
299 | return; | ||
300 | die("general protection fault", regs, error_code); | ||
301 | } | 295 | } |
302 | 296 | ||
303 | /* May run on IST stack. */ | 297 | /* May run on IST stack. */ |