Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1303782

Re: [PATCH v7 1/3] x86: Add classes to exception tables

From "Luck, Tony" <tony.luck@intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v7 1/3] x86: Add classes to exception tables
Date 2016-01-07 19:30 +0100
Message-ID <qOntU-3ug-5@gated-at.bofh.it> (permalink)
References (3 earlier) <qO0xl-4lZ-7@gated-at.bofh.it> <qO0GZ-4Es-1@gated-at.bofh.it> <qO0H2-4Es-33@gated-at.bofh.it> <qO2fL-5vA-1@gated-at.bofh.it> <qOhHQ-7YB-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v7 1/3] x86: Add classes to exception tables Tony Luck <tony.luck@intel.com> - 2016-01-05 01:20 +0100
  Re: [PATCH v7 1/3] x86: Add classes to exception tables Borislav Petkov <bp@alien8.de> - 2016-01-06 13:40 +0100
    Re: [PATCH v7 1/3] x86: Add classes to exception tables "Luck, Tony" <tony.luck@intel.com> - 2016-01-06 18:40 +0100
      Re: [PATCH v7 1/3] x86: Add classes to exception tables Linus Torvalds <torvalds@linux-foundation.org> - 2016-01-06 18:50 +0100
    Re: [PATCH v7 1/3] x86: Add classes to exception tables Andy Lutomirski <luto@amacapital.net> - 2016-01-06 19:00 +0100
      Re: [PATCH v7 1/3] x86: Add classes to exception tables Borislav Petkov <bp@alien8.de> - 2016-01-06 19:10 +0100
        Re: [PATCH v7 1/3] x86: Add classes to exception tables Andy Lutomirski <luto@amacapital.net> - 2016-01-06 19:10 +0100
          Re: [PATCH v7 1/3] x86: Add classes to exception tables Borislav Petkov <bp@alien8.de> - 2016-01-06 20:50 +0100
            Re: [PATCH v7 1/3] x86: Add classes to exception tables Borislav Petkov <bp@alien8.de> - 2016-01-07 13:20 +0100
              Re: [PATCH v7 1/3] x86: Add classes to exception tables "Luck, Tony" <tony.luck@intel.com> - 2016-01-07 19:30 +0100
              Re: [PATCH v7 1/3] x86: Add classes to exception tables "Luck, Tony" <tony.luck@intel.com> - 2016-01-08 02:50 +0100
                Re: [PATCH v7 1/3] x86: Add classes to exception tables Borislav Petkov <bp@alien8.de> - 2016-01-08 11:40 +0100
                RE: [PATCH v7 1/3] x86: Add classes to exception tables "Luck, Tony" <tony.luck@intel.com> - 2016-01-08 17:30 +0100
                Re: [PATCH v7 1/3] x86: Add classes to exception tables Borislav Petkov <bp@alien8.de> - 2016-01-08 18:30 +0100
                Re: [PATCH v7 1/3] x86: Add classes to exception tables Brian Gerst <brgerst@gmail.com> - 2016-01-08 23:30 +0100
              Re: [PATCH v7 1/3] x86: Add classes to exception tables "Luck, Tony" <tony.luck@intel.com> - 2016-01-08 06:40 +0100
                Re: [PATCH v7 1/3] x86: Add classes to exception tables Borislav Petkov <bp@alien8.de> - 2016-01-08 11:50 +0100
  Re: [PATCH v7 1/3] x86: Add classes to exception tables Borislav Petkov <bp@alien8.de> - 2016-01-06 13:40 +0100

csiph-web