Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-19 Thread Joerg Roedel
On Wed, Jan 17, 2018 at 10:12:32AM -0800, Andy Lutomirski wrote: > I would optimize for simplicity, not speed. You're already planning > to write to CR3, which is serializing, blows away the TLB, *and* takes > the absurdly large amount of time that the microcode needs to blow > away the TLB.

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-19 Thread Joerg Roedel
On Wed, Jan 17, 2018 at 10:12:32AM -0800, Andy Lutomirski wrote: > I would optimize for simplicity, not speed. You're already planning > to write to CR3, which is serializing, blows away the TLB, *and* takes > the absurdly large amount of time that the microcode needs to blow > away the TLB.

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Andy Lutomirski
On Wed, Jan 17, 2018 at 6:10 AM, Joerg Roedel wrote: > On Wed, Jan 17, 2018 at 05:57:53AM -0800, Brian Gerst wrote: >> On Wed, Jan 17, 2018 at 1:24 AM, Joerg Roedel wrote: > >> > I have no real idea on how to switch back to the entry stack without >> > access to

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Andy Lutomirski
On Wed, Jan 17, 2018 at 6:10 AM, Joerg Roedel wrote: > On Wed, Jan 17, 2018 at 05:57:53AM -0800, Brian Gerst wrote: >> On Wed, Jan 17, 2018 at 1:24 AM, Joerg Roedel wrote: > >> > I have no real idea on how to switch back to the entry stack without >> > access to per_cpu variables. I also can't

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Josh Poimboeuf
On Wed, Jan 17, 2018 at 03:14:18PM +0100, Joerg Roedel wrote: > On Wed, Jan 17, 2018 at 06:00:07AM -0800, Brian Gerst wrote: > > On Wed, Jan 17, 2018 at 5:57 AM, Brian Gerst wrote: > > But then again, you could take a fault on the trampoline stack if you > > get a bad segment.

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Josh Poimboeuf
On Wed, Jan 17, 2018 at 03:14:18PM +0100, Joerg Roedel wrote: > On Wed, Jan 17, 2018 at 06:00:07AM -0800, Brian Gerst wrote: > > On Wed, Jan 17, 2018 at 5:57 AM, Brian Gerst wrote: > > But then again, you could take a fault on the trampoline stack if you > > get a bad segment. Perhaps just

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Joerg Roedel
On Wed, Jan 17, 2018 at 06:00:07AM -0800, Brian Gerst wrote: > On Wed, Jan 17, 2018 at 5:57 AM, Brian Gerst wrote: > But then again, you could take a fault on the trampoline stack if you > get a bad segment. Perhaps just pushing the new stack pointer onto > the process stack

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Joerg Roedel
On Wed, Jan 17, 2018 at 06:00:07AM -0800, Brian Gerst wrote: > On Wed, Jan 17, 2018 at 5:57 AM, Brian Gerst wrote: > But then again, you could take a fault on the trampoline stack if you > get a bad segment. Perhaps just pushing the new stack pointer onto > the process stack before user segment

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Joerg Roedel
On Wed, Jan 17, 2018 at 05:57:53AM -0800, Brian Gerst wrote: > On Wed, Jan 17, 2018 at 1:24 AM, Joerg Roedel wrote: > > I have no real idea on how to switch back to the entry stack without > > access to per_cpu variables. I also can't access the cpu_entry_area for > > the cpu

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Joerg Roedel
On Wed, Jan 17, 2018 at 05:57:53AM -0800, Brian Gerst wrote: > On Wed, Jan 17, 2018 at 1:24 AM, Joerg Roedel wrote: > > I have no real idea on how to switch back to the entry stack without > > access to per_cpu variables. I also can't access the cpu_entry_area for > > the cpu yet, because for

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Brian Gerst
On Wed, Jan 17, 2018 at 5:57 AM, Brian Gerst wrote: > On Wed, Jan 17, 2018 at 1:24 AM, Joerg Roedel wrote: >> On Tue, Jan 16, 2018 at 02:48:43PM -0800, Andy Lutomirski wrote: >>> On Tue, Jan 16, 2018 at 8:36 AM, Joerg Roedel wrote: >>> > +

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Brian Gerst
On Wed, Jan 17, 2018 at 5:57 AM, Brian Gerst wrote: > On Wed, Jan 17, 2018 at 1:24 AM, Joerg Roedel wrote: >> On Tue, Jan 16, 2018 at 02:48:43PM -0800, Andy Lutomirski wrote: >>> On Tue, Jan 16, 2018 at 8:36 AM, Joerg Roedel wrote: >>> > + /* Restore user %edi and user %fs */ >>> > +

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Brian Gerst
On Wed, Jan 17, 2018 at 1:24 AM, Joerg Roedel wrote: > On Tue, Jan 16, 2018 at 02:48:43PM -0800, Andy Lutomirski wrote: >> On Tue, Jan 16, 2018 at 8:36 AM, Joerg Roedel wrote: >> > + /* Restore user %edi and user %fs */ >> > + movl (%edi), %edi >> >

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Brian Gerst
On Wed, Jan 17, 2018 at 1:24 AM, Joerg Roedel wrote: > On Tue, Jan 16, 2018 at 02:48:43PM -0800, Andy Lutomirski wrote: >> On Tue, Jan 16, 2018 at 8:36 AM, Joerg Roedel wrote: >> > + /* Restore user %edi and user %fs */ >> > + movl (%edi), %edi >> > + popl %fs >> >> Yikes!

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Joerg Roedel
On Tue, Jan 16, 2018 at 02:48:43PM -0800, Andy Lutomirski wrote: > On Tue, Jan 16, 2018 at 8:36 AM, Joerg Roedel wrote: > > + /* Restore user %edi and user %fs */ > > + movl (%edi), %edi > > + popl %fs > > Yikes! We're not *supposed* to be able to observe an

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-17 Thread Joerg Roedel
On Tue, Jan 16, 2018 at 02:48:43PM -0800, Andy Lutomirski wrote: > On Tue, Jan 16, 2018 at 8:36 AM, Joerg Roedel wrote: > > + /* Restore user %edi and user %fs */ > > + movl (%edi), %edi > > + popl %fs > > Yikes! We're not *supposed* to be able to observe an asynchronous >

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-16 Thread Andy Lutomirski
On Tue, Jan 16, 2018 at 8:36 AM, Joerg Roedel wrote: > From: Joerg Roedel > > Switch back to the trampoline stack before returning to > userspace. > > Signed-off-by: Joerg Roedel > --- > arch/x86/entry/entry_32.S| 58 >

Re: [PATCH 03/16] x86/entry/32: Leave the kernel via the trampoline stack

2018-01-16 Thread Andy Lutomirski
On Tue, Jan 16, 2018 at 8:36 AM, Joerg Roedel wrote: > From: Joerg Roedel > > Switch back to the trampoline stack before returning to > userspace. > > Signed-off-by: Joerg Roedel > --- > arch/x86/entry/entry_32.S| 58 > >