x86/entry: Consolidation - Part III (simple exceptions)
Subsystems (4)
v2 cover x86/entry: Consolidation - Part III (simple exceptions)
Hi!
This is the second version of the entry consolidation work part III covering simple exceptions. V1 can be found here:
https://lore.kernel.org/r/[email protected]
It applies on top of part II which is available here
https://lore.kernel.org/r/[email protected]
and is also available from git (including part II):
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel entry-v2-part3
The changes vs. V1:
- Remove #BP (int3) conversion as this needs extra care vs. kprobes (Peter)
- Fixup the FOOF bug do_invalid_op() call in fault.c
- Address the few review comments (mostly changelog and comment improvements)
- Picked up Reviewed-by and Acked-by tags
Thanks,
tglx
--- arch/x86/entry/entry_32.S | 160 +++++--------- arch/x86/entry/entry_64.S | 410 ++++++++++++++++++++------------------ arch/x86/include/asm/traps.h | 76 ------- arch/x86/kernel/idt.c | 28 +- arch/x86/kernel/traps.c | 131 +++++++----- arch/x86/mm/fault.c | 2 arch/x86/xen/enlighten_pv.c | 33 +-- arch/x86/xen/xen-asm_32.S | 2 arch/x86/xen/xen-asm_64.S | 28 +- b/arch/x86/include/asm/idtentry.h | 167 +++++++++++++++ b/arch/x86/include/asm/trapnr.h | 31 ++ 11 files changed, 611 insertions(+), 457 deletions(-)
PATCH v2 1/23 x86/traps: Split trap numbers out in a seperate header
From: Thomas Gleixner <[email protected]>
So they can be used in ASM code. For this it is also necessary to convert them to defines. Will be used for the rework of the entry code.
--- arch/x86/include/asm/trapnr.h | 31 +++++++++++++++++++++++++++++++ arch/x86/include/asm/traps.h | 26 +------------------------- 2 files changed, 32 insertions(+), 25 deletions(-)
arch/x86/include/asm/trapnr.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_TRAPNR_H +#define _ASM_X86_TRAPNR_H + +/* Interrupts/Exceptions */ + +#define X86_TRAP_DE 0/* Divide-by-zero */ +#define X86_TRAP_DB 1/* Debug */ +#define X86_TRAP_NMI 2/* Non-maskable Interrupt */ +#define X86_TRAP_BP 3/* Breakpoint */ +#define X86_TRAP_OF 4/* Overflow */ +#define X86_TRAP_BR 5/* Bound Range Exceeded */ +#define X86_TRAP_UD 6/* Invalid Opcode */ +#define X86_TRAP_NM 7/* Device Not Available */ +#define X86_TRAP_DF 8/* Double Fault */ +#define X86_TRAP_OLD_MF 9/* Coprocessor Segment Overrun */ +#define X86_TRAP_TS 10/* Invalid TSS */ +#define X86_TRAP_NP 11/* Segment Not Present */ +#define X86_TRAP_SS 12/* Stack Segment Fault */ +#define X86_TRAP_GP 13/* General Protection Fault */ +#define X86_TRAP_PF 14/* Page Fault */ +#define X86_TRAP_SPURIOUS 15/* Spurious Interrupt */ +#define X86_TRAP_MF 16/* x87 Floating-Point Exception */ +#define X86_TRAP_AC 17/* Alignment Check */ +#define X86_TRAP_MC 18/* Machine Check */ +#define X86_TRAP_XF 19/* SIMD Floating-Point Exception */ +#define X86_TRAP_VE 20/* Virtualization Exception */ +#define X86_TRAP_CP 21/* Control Protection Exception */ +#define X86_TRAP_IRET 32/* IRET Exception */ + +#endif
arch/x86/include/asm/traps.h +1 -25
@@ -7,6 +7,7 @@#include <asm/debugreg.h> #include <asm/siginfo.h> /* TRAP_TRACE, ... */ +#include <asm/trapnr.h> #define dotraplinkage __visible
@@ -129,31 +130,6 @@ void __noreturn handle_stack_overflow(co unsigned long fault_address);#endif -/* Interrupts/Exceptions */ -enum { -X86_TRAP_DE =0 ,/* 0, Divide-by-zero */ -X86_TRAP_DB ,/* 1, Debug */ -X86_TRAP_NMI ,/* 2, Non-maskable Interrupt */ -X86_TRAP_BP ,/* 3, Breakpoint */ -X86_TRAP_OF ,/* 4, Overflow */ -X86_TRAP_BR ,/* 5, Bound Range Exceeded */ -X86_TRAP_UD ,/* 6, Invalid Opcode */ -X86_TRAP_NM ,/* 7, Device Not Available */ -X86_TRAP_DF ,/* 8, Double Fault */ -X86_TRAP_OLD_MF ,/* 9, Coprocessor Segment Overrun */ -X86_TRAP_TS ,/* 10, Invalid TSS */ -X86_TRAP_NP ,/* 11, Segment Not Present */ -X86_TRAP_SS ,/* 12, Stack Segment Fault */ -X86_TRAP_GP ,/* 13, General Protection Fault */ -X86_TRAP_PF ,/* 14, Page Fault */ -X86_TRAP_SPURIOUS ,/* 15, Spurious Interrupt */ -X86_TRAP_MF ,/* 16, x87 Floating-Point Exception */ -X86_TRAP_AC ,/* 17, Alignment Check */ -X86_TRAP_MC ,/* 18, Machine Check */ -X86_TRAP_XF ,/* 19, SIMD Floating-Point Exception */ -X86_TRAP_IRET =32 ,/* 32, IRET Exception */ -}; -/* * Page fault error code bits: *
PATCH v2 2/23 x86/entry/64: Avoid pointless code when CONTEXT_TRACKING=n
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
GAS cannot optimize out the test and conditional jump when context tracking is disabled and CALL_enter_from_user_mode is an empty macro.
Wrap it in #ifdeffery. Will go away once all this is moved to C.
--- arch/x86/entry/entry_64.S | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/entry/entry_64.S +2 -0
@@ -884,12 +884,14 @@ apicinterrupt IRQ_WORK_VECTOR irq_work TRACE_IRQS_OFF .endif +#ifdef CONFIG_CONTEXT_TRACKING .if \paranoid == 0 testb $3, CS(%rsp) jz .Lfrom_kernel_no_context_tracking_\@ CALL_enter_from_user_mode .Lfrom_kernel_no_context_tracking_\@: .endif +#endif movq %rsp, %rdi /* pt_regs pointer */
PATCH v2 3/23 x86/entry/64: Reorder idtentries
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Move them all together so verifying the cleanup patches for binary equivalence will be easier.
--- arch/x86/entry/entry_64.S | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-)
arch/x86/entry/entry_64.S +19 -23
@@ -1019,18 +1019,36 @@ SYM_CODE_END(\sym) idtentry divide_error do_divide_error has_error_code=0 idtentry overflow do_overflow has_error_code=0 +idtentry int3 do_int3 has_error_code=0 create_gap=1 idtentry bounds do_bounds has_error_code=0 idtentry invalid_op do_invalid_op has_error_code=0 idtentry device_not_available do_device_not_available has_error_code=0 -idtentry double_fault do_double_fault has_error_code=1 paranoid=2 read_cr2=1 idtentry coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0 idtentry invalid_TSS do_invalid_TSS has_error_code=1 idtentry segment_not_present do_segment_not_present has_error_code=1 +idtentry stack_segment do_stack_segment has_error_code=1 +idtentry general_protection do_general_protection has_error_code=1 idtentry spurious_interrupt_bug do_spurious_interrupt_bug has_error_code=0 idtentry coprocessor_error do_coprocessor_error has_error_code=0 idtentry alignment_check do_alignment_check has_error_code=1 idtentry simd_coprocessor_error do_simd_coprocessor_error has_error_code=0 +idtentry page_fault do_page_fault has_error_code=1 read_cr2=1 +#ifdef CONFIG_KVM_GUEST +idtentry async_page_fault do_async_page_fault has_error_code=1 read_cr2=1 +#endif + +#ifdef CONFIG_X86_MCE +idtentry machine_check do_mce has_error_code=0 paranoid=1 +#endif +idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=IST_INDEX_DB ist_offset=DB_STACK_OFFSET +idtentry double_fault do_double_fault has_error_code=1 paranoid=2 read_cr2=1 + +#ifdef CONFIG_XEN_PV +idtentry hypervisor_callback xen_do_hypervisor_callback has_error_code=0 +idtentry xennmi do_nmi has_error_code=0 +idtentry xendebug do_debug has_error_code=0 +#endif /* * Reload gs selector with exception handling
@@ -1082,8 +1100,6 @@ SYM_FUNC_START(do_softirq_own_stack) SYM_FUNC_END(do_softirq_own_stack) #ifdef CONFIG_XEN_PV -idtentry hypervisor_callback xen_do_hypervisor_callback has_error_code=0 - /* * A note on the "critical region" in our callback handler. * We want to avoid stacking callback handlers due to events occurring
@@ -1186,26 +1202,6 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTO acrn_hv_callback_vector acrn_hv_vector_handler #endif -idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=IST_INDEX_DB ist_offset=DB_STACK_OFFSET -idtentry int3 do_int3 has_error_code=0 create_gap=1 -idtentry stack_segment do_stack_segment has_error_code=1 - -#ifdef CONFIG_XEN_PV -idtentry xennmi do_nmi has_error_code=0 -idtentry xendebug do_debug has_error_code=0 -#endif - -idtentry general_protection do_general_protection has_error_code=1 -idtentry page_fault do_page_fault has_error_code=1 read_cr2=1 - -#ifdef CONFIG_KVM_GUEST -idtentry async_page_fault do_async_page_fault has_error_code=1 read_cr2=1 -#endif - -#ifdef CONFIG_X86_MCE -idtentry machine_check do_mce has_error_code=0 paranoid=1 -#endif - /* * Save all registers in pt_regs, and switch gs if needed. * Use slow, but surefire "are we in kernel?" check.
PATCH v2 4/23 x86/entry: Distangle idtentry
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
idtentry is a completely unreadable maze. Split it into distinct idtentry variants which only contain the minimal code:
- idtentry for regular exceptions
- idtentry_mce_debug for #MCE and #DB
- idtentry_df for #DF
The generated binary code is equivalent.
--- arch/x86/entry/entry_64.S | 402 +++++++++++++++++++++++++--------------------- 1 file changed, 220 insertions(+), 182 deletions(-)
arch/x86/entry/entry_64.S +220 -182
@@ -37,6 +37,7 @@ #include <asm/pgtable_types.h> #include <asm/export.h> #include <asm/frame.h> +#include <asm/trapnr.h> #include <asm/nospec-branch.h> #include <linux/err.h>
@@ -490,6 +491,202 @@ SYM_CODE_END(spurious_entries_start) decl PER_CPU_VAR(irq_count) .endm +/** + * idtentry_body - Macro to emit code calling the C function + * @vector: Vector number + * @cfunc: C function to be called + * @has_error_code: Hardware pushed error code on stack + */ +.macro idtentry_body vector cfunc has_error_code:req + + call error_entry + UNWIND_HINT_REGS + + .if \vector == X86_TRAP_PF + /* + * Store CR2 early so subsequent faults cannot clobber it. Use R12 as + * intermediate storage as RDX can be clobbered in enter_from_user_mode(). + * GET_CR2_INTO can clobber RAX. + */ + GET_CR2_INTO(%r12); + .endif + + TRACE_IRQS_OFF + +#ifdef CONFIG_CONTEXT_TRACKING + testb $3, CS(%rsp) + jz .Lfrom_kernel_no_ctxt_tracking_\@ + CALL_enter_from_user_mode +.Lfrom_kernel_no_ctxt_tracking_\@: +#endif + + movq %rsp, %rdi /* pt_regs pointer into 1st argument*/ + + .if \has_error_code == 1 + movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/ + movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */ + .else + xorl %esi, %esi /* Clear the error code */ + .endif + + .if \vector == X86_TRAP_PF + movq %r12, %rdx /* Move CR2 into 3rd argument */ + .endif + + call \cfunc + + jmp error_exit +.endm + +/** + * idtentry - Macro to generate entry stubs for simple IDT entries + * @vector: Vector number + * @asmsym: ASM symbol for the entry point + * @cfunc: C function to be called + * @has_error_code: Hardware pushed error code on stack + * + * The macro emits code to set up the kernel context for straight forward + * and simple IDT entries. No IST stack, no paranoid entry checks. + */ +.macro idtentry vector asmsym cfunc has_error_code:req +SYM_CODE_START(\asmsym) + UNWIND_HINT_IRET_REGS offset=\has_error_code*8 + ASM_CLAC + + .if \has_error_code == 0 + pushq $-1 /* ORIG_RAX: no syscall to restart */ + .endif + + .if \vector == X86_TRAP_BP + /* + * If coming from kernel space, create a 6-word gap to allow the + * int3 handler to emulate a call instruction. + */ + testb $3, CS-ORIG_RAX(%rsp) + jnz .Lfrom_usermode_no_gap_\@ + .rept 6 + pushq 5*8(%rsp) + .endr + UNWIND_HINT_IRET_REGS offset=8 +.Lfrom_usermode_no_gap_\@: + .endif + + idtentry_body \vector \cfunc \has_error_code + +_ASM_NOKPROBE(\asmsym) +SYM_CODE_END(\asmsym) +.endm + +/* + * MCE and DB exceptions + */ +#define CPU_TSS_IST(x) PER_CPU_VAR(cpu_tss_rw) + (TSS_ist + (x) * 8) + +/** + * idtentry_mce_db - Macro to generate entry stubs for #MC and #DB + * @vector: Vector number + * @asmsym: ASM symbol for the entry point + * @cfunc: C function to be called + * + * The macro emits code to set up the kernel context for #MC and #DB + * + * If the entry comes from user space it uses the normal entry path + * including the return to user space work and preemption checks on + * exit. + * + * If hits in kernel mode then it needs to go through the paranoid + * entry as the exception can hit any random state. No preemption + * check on exit to keep the paranoid path simple. + * + * If the trap is #DB then the interrupt stack entry in the IST is + * moved to the second stack, so a potential recursion will have a + * fresh IST. + */ +.macro idtentry_mce_db vector asmsym cfunc +SYM_CODE_START(\asmsym) + UNWIND_HINT_IRET_REGS + ASM_CLAC + + pushq $-1 /* ORIG_RAX: no syscall to restart */ + + /* + * If the entry is from userspace, switch stacks and treat it as + * a normal entry. + */ + testb $3, CS-ORIG_RAX(%rsp) + jnz .Lfrom_usermode_switch_stack_\@ + + /* + * paranoid_entry returns SWAPGS flag for paranoid_exit in EBX. + * EBX == 0 -> SWAPGS, EBX == 1 -> no SWAPGS + */ + call paranoid_entry + + UNWIND_HINT_REGS + + .if \vector == X86_TRAP_DB + TRACE_IRQS_OFF_DEBUG + .else + TRACE_IRQS_OFF + .endif + + movq %rsp, %rdi /* pt_regs pointer */ + xorl %esi, %esi /* Clear the error code */ + + .if \vector == X86_TRAP_DB + subq $DB_STACK_OFFSET, CPU_TSS_IST(IST_INDEX_DB) + .endif + + call \cfunc + + .if \vector == X86_TRAP_DB + addq $DB_STACK_OFFSET, CPU_TSS_IST(IST_INDEX_DB) + .endif + + jmp paranoid_exit + + /* Switch to the regular task stack and use the noist entry point */ +.Lfrom_usermode_switch_stack_\@: + idtentry_body vector \cfunc, has_error_code=0 + +_ASM_NOKPROBE(\asmsym) +SYM_CODE_END(\asmsym) +.endm + +/* + * Double fault entry. Straight paranoid. No checks from which context + * this comes because for the espfix induced #DF this would do the wrong + * thing. + */ +.macro idtentry_df vector asmsym cfunc +SYM_CODE_START(\asmsym) + UNWIND_HINT_IRET_REGS offset=8 + ASM_CLAC + + /* + * paranoid_entry returns SWAPGS flag for paranoid_exit in EBX. + * EBX == 0 -> SWAPGS, EBX == 1 -> no SWAPGS + */ + call paranoid_entry + UNWIND_HINT_REGS + + /* Read CR2 early */ + GET_CR2_INTO(%r12); + + TRACE_IRQS_OFF + + movq %rsp, %rdi /* pt_regs pointer into first argument */ + movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/ + movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */ + movq %r12, %rdx /* Move CR2 into 3rd argument */ + call \cfunc + + jmp paranoid_exit + +_ASM_NOKPROBE(\asmsym) +SYM_CODE_END(\asmsym) +.endm + /* * Interrupt entry helper function. *
@@ -857,197 +1054,38 @@ apicinterrupt IRQ_WORK_VECTOR irq_work /* * Exception entry points. */ -#define CPU_TSS_IST(x) PER_CPU_VAR(cpu_tss_rw) + (TSS_ist + (x) * 8) - -.macro idtentry_part do_sym, has_error_code:req, read_cr2:req, paranoid:req, shift_ist=-1, ist_offset=0 - - .if \paranoid - call paranoid_entry - /* returned flag: ebx=0: need swapgs on exit, ebx=1: don't need it */ - .else - call error_entry - .endif - UNWIND_HINT_REGS - - .if \read_cr2 - /* - * Store CR2 early so subsequent faults cannot clobber it. Use R12 as - * intermediate storage as RDX can be clobbered in enter_from_user_mode(). - * GET_CR2_INTO can clobber RAX. - */ - GET_CR2_INTO(%r12); - .endif - - .if \shift_ist != -1 - TRACE_IRQS_OFF_DEBUG /* reload IDT in case of recursion */ - .else - TRACE_IRQS_OFF - .endif - -#ifdef CONFIG_CONTEXT_TRACKING - .if \paranoid == 0 - testb $3, CS(%rsp) - jz .Lfrom_kernel_no_context_tracking_\@ - CALL_enter_from_user_mode -.Lfrom_kernel_no_context_tracking_\@: - .endif -#endif - - movq %rsp, %rdi /* pt_regs pointer */ - - .if \has_error_code - movq ORIG_RAX(%rsp), %rsi /* get error code */ - movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */ - .else - xorl %esi, %esi /* no error code */ - .endif - - .if \shift_ist != -1 - subq $\ist_offset, CPU_TSS_IST(\shift_ist) - .endif - - .if \read_cr2 - movq %r12, %rdx /* Move CR2 into 3rd argument */ - .endif - - call \do_sym - - .if \shift_ist != -1 - addq $\ist_offset, CPU_TSS_IST(\shift_ist) - .endif - - .if \paranoid - /* this procedure expect "no swapgs" flag in ebx */ - jmp paranoid_exit - .else - jmp error_exit - .endif - -.endm - -/** - * idtentry - Generate an IDT entry stub - * @sym: Name of the generated entry point - * @do_sym: C function to be called - * @has_error_code: True if this IDT vector has an error code on the stack - * @paranoid: non-zero means that this vector may be invoked from - * kernel mode with user GSBASE and/or user CR3. - * 2 is special -- see below. - * @shift_ist: Set to an IST index if entries from kernel mode should - * decrement the IST stack so that nested entries get a - * fresh stack. (This is for #DB, which has a nasty habit - * of recursing.) - * @create_gap: create a 6-word stack gap when coming from kernel mode. - * @read_cr2: load CR2 into the 3rd argument; done before calling any C code - * - * idtentry generates an IDT stub that sets up a usable kernel context, - * creates struct pt_regs, and calls @do_sym. The stub has the following - * special behaviors: - * - * On an entry from user mode, the stub switches from the trampoline or - * IST stack to the normal thread stack. On an exit to user mode, the - * normal exit-to-usermode path is invoked. - * - * On an exit to kernel mode, if @paranoid == 0, we check for preemption, - * whereas we omit the preemption check if @paranoid != 0. This is purely - * because the implementation is simpler this way. The kernel only needs - * to check for asynchronous kernel preemption when IRQ handlers return. - * - * If @paranoid == 0, then the stub will handle IRET faults by pretending - * that the fault came from user mode. It will handle gs_change faults by - * pretending that the fault happened with kernel GSBASE. Since this handling - * is omitted for @paranoid != 0, the #GP, #SS, and #NP stubs must have - * @paranoid == 0. This special handling will do the wrong thing for - * espfix-induced #DF on IRET, so #DF must not use @paranoid == 0. - * - * @paranoid == 2 is special: the stub will never switch stacks. This is for - * #DF: if the thread stack is somehow unusable, we'll still get a useful OOPS. - */ -.macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1 ist_offset=0 create_gap=0 read_cr2=0 -SYM_CODE_START(\sym) - UNWIND_HINT_IRET_REGS offset=\has_error_code*8 - - /* Sanity check */ - .if \shift_ist != -1 && \paranoid != 1 - .error "using shift_ist requires paranoid=1" - .endif - - .if \create_gap && \paranoid - .error "using create_gap requires paranoid=0" - .endif - - ASM_CLAC - - .if \has_error_code == 0 - pushq $-1 /* ORIG_RAX: no syscall to restart */ - .endif - - .if \paranoid == 1 - testb $3, CS-ORIG_RAX(%rsp) /* If coming from userspace, switch stacks */ - jnz .Lfrom_usermode_switch_stack_\@ - .endif - - .if \create_gap == 1 - /* - * If coming from kernel space, create a 6-word gap to allow the - * int3 handler to emulate a call instruction. - */ - testb $3, CS-ORIG_RAX(%rsp) - jnz .Lfrom_usermode_no_gap_\@ - .rept 6 - pushq 5*8(%rsp) - .endr - UNWIND_HINT_IRET_REGS offset=8 -.Lfrom_usermode_no_gap_\@: - .endif - - idtentry_part \do_sym, \has_error_code, \read_cr2, \paranoid, \shift_ist, \ist_offset - - .if \paranoid == 1 - /* - * Entry from userspace. Switch stacks and treat it - * as a normal entry. This means that paranoid handlers - * run in real process context if user_mode(regs). - */ -.Lfrom_usermode_switch_stack_\@: - idtentry_part \do_sym, \has_error_code, \read_cr2, paranoid=0 - .endif - -_ASM_NOKPROBE(\sym) -SYM_CODE_END(\sym) -.endm -idtentry divide_error do_divide_error has_error_code=0 -idtentry overflow do_overflow has_error_code=0 -idtentry int3 do_int3 has_error_code=0 create_gap=1 -idtentry bounds do_bounds has_error_code=0 -idtentry invalid_op do_invalid_op has_error_code=0 -idtentry device_not_available do_device_not_available has_error_code=0 -idtentry coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0 -idtentry invalid_TSS do_invalid_TSS has_error_code=1 -idtentry segment_not_present do_segment_not_present has_error_code=1 -idtentry stack_segment do_stack_segment has_error_code=1 -idtentry general_protection do_general_protection has_error_code=1 -idtentry spurious_interrupt_bug do_spurious_interrupt_bug has_error_code=0 -idtentry coprocessor_error do_coprocessor_error has_error_code=0 -idtentry alignment_check do_alignment_check has_error_code=1 -idtentry simd_coprocessor_error do_simd_coprocessor_error has_error_code=0 +idtentry X86_TRAP_DE divide_error do_divide_error has_error_code=0 +idtentry X86_TRAP_OF overflow do_overflow has_error_code=0 +idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 +idtentry X86_TRAP_BR bounds do_bounds has_error_code=0 +idtentry X86_TRAP_UD invalid_op do_invalid_op has_error_code=0 +idtentry X86_TRAP_NM device_not_available do_device_not_available has_error_code=0 +idtentry X86_TRAP_OLD_MF coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0 +idtentry X86_TRAP_TS invalid_TSS do_invalid_TSS has_error_code=1 +idtentry X86_TRAP_NP segment_not_present do_segment_not_present has_error_code=1 +idtentry X86_TRAP_SS stack_segment do_stack_segment has_error_code=1 +idtentry X86_TRAP_GP general_protection do_general_protection has_error_code=1 +idtentry X86_TRAP_SPURIOUS spurious_interrupt_bug do_spurious_interrupt_bug has_error_code=0 +idtentry X86_TRAP_MF coprocessor_error do_coprocessor_error has_error_code=0 +idtentry X86_TRAP_AC alignment_check do_alignment_check has_error_code=1 +idtentry X86_TRAP_XF simd_coprocessor_error do_simd_coprocessor_error has_error_code=0 -idtentry page_fault do_page_fault has_error_code=1 read_cr2=1 +idtentry X86_TRAP_PF page_fault do_page_fault has_error_code=1 #ifdef CONFIG_KVM_GUEST -idtentry async_page_fault do_async_page_fault has_error_code=1 read_cr2=1 +idtentry X86_TRAP_PF async_page_fault do_async_page_fault has_error_code=1 #endif #ifdef CONFIG_X86_MCE -idtentry machine_check do_mce has_error_code=0 paranoid=1 +idtentry_mce_db X86_TRAP_MCE machine_check do_mce #endif -idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=IST_INDEX_DB ist_offset=DB_STACK_OFFSET -idtentry double_fault do_double_fault has_error_code=1 paranoid=2 read_cr2=1 +idtentry_mce_db X86_TRAP_DB debug do_debug +idtentry_df X86_TRAP_DF double_fault do_double_fault #ifdef CONFIG_XEN_PV -idtentry hypervisor_callback xen_do_hypervisor_callback has_error_code=0 -idtentry xennmi do_nmi has_error_code=0 -idtentry xendebug do_debug has_error_code=0 +idtentry 512 /* dummy */ hypervisor_callback xen_do_hypervisor_callback has_error_code=0 +idtentry X86_TRAP_NMI xennmi do_nmi has_error_code=0 +idtentry X86_TRAP_DB xendebug do_debug has_error_code=0 #endif /*
PATCH v2 5/23 x86/entry/32: Provide macro to emit IDT entry stubs
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
32 and 64 bit have unnecessary different ways to populate the exception entry code. Provide a idtentry macro which allows to consolidate all of that.
--- arch/x86/entry/entry_32.S | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
arch/x86/entry/entry_32.S +42 -0
@@ -44,6 +44,7 @@ #include <asm/asm.h> #include <asm/smap.h> #include <asm/frame.h> +#include <asm/trapnr.h> #include <asm/nospec-branch.h> #include "calling.h"
@@ -726,6 +727,47 @@ .Lend_\@: .endm + +#ifdef CONFIG_X86_INVD_BUG +.macro idtentry_push_func vector cfunc + .if \vector == X86_TRAP_XF + /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */ + ALTERNATIVE "pushl $do_general_protection", \ + "pushl $do_simd_coprocessor_error", \ + X86_FEATURE_XMM + .else + pushl $\cfunc + .endif +.endm +#else +.macro idtentry_push_func vector cfunc + pushl $\cfunc +.endm +#endif + +/** + * idtentry - Macro to generate entry stubs for simple IDT entries + * @vector: Vector number + * @asmsym: ASM symbol for the entry point + * @cfunc: C function to be called + * @has_error_code: Hardware pushed error code on stack + */ +.macro idtentry vector asmsym cfunc has_error_code:req +SYM_CODE_START(\asmsym) + ASM_CLAC + cld + + .if \has_error_code == 0 + pushl $0 /* Clear the error code */ + .endif + + /* Push the C-function address into the GS slot */ + idtentry_push_func \vector \cfunc + /* Invoke the common exception entry */ + jmp common_exception +SYM_CODE_END(\asmsym) +.endm + /* * %eax: prev task * %edx: next task
Re: [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs
Quoted 35 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
32 and 64 bit have unnecessary different ways to populate the exception entry code. Provide a idtentry macro which allows to consolidate all of that.
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Alexandre Chartre <[email protected]>--- arch/x86/entry/entry_32.S | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)arch/x86/entry/entry_32.S +8
-0@@ -44,6 +44,7 @@ #include <asm/asm.h> #include <asm/smap.h> #include <asm/frame.h> +#include <asm/trapnr.h> #include <asm/nospec-branch.h> #include "calling.h"@@ -726,6 +727,47 @@ .Lend_\@: .endm + +#ifdef CONFIG_X86_INVD_BUG +.macro idtentry_push_func vector cfunc + .if \vector == X86_TRAP_XF + /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */ + ALTERNATIVE "pushl $do_general_protection", \ + "pushl $do_simd_coprocessor_error", \
arch/x86/entry/entry_32.S line 746
Quoted 10 lines
arch/x86/entry/entry_32.S +10
-0+ X86_FEATURE_XMM + .else + pushl $\cfunc + .endif +.endm +#else +.macro idtentry_push_func vector cfunc + pushl $\cfunc +.endm +#endif
IMHO it would be better to push this to the C code and not make the asm more complicated. Something like:
dotraplinkage voiddo_simd_coprocessor_error(struct pt_regs *regs, long error_code) {
#ifdef CONFIG_X86_INVD_BUG
/* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */
if (!static_cpu_has(X86_FEATURE_XMM)) {
do_general_protection(regs, error_code);
return;
}
#endif
RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
math_error(regs, error_code, X86_TRAP_XF);
}--
Brian Gerst
Re: [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs
Quoted 24 lines · Brian Gerst
Quoted 6 lines · Thomas Gleixner
arch/x86/entry/entry_32.S +6
-0+#ifdef CONFIG_X86_INVD_BUG +.macro idtentry_push_func vector cfunc + .if \vector == X86_TRAP_XF + /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */ + ALTERNATIVE "pushl $do_general_protection", \ + "pushl $do_simd_coprocessor_error", \arch/x86/entry/entry_32.S line 746
Quoted 10 lines
arch/x86/entry/entry_32.S +10
-0+ X86_FEATURE_XMM + .else + pushl $\cfunc + .endif +.endm +#else +.macro idtentry_push_func vector cfunc + pushl $\cfunc +.endm +#endifIMHO it would be better to push this to the C code and not make the asm more complicated. Something like:
dotraplinkage void
do_simd_coprocessor_error(struct pt_regs *regs, long error_code){
Quoted 10 lines
#ifdef CONFIG_X86_INVD_BUG
/* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */
if (!static_cpu_has(X86_FEATURE_XMM)) {
do_general_protection(regs, error_code);
return;
}
#endif
RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
math_error(regs, error_code, X86_TRAP_XF);
}That's too obvious :)
Thanks for catching that!
tglx
PATCH v2 6/23 x86/idtentry: Provide macros to define/declare IDT entry points
In reply to Thomas GleixnerProvide DECLARE/DEFINE_IDTENTRY() macros.
DEFINE_IDTENTRY() provides a wrapper which acts as the function definition. The exception handler body is just appended to it with curly brackets. The entry point is marked notrace/noprobe so that irq tracing and the enter_from_user_mode() can be moved into the C-entry point. As all C-entries use the same macro (or a later variant) the necessary entry handling can be implemented at one central place.
DECLARE_IDTENTRY() provides the function prototypes:
- The C entry point cfunc
- The ASM entry point asm_cfunc
- The XEN/PV entry point xen_asm_cfunc
They all follow the same naming convention.
When included from ASM code DECLARE_IDTENTRY() is a macro which emits the low level entry point in assembly by instantiating idtentry.
IDTENTRY is the simplest variant which just has a pt_regs argument. It's going to be used for all exceptions which have no error code.
---
V2: Add comments to explain the C vs. ASM variants
--- arch/x86/entry/entry_32.S | 6 ++ arch/x86/entry/entry_64.S | 6 ++ arch/x86/include/asm/idtentry.h | 85 ++++++++++++++++++++++++++++++++++++++++ arch/x86/include/asm/traps.h | 2 4 files changed, 98 insertions(+), 1 deletion(-)
arch/x86/entry/entry_32.S +6 -0
@@ -769,6 +769,12 @@ SYM_CODE_END(\asmsym) .endm /* + * Include the defines which emit the idt entries which are shared + * shared between 32 and 64 bit. + */ +#include <asm/idtentry.h> + +/* * %eax: prev task * %edx: next task */
arch/x86/entry/entry_64.S +6 -0
@@ -688,6 +688,12 @@ SYM_CODE_END(\asmsym) .endm /* + * Include the defines which emit the idt entries which are shared + * shared between 32 and 64 bit. + */ +#include <asm/idtentry.h> + +/* * Interrupt entry helper function. * * Entry runs with interrupts off. Stack layout at entry:
arch/x86/include/asm/idtentry.h new file +85 -0
85 lines not on this page · raw message
arch/x86/include/asm/traps.h +1 -1
@@ -6,8 +6,8 @@#include <linux/kprobes.h> #include <asm/debugreg.h> +#include <asm/idtentry.h> #include <asm/siginfo.h> /* TRAP_TRACE, ... */ -#include <asm/trapnr.h> #define dotraplinkage __visible
PATCH v2 7/23 x86/traps: Prepare for using DEFINE_IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Prepare for using IDTENTRY to define the C exception/trap entry points. It would be possible to glue this into the existing macro maze, but it's simpler and better to read at the end to just make them distinct. Provide a trivial inline helper to read the trap address.
The existing macros will be removed once all instances are converted.
--- arch/x86/kernel/traps.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/x86/kernel/traps.c +5 -0
@@ -274,6 +274,11 @@ static void do_error_trap(struct pt_regs } } +static inline void __user *error_get_trap_addr (struct pt_regs *regs) +{ +return (void __user *)uprobe_get_trap_addr (regs); +} +#define IP ((void __user *)uprobe_get_trap_addr(regs))#define DO_ERROR (trapnr, signr, sicode, addr, str, name) \ dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
PATCH v2 8/23 x86/entry: Convert Divide Error to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #DE to IDTENTRY:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
No functional change.
---
V2: Add comment to explain the DECLARE_IDTENTRY macro magic at the
actual usage site.
--- arch/x86/entry/entry_32.S | 7 ------- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 12 ++++++++++++ arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 7 ++++++- arch/x86/xen/enlighten_pv.c | 7 ++++++- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 26 insertions(+), 15 deletions(-)
arch/x86/entry/entry_32.S +0 -7
@@ -1386,13 +1386,6 @@ SYM_CODE_START(alignment_check) jmp common_exception SYM_CODE_END(alignment_check) -SYM_CODE_START(divide_error) - ASM_CLAC - pushl $0 # no error code - pushl $do_divide_error - jmp common_exception -SYM_CODE_END(divide_error) - #ifdef CONFIG_X86_MCE SYM_CODE_START(machine_check) ASM_CLAC
arch/x86/entry/entry_64.S +0 -1
@@ -1061,7 +1061,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work * Exception entry points. */ -idtentry X86_TRAP_DE divide_error do_divide_error has_error_code=0 idtentry X86_TRAP_OF overflow do_overflow has_error_code=0 idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 idtentry X86_TRAP_BR bounds do_bounds has_error_code=0
arch/x86/include/asm/idtentry.h +12 -0
@@ -82,4 +82,16 @@ static __always_inline void __##func(str#endif /* __ASSEMBLY__ */ +/* +* The actual entry points. Note that DECLARE_IDTENTRY*() serves two +* purposes: +* - provide the function declarations when included from C-Code +* - emit the ASM stubs when included from entry_32/64.S +* +* This avoids duplicate defines and ensures that everything is consistent. +*/ + +/* Simple exception entry points. No hardware error code */ +DECLARE_IDTENTRY (X86_TRAP_DE , exc_divide_error); +#endif
arch/x86/include/asm/traps.h +0 -3
@@ -11,7 +11,6 @@#define dotraplinkage __visible -asmlinkage void divide_error(void); asmlinkage void debug(void); asmlinkage void nmi(void); asmlinkage void int3(void);
@@ -38,7 +37,6 @@ asmlinkage void machine_check(void); asmlinkage void simd_coprocessor_error(void);#if defined(CONFIG_X86_64 ) && defined(CONFIG_XEN_PV ) -asmlinkage void xen_divide_error(void); asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void);
@@ -62,7 +60,6 @@ asmlinkage void xen_machine_check(void); asmlinkage void xen_simd_coprocessor_error(void);#endif -dotraplinkage void do_divide_error(struct pt_regs *regs, long error_code); dotraplinkage void do_debug(struct pt_regs *regs, long error_code); dotraplinkage void do_nmi(struct pt_regs *regs, long error_code); dotraplinkage void do_int3(struct pt_regs *regs, long error_code);
arch/x86/kernel/idt.c +1 -1
@@ -70,7 +70,7 @@ static const __initconst struct idt_data* set up TSS. */ static const __initconst struct idt_data def_idts[] = { -INTG (X86_TRAP_DE , divide_error), +INTG (X86_TRAP_DE , asm_exc_divide_error),INTG (X86_TRAP_NMI , nmi),INTG (X86_TRAP_BR , bounds),INTG (X86_TRAP_UD , invalid_op),
arch/x86/kernel/traps.c +6 -1
@@ -279,6 +279,12 @@ static inline void __user *error_get_trareturn (void __user *)uprobe_get_trap_addr (regs); } +DEFINE_IDTENTRY (exc_divide_error) +{ +do_error_trap (regs,0 ,"divide_error" ,X86_TRAP_DE ,SIGFPE , +FPE_INTDIV ,error_get_trap_addr (regs)); +} +#define IP ((void __user *)uprobe_get_trap_addr(regs))#define DO_ERROR (trapnr, signr, sicode, addr, str, name) \ dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
@@ -286,7 +292,6 @@ dotraplinkage void do_##name(struct pt_rdo_error_trap (regs, error_code, str, trapnr, signr, sicode, addr); \ } -DO_ERROR(X86_TRAP_DE, SIGFPE, FPE_INTDIV, IP, "divide error", divide_error) DO_ERROR(X86_TRAP_OF, SIGSEGV, 0, NULL, "overflow", overflow) DO_ERROR(X86_TRAP_UD, SIGILL, ILL_ILLOPN, IP, "invalid opcode", invalid_op)DO_ERROR (X86_TRAP_OLD_MF ,SIGFPE ,0 ,NULL ,"coprocessor segment overrun" , coprocessor_segment_overrun)
arch/x86/xen/enlighten_pv.c +6 -1
@@ -602,6 +602,11 @@ struct trap_array_entry {bool ist_okay; }; +#define TRAP_ENTRY (func, ist_ok) { \ + .orig = asm_##func, \ + .xen = xen_asm_##func, \ + .ist_okay = ist_ok } +static struct trap_array_entry trap_array[] = { { debug, xen_xendebug, true }, { double_fault, xen_double_fault, true },
@@ -615,7 +620,7 @@ static struct trap_array_entry trap_arra { entry_INT80_compat, xen_entry_INT80_compat, false }, #endif { page_fault, xen_page_fault, false }, - { divide_error, xen_divide_error, false }, + TRAP_ENTRY(exc_divide_error, false ), { bounds, xen_bounds, false }, { invalid_op, xen_invalid_op, false }, { device_not_available, xen_device_not_available, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -28,7 +28,7 @@ SYM_CODE_END(xen_\name) _ASM_NOKPROBE(xen_\name) .endm -xen_pv_trap divide_error +xen_pv_trap asm_exc_divide_error xen_pv_trap debug xen_pv_trap xendebug xen_pv_trap int3
PATCH v2 9/23 x86/entry: Convert Overflow exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #OF to IDTENTRY:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 7 ------- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 6 +++++- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 9 insertions(+), 15 deletions(-)
arch/x86/entry/entry_32.S +0 -7
@@ -1334,13 +1334,6 @@ SYM_CODE_START(native_iret) SYM_CODE_END(native_iret) #endif -SYM_CODE_START(overflow) - ASM_CLAC - pushl $0 - pushl $do_overflow - jmp common_exception -SYM_CODE_END(overflow) - SYM_CODE_START(bounds) ASM_CLAC pushl $0
arch/x86/entry/entry_64.S +0 -1
@@ -1061,7 +1061,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work * Exception entry points. */ -idtentry X86_TRAP_OF overflow do_overflow has_error_code=0 idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 idtentry X86_TRAP_BR bounds do_bounds has_error_code=0 idtentry X86_TRAP_UD invalid_op do_invalid_op has_error_code=0
arch/x86/include/asm/idtentry.h +1 -0
@@ -93,5 +93,6 @@ static __always_inline void __##func(str/* Simple exception entry points. No hardware error code */ DECLARE_IDTENTRY (X86_TRAP_DE , exc_divide_error); +DECLARE_IDTENTRY (X86_TRAP_OF , exc_overflow);#endif
arch/x86/include/asm/traps.h +0 -3
@@ -14,7 +14,6 @@ asmlinkage void debug(void); asmlinkage void nmi(void); asmlinkage void int3(void); -asmlinkage void overflow(void); asmlinkage void bounds(void); asmlinkage void invalid_op(void); asmlinkage void device_not_available(void);
@@ -40,7 +39,6 @@ asmlinkage void simd_coprocessor_error(v asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); -asmlinkage void xen_overflow(void); asmlinkage void xen_bounds(void); asmlinkage void xen_invalid_op(void); asmlinkage void xen_device_not_available(void);
@@ -63,7 +61,6 @@ asmlinkage void xen_simd_coprocessor_err dotraplinkage void do_debug(struct pt_regs *regs, long error_code); dotraplinkage void do_nmi(struct pt_regs *regs, long error_code); dotraplinkage void do_int3(struct pt_regs *regs, long error_code); -dotraplinkage void do_overflow(struct pt_regs *regs, long error_code); dotraplinkage void do_bounds(struct pt_regs *regs, long error_code); dotraplinkage void do_invalid_op(struct pt_regs *regs, long error_code); dotraplinkage void do_device_not_available(struct pt_regs *regs, long error_code);
arch/x86/kernel/idt.c +1 -1
@@ -96,7 +96,7 @@ static const __initconst struct idt_data INTG(X86_TRAP_MC, &machine_check), #endif - SYSG(X86_TRAP_OF, overflow), + SYSG(X86_TRAP_OF, asm_exc_overflow),#if defined(CONFIG_IA32_EMULATION ) SYSG(IA32_SYSCALL_VECTOR, entry_INT80_compat),#elif defined(CONFIG_X86_32 )
arch/x86/kernel/traps.c +5 -1
@@ -285,6 +285,11 @@ DEFINE_IDTENTRY(exc_divide_error) FPE_INTDIV, error_get_trap_addr(regs)); } +DEFINE_IDTENTRY (exc_overflow) +{ +do_error_trap (regs,0 ,"overflow" ,X86_TRAP_OF ,SIGSEGV ,0 ,NULL ); +} +#define IP ((void __user *)uprobe_get_trap_addr(regs))#define DO_ERROR (trapnr, signr, sicode, addr, str, name) \ dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
@@ -292,7 +297,6 @@ dotraplinkage void do_##name(struct pt_rdo_error_trap (regs, error_code, str, trapnr, signr, sicode, addr); \ } -DO_ERROR(X86_TRAP_OF, SIGSEGV, 0, NULL, "overflow", overflow) DO_ERROR(X86_TRAP_UD, SIGILL, ILL_ILLOPN, IP, "invalid opcode", invalid_op) DO_ERROR(X86_TRAP_OLD_MF, SIGFPE, 0, NULL, "coprocessor segment overrun", coprocessor_segment_overrun)DO_ERROR (X86_TRAP_TS ,SIGSEGV ,0 ,NULL ,"invalid TSS" , invalid_TSS)
arch/x86/xen/enlighten_pv.c +1 -1
@@ -615,7 +615,7 @@ static struct trap_array_entry trap_arra#endif { nmi, xen_xennmi, true }, { int3, xen_int3, false }, - { overflow, xen_overflow, false }, +TRAP_ENTRY (exc_overflow, false ), #ifdef CONFIG_IA32_EMULATION { entry_INT80_compat, xen_entry_INT80_compat, false }, #endif
arch/x86/xen/xen-asm_64.S +1 -1
@@ -33,7 +33,7 @@ xen_pv_trap debug xen_pv_trap xendebug xen_pv_trap int3 xen_pv_trap xennmi -xen_pv_trap overflow +xen_pv_trap asm_exc_overflow xen_pv_trap bounds xen_pv_trap invalid_op xen_pv_trap device_not_available
PATCH v2 10/23 x86/entry: Convert Bounds exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #BR to IDTENTRY:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 7 ------- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 10 +++++----- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 9 insertions(+), 19 deletions(-)
arch/x86/entry/entry_32.S +0 -7
@@ -1334,13 +1334,6 @@ SYM_CODE_START(native_iret) SYM_CODE_END(native_iret) #endif -SYM_CODE_START(bounds) - ASM_CLAC - pushl $0 - pushl $do_bounds - jmp common_exception -SYM_CODE_END(bounds) - SYM_CODE_START(invalid_op) ASM_CLAC pushl $0
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_BR bounds do_bounds has_error_code=0 idtentry X86_TRAP_UD invalid_op do_invalid_op has_error_code=0 idtentry X86_TRAP_NM device_not_available do_device_not_available has_error_code=0 idtentry X86_TRAP_OLD_MF coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0
arch/x86/include/asm/idtentry.h +1 -0
@@ -94,5 +94,6 @@ static __always_inline void __##func(str/* Simple exception entry points. No hardware error code */ DECLARE_IDTENTRY (X86_TRAP_DE , exc_divide_error);DECLARE_IDTENTRY (X86_TRAP_OF , exc_overflow); +DECLARE_IDTENTRY (X86_TRAP_BR , exc_bounds);#endif
arch/x86/include/asm/traps.h +0 -3
@@ -14,7 +14,6 @@ asmlinkage void debug(void); asmlinkage void nmi(void); asmlinkage void int3(void); -asmlinkage void bounds(void); asmlinkage void invalid_op(void); asmlinkage void device_not_available(void);#ifdef CONFIG_X86_64
@@ -39,7 +38,6 @@ asmlinkage void simd_coprocessor_error(v asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); -asmlinkage void xen_bounds(void); asmlinkage void xen_invalid_op(void); asmlinkage void xen_device_not_available(void); asmlinkage void xen_double_fault(void);
@@ -61,7 +59,6 @@ asmlinkage void xen_simd_coprocessor_err dotraplinkage void do_debug(struct pt_regs *regs, long error_code); dotraplinkage void do_nmi(struct pt_regs *regs, long error_code); dotraplinkage void do_int3(struct pt_regs *regs, long error_code); -dotraplinkage void do_bounds(struct pt_regs *regs, long error_code); dotraplinkage void do_invalid_op(struct pt_regs *regs, long error_code); dotraplinkage void do_device_not_available(struct pt_regs *regs, long error_code);#if defined(CONFIG_X86_64 ) || defined(CONFIG_DOUBLEFAULT )
arch/x86/kernel/idt.c +1 -1
@@ -72,7 +72,7 @@ static const __initconst struct idt_datastatic const __initconst struct idt_data def_idts[] = {INTG (X86_TRAP_DE , asm_exc_divide_error),INTG (X86_TRAP_NMI , nmi), -INTG (X86_TRAP_BR , bounds), +INTG (X86_TRAP_BR , asm_exc_bounds),INTG (X86_TRAP_UD , invalid_op),INTG (X86_TRAP_NM , device_not_available),INTG (X86_TRAP_OLD_MF , coprocessor_segment_overrun),
arch/x86/kernel/traps.c +5 -5
@@ -446,18 +446,18 @@ dotraplinkage void do_double_fault(struc }#endif -dotraplinkage void do_bounds(struct pt_regs *regs, long error_code) +DEFINE_IDTENTRY (exc_bounds) {RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" ); -if (notify_die (DIE_TRAP ,"bounds" , regs, error_code, -X86_TRAP_BR ,SIGSEGV ) ==NOTIFY_STOP ) +if (notify_die (DIE_TRAP ,"bounds" , regs,0 , +X86_TRAP_BR ,SIGSEGV ) ==NOTIFY_STOP )return ;cond_local_irq_enable (regs);if (!user_mode (regs)) -die ("bounds" , regs, error_code); +die ("bounds" , regs,0 ); -do_trap (X86_TRAP_BR ,SIGSEGV ,"bounds" , regs, error_code,0 ,NULL ); +do_trap (X86_TRAP_BR ,SIGSEGV ,"bounds" , regs,0 ,0 ,NULL ); }enum kernel_gp_hint {
arch/x86/xen/enlighten_pv.c +1 -1
@@ -621,7 +621,7 @@ static struct trap_array_entry trap_arra#endif { page_fault, xen_page_fault, false },TRAP_ENTRY (exc_divide_error, false ), - { bounds, xen_bounds, false }, +TRAP_ENTRY (exc_bounds, false ), { invalid_op, xen_invalid_op, false }, { device_not_available, xen_device_not_available, false }, { coprocessor_segment_overrun, xen_coprocessor_segment_overrun, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -34,7 +34,7 @@ xen_pv_trap xendebug xen_pv_trap int3 xen_pv_trap xennmi xen_pv_trap asm_exc_overflow -xen_pv_trap bounds +xen_pv_trap asm_exc_bounds xen_pv_trap invalid_op xen_pv_trap device_not_available xen_pv_trap double_fault
PATCH v2 11/23 x86/entry: Convert Invalid Opcode exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #UD to IDTENTRY:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Fixup the FOOF bug call in fault.c
- Remove the old prototyoes
No functional change.
---
V2: Fixup the FOOF bug call into invalid op
--- arch/x86/entry/entry_32.S | 7 ------- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 8 +++++--- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 16 +++++++++++++++- arch/x86/mm/fault.c | 2 +- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 9 files changed, 25 insertions(+), 16 deletions(-)
arch/x86/entry/entry_32.S +0 -7
@@ -1334,13 +1334,6 @@ SYM_CODE_START(native_iret) SYM_CODE_END(native_iret) #endif -SYM_CODE_START(invalid_op) - ASM_CLAC - pushl $0 - pushl $do_invalid_op - jmp common_exception -SYM_CODE_END(invalid_op) - SYM_CODE_START(coprocessor_segment_overrun) ASM_CLAC pushl $0
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_UD invalid_op do_invalid_op has_error_code=0 idtentry X86_TRAP_NM device_not_available do_device_not_available has_error_code=0 idtentry X86_TRAP_OLD_MF coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0 idtentry X86_TRAP_TS invalid_TSS do_invalid_TSS has_error_code=1
arch/x86/include/asm/idtentry.h +1 -0
@@ -95,5 +95,6 @@ static __always_inline void __##func(strDECLARE_IDTENTRY (X86_TRAP_DE , exc_divide_error);DECLARE_IDTENTRY (X86_TRAP_OF , exc_overflow);DECLARE_IDTENTRY (X86_TRAP_BR , exc_bounds); +DECLARE_IDTENTRY (X86_TRAP_UD , exc_invalid_op);#endif
arch/x86/include/asm/traps.h +5 -3
@@ -14,7 +14,6 @@ asmlinkage void debug(void); asmlinkage void nmi(void); asmlinkage void int3(void); -asmlinkage void invalid_op(void); asmlinkage void device_not_available(void);#ifdef CONFIG_X86_64 asmlinkage void double_fault(void);
@@ -38,7 +37,6 @@ asmlinkage void simd_coprocessor_error(v asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); -asmlinkage void xen_invalid_op(void); asmlinkage void xen_device_not_available(void); asmlinkage void xen_double_fault(void); asmlinkage void xen_coprocessor_segment_overrun(void);
@@ -59,7 +57,6 @@ asmlinkage void xen_simd_coprocessor_err dotraplinkage void do_debug(struct pt_regs *regs, long error_code); dotraplinkage void do_nmi(struct pt_regs *regs, long error_code); dotraplinkage void do_int3(struct pt_regs *regs, long error_code); -dotraplinkage void do_invalid_op(struct pt_regs *regs, long error_code); dotraplinkage void do_device_not_available(struct pt_regs *regs, long error_code);#if defined(CONFIG_X86_64 ) || defined(CONFIG_DOUBLEFAULT ) dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);
@@ -86,6 +83,11 @@ struct bad_iret_stack *fixup_bad_iret(stvoid __init trap_init (void );#endif +#ifdef CONFIG_X86_F00F_BUG +/* For handling the FOOF bug */ +void handle_invalid_op (struct pt_regs *regs); +#endif +static inline int get_si_code (unsigned long condition) {if (condition &DR_STEP )
arch/x86/kernel/idt.c +1 -1
@@ -73,7 +73,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_DE , asm_exc_divide_error),INTG (X86_TRAP_NMI , nmi),INTG (X86_TRAP_BR , asm_exc_bounds), -INTG (X86_TRAP_UD , invalid_op), +INTG (X86_TRAP_UD , asm_exc_invalid_op),INTG (X86_TRAP_NM , device_not_available),INTG (X86_TRAP_OLD_MF , coprocessor_segment_overrun), INTG(X86_TRAP_TS, invalid_TSS),
arch/x86/kernel/traps.c +15 -1
@@ -290,6 +290,21 @@ DEFINE_IDTENTRY(exc_overflow)do_error_trap (regs,0 ,"overflow" ,X86_TRAP_OF ,SIGSEGV ,0 ,NULL ); } +#ifdef CONFIG_X86_F00F_BUG +void handle_invalid_op(struct pt_regs *regs) +#else +static inline void handle_invalid_op (struct pt_regs *regs) +{ +do_error_trap (regs,0 ,"invalid opcode" ,X86_TRAP_UD ,SIGILL , +ILL_ILLOPN ,error_get_trap_addr (regs)); +} +#endif + +DEFINE_IDTENTRY (exc_invalid_op) +{ +handle_invalid_op (regs); +} +#define IP ((void __user *)uprobe_get_trap_addr(regs))#define DO_ERROR (trapnr, signr, sicode, addr, str, name) \ dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
@@ -297,7 +312,6 @@ dotraplinkage void do_##name(struct pt_rdo_error_trap (regs, error_code, str, trapnr, signr, sicode, addr); \ } -DO_ERROR(X86_TRAP_UD, SIGILL, ILL_ILLOPN, IP, "invalid opcode", invalid_op) DO_ERROR(X86_TRAP_OLD_MF, SIGFPE, 0, NULL, "coprocessor segment overrun", coprocessor_segment_overrun) DO_ERROR(X86_TRAP_TS, SIGSEGV, 0, NULL, "invalid TSS", invalid_TSS)DO_ERROR (X86_TRAP_NP ,SIGBUS ,0 ,NULL ,"segment not present" , segment_not_present)
arch/x86/mm/fault.c +1 -1
@@ -544,7 +544,7 @@ static int is_f00f_bug(struct pt_regs *r nr = (address - idt_descr.address) >>3 ;if (nr ==6 ) { -do_invalid_op (regs,0 ); +handle_invalid_op (regs);return 1 ; } }
arch/x86/xen/enlighten_pv.c +1 -1
@@ -622,7 +622,7 @@ static struct trap_array_entry trap_arra { page_fault, xen_page_fault, false },TRAP_ENTRY (exc_divide_error, false ),TRAP_ENTRY (exc_bounds, false ), - { invalid_op, xen_invalid_op, false }, +TRAP_ENTRY (exc_invalid_op, false ), { device_not_available, xen_device_not_available, false }, { coprocessor_segment_overrun, xen_coprocessor_segment_overrun, false }, { invalid_TSS, xen_invalid_TSS, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -35,7 +35,7 @@ xen_pv_trap int3 xen_pv_trap xennmi xen_pv_trap asm_exc_overflow xen_pv_trap asm_exc_bounds -xen_pv_trap invalid_op +xen_pv_trap asm_exc_invalid_op xen_pv_trap device_not_available xen_pv_trap double_fault xen_pv_trap coprocessor_segment_overrun
PATCH v2 12/23 x86/entry: Convert Device not available exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #NM to IDTENTRY:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 7 ------- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 6 ++---- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 6 insertions(+), 18 deletions(-)
arch/x86/entry/entry_32.S +0 -7
@@ -1320,13 +1320,6 @@ SYM_CODE_START(simd_coprocessor_error) jmp common_exception SYM_CODE_END(simd_coprocessor_error) -SYM_CODE_START(device_not_available) - ASM_CLAC - pushl $0 - pushl $do_device_not_available - jmp common_exception -SYM_CODE_END(device_not_available) - #ifdef CONFIG_PARAVIRT SYM_CODE_START(native_iret) iret
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_NM device_not_available do_device_not_available has_error_code=0 idtentry X86_TRAP_OLD_MF coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0 idtentry X86_TRAP_TS invalid_TSS do_invalid_TSS has_error_code=1 idtentry X86_TRAP_NP segment_not_present do_segment_not_present has_error_code=1
arch/x86/include/asm/idtentry.h +1 -0
@@ -96,5 +96,6 @@ DECLARE_IDTENTRY(X86_TRAP_DE, exc_dividDECLARE_IDTENTRY (X86_TRAP_OF , exc_overflow);DECLARE_IDTENTRY (X86_TRAP_BR , exc_bounds);DECLARE_IDTENTRY (X86_TRAP_UD , exc_invalid_op); +DECLARE_IDTENTRY (X86_TRAP_NM , exc_device_not_available);#endif
arch/x86/include/asm/traps.h +0 -3
@@ -14,7 +14,6 @@ asmlinkage void debug(void); asmlinkage void nmi(void); asmlinkage void int3(void); -asmlinkage void device_not_available(void);#ifdef CONFIG_X86_64 asmlinkage void double_fault(void);#endif
@@ -37,7 +36,6 @@ asmlinkage void simd_coprocessor_error(v asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); -asmlinkage void xen_device_not_available(void); asmlinkage void xen_double_fault(void); asmlinkage void xen_coprocessor_segment_overrun(void); asmlinkage void xen_invalid_TSS(void);
@@ -57,7 +55,6 @@ asmlinkage void xen_simd_coprocessor_err dotraplinkage void do_debug(struct pt_regs *regs, long error_code); dotraplinkage void do_nmi(struct pt_regs *regs, long error_code); dotraplinkage void do_int3(struct pt_regs *regs, long error_code); -dotraplinkage void do_device_not_available(struct pt_regs *regs, long error_code);#if defined(CONFIG_X86_64 ) || defined(CONFIG_DOUBLEFAULT ) dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif
arch/x86/kernel/idt.c +1 -1
@@ -74,7 +74,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_NMI , nmi),INTG (X86_TRAP_BR , asm_exc_bounds),INTG (X86_TRAP_UD , asm_exc_invalid_op), -INTG (X86_TRAP_NM , device_not_available), +INTG (X86_TRAP_NM , asm_exc_device_not_available),INTG (X86_TRAP_OLD_MF , coprocessor_segment_overrun),INTG (X86_TRAP_TS , invalid_TSS), INTG(X86_TRAP_NP, segment_not_present),
arch/x86/kernel/traps.c +2 -4
@@ -920,8 +920,7 @@ do_spurious_interrupt_bug(struct pt_regs*/ } -dotraplinkage void -do_device_not_available (struct pt_regs *regs,long error_code) +DEFINE_IDTENTRY (exc_device_not_available) {unsigned long cr0 =read_cr0 ();
@@ -949,10 +948,9 @@ do_device_not_available(struct pt_regs ** to kill the task than getting stuck in a never-ending * loop of #NM faults. */ -die ("unexpected #NM exception" , regs, error_code); +die ("unexpected #NM exception" , regs,0 ); } } -NOKPROBE_SYMBOL (do_device_not_available);#ifdef CONFIG_X86_32 dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code)
arch/x86/xen/enlighten_pv.c +1 -1
@@ -623,7 +623,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_divide_error, false ),TRAP_ENTRY (exc_bounds, false ),TRAP_ENTRY (exc_invalid_op, false ), - { device_not_available, xen_device_not_available, false }, +TRAP_ENTRY (exc_device_not_available, false ), { coprocessor_segment_overrun, xen_coprocessor_segment_overrun, false }, { invalid_TSS, xen_invalid_TSS, false }, { segment_not_present, xen_segment_not_present, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -36,7 +36,7 @@ xen_pv_trap xennmi xen_pv_trap asm_exc_overflow xen_pv_trap asm_exc_bounds xen_pv_trap asm_exc_invalid_op -xen_pv_trap device_not_available +xen_pv_trap asm_exc_device_not_available xen_pv_trap double_fault xen_pv_trap coprocessor_segment_overrun xen_pv_trap invalid_TSS
PATCH v2 13/23 x86/entry: Convert Coprocessor segment overrun exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #OLD_MF to IDTENTRY:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 7 ------- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 7 ++++++- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 10 insertions(+), 15 deletions(-)
arch/x86/entry/entry_32.S +0 -7
@@ -1327,13 +1327,6 @@ SYM_CODE_START(native_iret) SYM_CODE_END(native_iret) #endif -SYM_CODE_START(coprocessor_segment_overrun) - ASM_CLAC - pushl $0 - pushl $do_coprocessor_segment_overrun - jmp common_exception -SYM_CODE_END(coprocessor_segment_overrun) - SYM_CODE_START(invalid_TSS) ASM_CLAC pushl $do_invalid_TSS
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_OLD_MF coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0 idtentry X86_TRAP_TS invalid_TSS do_invalid_TSS has_error_code=1 idtentry X86_TRAP_NP segment_not_present do_segment_not_present has_error_code=1 idtentry X86_TRAP_SS stack_segment do_stack_segment has_error_code=1
arch/x86/include/asm/idtentry.h +1 -0
@@ -97,5 +97,6 @@ DECLARE_IDTENTRY(X86_TRAP_OF, exc_overfDECLARE_IDTENTRY (X86_TRAP_BR , exc_bounds);DECLARE_IDTENTRY (X86_TRAP_UD , exc_invalid_op);DECLARE_IDTENTRY (X86_TRAP_NM , exc_device_not_available); +DECLARE_IDTENTRY (X86_TRAP_OLD_MF , exc_coproc_segment_overrun);#endif
arch/x86/include/asm/traps.h +0 -3
@@ -17,7 +17,6 @@ asmlinkage void int3(void);#ifdef CONFIG_X86_64 asmlinkage void double_fault(void);#endif -asmlinkage void coprocessor_segment_overrun(void); asmlinkage void invalid_TSS(void); asmlinkage void segment_not_present(void); asmlinkage void stack_segment(void);
@@ -37,7 +36,6 @@ asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); asmlinkage void xen_double_fault(void); -asmlinkage void xen_coprocessor_segment_overrun(void); asmlinkage void xen_invalid_TSS(void); asmlinkage void xen_segment_not_present(void); asmlinkage void xen_stack_segment(void);
@@ -58,7 +56,6 @@ dotraplinkage void do_int3(struct pt_reg#if defined(CONFIG_X86_64 ) || defined(CONFIG_DOUBLEFAULT ) dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif -dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *regs, long error_code); dotraplinkage void do_invalid_TSS(struct pt_regs *regs, long error_code); dotraplinkage void do_segment_not_present(struct pt_regs *regs, long error_code); dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code);
arch/x86/kernel/idt.c +1 -1
@@ -75,7 +75,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_BR , asm_exc_bounds),INTG (X86_TRAP_UD , asm_exc_invalid_op),INTG (X86_TRAP_NM , asm_exc_device_not_available), -INTG (X86_TRAP_OLD_MF , coprocessor_segment_overrun), +INTG (X86_TRAP_OLD_MF , asm_exc_coproc_segment_overrun),INTG (X86_TRAP_TS , invalid_TSS),INTG (X86_TRAP_NP , segment_not_present), INTG(X86_TRAP_SS, stack_segment),
arch/x86/kernel/traps.c +6 -1
@@ -305,6 +305,12 @@ DEFINE_IDTENTRY(exc_invalid_op)handle_invalid_op (regs); } +DEFINE_IDTENTRY (exc_coproc_segment_overrun) +{ +do_error_trap (regs,0 ,"coprocessor segment overrun" , +X86_TRAP_OLD_MF ,SIGFPE ,0 ,NULL ); +} +#define IP ((void __user *)uprobe_get_trap_addr(regs))#define DO_ERROR (trapnr, signr, sicode, addr, str, name) \ dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
@@ -312,7 +318,6 @@ dotraplinkage void do_##name(struct pt_rdo_error_trap (regs, error_code, str, trapnr, signr, sicode, addr); \ } -DO_ERROR(X86_TRAP_OLD_MF, SIGFPE, 0, NULL, "coprocessor segment overrun", coprocessor_segment_overrun) DO_ERROR(X86_TRAP_TS, SIGSEGV, 0, NULL, "invalid TSS", invalid_TSS) DO_ERROR(X86_TRAP_NP, SIGBUS, 0, NULL, "segment not present", segment_not_present)DO_ERROR (X86_TRAP_SS ,SIGBUS ,0 ,NULL ,"stack segment" , stack_segment)
arch/x86/xen/enlighten_pv.c +1 -1
@@ -624,7 +624,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_bounds, false ),TRAP_ENTRY (exc_invalid_op, false ),TRAP_ENTRY (exc_device_not_available, false ), - { coprocessor_segment_overrun, xen_coprocessor_segment_overrun, false }, +TRAP_ENTRY (exc_coproc_segment_overrun, false ), { invalid_TSS, xen_invalid_TSS, false }, { segment_not_present, xen_segment_not_present, false }, { stack_segment, xen_stack_segment, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -38,7 +38,7 @@ xen_pv_trap asm_exc_bounds xen_pv_trap asm_exc_invalid_op xen_pv_trap asm_exc_device_not_available xen_pv_trap double_fault -xen_pv_trap coprocessor_segment_overrun +xen_pv_trap asm_exc_coproc_segment_overrun xen_pv_trap invalid_TSS xen_pv_trap segment_not_present xen_pv_trap stack_segment
PATCH v2 14/23 x86/entry: Provide IDTENTRY_ERRORCODE
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Same as IDTENTRY but the C entry point has an error code argument.
--- arch/x86/include/asm/idtentry.h | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
arch/x86/include/asm/idtentry.h +45 -0
@@ -72,6 +72,48 @@ NOKPROBE_SYMBOL(func); \ \ static __always_inline void __##func(struct pt_regs *regs) +/** +* DECLARE_IDTENTRY_ERRORCODE - Declare functions for simple IDT entry points +* Error code pushed by hardware +* @vector: Vector number (ignored for C) +* @func: Function name of the entry point +* +* Declares three functions: +* - The ASM entry point: asm_##func +* - The XEN PV trap entry point: xen_##func (maybe unused) +* - The C handler called from the ASM entry point +* +* Same as DECLARE_IDTENTRY, but has an extra error_code argument for the +* C-handler. +*/ +#define DECLARE_IDTENTRY_ERRORCODE (vector, func) \ + asmlinkage void asm_##func(void); \ + asmlinkage void xen_asm_##func(void); \ + __visible void func(struct pt_regs *regs, unsigned long error_code) + +/** +* DEFINE_IDTENTRY_ERRORCODE - Emit code for simple IDT entry points +* Error code pushed by hardware +* @func: Function name of the entry point +* +* Same as DEFINE_IDTENTRY, but has an extra error_code argument +*/ +#define DEFINE_IDTENTRY_ERRORCODE (func) \ +static __always_inline void __##func(struct pt_regs *regs, \ + unsigned long error_code); \ + \ +__visible notrace void func(struct pt_regs *regs, \ + unsigned long error_code) \ +{ \ + idtentry_enter(regs); \ + __##func (regs, error_code); \ + idtentry_exit(regs); \ +} \ +NOKPROBE_SYMBOL(func); \ + \ +static __always_inline void __##func(struct pt_regs *regs, \ + unsigned long error_code) +#else /* !__ASSEMBLY__ */ /*
@@ -80,6 +122,9 @@ static __always_inline void __##func(str#define DECLARE_IDTENTRY (vector, func) \ idtentry vector asm_##func func has_error_code=0 +#define DECLARE_IDTENTRY_ERRORCODE (vector, func) \ + idtentry vector asm_##func func has_error_code=1 +#endif /* __ASSEMBLY__ */ /*
PATCH v2 15/23 x86/entry: Convert Invalid TSS exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #TS to IDTENTRY_ERRORCODE:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 6 ------ arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 3 +++ arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 7 ++++++- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 12 insertions(+), 14 deletions(-)
arch/x86/entry/entry_32.S +0 -6
@@ -1327,12 +1327,6 @@ SYM_CODE_START(native_iret) SYM_CODE_END(native_iret) #endif -SYM_CODE_START(invalid_TSS) - ASM_CLAC - pushl $do_invalid_TSS - jmp common_exception -SYM_CODE_END(invalid_TSS) - SYM_CODE_START(segment_not_present) ASM_CLAC pushl $do_segment_not_present
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_TS invalid_TSS do_invalid_TSS has_error_code=1 idtentry X86_TRAP_NP segment_not_present do_segment_not_present has_error_code=1 idtentry X86_TRAP_SS stack_segment do_stack_segment has_error_code=1 idtentry X86_TRAP_GP general_protection do_general_protection has_error_code=1
arch/x86/include/asm/idtentry.h +3 -0
@@ -144,4 +144,7 @@ DECLARE_IDTENTRY(X86_TRAP_UD, exc_invalDECLARE_IDTENTRY (X86_TRAP_NM , exc_device_not_available);DECLARE_IDTENTRY (X86_TRAP_OLD_MF , exc_coproc_segment_overrun); +/* Simple exception entries with error code pushed by hardware */ +DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_TS , exc_invalid_tss); +#endif
arch/x86/include/asm/traps.h +0 -3
@@ -17,7 +17,6 @@ asmlinkage void int3(void);#ifdef CONFIG_X86_64 asmlinkage void double_fault(void);#endif -asmlinkage void invalid_TSS(void); asmlinkage void segment_not_present(void); asmlinkage void stack_segment(void); asmlinkage void general_protection(void);
@@ -36,7 +35,6 @@ asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); asmlinkage void xen_double_fault(void); -asmlinkage void xen_invalid_TSS(void); asmlinkage void xen_segment_not_present(void); asmlinkage void xen_stack_segment(void); asmlinkage void xen_general_protection(void);
@@ -56,7 +54,6 @@ dotraplinkage void do_int3(struct pt_reg#if defined(CONFIG_X86_64 ) || defined(CONFIG_DOUBLEFAULT ) dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif -dotraplinkage void do_invalid_TSS(struct pt_regs *regs, long error_code); dotraplinkage void do_segment_not_present(struct pt_regs *regs, long error_code); dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code); dotraplinkage void do_general_protection(struct pt_regs *regs, long error_code);
arch/x86/kernel/idt.c +1 -1
@@ -76,7 +76,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_UD , asm_exc_invalid_op),INTG (X86_TRAP_NM , asm_exc_device_not_available),INTG (X86_TRAP_OLD_MF , asm_exc_coproc_segment_overrun), -INTG (X86_TRAP_TS , invalid_TSS), +INTG (X86_TRAP_TS , asm_exc_invalid_tss),INTG (X86_TRAP_NP , segment_not_present),INTG (X86_TRAP_SS , stack_segment), INTG(X86_TRAP_GP, general_protection),
arch/x86/kernel/traps.c +6 -1
@@ -311,6 +311,12 @@ DEFINE_IDTENTRY(exc_coproc_segment_overr X86_TRAP_OLD_MF, SIGFPE, 0, NULL); } +DEFINE_IDTENTRY_ERRORCODE (exc_invalid_tss) +{ +do_error_trap (regs, error_code,"invalid TSS" ,X86_TRAP_TS ,SIGSEGV , +0 ,NULL ); +} +#define IP ((void __user *)uprobe_get_trap_addr(regs))#define DO_ERROR (trapnr, signr, sicode, addr, str, name) \ dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
@@ -318,7 +324,6 @@ dotraplinkage void do_##name(struct pt_rdo_error_trap (regs, error_code, str, trapnr, signr, sicode, addr); \ } -DO_ERROR(X86_TRAP_TS, SIGSEGV, 0, NULL, "invalid TSS", invalid_TSS) DO_ERROR(X86_TRAP_NP, SIGBUS, 0, NULL, "segment not present", segment_not_present) DO_ERROR(X86_TRAP_SS, SIGBUS, 0, NULL, "stack segment", stack_segment)DO_ERROR (X86_TRAP_AC ,SIGBUS ,BUS_ADRALN ,NULL ,"alignment check" , alignment_check)
arch/x86/xen/enlighten_pv.c +1 -1
@@ -625,7 +625,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_invalid_op, false ),TRAP_ENTRY (exc_device_not_available, false ),TRAP_ENTRY (exc_coproc_segment_overrun, false ), - { invalid_TSS, xen_invalid_TSS, false }, +TRAP_ENTRY (exc_invalid_tss, false ), { segment_not_present, xen_segment_not_present, false }, { stack_segment, xen_stack_segment, false }, { general_protection, xen_general_protection, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -39,7 +39,7 @@ xen_pv_trap asm_exc_invalid_op xen_pv_trap asm_exc_device_not_available xen_pv_trap double_fault xen_pv_trap asm_exc_coproc_segment_overrun -xen_pv_trap invalid_TSS +xen_pv_trap asm_exc_invalid_tss xen_pv_trap segment_not_present xen_pv_trap stack_segment xen_pv_trap general_protection
PATCH v2 16/23 x86/entry: Convert Segment not present exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #NP to IDTENTRY_ERRORCODE:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 6 ------ arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 7 ++++++- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 10 insertions(+), 14 deletions(-)
arch/x86/entry/entry_32.S +0 -6
@@ -1327,12 +1327,6 @@ SYM_CODE_START(native_iret) SYM_CODE_END(native_iret) #endif -SYM_CODE_START(segment_not_present) - ASM_CLAC - pushl $do_segment_not_present - jmp common_exception -SYM_CODE_END(segment_not_present) - SYM_CODE_START(stack_segment) ASM_CLAC pushl $do_stack_segment
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_NP segment_not_present do_segment_not_present has_error_code=1 idtentry X86_TRAP_SS stack_segment do_stack_segment has_error_code=1 idtentry X86_TRAP_GP general_protection do_general_protection has_error_code=1 idtentry X86_TRAP_SPURIOUS spurious_interrupt_bug do_spurious_interrupt_bug has_error_code=0
arch/x86/include/asm/idtentry.h +1 -0
@@ -146,5 +146,6 @@ DECLARE_IDTENTRY(X86_TRAP_OLD_MF, exc_co/* Simple exception entries with error code pushed by hardware */ DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_TS , exc_invalid_tss); +DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_NP , exc_segment_not_present);#endif
arch/x86/include/asm/traps.h +0 -3
@@ -17,7 +17,6 @@ asmlinkage void int3(void);#ifdef CONFIG_X86_64 asmlinkage void double_fault(void);#endif -asmlinkage void segment_not_present(void); asmlinkage void stack_segment(void); asmlinkage void general_protection(void); asmlinkage void page_fault(void);
@@ -35,7 +34,6 @@ asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); asmlinkage void xen_double_fault(void); -asmlinkage void xen_segment_not_present(void); asmlinkage void xen_stack_segment(void); asmlinkage void xen_general_protection(void); asmlinkage void xen_page_fault(void);
@@ -54,7 +52,6 @@ dotraplinkage void do_int3(struct pt_reg#if defined(CONFIG_X86_64 ) || defined(CONFIG_DOUBLEFAULT ) dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif -dotraplinkage void do_segment_not_present(struct pt_regs *regs, long error_code); dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code); dotraplinkage void do_general_protection(struct pt_regs *regs, long error_code); dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
arch/x86/kernel/idt.c +1 -1
@@ -77,7 +77,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_NM , asm_exc_device_not_available),INTG (X86_TRAP_OLD_MF , asm_exc_coproc_segment_overrun),INTG (X86_TRAP_TS , asm_exc_invalid_tss), -INTG (X86_TRAP_NP , segment_not_present), +INTG (X86_TRAP_NP , asm_exc_segment_not_present),INTG (X86_TRAP_SS , stack_segment),INTG (X86_TRAP_GP , general_protection), INTG(X86_TRAP_SPURIOUS, spurious_interrupt_bug),
arch/x86/kernel/traps.c +6 -1
@@ -317,6 +317,12 @@ DEFINE_IDTENTRY_ERRORCODE(exc_invalid_ts 0, NULL); } +DEFINE_IDTENTRY_ERRORCODE (exc_segment_not_present) +{ +do_error_trap (regs, error_code,"segment not present" ,X86_TRAP_NP , +SIGBUS ,0 ,NULL ); +} +#define IP ((void __user *)uprobe_get_trap_addr(regs))#define DO_ERROR (trapnr, signr, sicode, addr, str, name) \ dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
@@ -324,7 +330,6 @@ dotraplinkage void do_##name(struct pt_rdo_error_trap (regs, error_code, str, trapnr, signr, sicode, addr); \ } -DO_ERROR(X86_TRAP_NP, SIGBUS, 0, NULL, "segment not present", segment_not_present) DO_ERROR(X86_TRAP_SS, SIGBUS, 0, NULL, "stack segment", stack_segment) DO_ERROR(X86_TRAP_AC, SIGBUS, BUS_ADRALN, NULL, "alignment check", alignment_check)#undef IP
arch/x86/xen/enlighten_pv.c +1 -1
@@ -626,7 +626,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_device_not_available, false ),TRAP_ENTRY (exc_coproc_segment_overrun, false ),TRAP_ENTRY (exc_invalid_tss, false ), - { segment_not_present, xen_segment_not_present, false }, +TRAP_ENTRY (exc_segment_not_present, false ), { stack_segment, xen_stack_segment, false }, { general_protection, xen_general_protection, false }, { spurious_interrupt_bug, xen_spurious_interrupt_bug, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -40,7 +40,7 @@ xen_pv_trap asm_exc_device_not_available xen_pv_trap double_fault xen_pv_trap asm_exc_coproc_segment_overrun xen_pv_trap asm_exc_invalid_tss -xen_pv_trap segment_not_present +xen_pv_trap asm_exc_segment_not_present xen_pv_trap stack_segment xen_pv_trap general_protection xen_pv_trap page_fault
PATCH v2 17/23 x86/entry: Convert Stack segment exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #SS to IDTENTRY_ERRORCODE:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 6 ------ arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 7 ++++++- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 10 insertions(+), 14 deletions(-)
arch/x86/entry/entry_32.S +0 -6
@@ -1327,12 +1327,6 @@ SYM_CODE_START(native_iret) SYM_CODE_END(native_iret) #endif -SYM_CODE_START(stack_segment) - ASM_CLAC - pushl $do_stack_segment - jmp common_exception -SYM_CODE_END(stack_segment) - SYM_CODE_START(alignment_check) ASM_CLAC pushl $do_alignment_check
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_SS stack_segment do_stack_segment has_error_code=1 idtentry X86_TRAP_GP general_protection do_general_protection has_error_code=1 idtentry X86_TRAP_SPURIOUS spurious_interrupt_bug do_spurious_interrupt_bug has_error_code=0 idtentry X86_TRAP_MF coprocessor_error do_coprocessor_error has_error_code=0
arch/x86/include/asm/idtentry.h +1 -0
@@ -147,5 +147,6 @@ DECLARE_IDTENTRY(X86_TRAP_OLD_MF, exc_co/* Simple exception entries with error code pushed by hardware */ DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_TS , exc_invalid_tss);DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_NP , exc_segment_not_present); +DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_SS , exc_stack_segment);#endif
arch/x86/include/asm/traps.h +0 -3
@@ -17,7 +17,6 @@ asmlinkage void int3(void);#ifdef CONFIG_X86_64 asmlinkage void double_fault(void);#endif -asmlinkage void stack_segment(void); asmlinkage void general_protection(void); asmlinkage void page_fault(void); asmlinkage void async_page_fault(void);
@@ -34,7 +33,6 @@ asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); asmlinkage void xen_double_fault(void); -asmlinkage void xen_stack_segment(void); asmlinkage void xen_general_protection(void); asmlinkage void xen_page_fault(void); asmlinkage void xen_spurious_interrupt_bug(void);
@@ -52,7 +50,6 @@ dotraplinkage void do_int3(struct pt_reg#if defined(CONFIG_X86_64 ) || defined(CONFIG_DOUBLEFAULT ) dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif -dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code); dotraplinkage void do_general_protection(struct pt_regs *regs, long error_code); dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address); dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code);
arch/x86/kernel/idt.c +1 -1
@@ -78,7 +78,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_OLD_MF , asm_exc_coproc_segment_overrun),INTG (X86_TRAP_TS , asm_exc_invalid_tss),INTG (X86_TRAP_NP , asm_exc_segment_not_present), -INTG (X86_TRAP_SS , stack_segment), +INTG (X86_TRAP_SS , asm_exc_stack_segment),INTG (X86_TRAP_GP , general_protection),INTG (X86_TRAP_SPURIOUS , spurious_interrupt_bug), INTG(X86_TRAP_MF, coprocessor_error),
arch/x86/kernel/traps.c +6 -1
@@ -323,6 +323,12 @@ DEFINE_IDTENTRY_ERRORCODE(exc_segment_no SIGBUS, 0, NULL); } +DEFINE_IDTENTRY_ERRORCODE (exc_stack_segment) +{ +do_error_trap (regs, error_code,"stack segment" ,X86_TRAP_SS ,SIGBUS , +0 ,NULL ); +} +#define IP ((void __user *)uprobe_get_trap_addr(regs))#define DO_ERROR (trapnr, signr, sicode, addr, str, name) \ dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
@@ -330,7 +336,6 @@ dotraplinkage void do_##name(struct pt_rdo_error_trap (regs, error_code, str, trapnr, signr, sicode, addr); \ } -DO_ERROR(X86_TRAP_SS, SIGBUS, 0, NULL, "stack segment", stack_segment) DO_ERROR(X86_TRAP_AC, SIGBUS, BUS_ADRALN, NULL, "alignment check", alignment_check)#undef IP
arch/x86/xen/enlighten_pv.c +1 -1
@@ -627,7 +627,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_coproc_segment_overrun, false ),TRAP_ENTRY (exc_invalid_tss, false ),TRAP_ENTRY (exc_segment_not_present, false ), - { stack_segment, xen_stack_segment, false }, +TRAP_ENTRY (exc_stack_segment, false ), { general_protection, xen_general_protection, false }, { spurious_interrupt_bug, xen_spurious_interrupt_bug, false }, { coprocessor_error, xen_coprocessor_error, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -41,7 +41,7 @@ xen_pv_trap double_fault xen_pv_trap asm_exc_coproc_segment_overrun xen_pv_trap asm_exc_invalid_tss xen_pv_trap asm_exc_segment_not_present -xen_pv_trap stack_segment +xen_pv_trap asm_exc_stack_segment xen_pv_trap general_protection xen_pv_trap page_fault xen_pv_trap spurious_interrupt_bug
PATCH v2 18/23 x86/entry: Convert General protection exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #GP to IDTENTRY_ERRORCODE:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 8 +------- arch/x86/entry/entry_64.S | 3 +-- arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 7 +++---- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 9 insertions(+), 19 deletions(-)
arch/x86/entry/entry_32.S +1 -7
@@ -732,7 +732,7 @@ .macro idtentry_push_func vector cfunc .if \vector == X86_TRAP_XF /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */ - ALTERNATIVE "pushl $do_general_protection", \ + ALTERNATIVE "pushl $exc_general_protection", \ "pushl $do_simd_coprocessor_error", \ X86_FEATURE_XMM .else
@@ -1659,12 +1659,6 @@ SYM_CODE_START(int3) jmp common_exception SYM_CODE_END(int3) -SYM_CODE_START(general_protection) - ASM_CLAC - pushl $do_general_protection - jmp common_exception -SYM_CODE_END(general_protection) - #ifdef CONFIG_KVM_GUEST SYM_CODE_START(async_page_fault) ASM_CLAC
arch/x86/entry/entry_64.S +1 -2
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_GP general_protection do_general_protection has_error_code=1 idtentry X86_TRAP_SPURIOUS spurious_interrupt_bug do_spurious_interrupt_bug has_error_code=0 idtentry X86_TRAP_MF coprocessor_error do_coprocessor_error has_error_code=0 idtentry X86_TRAP_AC alignment_check do_alignment_check has_error_code=1
@@ -1202,7 +1201,7 @@ SYM_CODE_START(xen_failsafe_callback) addq $0x30, %rsp pushq $0 /* RIP */ UNWIND_HINT_IRET_REGS offset=8 - jmp general_protection + jmp asm_exc_general_protection 1: /* Segment mismatch => Category 1 (Bad segment). Retry the IRET. */ movq (%rsp), %rcx movq 8(%rsp), %r11
arch/x86/include/asm/idtentry.h +1 -0
@@ -148,5 +148,6 @@ DECLARE_IDTENTRY(X86_TRAP_OLD_MF, exc_coDECLARE_IDTENTRY_ERRORCODE (X86_TRAP_TS , exc_invalid_tss);DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_NP , exc_segment_not_present);DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_SS , exc_stack_segment); +DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_GP , exc_general_protection);#endif
arch/x86/include/asm/traps.h +0 -3
@@ -17,7 +17,6 @@ asmlinkage void int3(void);#ifdef CONFIG_X86_64 asmlinkage void double_fault(void);#endif -asmlinkage void general_protection(void); asmlinkage void page_fault(void); asmlinkage void async_page_fault(void); asmlinkage void spurious_interrupt_bug(void);
@@ -33,7 +32,6 @@ asmlinkage void xen_xennmi(void); asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); asmlinkage void xen_double_fault(void); -asmlinkage void xen_general_protection(void); asmlinkage void xen_page_fault(void); asmlinkage void xen_spurious_interrupt_bug(void); asmlinkage void xen_coprocessor_error(void);
@@ -50,7 +48,6 @@ dotraplinkage void do_int3(struct pt_reg#if defined(CONFIG_X86_64 ) || defined(CONFIG_DOUBLEFAULT ) dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif -dotraplinkage void do_general_protection(struct pt_regs *regs, long error_code); dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address); dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code); dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code);
arch/x86/kernel/idt.c +1 -1
@@ -79,7 +79,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_TS , asm_exc_invalid_tss),INTG (X86_TRAP_NP , asm_exc_segment_not_present),INTG (X86_TRAP_SS , asm_exc_stack_segment), -INTG (X86_TRAP_GP , general_protection), +INTG (X86_TRAP_GP , asm_exc_general_protection),INTG (X86_TRAP_SPURIOUS , spurious_interrupt_bug),INTG (X86_TRAP_MF , coprocessor_error), INTG(X86_TRAP_AC, alignment_check),
arch/x86/kernel/traps.c +3 -4
@@ -214,7 +214,7 @@ do_trap_no_signal(struct task_struct *ts* process no chance to handle the signal and notice the * kernel fault information, so that won't result in polluting * the information about previously queued, but not yet -* delivered, faults. See also do_general_protection below. +* delivered, faults. See also exc_general_protection below. */ tsk->thread.error_code = error_code; tsk->thread.trap_nr = trapnr;
@@ -419,7 +419,7 @@ dotraplinkage void do_double_fault(struc* which is what the stub expects, given that the faulting * RIP will be the IRET instruction. */ - regs->ip = (unsigned long )general_protection; + regs->ip = (unsigned long )asm_exc_general_protection; regs->sp = (unsigned long )&gpregs->orig_ax;return ;
@@ -538,7 +538,7 @@ static enum kernel_gp_hint get_kernel_gp#define GPFSTR "general protection fault" -dotraplinkage void do_general_protection(struct pt_regs *regs, long error_code) +DEFINE_IDTENTRY_ERRORCODE (exc_general_protection) {char desc[sizeof (GPFSTR ) +50 +2 *sizeof (unsigned long ) +1 ] =GPFSTR ;enum kernel_gp_hint hint =GP_NO_HINT ;
@@ -612,7 +612,6 @@ dotraplinkage void do_general_protectiondie_addr (desc, regs, error_code, gp_addr); } -NOKPROBE_SYMBOL (do_general_protection); dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code) {
arch/x86/xen/enlighten_pv.c +1 -1
@@ -628,7 +628,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_invalid_tss, false ),TRAP_ENTRY (exc_segment_not_present, false ),TRAP_ENTRY (exc_stack_segment, false ), - { general_protection, xen_general_protection, false }, +TRAP_ENTRY (exc_general_protection, false ), { spurious_interrupt_bug, xen_spurious_interrupt_bug, false }, { coprocessor_error, xen_coprocessor_error, false }, { alignment_check, xen_alignment_check, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -42,7 +42,7 @@ xen_pv_trap asm_exc_coproc_segment_overr xen_pv_trap asm_exc_invalid_tss xen_pv_trap asm_exc_segment_not_present xen_pv_trap asm_exc_stack_segment -xen_pv_trap general_protection +xen_pv_trap asm_exc_general_protection xen_pv_trap page_fault xen_pv_trap spurious_interrupt_bug xen_pv_trap coprocessor_error
PATCH v2 19/23 x86/entry: Convert Spurious interrupt bug exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #SPURIOUS to IDTENTRY_ERRORCODE:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 7 ------- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 3 +-- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 5 insertions(+), 16 deletions(-)
arch/x86/entry/entry_32.S +0 -7
@@ -1342,13 +1342,6 @@ SYM_CODE_START(machine_check) SYM_CODE_END(machine_check) #endif -SYM_CODE_START(spurious_interrupt_bug) - ASM_CLAC - pushl $0 - pushl $do_spurious_interrupt_bug - jmp common_exception -SYM_CODE_END(spurious_interrupt_bug) - #ifdef CONFIG_XEN_PV SYM_FUNC_START(xen_hypervisor_callback) /*
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_SPURIOUS spurious_interrupt_bug do_spurious_interrupt_bug has_error_code=0 idtentry X86_TRAP_MF coprocessor_error do_coprocessor_error has_error_code=0 idtentry X86_TRAP_AC alignment_check do_alignment_check has_error_code=1 idtentry X86_TRAP_XF simd_coprocessor_error do_simd_coprocessor_error has_error_code=0
arch/x86/include/asm/idtentry.h +1 -0
@@ -143,6 +143,7 @@ DECLARE_IDTENTRY(X86_TRAP_BR, exc_boundDECLARE_IDTENTRY (X86_TRAP_UD , exc_invalid_op);DECLARE_IDTENTRY (X86_TRAP_NM , exc_device_not_available);DECLARE_IDTENTRY (X86_TRAP_OLD_MF , exc_coproc_segment_overrun); +DECLARE_IDTENTRY (X86_TRAP_SPURIOUS , exc_spurious_interrupt_bug);/* Simple exception entries with error code pushed by hardware */ DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_TS , exc_invalid_tss);
arch/x86/include/asm/traps.h +0 -3
@@ -19,7 +19,6 @@ asmlinkage void double_fault(void);#endif asmlinkage void page_fault(void); asmlinkage void async_page_fault(void); -asmlinkage void spurious_interrupt_bug(void); asmlinkage void coprocessor_error(void); asmlinkage void alignment_check(void);#ifdef CONFIG_X86_MCE
@@ -33,7 +32,6 @@ asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); asmlinkage void xen_double_fault(void); asmlinkage void xen_page_fault(void); -asmlinkage void xen_spurious_interrupt_bug(void); asmlinkage void xen_coprocessor_error(void); asmlinkage void xen_alignment_check(void);#ifdef CONFIG_X86_MCE
@@ -49,7 +47,6 @@ dotraplinkage void do_int3(struct pt_reg dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address); -dotraplinkage void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code); dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code); dotraplinkage void do_alignment_check(struct pt_regs *regs, long error_code); dotraplinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code);
arch/x86/kernel/idt.c +1 -1
@@ -80,7 +80,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_NP , asm_exc_segment_not_present),INTG (X86_TRAP_SS , asm_exc_stack_segment),INTG (X86_TRAP_GP , asm_exc_general_protection), -INTG (X86_TRAP_SPURIOUS , spurious_interrupt_bug), +INTG (X86_TRAP_SPURIOUS , asm_exc_spurious_interrupt_bug),INTG (X86_TRAP_MF , coprocessor_error),INTG (X86_TRAP_AC , alignment_check), INTG(X86_TRAP_XF, simd_coprocessor_error),
arch/x86/kernel/traps.c +1 -2
@@ -915,8 +915,7 @@ do_simd_coprocessor_error(struct pt_regsmath_error (regs, error_code,X86_TRAP_XF ); } -dotraplinkage void -do_spurious_interrupt_bug (struct pt_regs *regs,long error_code) +DEFINE_IDTENTRY (exc_spurious_interrupt_bug) {/* * This addresses a Pentium Pro Erratum:
arch/x86/xen/enlighten_pv.c +1 -1
@@ -629,7 +629,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_segment_not_present, false ),TRAP_ENTRY (exc_stack_segment, false ),TRAP_ENTRY (exc_general_protection, false ), - { spurious_interrupt_bug, xen_spurious_interrupt_bug, false }, +TRAP_ENTRY (exc_spurious_interrupt_bug, false ), { coprocessor_error, xen_coprocessor_error, false }, { alignment_check, xen_alignment_check, false }, { simd_coprocessor_error, xen_simd_coprocessor_error, false },
arch/x86/xen/xen-asm_64.S +1 -1
@@ -44,7 +44,7 @@ xen_pv_trap asm_exc_segment_not_present xen_pv_trap asm_exc_stack_segment xen_pv_trap asm_exc_general_protection xen_pv_trap page_fault -xen_pv_trap spurious_interrupt_bug +xen_pv_trap asm_exc_spurious_interrupt_bug xen_pv_trap coprocessor_error xen_pv_trap alignment_check #ifdef CONFIG_X86_MCE
PATCH v2 20/23 x86/entry: Convert Coprocessor error exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #MF to IDTENTRY_ERRORCODE:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 7 ------- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 4 ++-- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 6 insertions(+), 16 deletions(-)
arch/x86/entry/entry_32.S +0 -7
@@ -1299,13 +1299,6 @@ SYM_FUNC_END(name) /* The include is where all of the SMP etc. interrupts come from */ #include <asm/entry_arch.h> -SYM_CODE_START(coprocessor_error) - ASM_CLAC - pushl $0 - pushl $do_coprocessor_error - jmp common_exception -SYM_CODE_END(coprocessor_error) - SYM_CODE_START(simd_coprocessor_error) ASM_CLAC pushl $0
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_MF coprocessor_error do_coprocessor_error has_error_code=0 idtentry X86_TRAP_AC alignment_check do_alignment_check has_error_code=1 idtentry X86_TRAP_XF simd_coprocessor_error do_simd_coprocessor_error has_error_code=0
arch/x86/include/asm/idtentry.h +1 -0
@@ -144,6 +144,7 @@ DECLARE_IDTENTRY(X86_TRAP_UD, exc_invalDECLARE_IDTENTRY (X86_TRAP_NM , exc_device_not_available);DECLARE_IDTENTRY (X86_TRAP_OLD_MF , exc_coproc_segment_overrun);DECLARE_IDTENTRY (X86_TRAP_SPURIOUS , exc_spurious_interrupt_bug); +DECLARE_IDTENTRY (X86_TRAP_MF , exc_coprocessor_error);/* Simple exception entries with error code pushed by hardware */ DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_TS , exc_invalid_tss);
arch/x86/include/asm/traps.h +0 -3
@@ -19,7 +19,6 @@ asmlinkage void double_fault(void);#endif asmlinkage void page_fault(void); asmlinkage void async_page_fault(void); -asmlinkage void coprocessor_error(void); asmlinkage void alignment_check(void);#ifdef CONFIG_X86_MCE asmlinkage void machine_check(void);
@@ -32,7 +31,6 @@ asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); asmlinkage void xen_double_fault(void); asmlinkage void xen_page_fault(void); -asmlinkage void xen_coprocessor_error(void); asmlinkage void xen_alignment_check(void);#ifdef CONFIG_X86_MCE asmlinkage void xen_machine_check(void);
@@ -47,7 +45,6 @@ dotraplinkage void do_int3(struct pt_reg dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address); -dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code); dotraplinkage void do_alignment_check(struct pt_regs *regs, long error_code); dotraplinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_32
arch/x86/kernel/idt.c +1 -1
@@ -81,7 +81,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_SS , asm_exc_stack_segment),INTG (X86_TRAP_GP , asm_exc_general_protection),INTG (X86_TRAP_SPURIOUS , asm_exc_spurious_interrupt_bug), -INTG (X86_TRAP_MF , coprocessor_error), +INTG (X86_TRAP_MF , asm_exc_coprocessor_error),INTG (X86_TRAP_AC , alignment_check), INTG(X86_TRAP_XF, simd_coprocessor_error),
arch/x86/kernel/traps.c +2 -2
@@ -902,10 +902,10 @@ static void math_error(struct pt_regs *r (void __user *)uprobe_get_trap_addr(regs)); } -dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code) +DEFINE_IDTENTRY (exc_coprocessor_error) {RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" ); -math_error (regs, error_code,X86_TRAP_MF ); +math_error (regs,0 ,X86_TRAP_MF ); }dotraplinkage void
arch/x86/xen/enlighten_pv.c +1 -1
@@ -630,7 +630,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_stack_segment, false ),TRAP_ENTRY (exc_general_protection, false ),TRAP_ENTRY (exc_spurious_interrupt_bug, false ), - { coprocessor_error, xen_coprocessor_error, false }, +TRAP_ENTRY (exc_coprocessor_error, false ), { alignment_check, xen_alignment_check, false }, { simd_coprocessor_error, xen_simd_coprocessor_error, false }, };
arch/x86/xen/xen-asm_64.S +1 -1
@@ -45,7 +45,7 @@ xen_pv_trap asm_exc_stack_segment xen_pv_trap asm_exc_general_protection xen_pv_trap page_fault xen_pv_trap asm_exc_spurious_interrupt_bug -xen_pv_trap coprocessor_error +xen_pv_trap asm_exc_coprocessor_error xen_pv_trap alignment_check #ifdef CONFIG_X86_MCE xen_pv_trap machine_check
PATCH v2 21/23 x86/entry: Convert Alignment check exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #AC to IDTENTRY_ERRORCODE:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 6 ------ arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 12 ++++-------- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 8 insertions(+), 21 deletions(-)
arch/x86/entry/entry_32.S +0 -6
@@ -1320,12 +1320,6 @@ SYM_CODE_START(native_iret) SYM_CODE_END(native_iret) #endif -SYM_CODE_START(alignment_check) - ASM_CLAC - pushl $do_alignment_check - jmp common_exception -SYM_CODE_END(alignment_check) - #ifdef CONFIG_X86_MCE SYM_CODE_START(machine_check) ASM_CLAC
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_AC alignment_check do_alignment_check has_error_code=1 idtentry X86_TRAP_XF simd_coprocessor_error do_simd_coprocessor_error has_error_code=0 idtentry X86_TRAP_PF page_fault do_page_fault has_error_code=1
arch/x86/include/asm/idtentry.h +1 -0
@@ -151,5 +151,6 @@ DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_TS,DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_NP , exc_segment_not_present);DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_SS , exc_stack_segment);DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_GP , exc_general_protection); +DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_AC , exc_alignment_check);#endif
arch/x86/include/asm/traps.h +0 -3
@@ -19,7 +19,6 @@ asmlinkage void double_fault(void);#endif asmlinkage void page_fault(void); asmlinkage void async_page_fault(void); -asmlinkage void alignment_check(void);#ifdef CONFIG_X86_MCE asmlinkage void machine_check(void);#endif /* CONFIG_X86_MCE */
@@ -31,7 +30,6 @@ asmlinkage void xen_xendebug(void); asmlinkage void xen_int3(void); asmlinkage void xen_double_fault(void); asmlinkage void xen_page_fault(void); -asmlinkage void xen_alignment_check(void);#ifdef CONFIG_X86_MCE asmlinkage void xen_machine_check(void);#endif /* CONFIG_X86_MCE */
@@ -45,7 +43,6 @@ dotraplinkage void do_int3(struct pt_reg dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address); -dotraplinkage void do_alignment_check(struct pt_regs *regs, long error_code); dotraplinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_32 dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code);
arch/x86/kernel/idt.c +1 -1
@@ -82,7 +82,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_GP , asm_exc_general_protection),INTG (X86_TRAP_SPURIOUS , asm_exc_spurious_interrupt_bug),INTG (X86_TRAP_MF , asm_exc_coprocessor_error), -INTG (X86_TRAP_AC , alignment_check), +INTG (X86_TRAP_AC , asm_exc_alignment_check),INTG (X86_TRAP_XF , simd_coprocessor_error), #ifdef CONFIG_X86_32
arch/x86/kernel/traps.c +4 -8
@@ -329,16 +329,12 @@ DEFINE_IDTENTRY_ERRORCODE(exc_stack_segm 0, NULL); } -#define IP ((void __user *)uprobe_get_trap_addr(regs)) -#define DO_ERROR (trapnr, signr, sicode, addr, str, name) \ -dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \ -{ \ - do_error_trap(regs, error_code, str, trapnr, signr, sicode, addr); \ +DEFINE_IDTENTRY_ERRORCODE (exc_alignment_check) +{ +do_error_trap (regs, error_code,"alignement check" ,X86_TRAP_AC , +SIGBUS ,BUS_ADRALN ,NULL ); } -DO_ERROR(X86_TRAP_AC, SIGBUS, BUS_ADRALN, NULL, "alignment check", alignment_check) -#undef IP -#ifdef CONFIG_VMAP_STACK __visible void __noreturn handle_stack_overflow(const char *message, struct pt_regs *regs,
arch/x86/xen/enlighten_pv.c +1 -1
@@ -631,7 +631,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_general_protection, false ),TRAP_ENTRY (exc_spurious_interrupt_bug, false ),TRAP_ENTRY (exc_coprocessor_error, false ), - { alignment_check, xen_alignment_check, false }, +TRAP_ENTRY (exc_alignment_check, false ), { simd_coprocessor_error, xen_simd_coprocessor_error, false }, };
arch/x86/xen/xen-asm_64.S +1 -1
@@ -46,7 +46,7 @@ xen_pv_trap asm_exc_general_protection xen_pv_trap page_fault xen_pv_trap asm_exc_spurious_interrupt_bug xen_pv_trap asm_exc_coprocessor_error -xen_pv_trap alignment_check +xen_pv_trap asm_exc_alignment_check #ifdef CONFIG_X86_MCE xen_pv_trap machine_check #endif /* CONFIG_X86_MCE */
PATCH v2 22/23 x86/entry: Convert SIMD coprocessor error exception to IDTENTRY
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert #XF to IDTENTRY_ERRORCODE:
- Implement the C entry point with DEFINE_IDTENTRY
- Emit the ASM stub with DECLARE_IDTENTRY
- Remove the ASM idtentry in 64bit
- Remove the open coded ASM entry code in 32bit
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 16 +--------------- arch/x86/entry/entry_64.S | 1 - arch/x86/include/asm/idtentry.h | 1 + arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/idt.c | 2 +- arch/x86/kernel/traps.c | 21 ++++++++++----------- arch/x86/xen/enlighten_pv.c | 2 +- arch/x86/xen/xen-asm_64.S | 2 +- 8 files changed, 15 insertions(+), 33 deletions(-)
arch/x86/entry/entry_32.S +1 -15
@@ -733,7 +733,7 @@ .if \vector == X86_TRAP_XF /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */ ALTERNATIVE "pushl $exc_general_protection", \ - "pushl $do_simd_coprocessor_error", \ + "pushl $exc_simd_coprocessor_error", \ X86_FEATURE_XMM .else pushl $\cfunc
@@ -1299,20 +1299,6 @@ SYM_FUNC_END(name) /* The include is where all of the SMP etc. interrupts come from */ #include <asm/entry_arch.h> -SYM_CODE_START(simd_coprocessor_error) - ASM_CLAC - pushl $0 -#ifdef CONFIG_X86_INVD_BUG - /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */ - ALTERNATIVE "pushl $do_general_protection", \ - "pushl $do_simd_coprocessor_error", \ - X86_FEATURE_XMM -#else - pushl $do_simd_coprocessor_error -#endif - jmp common_exception -SYM_CODE_END(simd_coprocessor_error) - #ifdef CONFIG_PARAVIRT SYM_CODE_START(native_iret) iret
arch/x86/entry/entry_64.S +0 -1
@@ -1062,7 +1062,6 @@ apicinterrupt IRQ_WORK_VECTOR irq_work */ idtentry X86_TRAP_BP int3 do_int3 has_error_code=0 -idtentry X86_TRAP_XF simd_coprocessor_error do_simd_coprocessor_error has_error_code=0 idtentry X86_TRAP_PF page_fault do_page_fault has_error_code=1 #ifdef CONFIG_KVM_GUEST
arch/x86/include/asm/idtentry.h +1 -0
@@ -145,6 +145,7 @@ DECLARE_IDTENTRY(X86_TRAP_NM, exc_devicDECLARE_IDTENTRY (X86_TRAP_OLD_MF , exc_coproc_segment_overrun);DECLARE_IDTENTRY (X86_TRAP_SPURIOUS , exc_spurious_interrupt_bug);DECLARE_IDTENTRY (X86_TRAP_MF , exc_coprocessor_error); +DECLARE_IDTENTRY (X86_TRAP_XF , exc_simd_coprocessor_error);/* Simple exception entries with error code pushed by hardware */ DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_TS , exc_invalid_tss);
arch/x86/include/asm/traps.h +0 -3
@@ -22,7 +22,6 @@ asmlinkage void async_page_fault(void);#ifdef CONFIG_X86_MCE asmlinkage void machine_check(void);#endif /* CONFIG_X86_MCE */ -asmlinkage void simd_coprocessor_error(void);#if defined(CONFIG_X86_64 ) && defined(CONFIG_XEN_PV ) asmlinkage void xen_xennmi(void);
@@ -33,7 +32,6 @@ asmlinkage void xen_page_fault(void);#ifdef CONFIG_X86_MCE asmlinkage void xen_machine_check(void);#endif /* CONFIG_X86_MCE */ -asmlinkage void xen_simd_coprocessor_error(void);#endif dotraplinkage void do_debug(struct pt_regs *regs, long error_code);
@@ -43,7 +41,6 @@ dotraplinkage void do_int3(struct pt_reg dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address); -dotraplinkage void do_simd_coprocessor_error(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_32 dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code);#endif
arch/x86/kernel/idt.c +1 -1
@@ -83,7 +83,7 @@ static const __initconst struct idt_dataINTG (X86_TRAP_SPURIOUS , asm_exc_spurious_interrupt_bug),INTG (X86_TRAP_MF , asm_exc_coprocessor_error),INTG (X86_TRAP_AC , asm_exc_alignment_check), -INTG (X86_TRAP_XF , simd_coprocessor_error), +INTG (X86_TRAP_XF , asm_exc_simd_coprocessor_error), #ifdef CONFIG_X86_32 TSKG(X86_TRAP_DF, GDT_ENTRY_DOUBLEFAULT_TSS),
arch/x86/kernel/traps.c +10 -11
@@ -858,7 +858,7 @@ NOKPROBE_SYMBOL(do_debug);* the correct behaviour even in the presence of the asynchronous * IRQ13 behaviour */ -static void math_error (struct pt_regs *regs,int error_code,int trapnr) +static void math_error (struct pt_regs *regs,int trapnr) {struct task_struct *task = current;struct fpu *fpu = &task->thread.fpu;
@@ -869,15 +869,15 @@ static void math_error(struct pt_regs *rcond_local_irq_enable (regs);if (!user_mode (regs)) { -if (fixup_exception (regs, trapnr, error_code,0 )) +if (fixup_exception (regs, trapnr,0 ,0 ))return ; - task->thread.error_code = error_code; + task->thread.error_code =0 ; task->thread.trap_nr = trapnr; -if (notify_die (DIE_TRAP , str, regs, error_code, - trapnr,SIGFPE ) !=NOTIFY_STOP ) -die (str, regs, error_code); +if (notify_die (DIE_TRAP , str, regs,0 ,trapnr, +SIGFPE ) !=NOTIFY_STOP ) +die (str, regs,0 );return ; }
@@ -887,7 +887,7 @@ static void math_error(struct pt_regs *rfpu__save (fpu); task->thread.trap_nr = trapnr; - task->thread.error_code = error_code; + task->thread.error_code =0 ; si_code =fpu__exception_code (fpu, trapnr);/* Retry when we get spurious exceptions: */
@@ -901,14 +901,13 @@ static void math_error(struct pt_regs *rDEFINE_IDTENTRY (exc_coprocessor_error) {RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" ); -math_error (regs,0 ,X86_TRAP_MF ); +math_error (regs,X86_TRAP_MF ); } -dotraplinkage void -do_simd_coprocessor_error (struct pt_regs *regs,long error_code) +DEFINE_IDTENTRY (exc_simd_coprocessor_error) {RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" ); -math_error (regs, error_code,X86_TRAP_XF ); +math_error (regs,X86_TRAP_XF ); }DEFINE_IDTENTRY (exc_spurious_interrupt_bug)
arch/x86/xen/enlighten_pv.c +1 -1
@@ -632,7 +632,7 @@ static struct trap_array_entry trap_arraTRAP_ENTRY (exc_spurious_interrupt_bug, false ),TRAP_ENTRY (exc_coprocessor_error, false ),TRAP_ENTRY (exc_alignment_check, false ), - { simd_coprocessor_error, xen_simd_coprocessor_error, false }, + TRAP_ENTRY(exc_simd_coprocessor_error, false ), };static bool __ref get_trap_addr (void **addr,unsigned int ist)
arch/x86/xen/xen-asm_64.S +1 -1
@@ -50,7 +50,7 @@ xen_pv_trap asm_exc_alignment_check #ifdef CONFIG_X86_MCE xen_pv_trap machine_check #endif /* CONFIG_X86_MCE */ -xen_pv_trap simd_coprocessor_error +xen_pv_trap asm_exc_simd_coprocessor_error #ifdef CONFIG_IA32_EMULATION xen_pv_trap entry_INT80_compat #endif
PATCH v2 23/23 x86/entry/32: Convert IRET exception to IDTENTRY_SW
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert the IRET exception handler to IDTENTRY_SW. This is slightly different than the conversions of hardware exceptions as the IRET exception is invoked via an exception table when IRET faults. So it just uses the IDTENTRY_SW mechanism for consistency. It does not emit ASM code as it does not fit the other idtentry exceptions.
- Implement the C entry point with DEFINE_IDTENTRY_SW() which maps to DEFINE_IDTENTRY()
- Fixup the XEN/PV code
- Remove the old prototyoes
No functional change.
--- arch/x86/entry/entry_32.S | 12 ++++++------ arch/x86/include/asm/idtentry.h | 10 ++++++++++ arch/x86/include/asm/traps.h | 3 --- arch/x86/kernel/traps.c | 6 +++--- arch/x86/xen/xen-asm_32.S | 2 +- 5 files changed, 20 insertions(+), 13 deletions(-)
arch/x86/entry/entry_32.S +6 -6
@@ -1156,9 +1156,9 @@ SYM_FUNC_START(entry_INT80_32) jmp .Lirq_return .section .fixup, "ax" -SYM_CODE_START(iret_exc) +SYM_CODE_START(asm_exc_iret_error) pushl $0 # no error code - pushl $do_iret_error + pushl $exc_iret_error #ifdef CONFIG_DEBUG_ENTRY /*
@@ -1173,9 +1173,9 @@ SYM_CODE_START(iret_exc) #endif jmp common_exception -SYM_CODE_END(iret_exc) +SYM_CODE_END(asm_exc_iret_error) .previous - _ASM_EXTABLE(.Lirq_return, iret_exc) + _ASM_EXTABLE(.Lirq_return, asm_exc_iret_error) SYM_FUNC_END(entry_INT80_32) .macro FIXUP_ESPFIX_STACK
@@ -1302,7 +1302,7 @@ SYM_FUNC_END(name) #ifdef CONFIG_PARAVIRT SYM_CODE_START(native_iret) iret - _ASM_EXTABLE(native_iret, iret_exc) + _ASM_EXTABLE(native_iret, asm_exc_iret_error) SYM_CODE_END(native_iret) #endif
@@ -1367,7 +1367,7 @@ SYM_FUNC_START(xen_failsafe_callback) popl %eax lea 16(%esp), %esp jz 5f - jmp iret_exc + jmp asm_exc_iret_error 5: pushl $-1 /* orig_ax = -1 => not a system call */ SAVE_ALL ENCODE_FRAME_POINTER
arch/x86/include/asm/idtentry.h +10 -0
@@ -72,6 +72,10 @@ NOKPROBE_SYMBOL(func); \ \ static __always_inline void __##func(struct pt_regs *regs) +/* Special case for 32bit IRET 'trap' */ +#define DECLARE_IDTENTRY_SW DECLARE_IDTENTRY +#define DEFINE_IDTENTRY_SW DEFINE_IDTENTRY +/** * DECLARE_IDTENTRY_ERRORCODE - Declare functions for simple IDT entry points * Error code pushed by hardware
@@ -125,6 +129,9 @@ static __always_inline void __##func(str#define DECLARE_IDTENTRY_ERRORCODE (vector, func) \ idtentry vector asm_##func func has_error_code=1 +/* Special case for 32bit IRET 'trap'. Do not emit ASM code */ +#define DECLARE_IDTENTRY_SW (vector, func) +#endif /* __ASSEMBLY__ */ /*
@@ -147,6 +154,9 @@ DECLARE_IDTENTRY(X86_TRAP_SPURIOUS, exc_DECLARE_IDTENTRY (X86_TRAP_MF , exc_coprocessor_error);DECLARE_IDTENTRY (X86_TRAP_XF , exc_simd_coprocessor_error); +/* 32bit software IRET trap. Do not emit ASM code */ +DECLARE_IDTENTRY_SW (X86_TRAP_IRET , exc_iret_error); +/* Simple exception entries with error code pushed by hardware */ DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_TS , exc_invalid_tss);DECLARE_IDTENTRY_ERRORCODE (X86_TRAP_NP , exc_segment_not_present);
arch/x86/include/asm/traps.h +0 -3
@@ -41,9 +41,6 @@ dotraplinkage void do_int3(struct pt_reg dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code, unsigned long cr2);#endif dotraplinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address); -#ifdef CONFIG_X86_32 -dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code); -#endif dotraplinkage void do_mce(struct pt_regs *regs, long error_code);#ifdef CONFIG_X86_64
arch/x86/kernel/traps.c +3 -3
@@ -966,14 +966,14 @@ DEFINE_IDTENTRY(exc_device_not_available }#ifdef CONFIG_X86_32 -dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code) +DEFINE_IDTENTRY_SW (exc_iret_error) {RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" );local_irq_enable (); -if (notify_die (DIE_TRAP ,"iret exception" , regs, error_code, +if (notify_die (DIE_TRAP ,"iret exception" , regs,0 ,X86_TRAP_IRET ,SIGILL ) !=NOTIFY_STOP ) { -do_trap (X86_TRAP_IRET ,SIGILL ,"iret exception" , regs, error_code, +do_trap (X86_TRAP_IRET ,SIGILL ,"iret exception" , regs,0 ,ILL_BADSTK , (void __user *)NULL ); } }
arch/x86/xen/xen-asm_32.S +1 -1
@@ -117,7 +117,7 @@ SYM_CODE_START(xen_iret) 1: iret xen_iret_end_crit: - _ASM_EXTABLE(1b, iret_exc) + _ASM_EXTABLE(1b, asm_exc_iret_error) hyper_iret: /* put this out of line since its very rarely used */
Jürgen Groß
maintainerQuoted 17 lines · Thomas Gleixner
Hi!
This is the second version of the entry consolidation work part III covering simple exceptions. V1 can be found here:
https://lore.kernel.org/r/[email protected]It applies on top of part II which is available here
https://lore.kernel.org/r/[email protected]and is also available from git (including part II):
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/develentry-v2-part3The changes vs. V1:
Quoted 7 lines
- Remove #BP (int3) conversion as this needs extra care vs. kprobes (Peter)
- Fixup the FOOF bug
do_invalid_op()call infault.c- Address the few review comments (mostly changelog and comment improvements)
- Picked up Reviewed-by and Acked-by tags
FWIW: tested to be bootable as Xen dom0 (at least when adding commit bba42affa732d6fd5b).
Juergen