x86/idt: Move early IDT setup out of 32-bit asm

The early IDT setup can be done in C code like it's done on 64-bit kernels.
Reuse the 64-bit version.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20170828064958.757980775@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Thomas Gleixner 2017-08-28 08:47:48 +02:00 committed by Ingo Molnar
parent 588787fde7
commit 87e81786b1
4 changed files with 11 additions and 34 deletions

View File

@ -238,6 +238,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
extern const char early_idt_handler_array[NUM_EXCEPTION_VECTORS][EARLY_IDT_HANDLER_SIZE]; extern const char early_idt_handler_array[NUM_EXCEPTION_VECTORS][EARLY_IDT_HANDLER_SIZE];
extern void early_ignore_irq(void);
/* /*
* Load a segment. Fall back on loading the zero segment if something goes * Load a segment. Fall back on loading the zero segment if something goes

View File

@ -10,6 +10,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/memblock.h> #include <linux/memblock.h>
#include <asm/desc.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/e820/api.h> #include <asm/e820/api.h>
@ -30,6 +31,9 @@ static void __init i386_default_early_setup(void)
asmlinkage __visible void __init i386_start_kernel(void) asmlinkage __visible void __init i386_start_kernel(void)
{ {
cr4_init_shadow(); cr4_init_shadow();
idt_setup_early_handler();
sanitize_boot_params(&boot_params); sanitize_boot_params(&boot_params);
x86_early_init_platform_quirks(); x86_early_init_platform_quirks();

View File

@ -345,7 +345,6 @@ ENTRY(startup_32_smp)
movl %eax,%cr0 movl %eax,%cr0
lgdt early_gdt_descr lgdt early_gdt_descr
lidt idt_descr
ljmp $(__KERNEL_CS),$1f ljmp $(__KERNEL_CS),$1f
1: movl $(__KERNEL_DS),%eax # reload all the segment registers 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
movl %eax,%ss # after changing gdt. movl %eax,%ss # after changing gdt.
@ -378,37 +377,6 @@ ENDPROC(startup_32_smp)
*/ */
__INIT __INIT
setup_once: setup_once:
/*
* Set up a idt with 256 interrupt gates that push zero if there
* is no error code and then jump to early_idt_handler_common.
* It doesn't actually load the idt - that needs to be done on
* each CPU. Interrupts are enabled elsewhere, when we can be
* relatively sure everything is ok.
*/
movl $idt_table,%edi
movl $early_idt_handler_array,%eax
movl $NUM_EXCEPTION_VECTORS,%ecx
1:
movl %eax,(%edi)
movl %eax,4(%edi)
/* interrupt gate, dpl=0, present */
movl $(0x8E000000 + __KERNEL_CS),2(%edi)
addl $EARLY_IDT_HANDLER_SIZE,%eax
addl $8,%edi
loop 1b
movl $256 - NUM_EXCEPTION_VECTORS,%ecx
movl $ignore_int,%edx
movl $(__KERNEL_CS << 16),%eax
movw %dx,%ax /* selector = 0x0010 = cs */
movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
2:
movl %eax,(%edi)
movl %edx,4(%edi)
addl $8,%edi
loop 2b
#ifdef CONFIG_CC_STACKPROTECTOR #ifdef CONFIG_CC_STACKPROTECTOR
/* /*
* Configure the stack canary. The linker can't handle this by * Configure the stack canary. The linker can't handle this by
@ -498,7 +466,7 @@ ENDPROC(early_idt_handler_common)
/* This is the default interrupt "handler" :-) */ /* This is the default interrupt "handler" :-) */
ALIGN ALIGN
ignore_int: ENTRY(early_ignore_irq)
cld cld
#ifdef CONFIG_PRINTK #ifdef CONFIG_PRINTK
pushl %eax pushl %eax
@ -533,7 +501,7 @@ ignore_int:
hlt_loop: hlt_loop:
hlt hlt
jmp hlt_loop jmp hlt_loop
ENDPROC(ignore_int) ENDPROC(early_ignore_irq)
__INITDATA __INITDATA
.align 4 .align 4
GLOBAL(early_recursion_flag) GLOBAL(early_recursion_flag)

View File

@ -34,6 +34,10 @@ void __init idt_setup_early_handler(void)
for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
set_intr_gate(i, early_idt_handler_array[i]); set_intr_gate(i, early_idt_handler_array[i]);
#ifdef CONFIG_X86_32
for ( ; i < NR_VECTORS; i++)
set_intr_gate(i, early_ignore_irq);
#endif
load_idt(&idt_descr); load_idt(&idt_descr);
} }