* [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions)
@ 2020-03-08 23:14 Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 01/23] x86/traps: Split trap numbers out in a seperate header Thomas Gleixner
` (23 more replies)
0 siblings, 24 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
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/20200225221606.511535280@linutronix.de
It applies on top of part II which is available here
https://lore.kernel.org/r/20200308222359.370649591@linutronix.de
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(-)
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 01/23] x86/traps: Split trap numbers out in a seperate header
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 02/23] x86/entry/64: Avoid pointless code when CONTEXT_TRACKING=n Thomas Gleixner
` (22 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre, Andy Lutomirski
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
---
arch/x86/include/asm/trapnr.h | 31 +++++++++++++++++++++++++++++++
arch/x86/include/asm/traps.h | 26 +-------------------------
2 files changed, 32 insertions(+), 25 deletions(-)
--- /dev/null
+++ b/arch/x86/include/asm/trapnr.h
@@ -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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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:
*
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 02/23] x86/entry/64: Avoid pointless code when CONTEXT_TRACKING=n
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 01/23] x86/traps: Split trap numbers out in a seperate header Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 03/23] x86/entry/64: Reorder idtentries Thomas Gleixner
` (21 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre, Andy Lutomirski
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Acked-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/entry/entry_64.S | 2 ++
1 file changed, 2 insertions(+)
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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 */
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 03/23] x86/entry/64: Reorder idtentries
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 01/23] x86/traps: Split trap numbers out in a seperate header Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 02/23] x86/entry/64: Avoid pointless code when CONTEXT_TRACKING=n Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 04/23] x86/entry: Distangle idtentry Thomas Gleixner
` (20 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre, Andy Lutomirski
From: Thomas Gleixner <tglx@linutronix.de>
Move them all together so verifying the cleanup patches for binary
equivalence will be easier.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/entry/entry_64.S | 42 +++++++++++++++++++-----------------------
1 file changed, 19 insertions(+), 23 deletions(-)
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 04/23] x86/entry: Distangle idtentry
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (2 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 03/23] x86/entry/64: Reorder idtentries Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs Thomas Gleixner
` (19 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
---
arch/x86/entry/entry_64.S | 402 +++++++++++++++++++++++++---------------------
1 file changed, 220 insertions(+), 182 deletions(-)
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
/*
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (3 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 04/23] x86/entry: Distangle idtentry Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-09 5:08 ` Brian Gerst
2020-03-08 23:14 ` [patch part-III V2 06/23] x86/idtentry: Provide macros to define/declare IDT entry points Thomas Gleixner
` (18 subsequent siblings)
23 siblings, 1 reply; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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 <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
---
arch/x86/entry/entry_32.S | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 06/23] x86/idtentry: Provide macros to define/declare IDT entry points
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (4 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 07/23] x86/traps: Prepare for using DEFINE_IDTENTRY Thomas Gleixner
` (17 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
Provide 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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
*/
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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:
--- /dev/null
+++ b/arch/x86/include/asm/idtentry.h
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_IDTENTRY_H
+#define _ASM_X86_IDTENTRY_H
+
+/* Interrupts/Exceptions */
+#include <asm/trapnr.h>
+
+#ifndef __ASSEMBLY__
+
+/**
+ * idtentry_enter - Handle state tracking on idtentry
+ * @regs: Pointer to pt_regs of interrupted context
+ *
+ * Place holder for now.
+ */
+static __always_inline void idtentry_enter(struct pt_regs *regs)
+{
+}
+
+/**
+ * idtentry_exit - Prepare returning to low level ASM code
+ *
+ * Place holder for now.
+ */
+static __always_inline void idtentry_exit(struct pt_regs *regs)
+{
+}
+
+/**
+ * DECLARE_IDTENTRY - Declare functions for simple IDT entry points
+ * No 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
+ *
+ * Note: This is the C variant of DECLARE_IDTENTRY(). As the name says it
+ * declares the entry points for usage in C code. There is an ASM variant
+ * as well which is used to emit the entry stubs in entry_32/64.S.
+ */
+#define DECLARE_IDTENTRY(vector, func) \
+ asmlinkage void asm_##func(void); \
+ asmlinkage void xen_asm_##func(void); \
+ __visible void func(struct pt_regs *regs)
+
+/**
+ * DEFINE_IDTENTRY - Emit code for simple IDT entry points
+ * @func: Function name of the entry point
+ *
+ * @func is called from ASM entry code with interrupts disabled.
+ *
+ * The macro is written so it acts as function definition. Append the
+ * body with a pair of curly brackets.
+ *
+ * idtentry_enter() contains common code which has to be invoked before
+ * arbitrary code in the body. idtentry_exit() contains common code
+ * which has to run before returning to the low level assembly code.
+ */
+#define DEFINE_IDTENTRY(func) \
+static __always_inline void __##func(struct pt_regs *regs); \
+ \
+__visible notrace void func(struct pt_regs *regs) \
+{ \
+ idtentry_enter(regs); \
+ __##func (regs); \
+ idtentry_exit(regs); \
+} \
+NOKPROBE_SYMBOL(func); \
+ \
+static __always_inline void __##func(struct pt_regs *regs)
+
+#else /* !__ASSEMBLY__ */
+
+/*
+ * The ASM variants for DECLARE_IDTENTRY*() which emit the ASM entry stubs.
+ */
+#define DECLARE_IDTENTRY(vector, func) \
+ idtentry vector asm_##func func has_error_code=0
+
+#endif /* __ASSEMBLY__ */
+
+#endif
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 07/23] x86/traps: Prepare for using DEFINE_IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (5 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 06/23] x86/idtentry: Provide macros to define/declare IDT entry points Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 08/23] x86/entry: Convert Divide Error to IDTENTRY Thomas Gleixner
` (16 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
---
arch/x86/kernel/traps.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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) \
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 08/23] x86/entry: Convert Divide Error to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (6 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 07/23] x86/traps: Prepare for using DEFINE_IDTENTRY Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 09/23] x86/entry: Convert Overflow exception " Thomas Gleixner
` (15 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -279,6 +279,12 @@ static inline void __user *error_get_tra
return (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_r
do_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)
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 09/23] x86/entry: Convert Overflow exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (7 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 08/23] x86/entry: Convert Divide Error to IDTENTRY Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 10/23] x86/entry: Convert Bounds " Thomas Gleixner
` (14 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -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)
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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_r
do_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)
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -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
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 10/23] x86/entry: Convert Bounds exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (8 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 09/23] x86/entry: Convert Overflow exception " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 11/23] x86/entry: Convert Invalid Opcode " Thomas Gleixner
` (13 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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)
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -72,7 +72,7 @@ static const __initconst struct idt_data
static 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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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 {
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 11/23] x86/entry: Convert Invalid Opcode exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (9 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 10/23] x86/entry: Convert Bounds " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 12/23] x86/entry: Convert Device not available " Thomas Gleixner
` (12 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -95,5 +95,6 @@ static __always_inline void __##func(str
DECLARE_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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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(st
void __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)
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -73,7 +73,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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_r
do_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)
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -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;
}
}
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 12/23] x86/entry: Convert Device not available exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (10 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 11/23] x86/entry: Convert Invalid Opcode " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 13/23] x86/entry: Convert Coprocessor segment overrun " Thomas Gleixner
` (11 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -96,5 +96,6 @@ DECLARE_IDTENTRY(X86_TRAP_DE, exc_divid
DECLARE_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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -74,7 +74,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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)
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -623,7 +623,7 @@ static struct trap_array_entry trap_arra
TRAP_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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 13/23] x86/entry: Convert Coprocessor segment overrun exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (11 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 12/23] x86/entry: Convert Device not available " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 14/23] x86/entry: Provide IDTENTRY_ERRORCODE Thomas Gleixner
` (10 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -97,5 +97,6 @@ DECLARE_IDTENTRY(X86_TRAP_OF, exc_overf
DECLARE_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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -75,7 +75,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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_r
do_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)
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -624,7 +624,7 @@ static struct trap_array_entry trap_arra
TRAP_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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 14/23] x86/entry: Provide IDTENTRY_ERRORCODE
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (12 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 13/23] x86/entry: Convert Coprocessor segment overrun " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 15/23] x86/entry: Convert Invalid TSS exception to IDTENTRY Thomas Gleixner
` (9 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
Same as IDTENTRY but the C entry point has an error code argument.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/include/asm/idtentry.h | 45 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -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__ */
/*
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 15/23] x86/entry: Convert Invalid TSS exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (13 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 14/23] x86/entry: Provide IDTENTRY_ERRORCODE Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 16/23] x86/entry: Convert Segment not present " Thomas Gleixner
` (8 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -144,4 +144,7 @@ DECLARE_IDTENTRY(X86_TRAP_UD, exc_inval
DECLARE_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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -76,7 +76,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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_r
do_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)
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -625,7 +625,7 @@ static struct trap_array_entry trap_arra
TRAP_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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 16/23] x86/entry: Convert Segment not present exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (14 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 15/23] x86/entry: Convert Invalid TSS exception to IDTENTRY Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 17/23] x86/entry: Convert Stack segment " Thomas Gleixner
` (7 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -77,7 +77,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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_r
do_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
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -626,7 +626,7 @@ static struct trap_array_entry trap_arra
TRAP_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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 17/23] x86/entry: Convert Stack segment exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (15 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 16/23] x86/entry: Convert Segment not present " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 18/23] x86/entry: Convert General protection " Thomas Gleixner
` (6 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -78,7 +78,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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_r
do_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
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -627,7 +627,7 @@ static struct trap_array_entry trap_arra
TRAP_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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 18/23] x86/entry: Convert General protection exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (16 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 17/23] x86/entry: Convert Stack segment " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 19/23] x86/entry: Convert Spurious interrupt bug " Thomas Gleixner
` (5 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -148,5 +148,6 @@ DECLARE_IDTENTRY(X86_TRAP_OLD_MF, exc_co
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);
+DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_GP, exc_general_protection);
#endif
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -79,7 +79,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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_protection
die_addr(desc, regs, error_code, gp_addr);
}
-NOKPROBE_SYMBOL(do_general_protection);
dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
{
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -628,7 +628,7 @@ static struct trap_array_entry trap_arra
TRAP_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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 19/23] x86/entry: Convert Spurious interrupt bug exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (17 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 18/23] x86/entry: Convert General protection " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 20/23] x86/entry: Convert Coprocessor error " Thomas Gleixner
` (4 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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)
/*
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -143,6 +143,7 @@ DECLARE_IDTENTRY(X86_TRAP_BR, exc_bound
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);
+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);
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -80,7 +80,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -915,8 +915,7 @@ do_simd_coprocessor_error(struct pt_regs
math_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:
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -629,7 +629,7 @@ static struct trap_array_entry trap_arra
TRAP_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 },
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 20/23] x86/entry: Convert Coprocessor error exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (18 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 19/23] x86/entry: Convert Spurious interrupt bug " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 21/23] x86/entry: Convert Alignment check " Thomas Gleixner
` (3 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -144,6 +144,7 @@ DECLARE_IDTENTRY(X86_TRAP_UD, exc_inval
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);
+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);
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -81,7 +81,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -630,7 +630,7 @@ static struct trap_array_entry trap_arra
TRAP_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 },
};
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 21/23] x86/entry: Convert Alignment check exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (19 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 20/23] x86/entry: Convert Coprocessor error " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 22/23] x86/entry: Convert SIMD coprocessor error " Thomas Gleixner
` (2 subsequent siblings)
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -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
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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);
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -82,7 +82,7 @@ static const __initconst struct idt_data
INTG(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
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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,
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -631,7 +631,7 @@ static struct trap_array_entry trap_arra
TRAP_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 },
};
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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 */
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 22/23] x86/entry: Convert SIMD coprocessor error exception to IDTENTRY
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (20 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 21/23] x86/entry: Convert Alignment check " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 23/23] x86/entry/32: Convert IRET exception to IDTENTRY_SW Thomas Gleixner
2020-03-09 9:32 ` [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Jürgen Groß
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -145,6 +145,7 @@ DECLARE_IDTENTRY(X86_TRAP_NM, exc_devic
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);
+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);
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -83,7 +83,7 @@ static const __initconst struct idt_data
INTG(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),
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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 *r
cond_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 *r
fpu__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 *r
DEFINE_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)
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -632,7 +632,7 @@ static struct trap_array_entry trap_arra
TRAP_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)
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -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
^ permalink raw reply [flat|nested] 27+ messages in thread
* [patch part-III V2 23/23] x86/entry/32: Convert IRET exception to IDTENTRY_SW
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (21 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 22/23] x86/entry: Convert SIMD coprocessor error " Thomas Gleixner
@ 2020-03-08 23:14 ` Thomas Gleixner
2020-03-09 9:32 ` [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Jürgen Groß
23 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-08 23:14 UTC (permalink / raw)
To: LKML
Cc: x86, Steven Rostedt, Brian Gerst, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
From: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
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(-)
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -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
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -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);
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -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
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -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);
}
}
--- a/arch/x86/xen/xen-asm_32.S
+++ b/arch/x86/xen/xen-asm_32.S
@@ -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 */
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs
2020-03-08 23:14 ` [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs Thomas Gleixner
@ 2020-03-09 5:08 ` Brian Gerst
2020-03-09 7:01 ` Thomas Gleixner
0 siblings, 1 reply; 27+ messages in thread
From: Brian Gerst @ 2020-03-09 5:08 UTC (permalink / raw)
To: Thomas Gleixner
Cc: LKML, the arch/x86 maintainers, Steven Rostedt, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
On Sun, Mar 8, 2020 at 7:24 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> From: Thomas Gleixner <tglx@linutronix.de>
>
> 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 <tglx@linutronix.de>
> Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
>
> ---
> arch/x86/entry/entry_32.S | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 42 insertions(+)
>
> --- a/arch/x86/entry/entry_32.S
> +++ b/arch/x86/entry/entry_32.S
> @@ -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
IMHO 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)
{
#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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs
2020-03-09 5:08 ` Brian Gerst
@ 2020-03-09 7:01 ` Thomas Gleixner
0 siblings, 0 replies; 27+ messages in thread
From: Thomas Gleixner @ 2020-03-09 7:01 UTC (permalink / raw)
To: Brian Gerst
Cc: LKML, the arch/x86 maintainers, Steven Rostedt, Juergen Gross,
Frederic Weisbecker, Alexandre Chartre
Brian Gerst <brgerst@gmail.com> writes:
> On Sun, Mar 8, 2020 at 7:24 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>> +#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
>
> IMHO 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)
> {
> #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
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions)
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
` (22 preceding siblings ...)
2020-03-08 23:14 ` [patch part-III V2 23/23] x86/entry/32: Convert IRET exception to IDTENTRY_SW Thomas Gleixner
@ 2020-03-09 9:32 ` Jürgen Groß
23 siblings, 0 replies; 27+ messages in thread
From: Jürgen Groß @ 2020-03-09 9:32 UTC (permalink / raw)
To: Thomas Gleixner, LKML
Cc: x86, Steven Rostedt, Brian Gerst, Frederic Weisbecker, Alexandre Chartre
On 09.03.20 00:14, Thomas Gleixner wrote:
> 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/20200225221606.511535280@linutronix.de
>
> It applies on top of part II which is available here
>
> https://lore.kernel.org/r/20200308222359.370649591@linutronix.de
>
> 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
FWIW: tested to be bootable as Xen dom0 (at least when adding commit
bba42affa732d6fd5b).
Juergen
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2020-03-09 9:32 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-08 23:14 [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 01/23] x86/traps: Split trap numbers out in a seperate header Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 02/23] x86/entry/64: Avoid pointless code when CONTEXT_TRACKING=n Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 03/23] x86/entry/64: Reorder idtentries Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 04/23] x86/entry: Distangle idtentry Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 05/23] x86/entry/32: Provide macro to emit IDT entry stubs Thomas Gleixner
2020-03-09 5:08 ` Brian Gerst
2020-03-09 7:01 ` Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 06/23] x86/idtentry: Provide macros to define/declare IDT entry points Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 07/23] x86/traps: Prepare for using DEFINE_IDTENTRY Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 08/23] x86/entry: Convert Divide Error to IDTENTRY Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 09/23] x86/entry: Convert Overflow exception " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 10/23] x86/entry: Convert Bounds " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 11/23] x86/entry: Convert Invalid Opcode " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 12/23] x86/entry: Convert Device not available " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 13/23] x86/entry: Convert Coprocessor segment overrun " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 14/23] x86/entry: Provide IDTENTRY_ERRORCODE Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 15/23] x86/entry: Convert Invalid TSS exception to IDTENTRY Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 16/23] x86/entry: Convert Segment not present " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 17/23] x86/entry: Convert Stack segment " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 18/23] x86/entry: Convert General protection " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 19/23] x86/entry: Convert Spurious interrupt bug " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 20/23] x86/entry: Convert Coprocessor error " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 21/23] x86/entry: Convert Alignment check " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 22/23] x86/entry: Convert SIMD coprocessor error " Thomas Gleixner
2020-03-08 23:14 ` [patch part-III V2 23/23] x86/entry/32: Convert IRET exception to IDTENTRY_SW Thomas Gleixner
2020-03-09 9:32 ` [patch part-III V2 00/23] x86/entry: Consolidation - Part III (simple exceptions) Jürgen Groß
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).