From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753215AbdH2LXw (ORCPT ); Tue, 29 Aug 2017 07:23:52 -0400 Received: from terminus.zytor.com ([65.50.211.136]:42337 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752899AbdH2LXs (ORCPT ); Tue, 29 Aug 2017 07:23:48 -0400 Date: Tue, 29 Aug 2017 04:18:02 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: peterz@infradead.org, tglx@linutronix.de, dvlasenk@redhat.com, luto@kernel.org, hpa@zytor.com, mingo@kernel.org, bp@alien8.de, rostedt@goodmis.org, brgerst@gmail.com, jpoimboe@redhat.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org Reply-To: jpoimboe@redhat.com, brgerst@gmail.com, rostedt@goodmis.org, bp@alien8.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, luto@kernel.org, dvlasenk@redhat.com, tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org, hpa@zytor.com In-Reply-To: <20170828064958.929139008@linutronix.de> References: <20170828064958.929139008@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/apic] x86/idt: Switch early trap init to IDT tables Git-Commit-ID: 433f8924fa8e55a50ce57f3b8a33ed095c405644 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 433f8924fa8e55a50ce57f3b8a33ed095c405644 Gitweb: http://git.kernel.org/tip/433f8924fa8e55a50ce57f3b8a33ed095c405644 Author: Thomas Gleixner AuthorDate: Mon, 28 Aug 2017 08:47:50 +0200 Committer: Ingo Molnar CommitDate: Tue, 29 Aug 2017 12:07:27 +0200 x86/idt: Switch early trap init to IDT tables Add the initialization table for the early trap setup and replace the early trap init code. Signed-off-by: Thomas Gleixner Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Steven Rostedt Link: http://lkml.kernel.org/r/20170828064958.929139008@linutronix.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/idt.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/setup.c | 4 ++-- arch/x86/kernel/traps.c | 27 ------------------------- 3 files changed, 55 insertions(+), 29 deletions(-) diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index ae6fc12..64e2211 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -48,6 +48,28 @@ struct idt_data { #define TSKG(_vector, _gdt) \ G(_vector, NULL, DEFAULT_STACK, GATE_TASK, DPL0, _gdt << 3) +/* + * Early traps running on the DEFAULT_STACK because the other interrupt + * stacks work only after cpu_init(). + */ +static const __initdata struct idt_data early_idts[] = { + INTG(X86_TRAP_DB, debug), + SYSG(X86_TRAP_BP, int3), +#ifdef CONFIG_X86_32 + INTG(X86_TRAP_PF, page_fault), +#endif +}; + +#ifdef CONFIG_X86_64 +/* + * Early traps running on the DEFAULT_STACK because the other interrupt + * stacks work only after cpu_init(). + */ +static const __initdata struct idt_data early_pf_idts[] = { + INTG(X86_TRAP_PF, page_fault), +}; +#endif + /* Must be page-aligned because the real IDT is used in a fixmap. */ gate_desc idt_table[IDT_ENTRIES] __page_aligned_bss; @@ -93,6 +115,37 @@ idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size) } /** + * idt_setup_early_traps - Initialize the idt table with early traps + * + * On X8664 these traps do not use interrupt stacks as they can't work + * before cpu_init() is invoked and sets up TSS. The IST variants are + * installed after that. + */ +void __init idt_setup_early_traps(void) +{ + idt_setup_from_table(idt_table, early_idts, ARRAY_SIZE(early_idts)); + load_idt(&idt_descr); +} + +#ifdef CONFIG_X86_64 +/** + * idt_setup_early_pf - Initialize the idt table with early pagefault handler + * + * On X8664 this does not use interrupt stacks as they can't work before + * cpu_init() is invoked and sets up TSS. The IST variant is installed + * after that. + * + * FIXME: Why is 32bit and 64bit installing the PF handler at different + * places in the early setup code? + */ +void __init idt_setup_early_pf(void) +{ + idt_setup_from_table(idt_table, early_pf_idts, + ARRAY_SIZE(early_pf_idts)); +} +#endif + +/** * idt_setup_early_handler - Initializes the idt table with early handlers */ void __init idt_setup_early_handler(void) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index ecab322..30dc84e 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -891,7 +891,7 @@ void __init setup_arch(char **cmdline_p) */ olpc_ofw_detect(); - early_trap_init(); + idt_setup_early_traps(); early_cpu_init(); early_ioremap_init(); @@ -1162,7 +1162,7 @@ void __init setup_arch(char **cmdline_p) init_mem_mapping(); - early_trap_pf_init(); + idt_setup_early_pf(); /* * Update mmu_cr4_features (and, indirectly, trampoline_cr4_features) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 41f4cd3..835c7e8 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -923,33 +923,6 @@ dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code) } #endif -/* Set of traps needed for early debugging. */ -void __init early_trap_init(void) -{ - /* - * Don't use IST to set DEBUG_STACK as it doesn't work until TSS - * is ready in cpu_init() <-- trap_init(). Before trap_init(), - * CPU runs at ring 0 so it is impossible to hit an invalid - * stack. Using the original stack works well enough at this - * early stage. DEBUG_STACK will be equipped after cpu_init() in - * trap_init(). - */ - set_intr_gate(X86_TRAP_DB, debug); - /* int3 can be called from all */ - set_system_intr_gate(X86_TRAP_BP, &int3); -#ifdef CONFIG_X86_32 - set_intr_gate(X86_TRAP_PF, page_fault); -#endif - load_idt(&idt_descr); -} - -void __init early_trap_pf_init(void) -{ -#ifdef CONFIG_X86_64 - set_intr_gate(X86_TRAP_PF, page_fault); -#endif -} - void __init trap_init(void) { int i;