[PATCH 1/3] x86, extable: Cleanup fixup_exception

From: Borislav Petkov
Date: Sat Mar 31 2012 - 10:29:03 EST


And especially, fork out the CONFIG_PNPBIOS lump into its own function
and salvage a tab by inverting error code checking.

No functionality change.

Signed-off-by: Borislav Petkov <bp@xxxxxxxxx>
---
arch/x86/mm/extable.c | 33 ++++++++++++++++++---------------
1 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
index 1fb85dbe390a..08aecb0d3132 100644
--- a/arch/x86/mm/extable.c
+++ b/arch/x86/mm/extable.c
@@ -2,13 +2,10 @@
#include <linux/spinlock.h>
#include <asm/uaccess.h>

-
-int fixup_exception(struct pt_regs *regs)
+static void pnp_bios_is_crap(unsigned long cs)
{
- const struct exception_table_entry *fixup;
-
#ifdef CONFIG_PNPBIOS
- if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
+ if (unlikely(SEGMENT_IS_PNP_CODE(cs))) {
extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
extern u32 pnp_bios_is_utter_crap;
pnp_bios_is_utter_crap = 1;
@@ -20,18 +17,24 @@ int fixup_exception(struct pt_regs *regs)
panic("do_trap: can't hit this");
}
#endif
+}
+
+int fixup_exception(struct pt_regs *regs)
+{
+ const struct exception_table_entry *fixup;
+
+ pnp_bios_is_crap(regs->cs);

fixup = search_exception_tables(regs->ip);
- if (fixup) {
- /* If fixup is less than 16, it means uaccess error */
- if (fixup->fixup < 16) {
- current_thread_info()->uaccess_err = 1;
- regs->ip += fixup->fixup;
- return 1;
- }
- regs->ip = fixup->fixup;
+ if (!fixup)
+ return 0;
+
+ /* If fixup is less than 16, it means uaccess error */
+ if (fixup->fixup < 16) {
+ current_thread_info()->uaccess_err = 1;
+ regs->ip += fixup->fixup;
return 1;
}
-
- return 0;
+ regs->ip = fixup->fixup;
+ return 1;
}
--
1.7.5.3.401.gfb674

--
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/