Skip to contentSkip to conversation

x86: Use fixup_exception() in traps_64.c

PATCH Applied Harvey Harrison 2 participants 2 messages Jan 9, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Use fixup_exception() in traps_64.c

Use the fixup_exception() helper instead of the open-coded search_extable() users.

---
Ingo, this depends on my patch in x86.git unifying extable.c that introduces fixup_exception() to X86_64.

 arch/x86/kernel/traps_64.c |   47 ++++++++++++++-----------------------------
 1 files changed, 15 insertions(+), 32 deletions(-)
arch/x86/kernel/traps_64.c +15 -32
index e3d1ca1..c173687 100644
@@ -606,19 +606,12 @@ static void __kprobes do_trap(int trapnr, int signr, char *str,
 	}
 
 
-	/* kernel trap */ 
-	{	     
-		const struct exception_table_entry *fixup;
-		fixup = search_exception_tables(regs->ip);
-		if (fixup)
-			regs->ip = fixup->fixup;
-		else {
-			tsk->thread.error_code = error_code;
-			tsk->thread.trap_no = trapnr;
-			die(str, regs, error_code);
-		}
-		return;
+	if (!fixup_exception(regs)) {
+		tsk->thread.error_code = error_code;
+		tsk->thread.trap_no = trapnr;
+		die(str, regs, error_code);
 	}
+	return;
 }
 
 #define DO_ERROR(trapnr, signr, str, name) \
@@ -707,22 +700,15 @@ asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
 		return;
 	} 
 
-	/* kernel gp */
-	{
-		const struct exception_table_entry *fixup;
-		fixup = search_exception_tables(regs->ip);
-		if (fixup) {
-			regs->ip = fixup->fixup;
-			return;
-		}
+	if (fixup_exception(regs))
+		return;
 
-		tsk->thread.error_code = error_code;
-		tsk->thread.trap_no = 13;
-		if (notify_die(DIE_GPF, "general protection fault", regs,
-					error_code, 13, SIGSEGV) == NOTIFY_STOP)
-			return;
-		die("general protection fault", regs, error_code);
-	}
+	tsk->thread.error_code = error_code;
+	tsk->thread.trap_no = 13;
+	if (notify_die(DIE_GPF, "general protection fault", regs,
+				error_code, 13, SIGSEGV) == NOTIFY_STOP)
+		return;
+	die("general protection fault", regs, error_code);
 }
 
 static __kprobes void
@@ -914,12 +900,9 @@ clear_TF_reenable:
 
 static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
 {
-	const struct exception_table_entry *fixup;
-	fixup = search_exception_tables(regs->ip);
-	if (fixup) {
-		regs->ip = fixup->fixup;
+	if (fixup_exception(regs))
 		return 1;
-	}
+
 	notify_die(DIE_GPF, str, regs, 0, trapnr, SIGFPE);
 	/* Illegal floating point operation in the kernel */
 	current->thread.trap_no = trapnr;
Signature · 1 line
1.5.4.rc2.1164.g6451
Applied
#1 lore raw
Quoted 2 lines · Harvey Harrison

Use the fixup_exception() helper instead of the open-coded search_extable() users.

thanks, applied.

Ingo