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-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-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 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",

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",

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

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

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

2018-08-30 Thread Tony Luck
The trick with flipping bit 63 to avoid loading the address of the 1:1 mapping of the poisoned page while we update the 1:1 map used to work when we wanted to unmap the page. But it falls down horribly when we try to directly set the page as uncacheable. The problem is that when we change the

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

2018-08-30 Thread Tony Luck
The trick with flipping bit 63 to avoid loading the address of the 1:1 mapping of the poisoned page while we update the 1:1 map used to work when we wanted to unmap the page. But it falls down horribly when we try to directly set the page as uncacheable. The problem is that when we change the