From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753035AbcAGSWs (ORCPT ); Thu, 7 Jan 2016 13:22:48 -0500 Received: from mga14.intel.com ([192.55.52.115]:33829 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751220AbcAGSWr (ORCPT ); Thu, 7 Jan 2016 13:22:47 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,533,1444719600"; d="scan'208";a="876633693" Date: Thu, 7 Jan 2016 10:22:46 -0800 From: "Luck, Tony" To: Borislav Petkov Cc: Andy Lutomirski , Ingo Molnar , Andrew Morton , Andy Lutomirski , Dan Williams , Robert , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , linux-nvdimm , X86 ML Subject: Re: [PATCH v7 1/3] x86: Add classes to exception tables Message-ID: <20160107182246.GA21892@agluck-desk.sc.intel.com> References: <20160106123346.GC19507@pd.tnic> <20160106175948.GA16647@pd.tnic> <20160106194222.GC16647@pd.tnic> <20160107121131.GB23768@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160107121131.GB23768@pd.tnic> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 07, 2016 at 01:11:31PM +0100, Borislav Petkov wrote: > #ifdef __ASSEMBLY__ > # define _ASM_EXTABLE(from,to) \ > .pushsection "__ex_table","a" ; \ > - .balign 8 ; \ > + .balign 4 ; \ > .long (from) - . ; \ > .long (to) - . ; \ > + .long 0; \ Why not .long ex_handler_default - . ; Then you wouldn't have to special case the zero in the lookup (and in the sort, which you don't do now, but should) > @@ -33,42 +67,36 @@ int fixup_exception(struct pt_regs *regs) > } > #endif > > - fixup = search_exception_tables(regs->ip); > - if (fixup) { > - new_ip = ex_fixup_addr(fixup); > - > - if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) { > - /* Special hack for uaccess_err */ > - current_thread_info()->uaccess_err = 1; > - new_ip -= 0x7ffffff0; > - } > - regs->ip = new_ip; > - return 1; > - } > + e = search_exception_tables(regs->ip); > + if (!e) > + return 0; > > - return 0; > + new_ip = ex_fixup_addr(e); Assigned, but not used - delete the declaration above too. > +static void x86_sort_relative_table(char *extab_image, int image_size) > +{ > + int i; > + > + i = 0; > + while (i < image_size) { > + uint32_t *loc = (uint32_t *)(extab_image + i); > + > + w(r(loc) + i, loc); > + w(r(loc + 1) + i + 4, loc + 1); Need to twiddle the 'handler' field too (unless it is 0). If you give up on the magic zero and fill in the offset to ex_handler_default then I *think* you need: w(r(loc + 2) + i + 8, loc + 2); the special case *might* be: if (r(loc + 2)) w(r(loc + 2) + i + 8, loc + 2); > + > + i += sizeof(uint32_t) * 3; > + } > + > + qsort(extab_image, image_size / 12, 12, compare_relative_table); > + > + i = 0; > + while (i < image_size) { > + uint32_t *loc = (uint32_t *)(extab_image + i); > + > + w(r(loc) - i, loc); > + w(r(loc + 1) - (i + 4), loc + 1); ditto, untwiddle the handler (unless it was zero) w(r(loc + 2) - (i + 8), loc + 2); There is also arch/x86/mm/extable.c:sort_extable() which will be used on the main kernel exception table if for some reason the build skipped using scripts/sortextable ... and is always used for exception tables in modules. It also needs to know about the new field (and would be another place to special case the zero fields for the default handler). -Tony