From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbcAFRyl (ORCPT ); Wed, 6 Jan 2016 12:54:41 -0500 Received: from mail-ob0-f179.google.com ([209.85.214.179]:35088 "EHLO mail-ob0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751595AbcAFRyj (ORCPT ); Wed, 6 Jan 2016 12:54:39 -0500 MIME-Version: 1.0 In-Reply-To: <20160106123346.GC19507@pd.tnic> References: <20160106123346.GC19507@pd.tnic> From: Andy Lutomirski Date: Wed, 6 Jan 2016 09:54:19 -0800 Message-ID: Subject: Re: [PATCH v7 1/3] x86: Add classes to exception tables To: Borislav Petkov Cc: Tony Luck , Ingo Molnar , Andrew Morton , Andy Lutomirski , Dan Williams , Robert , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , linux-nvdimm , X86 ML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 6, 2016 at 4:33 AM, Borislav Petkov wrote: > On Wed, Dec 30, 2015 at 09:59:29AM -0800, Tony Luck wrote: >> Starting with a patch from Andy Lutomirski >> that used linker relocation trickery to free up a couple of bits >> in the "fixup" field of the exception table (and generalized the >> uaccess_err hack to use one of the classes). > > So I still think that the other idea Andy gave with putting the handler > in the exception table is much cleaner and straightforward. > > Here's a totally untested patch which at least builds here. I think this > approach is much more extensible and simpler for the price of a couple > of KBs of __ex_table size. > > --- > diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h > index 189679aba703..43b509c88b13 100644 > --- a/arch/x86/include/asm/asm.h > +++ b/arch/x86/include/asm/asm.h > @@ -44,18 +44,20 @@ > > /* Exception table entry */ > #ifdef __ASSEMBLY__ > -# define _ASM_EXTABLE(from,to) \ > +# define _ASM_EXTABLE(from,to) \ > .pushsection "__ex_table","a" ; \ > .balign 8 ; \ > .long (from) - . ; \ > .long (to) - . ; \ > + .long 0 - .; \ I assume that this zero is to save the couple of bytes for the relocation entry on relocatable kernels? If so, ... > +inline ex_handler_t ex_fixup_handler(const struct exception_table_entry *x) > +{ > + return (ex_handler_t)&x->handler + x->handler; I would check for zero here, because... > + new_ip = ex_fixup_addr(e); > + handler = ex_fixup_handler(e); > + > + if (!handler) > + handler = ex_handler_default; the !handler condition here will never trigger because the offset was already applied. Otherwise this looks generally sane. --Andy