Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754079AbdHZCZQ (ORCPT ); Fri, 25 Aug 2017 22:25:16 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:36650 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751411AbdHZCZP (ORCPT ); Fri, 25 Aug 2017 22:25:15 -0400 Subject: Re: [patch V2 35/44] x86/idt: Switch early trap init to IDT tables To: Thomas Gleixner , LKML References: <20170825214648.264521964@linutronix.de> <20170825214942.983480384@linutronix.de> Cc: Ingo Molnar , Peter Anvin , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Steven Rostedt , Juergen Gross From: Boris Ostrovsky Message-ID: <7e182f46-d27b-9414-fb6d-ee48906a4180@oracle.com> Date: Fri, 25 Aug 2017 22:24:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170825214942.983480384@linutronix.de> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1388 Lines: 44 On 08/25/2017 05:47 PM, Thomas Gleixner wrote: > > -/* 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); This breaks 64-bit Xen PV guests: idt_setup_early_handler() is called from x86_64_start_kernel(), which is not executed on those guests. The patch below fixes it. -boris diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 03fb07d..ed0fb8a 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -1374,6 +1374,7 @@ asmlinkage __visible void __init xen_start_kernel(void) i386_start_kernel(); #else cr4_init_shadow(); /* 32b kernel does this in i386_start_kernel() */ + load_idt(&idt_descr); x86_64_start_reservations((char *)__pa_symbol(&boot_params)); #endif }