RE: [PATCH] x86/mce: Fix set_mce_nospec() to avoid #GP fault

2018-09-10 Thread David Laight
From: Linus Torvalds > ... > You could literally do something like > > /* Make it canonical in case we flipped the high bit */ > addr = (long)(addr<<1)>>1; Isn't it safer to use a mask and let the compiler decide if two shifts are a good implementation? addr &= ~HIGH_MAGIC_BIT;

Re: [PATCH] x86/mce: Fix set_mce_nospec() to avoid #GP fault

2018-08-31 Thread Thomas Gleixner
On Thu, 30 Aug 2018, Linus Torvalds wrote: > On Thu, Aug 30, 2018 at 6:49 PM Tony Luck wrote: > > > > Just checking "do we have a non-canonical address" at the bottom of that > > call stack and flipping bit 63 back on again seems like a bad idea. > > You could literally do something like > >

Re: [PATCH] x86/mce: Fix set_mce_nospec() to avoid #GP fault

2018-08-30 Thread Linus Torvalds
On Thu, Aug 30, 2018 at 6:49 PM Tony Luck wrote: > > Just checking "do we have a non-canonical address" at the bottom of that > call stack and flipping bit 63 back on again seems like a bad idea. You could literally do something like /* Make it canonical in case we flipped the high bit */

Re: [PATCH] x86/mce: Fix set_mce_nospec() to avoid #GP fault

2018-08-30 Thread Tony Luck
On Thu, Aug 30, 2018 at 6:30 PM Linus Torvalds wrote: > > On Thu, Aug 30, 2018 at 2:45 PM Tony Luck wrote: > > > > Fix is to move one step at a time. First mark the page not present > > (using the decoy address). Then it is safe to use the actual address > > of the 1:1 mapping to mark it "uc", an

Re: [PATCH] x86/mce: Fix set_mce_nospec() to avoid #GP fault

2018-08-30 Thread Linus Torvalds
On Thu, Aug 30, 2018 at 2:45 PM Tony Luck wrote: > > Fix is to move one step at a time. First mark the page not present > (using the decoy address). Then it is safe to use the actual address > of the 1:1 mapping to mark it "uc", and finally as present. Can't we do it in one step, but make sure th