x86-64: Move K8 B step iret fixup to fault entry asm.
PATCH 1/1 x86-64: Move K8 B step iret fixup to fault entry asm.
Move the handling of truncated %rip from an iret fault to the fault entry path. This allows x86-64 to use the standard search_extable function.
Signed-off-by Brian Gerst <[email protected]>
--- arch/x86/include/asm/uaccess.h | 1 - arch/x86/kernel/entry_64.S | 11 ++++++++--- arch/x86/mm/extable.c | 31 ------------------------------- 3 files changed, 8 insertions(+), 35 deletions(-)
arch/x86/include/asm/uaccess.h +0 -1
@@ -570,7 +570,6 @@ extern struct movsl_mask {#ifdef CONFIG_X86_32 # include "uaccess_32.h" #else -# define ARCH_HAS_SEARCH_EXTABLE # include "uaccess_64.h" #endif
arch/x86/kernel/entry_64.S +8 -3
@@ -1491,12 +1491,17 @@ error_kernelspace: leaq irq_return(%rip),%rcx cmpq %rcx,RIP+8(%rsp) je error_swapgs - movl %ecx,%ecx /* zero extend */ - cmpq %rcx,RIP+8(%rsp) - je error_swapgs + movl %ecx,%eax /* zero extend */ + cmpq %rax,RIP+8(%rsp) + je bstep_iret cmpq $gs_change,RIP+8(%rsp) je error_swapgs jmp error_sti + +bstep_iret: + /* Fix truncated RIP */ + movq %rcx,RIP+8(%rsp) + je error_swapgs END(error_entry)
arch/x86/mm/extable.c +0 -31
@@ -35,34 +35,3 @@ int fixup_exception(struct pt_regs *regs)return 0 ; } - -#ifdef CONFIG_X86_64 -/* -* Need to defined our own search_extable on X86_64 to work around -* a B stepping K8 bug. -*/ -const struct exception_table_entry * -search_extable (const struct exception_table_entry *first, -const struct exception_table_entry *last, -unsigned long value) -{ -/* B stepping K8 bug */ -if ((value >>32 ) ==0 ) - value |=0xffffffffUL <<32 ; - -while (first <= last) { -const struct exception_table_entry *mid; -long diff; - - mid = (last - first) /2 + first; - diff = mid->insn - value; -if (diff ==0 ) -return mid; -else if (diff <0 ) - first = mid+1 ; -else - last = mid-1 ; - } -return NULL ; -} -#endif
Signature · 1 line
1.6.2.5
[tip:x86/asm] x86, 64-bit: Move K8 B step iret fixup to fault entry asm
Commit-ID: ae24ffe5ecec17c956ac25371d7c2e12b4b36e53 Gitweb: http://git.kernel.org/tip/ae24ffe5ecec17c956ac25371d7c2e12b4b36e53 Author: Brian Gerst <[email protected]> AuthorDate: Mon, 12 Oct 2009 10:18:23 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 12 Oct 2009 18:29:46 +0200
x86, 64-bit: Move K8 B step iret fixup to fault entry asm
Move the handling of truncated %rip from an iret fault to the fault entry path.
This allows x86-64 to use the standard search_extable() function.
Signed-off-by Brian Gerst <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Jan Beulich <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- arch/x86/include/asm/uaccess.h | 1 - arch/x86/kernel/entry_64.S | 11 ++++++++--- arch/x86/mm/extable.c | 31 ------------------------------- 3 files changed, 8 insertions(+), 35 deletions(-)
arch/x86/include/asm/uaccess.h +0 -1
@@ -570,7 +570,6 @@ extern struct movsl_mask {#ifdef CONFIG_X86_32 # include "uaccess_32.h" #else -# define ARCH_HAS_SEARCH_EXTABLE # include "uaccess_64.h" #endif
arch/x86/kernel/entry_64.S +8 -3
@@ -1491,12 +1491,17 @@ error_kernelspace: leaq irq_return(%rip),%rcx cmpq %rcx,RIP+8(%rsp) je error_swapgs - movl %ecx,%ecx /* zero extend */ - cmpq %rcx,RIP+8(%rsp) - je error_swapgs + movl %ecx,%eax /* zero extend */ + cmpq %rax,RIP+8(%rsp) + je bstep_iret cmpq $gs_change,RIP+8(%rsp) je error_swapgs jmp error_sti + +bstep_iret: + /* Fix truncated RIP */ + movq %rcx,RIP+8(%rsp) + je error_swapgs END(error_entry)
arch/x86/mm/extable.c +0 -31
@@ -35,34 +35,3 @@ int fixup_exception(struct pt_regs *regs)return 0 ; } - -#ifdef CONFIG_X86_64 -/* -* Need to defined our own search_extable on X86_64 to work around -* a B stepping K8 bug. -*/ -const struct exception_table_entry * -search_extable (const struct exception_table_entry *first, -const struct exception_table_entry *last, -unsigned long value) -{ -/* B stepping K8 bug */ -if ((value >>32 ) ==0 ) - value |=0xffffffffUL <<32 ; - -while (first <= last) { -const struct exception_table_entry *mid; -long diff; - - mid = (last - first) /2 + first; - diff = mid->insn - value; -if (diff ==0 ) -return mid; -else if (diff <0 ) - first = mid+1 ; -else - last = mid-1 ; - } -return NULL ; -} -#endif