linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tony Luck <tony.luck@gmail.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Lutomirski <luto@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>, Robert <elliott@hpe.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	linux-nvdimm <linux-nvdimm@ml01.01.org>, X86-ML <x86@kernel.org>
Subject: Re: [PATCH v6 1/4] x86: Clean up extable entry format (and free up a bit)
Date: Mon, 4 Jan 2016 09:26:53 -0800	[thread overview]
Message-ID: <CA+8MBbKZ6VfN9t5-dYNHhZVU0k2HEr+E7Un0y2gtsxE0sDgoHQ@mail.gmail.com> (raw)
In-Reply-To: <20160104120751.GG22941@pd.tnic>

On Mon, Jan 4, 2016 at 4:07 AM, Borislav Petkov <bp@alien8.de> wrote:
>> + * (target - here) + (class) + 0x20000000
>
> I still don't understand that bit 29 thing.
>
> Because the offset is negative?

I think so.  The .fixup section is placed in the end of .text, and the ex_table
itself is pretty much right after.  So all the "fixup" offsets will be
small negative
numbers (the "insn" ones are also negative, but will be bigger since they
potentially need to reach all the way to the start of .text).

Adding 0x20000000 makes everything positive (so our legacy exception
table entries have bit31==bit30==0) and perhaps makes it fractionally clearer
how we manipulate the top bits for the other classes ... but only
slightly. I got
very confused by it too).

It is all made more complex because these values need to be something
that "ld" can relocate when vmlinux is put together from all the ".o" files.
So we can't just use "x | BIT(30)" etc.


>> +#define _EXTABLE_CLASS_EX    0x80000000      /* uaccess + set uaccess_err */
>
>                                 BIT(31) is more readable.

Not to the assembler :-(

> Why not simply:
>
>         .long (to) - . + (bias) ;
>
> and
>
>         " .long (" #to ") - . + "(" #bias ") "\n"
>
> below and get rid of that _EXPAND_EXTABLE_BIAS()?

Andy - this part is your code and I'm not sure what the trick is here.

>>  ex_fixup_addr(const struct exception_table_entry *x)
>>  {
>> -     return (unsigned long)&x->fixup + x->fixup;
>> +     long offset = (long)((u32)x->fixup & 0x3fffffff) - (long)0x20000000;
>
> So basically:
>
>         x->fixup & 0x1fffffff
>
> Why the explicit subtraction of bit 29?

We added it to begin with ... need to subtract to get back to the
original offset.

> IOW, I was expecting something simpler for the whole scheme like:
>
> ex_class:
>
>         return x->fixup & 0xC0000000;

ex_class (after part2) is just "(u32)x->fixup >> 30" (because I wanted
a result in [0..3])

> ex_fixup_addr:
>
>         return x->fixup | 0xC0000000;
>
> Why can't it be done this way?

Because relocations ... the linker can only add/subtract values when
making vmlinux ... it can't OR bits in.

-Tony

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2016-01-04 17:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04  1:02 [PATCH v6 0/4] Machine check recovery when kernel accesses poison Tony Luck
2015-12-30 17:59 ` [PATCH v6 1/4] x86: Clean up extable entry format (and free up a bit) Andy Lutomirski
2016-01-04  1:37   ` Tony Luck
2016-01-04  7:49     ` Ingo Molnar
2016-01-04 12:07   ` Borislav Petkov
2016-01-04 17:26     ` Tony Luck [this message]
2016-01-04 18:08       ` Andy Lutomirski
2016-01-04 18:59         ` Tony Luck
2016-01-04 19:05           ` Andy Lutomirski
2016-01-04 21:02         ` Borislav Petkov
2016-01-04 22:29           ` Andy Lutomirski
2016-01-04 23:02             ` Borislav Petkov
2016-01-04 23:04               ` Borislav Petkov
2016-01-04 23:25               ` Andy Lutomirski
2016-01-05 11:20                 ` Borislav Petkov
2016-01-04 23:11         ` Tony Luck
2015-12-30 18:56 ` [PATCH v6 2/4] x86: Cleanup and add a new exception class Tony Luck
2016-01-04 14:22   ` Borislav Petkov
2016-01-04 17:00     ` Luck, Tony
2016-01-04 20:32       ` Borislav Petkov
2016-01-04 22:23         ` Andy Lutomirski
2015-12-31 19:40 ` [PATCH v6 3/4] x86, mce: Check for faults tagged in EXTABLE_CLASS_FAULT exception table entries Tony Luck
2015-12-31 19:43 ` [PATCH v6 4/4] x86, mce: Add __mcsafe_copy() Tony Luck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+8MBbKZ6VfN9t5-dYNHhZVU0k2HEr+E7Un0y2gtsxE0sDgoHQ@mail.gmail.com \
    --to=tony.luck@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=elliott@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@ml01.01.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox