From mboxrd@z Thu Jan 1 00:00:00 1970 From: Borislav Petkov Subject: Re: [PATCH v5 3/9] x86/head: Move early exception panic code into early_fixup_exception Date: Sat, 2 Apr 2016 20:39:19 +0200 Message-ID: <20160402183919.GA2538@pd.tnic> References: <4085070316fc3ab29538d3fcfe282648d1d4ee2e.1459605520.git.luto@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: X86 ML , Paolo Bonzini , Peter Zijlstra , KVM list , Arjan van de Ven , xen-devel , linux-kernel@vger.kernel.org, Linus Torvalds , Andrew Morton To: Andy Lutomirski Return-path: Received: from mail.skyhub.de ([78.46.96.112]:49812 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751219AbcDBSj0 (ORCPT ); Sat, 2 Apr 2016 14:39:26 -0400 Content-Disposition: inline In-Reply-To: <4085070316fc3ab29538d3fcfe282648d1d4ee2e.1459605520.git.luto@kernel.org> Sender: kvm-owner@vger.kernel.org List-ID: On Sat, Apr 02, 2016 at 07:01:34AM -0700, Andy Lutomirski wrote: > This removes a bunch of assembly and adds some C code instead. It > changes the actual printouts on both 32-bit and 64-bit kernels, but > they still seem okay. > > Signed-off-by: Andy Lutomirski > --- > arch/x86/include/asm/uaccess.h | 2 +- > arch/x86/kernel/head_32.S | 49 +++++------------------------------------- > arch/x86/kernel/head_64.S | 45 ++------------------------------------ > arch/x86/mm/extable.c | 29 ++++++++++++++++++++----- > 4 files changed, 32 insertions(+), 93 deletions(-) ... > @@ -99,21 +101,38 @@ int __init early_fixup_exception(struct pt_regs *regs, int trapnr) > > /* Ignore early NMIs. */ > if (trapnr == X86_TRAP_NMI) > - return 1; > + return; > + > + if (early_recursion_flag > 2) > + goto halt_loop; > + > + if (regs->cs != __KERNEL_CS) > + goto fail; > > e = search_exception_tables(regs->ip); > if (!e) > - return 0; > + goto fail; > > new_ip = ex_fixup_addr(e); > handler = ex_fixup_handler(e); > > /* special handling not supported during early boot */ > if (handler != ex_handler_default) > - return 0; > + goto fail; > > regs->ip = new_ip; > - return 1; > + return; > + > +fail: > + early_printk("PANIC: early exception 0x%02x IP %lx:%lx error %lx cr2 0x%lx\n", > + (unsigned)trapnr, (unsigned long)regs->cs, regs->ip, > + regs->orig_ax, read_cr2()); > + > + show_regs(regs); To make this even better, it could be something called early_show_regs() or so and be a simplified version of __show_regs() on both bitness but which calls early_printk(). This way you'll be able to get out stuff to the console as early as possible. Btw, you don't need to dump rIP, CR2, etc in the PANIC message above since you're going to early_show_regs() anyway. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.