[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrUJVDpzNQMsY=_jWNOMer+TdW2p4wES4OBCfYU7gq3fbg@mail.gmail.com>
Date: Sat, 2 Apr 2016 13:13:37 -0700
From: Andy Lutomirski <luto@...capital.net>
To: Borislav Petkov <bp@...en8.de>
Cc: Andy Lutomirski <luto@...nel.org>, X86 ML <x86@...nel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
KVM list <kvm@...r.kernel.org>,
Arjan van de Ven <arjan@...ux.intel.com>,
xen-devel <Xen-devel@...ts.xen.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v5 3/9] x86/head: Move early exception panic code into early_fixup_exception
On Sat, Apr 2, 2016 at 11:39 AM, Borislav Petkov <bp@...en8.de> wrote:
> 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 <luto@...nel.org>
>> ---
>> 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.
Given that I this isn't really a regression with my patches (it
probably never worked much better on 32-bit and the regs never would
have shown at all on 64-bit), I propose a different approach: make
printk work earlier. Something like:
if (early) {
early_printk(args);
}
or early_vprintk or whatever.
If the cost of a branch mattered, this could be alternative-patched
out later on, but that seems silly. I also bet that a more sensible
fallback could be created in which printk would try to use an early
console if there's no real console.
--Andy
Powered by blists - more mailing lists