Re: RFC: userspace exception fixups

2018-11-26 Thread Jarkko Sakkinen
On Mon, Nov 26, 2018 at 06:35:34AM -0800, Sean Christopherson wrote: > And how would you determine the #UD is related to SGX? Hardware doesn't > provide any indication that a #UD (or any other fault) is related to SGX > or occurred in an enclave. The only fault that is special-cased in a >

Re: RFC: userspace exception fixups

2018-11-26 Thread Jarkko Sakkinen
On Mon, Nov 26, 2018 at 06:35:34AM -0800, Sean Christopherson wrote: > And how would you determine the #UD is related to SGX? Hardware doesn't > provide any indication that a #UD (or any other fault) is related to SGX > or occurred in an enclave. The only fault that is special-cased in a >

Re: RFC: userspace exception fixups

2018-11-26 Thread Sean Christopherson
On Wed, Nov 21, 2018 at 05:17:34PM +0200, Jarkko Sakkinen wrote: > On Wed, Nov 21, 2018 at 05:17:32AM +, Jethro Beekman wrote: > > Jarkko, can you please explain you solution in detail? The CPU receives an > > exception. This will be handled by the kernel exception handler. What > >

Re: RFC: userspace exception fixups

2018-11-26 Thread Sean Christopherson
On Wed, Nov 21, 2018 at 05:17:34PM +0200, Jarkko Sakkinen wrote: > On Wed, Nov 21, 2018 at 05:17:32AM +, Jethro Beekman wrote: > > Jarkko, can you please explain you solution in detail? The CPU receives an > > exception. This will be handled by the kernel exception handler. What > >

Re: RFC: userspace exception fixups

2018-11-24 Thread Jarkko Sakkinen
On Wed, Nov 21, 2018 at 05:17:34PM +0200, Jarkko Sakkinen wrote: > On Wed, Nov 21, 2018 at 05:17:32AM +, Jethro Beekman wrote: > > Jarkko, can you please explain you solution in detail? The CPU receives an > > exception. This will be handled by the kernel exception handler. What > >

Re: RFC: userspace exception fixups

2018-11-24 Thread Jarkko Sakkinen
On Wed, Nov 21, 2018 at 05:17:34PM +0200, Jarkko Sakkinen wrote: > On Wed, Nov 21, 2018 at 05:17:32AM +, Jethro Beekman wrote: > > Jarkko, can you please explain you solution in detail? The CPU receives an > > exception. This will be handled by the kernel exception handler. What > >

Re: RFC: userspace exception fixups

2018-11-21 Thread Jarkko Sakkinen
On Wed, Nov 21, 2018 at 05:17:32AM +, Jethro Beekman wrote: > Jarkko, can you please explain you solution in detail? The CPU receives an > exception. This will be handled by the kernel exception handler. What > information does the kernel exception handler use to determine whether to > deliver

Re: RFC: userspace exception fixups

2018-11-21 Thread Jarkko Sakkinen
On Wed, Nov 21, 2018 at 05:17:32AM +, Jethro Beekman wrote: > Jarkko, can you please explain you solution in detail? The CPU receives an > exception. This will be handled by the kernel exception handler. What > information does the kernel exception handler use to determine whether to > deliver

Re: RFC: userspace exception fixups

2018-11-20 Thread Jethro Beekman
On 2018-11-21 04:25, Jarkko Sakkinen wrote: On Tue, Nov 20, 2018 at 07:19:37AM -0800, Andy Lutomirski wrote: general by mucking with some regs and retrying -- that will infinite loop and confuse everyone. I'm not even 100% convinced that decoding the insn stream is useful -- AEP can point to

Re: RFC: userspace exception fixups

2018-11-20 Thread Jethro Beekman
On 2018-11-21 04:25, Jarkko Sakkinen wrote: On Tue, Nov 20, 2018 at 07:19:37AM -0800, Andy Lutomirski wrote: general by mucking with some regs and retrying -- that will infinite loop and confuse everyone. I'm not even 100% convinced that decoding the insn stream is useful -- AEP can point to

Re: RFC: userspace exception fixups

2018-11-20 Thread Jarkko Sakkinen
On Tue, Nov 20, 2018 at 07:19:37AM -0800, Andy Lutomirski wrote: > What is "#GP with EPCM"? We certainly don't want to react to #UD in A typo. Meant #PF with PF_SGX set i.e. EPCM conflict. > general by mucking with some regs and retrying -- that will infinite > loop and confuse everyone. I'm

Re: RFC: userspace exception fixups

2018-11-20 Thread Jarkko Sakkinen
On Tue, Nov 20, 2018 at 07:19:37AM -0800, Andy Lutomirski wrote: > What is "#GP with EPCM"? We certainly don't want to react to #UD in A typo. Meant #PF with PF_SGX set i.e. EPCM conflict. > general by mucking with some regs and retrying -- that will infinite > loop and confuse everyone. I'm

Re: RFC: userspace exception fixups

2018-11-20 Thread Jarkko Sakkinen
On Tue, Nov 20, 2018 at 12:11:33PM +0200, Jarkko Sakkinen wrote: > On Mon, Nov 19, 2018 at 09:00:08AM -0800, Andy Lutomirski wrote: > > On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen > > wrote: > > > > > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > > > 1. The kernel

Re: RFC: userspace exception fixups

2018-11-20 Thread Jarkko Sakkinen
On Tue, Nov 20, 2018 at 12:11:33PM +0200, Jarkko Sakkinen wrote: > On Mon, Nov 19, 2018 at 09:00:08AM -0800, Andy Lutomirski wrote: > > On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen > > wrote: > > > > > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > > > 1. The kernel

Re: RFC: userspace exception fixups

2018-11-20 Thread Sean Christopherson
On Tue, Nov 20, 2018 at 12:11:33PM +0200, Jarkko Sakkinen wrote: > On Mon, Nov 19, 2018 at 09:00:08AM -0800, Andy Lutomirski wrote: > > On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen > > wrote: > > > > > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > > > 1. The kernel

Re: RFC: userspace exception fixups

2018-11-20 Thread Sean Christopherson
On Tue, Nov 20, 2018 at 12:11:33PM +0200, Jarkko Sakkinen wrote: > On Mon, Nov 19, 2018 at 09:00:08AM -0800, Andy Lutomirski wrote: > > On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen > > wrote: > > > > > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > > > 1. The kernel

Re: RFC: userspace exception fixups

2018-11-20 Thread Andy Lutomirski
On Tue, Nov 20, 2018 at 2:11 AM Jarkko Sakkinen wrote: > > On Mon, Nov 19, 2018 at 09:00:08AM -0800, Andy Lutomirski wrote: > > On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen > > wrote: > > > > > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > > > 1. The kernel needs some

Re: RFC: userspace exception fixups

2018-11-20 Thread Andy Lutomirski
On Tue, Nov 20, 2018 at 2:11 AM Jarkko Sakkinen wrote: > > On Mon, Nov 19, 2018 at 09:00:08AM -0800, Andy Lutomirski wrote: > > On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen > > wrote: > > > > > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > > > 1. The kernel needs some

Re: RFC: userspace exception fixups

2018-11-20 Thread Jarkko Sakkinen
On Mon, Nov 19, 2018 at 09:00:08AM -0800, Andy Lutomirski wrote: > On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen > wrote: > > > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > > 1. The kernel needs some way to know *when* to apply this fixup. > > > Decoding the

Re: RFC: userspace exception fixups

2018-11-20 Thread Jarkko Sakkinen
On Mon, Nov 19, 2018 at 09:00:08AM -0800, Andy Lutomirski wrote: > On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen > wrote: > > > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > > 1. The kernel needs some way to know *when* to apply this fixup. > > > Decoding the

Re: RFC: userspace exception fixups

2018-11-19 Thread Andy Lutomirski
On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen wrote: > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > 1. The kernel needs some way to know *when* to apply this fixup. > > Decoding the instruction stream and doing it to all exceptions that > > hit an ENCLU instruction

Re: RFC: userspace exception fixups

2018-11-19 Thread Andy Lutomirski
On Mon, Nov 19, 2018 at 8:02 AM Jarkko Sakkinen wrote: > > On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > > 1. The kernel needs some way to know *when* to apply this fixup. > > Decoding the instruction stream and doing it to all exceptions that > > hit an ENCLU instruction

Re: RFC: userspace exception fixups

2018-11-19 Thread Jarkko Sakkinen
On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > 1. The kernel needs some way to know *when* to apply this fixup. > Decoding the instruction stream and doing it to all exceptions that > hit an ENCLU instruction seems like a poor design. I'm not sure why you would ever need to do

Re: RFC: userspace exception fixups

2018-11-19 Thread Jarkko Sakkinen
On Mon, Nov 19, 2018 at 07:29:36AM -0800, Andy Lutomirski wrote: > 1. The kernel needs some way to know *when* to apply this fixup. > Decoding the instruction stream and doing it to all exceptions that > hit an ENCLU instruction seems like a poor design. I'm not sure why you would ever need to do

Re: RFC: userspace exception fixups

2018-11-19 Thread Andy Lutomirski
On Sat, Nov 17, 2018 at 11:16 PM Jarkko Sakkinen wrote: > > On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > > Hi all- > > > > The people working on SGX enablement are grappling with a somewhat > > annoying issue: the x86 EENTER instruction is used from user code and > > can, as

Re: RFC: userspace exception fixups

2018-11-19 Thread Andy Lutomirski
On Sat, Nov 17, 2018 at 11:16 PM Jarkko Sakkinen wrote: > > On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > > Hi all- > > > > The people working on SGX enablement are grappling with a somewhat > > annoying issue: the x86 EENTER instruction is used from user code and > > can, as

Re: RFC: userspace exception fixups

2018-11-19 Thread Jarkko Sakkinen
On Mon, Nov 19, 2018 at 04:05:43PM +0200, Jarkko Sakkinen wrote: > On Mon, Nov 19, 2018 at 05:17:26AM +, Jethro Beekman wrote: > > On 2018-11-18 18:32, Jarkko Sakkinen wrote: > > > On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: > > > > On Thu, Nov 01, 2018 at 10:53:40AM

Re: RFC: userspace exception fixups

2018-11-19 Thread Jarkko Sakkinen
On Mon, Nov 19, 2018 at 04:05:43PM +0200, Jarkko Sakkinen wrote: > On Mon, Nov 19, 2018 at 05:17:26AM +, Jethro Beekman wrote: > > On 2018-11-18 18:32, Jarkko Sakkinen wrote: > > > On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: > > > > On Thu, Nov 01, 2018 at 10:53:40AM

Re: RFC: userspace exception fixups

2018-11-19 Thread Jarkko Sakkinen
On Mon, Nov 19, 2018 at 05:17:26AM +, Jethro Beekman wrote: > On 2018-11-18 18:32, Jarkko Sakkinen wrote: > > On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: > > > On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > > > > Hi all- > > > > > > > > The people

Re: RFC: userspace exception fixups

2018-11-19 Thread Jarkko Sakkinen
On Mon, Nov 19, 2018 at 05:17:26AM +, Jethro Beekman wrote: > On 2018-11-18 18:32, Jarkko Sakkinen wrote: > > On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: > > > On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > > > > Hi all- > > > > > > > > The people

Re: RFC: userspace exception fixups

2018-11-18 Thread Jethro Beekman
On 2018-11-18 18:32, Jarkko Sakkinen wrote: On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: Hi all- The people working on SGX enablement are grappling with a somewhat annoying issue: the x86 EENTER instruction

Re: RFC: userspace exception fixups

2018-11-18 Thread Jethro Beekman
On 2018-11-18 18:32, Jarkko Sakkinen wrote: On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: Hi all- The people working on SGX enablement are grappling with a somewhat annoying issue: the x86 EENTER instruction

Re: RFC: userspace exception fixups

2018-11-18 Thread Jarkko Sakkinen
On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: > On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > > Hi all- > > > > The people working on SGX enablement are grappling with a somewhat > > annoying issue: the x86 EENTER instruction is used from user code and > >

Re: RFC: userspace exception fixups

2018-11-18 Thread Jarkko Sakkinen
On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: > On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > > Hi all- > > > > The people working on SGX enablement are grappling with a somewhat > > annoying issue: the x86 EENTER instruction is used from user code and > >

Re: RFC: userspace exception fixups

2018-11-17 Thread Jarkko Sakkinen
On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: > On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > > Hi all- > > > > The people working on SGX enablement are grappling with a somewhat > > annoying issue: the x86 EENTER instruction is used from user code and > >

Re: RFC: userspace exception fixups

2018-11-17 Thread Jarkko Sakkinen
On Sun, Nov 18, 2018 at 09:15:48AM +0200, Jarkko Sakkinen wrote: > On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > > Hi all- > > > > The people working on SGX enablement are grappling with a somewhat > > annoying issue: the x86 EENTER instruction is used from user code and > >

Re: RFC: userspace exception fixups

2018-11-17 Thread Jarkko Sakkinen
On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > Hi all- > > The people working on SGX enablement are grappling with a somewhat > annoying issue: the x86 EENTER instruction is used from user code and > can, as part of its normal-ish operation, raise an exception. It is > also

Re: RFC: userspace exception fixups

2018-11-17 Thread Jarkko Sakkinen
On Thu, Nov 01, 2018 at 10:53:40AM -0700, Andy Lutomirski wrote: > Hi all- > > The people working on SGX enablement are grappling with a somewhat > annoying issue: the x86 EENTER instruction is used from user code and > can, as part of its normal-ish operation, raise an exception. It is > also

Re: RFC: userspace exception fixups

2018-11-08 Thread Christoph Hellwig
On Thu, Nov 08, 2018 at 12:05:42PM -0800, Andy Lutomirski wrote: > This whole thing is a mess. I'm starting to think that the cleanest > solution would be to provide a way to just tell the kernel that > certain RIP values have exception fixups. The bay far cleanest solution would be to say that

Re: RFC: userspace exception fixups

2018-11-08 Thread Christoph Hellwig
On Thu, Nov 08, 2018 at 12:05:42PM -0800, Andy Lutomirski wrote: > This whole thing is a mess. I'm starting to think that the cleanest > solution would be to provide a way to just tell the kernel that > certain RIP values have exception fixups. The bay far cleanest solution would be to say that

Re: RFC: userspace exception fixups

2018-11-08 Thread Sean Christopherson
On Thu, Nov 08, 2018 at 01:50:31PM -0800, Dave Hansen wrote: > On 11/8/18 1:16 PM, Sean Christopherson wrote: > > On Thu, Nov 08, 2018 at 12:10:30PM -0800, Dave Hansen wrote: > >> On 11/8/18 12:05 PM, Andy Lutomirski wrote: > >>> Hmm. The idea being that the SDK preserves RBP but not RSP. That's

Re: RFC: userspace exception fixups

2018-11-08 Thread Sean Christopherson
On Thu, Nov 08, 2018 at 01:50:31PM -0800, Dave Hansen wrote: > On 11/8/18 1:16 PM, Sean Christopherson wrote: > > On Thu, Nov 08, 2018 at 12:10:30PM -0800, Dave Hansen wrote: > >> On 11/8/18 12:05 PM, Andy Lutomirski wrote: > >>> Hmm. The idea being that the SDK preserves RBP but not RSP. That's

Re: RFC: userspace exception fixups

2018-11-08 Thread Dave Hansen
On 11/8/18 1:16 PM, Sean Christopherson wrote: > On Thu, Nov 08, 2018 at 12:10:30PM -0800, Dave Hansen wrote: >> On 11/8/18 12:05 PM, Andy Lutomirski wrote: >>> Hmm. The idea being that the SDK preserves RBP but not RSP. That's >>> not the most terrible thing in the world. But could the SDK

Re: RFC: userspace exception fixups

2018-11-08 Thread Dave Hansen
On 11/8/18 1:16 PM, Sean Christopherson wrote: > On Thu, Nov 08, 2018 at 12:10:30PM -0800, Dave Hansen wrote: >> On 11/8/18 12:05 PM, Andy Lutomirski wrote: >>> Hmm. The idea being that the SDK preserves RBP but not RSP. That's >>> not the most terrible thing in the world. But could the SDK

Re: RFC: userspace exception fixups

2018-11-08 Thread Sean Christopherson
On Thu, Nov 08, 2018 at 12:10:30PM -0800, Dave Hansen wrote: > On 11/8/18 12:05 PM, Andy Lutomirski wrote: > > Hmm. The idea being that the SDK preserves RBP but not RSP. That's > > not the most terrible thing in the world. But could the SDK live with > > something more like my suggestion where

Re: RFC: userspace exception fixups

2018-11-08 Thread Sean Christopherson
On Thu, Nov 08, 2018 at 12:10:30PM -0800, Dave Hansen wrote: > On 11/8/18 12:05 PM, Andy Lutomirski wrote: > > Hmm. The idea being that the SDK preserves RBP but not RSP. That's > > not the most terrible thing in the world. But could the SDK live with > > something more like my suggestion where

Re: RFC: userspace exception fixups

2018-11-08 Thread Dave Hansen
On 11/8/18 12:05 PM, Andy Lutomirski wrote: > Hmm. The idea being that the SDK preserves RBP but not RSP. That's > not the most terrible thing in the world. But could the SDK live with > something more like my suggestion where the vDSO supplies a normal > function that takes a struct containing

Re: RFC: userspace exception fixups

2018-11-08 Thread Dave Hansen
On 11/8/18 12:05 PM, Andy Lutomirski wrote: > Hmm. The idea being that the SDK preserves RBP but not RSP. That's > not the most terrible thing in the world. But could the SDK live with > something more like my suggestion where the vDSO supplies a normal > function that takes a struct containing

Re: RFC: userspace exception fixups

2018-11-08 Thread Andy Lutomirski
On Thu, Nov 8, 2018 at 11:54 AM Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 01:07:54PM -0800, Andy Lutomirski wrote: > > > > > > > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > > > >> On 11/6/18 12:12 PM, Andy Lutomirski wrote: > > >> True, but what if we have a nasty enclave

Re: RFC: userspace exception fixups

2018-11-08 Thread Andy Lutomirski
On Thu, Nov 8, 2018 at 11:54 AM Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 01:07:54PM -0800, Andy Lutomirski wrote: > > > > > > > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > > > >> On 11/6/18 12:12 PM, Andy Lutomirski wrote: > > >> True, but what if we have a nasty enclave

Re: RFC: userspace exception fixups

2018-11-08 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 01:07:54PM -0800, Andy Lutomirski wrote: > > > > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > >> On 11/6/18 12:12 PM, Andy Lutomirski wrote: > >> True, but what if we have a nasty enclave that writes to memory just > >> below SP *before* decrementing SP? > > >

Re: RFC: userspace exception fixups

2018-11-08 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 01:07:54PM -0800, Andy Lutomirski wrote: > > > > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > >> On 11/6/18 12:12 PM, Andy Lutomirski wrote: > >> True, but what if we have a nasty enclave that writes to memory just > >> below SP *before* decrementing SP? > > >

Re: RFC: userspace exception fixups

2018-11-08 Thread Jarkko Sakkinen
On Wed, Nov 07, 2018 at 01:40:59PM -0800, Sean Christopherson wrote: > > In that case it seems like the only way to use SGX that's not a gaping > > security hole is to run the SGX enclave in its own fully-seccomp (or > > equivalent) process, with no host application in the same address > > space.

Re: RFC: userspace exception fixups

2018-11-08 Thread Jarkko Sakkinen
On Wed, Nov 07, 2018 at 01:40:59PM -0800, Sean Christopherson wrote: > > In that case it seems like the only way to use SGX that's not a gaping > > security hole is to run the SGX enclave in its own fully-seccomp (or > > equivalent) process, with no host application in the same address > > space.

Re: RFC: userspace exception fixups

2018-11-08 Thread Jarkko Sakkinen
On Wed, Nov 07, 2018 at 12:56:58PM -0800, Dave Hansen wrote: > On 11/7/18 11:01 AM, Sean Christopherson wrote: > > Going off comments in similar code related to UMIP, we'd need to figure > > out how to handle protection keys. > > There are two options: > 1. Don't depend on the userspace mapping.

Re: RFC: userspace exception fixups

2018-11-08 Thread Jarkko Sakkinen
On Wed, Nov 07, 2018 at 12:56:58PM -0800, Dave Hansen wrote: > On 11/7/18 11:01 AM, Sean Christopherson wrote: > > Going off comments in similar code related to UMIP, we'd need to figure > > out how to handle protection keys. > > There are two options: > 1. Don't depend on the userspace mapping.

Re: RFC: userspace exception fixups

2018-11-07 Thread Sean Christopherson
On Wed, Nov 07, 2018 at 04:27:58PM -0500, Rich Felker wrote: > On Tue, Nov 06, 2018 at 03:26:16PM -0800, Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 06:17:30PM -0500, Rich Felker wrote: > > > On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > > > > On Tue, Nov 6, 2018 at

Re: RFC: userspace exception fixups

2018-11-07 Thread Sean Christopherson
On Wed, Nov 07, 2018 at 04:27:58PM -0500, Rich Felker wrote: > On Tue, Nov 06, 2018 at 03:26:16PM -0800, Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 06:17:30PM -0500, Rich Felker wrote: > > > On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > > > > On Tue, Nov 6, 2018 at

Re: RFC: userspace exception fixups

2018-11-07 Thread Andy Lutomirski
On Wed, Nov 7, 2018 at 1:28 PM Rich Felker wrote: > > On Tue, Nov 06, 2018 at 03:26:16PM -0800, Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 06:17:30PM -0500, Rich Felker wrote: > > > On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > > > > On Tue, Nov 6, 2018 at 10:41

Re: RFC: userspace exception fixups

2018-11-07 Thread Andy Lutomirski
On Wed, Nov 7, 2018 at 1:28 PM Rich Felker wrote: > > On Tue, Nov 06, 2018 at 03:26:16PM -0800, Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 06:17:30PM -0500, Rich Felker wrote: > > > On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > > > > On Tue, Nov 6, 2018 at 10:41

Re: RFC: userspace exception fixups

2018-11-07 Thread Rich Felker
On Tue, Nov 06, 2018 at 03:26:16PM -0800, Sean Christopherson wrote: > On Tue, Nov 06, 2018 at 06:17:30PM -0500, Rich Felker wrote: > > On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > > > On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: > > > > > > > > On 11/6/18 10:20 AM,

Re: RFC: userspace exception fixups

2018-11-07 Thread Rich Felker
On Tue, Nov 06, 2018 at 03:26:16PM -0800, Sean Christopherson wrote: > On Tue, Nov 06, 2018 at 06:17:30PM -0500, Rich Felker wrote: > > On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > > > On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: > > > > > > > > On 11/6/18 10:20 AM,

Re: RFC: userspace exception fixups

2018-11-07 Thread Dave Hansen
On 11/7/18 11:01 AM, Sean Christopherson wrote: > Going off comments in similar code related to UMIP, we'd need to figure > out how to handle protection keys. There are two options: 1. Don't depend on the userspace mapping. Do get_user_pages() to find the instruction in the kernel direct map,

Re: RFC: userspace exception fixups

2018-11-07 Thread Dave Hansen
On 11/7/18 11:01 AM, Sean Christopherson wrote: > Going off comments in similar code related to UMIP, we'd need to figure > out how to handle protection keys. There are two options: 1. Don't depend on the userspace mapping. Do get_user_pages() to find the instruction in the kernel direct map,

Re: RFC: userspace exception fixups

2018-11-07 Thread Sean Christopherson
On Wed, Nov 07, 2018 at 07:34:52AM -0800, Sean Christopherson wrote: > On Tue, Nov 06, 2018 at 05:17:14PM -0800, Andy Lutomirski wrote: > > On Tue, Nov 6, 2018 at 4:02 PM Sean Christopherson > > wrote: > > > > > > On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy Lutomirski wrote: > > > > On Tue,

Re: RFC: userspace exception fixups

2018-11-07 Thread Sean Christopherson
On Wed, Nov 07, 2018 at 07:34:52AM -0800, Sean Christopherson wrote: > On Tue, Nov 06, 2018 at 05:17:14PM -0800, Andy Lutomirski wrote: > > On Tue, Nov 6, 2018 at 4:02 PM Sean Christopherson > > wrote: > > > > > > On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy Lutomirski wrote: > > > > On Tue,

Re: RFC: userspace exception fixups

2018-11-07 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 05:17:14PM -0800, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 4:02 PM Sean Christopherson > wrote: > > > > On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy Lutomirski wrote: > > > On Tue, Nov 6, 2018 at 3:35 PM Sean Christopherson > > > wrote: > > > > > > > > On Tue,

Re: RFC: userspace exception fixups

2018-11-07 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 05:17:14PM -0800, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 4:02 PM Sean Christopherson > wrote: > > > > On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy Lutomirski wrote: > > > On Tue, Nov 6, 2018 at 3:35 PM Sean Christopherson > > > wrote: > > > > > > > > On Tue,

Re: RFC: userspace exception fixups

2018-11-06 Thread Jethro Beekman
On 2018-11-07 02:17, Andy Lutomirski wrote: On Tue, Nov 6, 2018 at 4:02 PM Sean Christopherson wrote: /* * EEXIT or EENTER faulted. In the latter case, %RAX already holds some * fault indicator, e.g. -EFAULT. */ eexit_or_eenter_fault: ret But userspace wants to know whether it

Re: RFC: userspace exception fixups

2018-11-06 Thread Jethro Beekman
On 2018-11-07 02:17, Andy Lutomirski wrote: On Tue, Nov 6, 2018 at 4:02 PM Sean Christopherson wrote: /* * EEXIT or EENTER faulted. In the latter case, %RAX already holds some * fault indicator, e.g. -EFAULT. */ eexit_or_eenter_fault: ret But userspace wants to know whether it

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
On Tue, Nov 6, 2018 at 4:02 PM Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy Lutomirski wrote: > > On Tue, Nov 6, 2018 at 3:35 PM Sean Christopherson > > wrote: > > > > > > On Tue, Nov 06, 2018 at 03:00:56PM -0800, Andy Lutomirski wrote: > > > > > > > > > > > > >>

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
On Tue, Nov 6, 2018 at 4:02 PM Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy Lutomirski wrote: > > On Tue, Nov 6, 2018 at 3:35 PM Sean Christopherson > > wrote: > > > > > > On Tue, Nov 06, 2018 at 03:00:56PM -0800, Andy Lutomirski wrote: > > > > > > > > > > > > >>

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 3:35 PM Sean Christopherson > wrote: > > > > On Tue, Nov 06, 2018 at 03:00:56PM -0800, Andy Lutomirski wrote: > > > > > > > > > >> On Nov 6, 2018, at 1:59 PM, Sean Christopherson > > > >> wrote: > > > >> >

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 03:39:48PM -0800, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 3:35 PM Sean Christopherson > wrote: > > > > On Tue, Nov 06, 2018 at 03:00:56PM -0800, Andy Lutomirski wrote: > > > > > > > > > >> On Nov 6, 2018, at 1:59 PM, Sean Christopherson > > > >> wrote: > > > >> >

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
On Tue, Nov 6, 2018 at 3:35 PM Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 03:00:56PM -0800, Andy Lutomirski wrote: > > > > > > >> On Nov 6, 2018, at 1:59 PM, Sean Christopherson > > >> wrote: > > >> > > >>> On Tue, 2018-11-06 at 13:41 -0800, Andy Lutomirski wrote: > > >> Sean, how

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
On Tue, Nov 6, 2018 at 3:35 PM Sean Christopherson wrote: > > On Tue, Nov 06, 2018 at 03:00:56PM -0800, Andy Lutomirski wrote: > > > > > > >> On Nov 6, 2018, at 1:59 PM, Sean Christopherson > > >> wrote: > > >> > > >>> On Tue, 2018-11-06 at 13:41 -0800, Andy Lutomirski wrote: > > >> Sean, how

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 03:00:56PM -0800, Andy Lutomirski wrote: > > > >> On Nov 6, 2018, at 1:59 PM, Sean Christopherson > >> wrote: > >> > >>> On Tue, 2018-11-06 at 13:41 -0800, Andy Lutomirski wrote: > >> Sean, how does the current SDK AEX handler decide whether to do > >> EENTER, ERESUME,

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 03:00:56PM -0800, Andy Lutomirski wrote: > > > >> On Nov 6, 2018, at 1:59 PM, Sean Christopherson > >> wrote: > >> > >>> On Tue, 2018-11-06 at 13:41 -0800, Andy Lutomirski wrote: > >> Sean, how does the current SDK AEX handler decide whether to do > >> EENTER, ERESUME,

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 06:17:30PM -0500, Rich Felker wrote: > On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > > On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: > > > > > > On 11/6/18 10:20 AM, Andy Lutomirski wrote: > > > > I almost feel like the right solution is to call

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, Nov 06, 2018 at 06:17:30PM -0500, Rich Felker wrote: > On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > > On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: > > > > > > On 11/6/18 10:20 AM, Andy Lutomirski wrote: > > > > I almost feel like the right solution is to call

Re: RFC: userspace exception fixups

2018-11-06 Thread Rich Felker
On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: > > > > On 11/6/18 10:20 AM, Andy Lutomirski wrote: > > > I almost feel like the right solution is to call into SGX on its own > > > private stack or maybe even its own private

Re: RFC: userspace exception fixups

2018-11-06 Thread Rich Felker
On Tue, Nov 06, 2018 at 11:02:11AM -0800, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: > > > > On 11/6/18 10:20 AM, Andy Lutomirski wrote: > > > I almost feel like the right solution is to call into SGX on its own > > > private stack or maybe even its own private

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
>> On Nov 6, 2018, at 1:59 PM, Sean Christopherson >> wrote: >> >>> On Tue, 2018-11-06 at 13:41 -0800, Andy Lutomirski wrote: On Tue, Nov 6, 2018 at 1:07 PM Andy Lutomirski wrote: > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > On 11/6/18 12:12 PM,

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
>> On Nov 6, 2018, at 1:59 PM, Sean Christopherson >> wrote: >> >>> On Tue, 2018-11-06 at 13:41 -0800, Andy Lutomirski wrote: On Tue, Nov 6, 2018 at 1:07 PM Andy Lutomirski wrote: > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > On 11/6/18 12:12 PM,

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, 2018-11-06 at 13:41 -0800, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 1:07 PM Andy Lutomirski wrote: > > > > > > > > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > > > > > > > > > On 11/6/18 12:12 PM, Andy Lutomirski wrote: > > > > True, but what if we have a nasty enclave

Re: RFC: userspace exception fixups

2018-11-06 Thread Sean Christopherson
On Tue, 2018-11-06 at 13:41 -0800, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 1:07 PM Andy Lutomirski wrote: > > > > > > > > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > > > > > > > > > On 11/6/18 12:12 PM, Andy Lutomirski wrote: > > > > True, but what if we have a nasty enclave

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
On Tue, Nov 6, 2018 at 1:07 PM Andy Lutomirski wrote: > > > > > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > >> On 11/6/18 12:12 PM, Andy Lutomirski wrote: > >> True, but what if we have a nasty enclave that writes to memory just > >> below SP *before* decrementing SP? > > > > Yeah, that

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
On Tue, Nov 6, 2018 at 1:07 PM Andy Lutomirski wrote: > > > > > On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > > > >> On 11/6/18 12:12 PM, Andy Lutomirski wrote: > >> True, but what if we have a nasty enclave that writes to memory just > >> below SP *before* decrementing SP? > > > > Yeah, that

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
> On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > >> On 11/6/18 12:12 PM, Andy Lutomirski wrote: >> True, but what if we have a nasty enclave that writes to memory just >> below SP *before* decrementing SP? > > Yeah, that would be unfortunate. If an enclave did this (roughly): > >1.

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
> On Nov 6, 2018, at 1:00 PM, Dave Hansen wrote: > >> On 11/6/18 12:12 PM, Andy Lutomirski wrote: >> True, but what if we have a nasty enclave that writes to memory just >> below SP *before* decrementing SP? > > Yeah, that would be unfortunate. If an enclave did this (roughly): > >1.

Re: RFC: userspace exception fixups

2018-11-06 Thread Dave Hansen
On 11/6/18 12:12 PM, Andy Lutomirski wrote: > True, but what if we have a nasty enclave that writes to memory just > below SP *before* decrementing SP? Yeah, that would be unfortunate. If an enclave did this (roughly): 1. EENTER 2. Hardware sets eenter_hwframe->sp = %sp

Re: RFC: userspace exception fixups

2018-11-06 Thread Dave Hansen
On 11/6/18 12:12 PM, Andy Lutomirski wrote: > True, but what if we have a nasty enclave that writes to memory just > below SP *before* decrementing SP? Yeah, that would be unfortunate. If an enclave did this (roughly): 1. EENTER 2. Hardware sets eenter_hwframe->sp = %sp

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
> On Nov 6, 2018, at 11:22 AM, Dave Hansen wrote: > >> On 11/6/18 11:02 AM, Andy Lutomirski wrote: >>> On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: >>> On 11/6/18 10:20 AM, Andy Lutomirski wrote: I almost feel like the right solution is to call into SGX on its own

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
> On Nov 6, 2018, at 11:22 AM, Dave Hansen wrote: > >> On 11/6/18 11:02 AM, Andy Lutomirski wrote: >>> On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: >>> On 11/6/18 10:20 AM, Andy Lutomirski wrote: I almost feel like the right solution is to call into SGX on its own

Re: RFC: userspace exception fixups

2018-11-06 Thread Dave Hansen
On 11/6/18 11:02 AM, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: >> >> On 11/6/18 10:20 AM, Andy Lutomirski wrote: >>> I almost feel like the right solution is to call into SGX on its own >>> private stack or maybe even its own private address space. >> >> Yeah, I

Re: RFC: userspace exception fixups

2018-11-06 Thread Dave Hansen
On 11/6/18 11:02 AM, Andy Lutomirski wrote: > On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: >> >> On 11/6/18 10:20 AM, Andy Lutomirski wrote: >>> I almost feel like the right solution is to call into SGX on its own >>> private stack or maybe even its own private address space. >> >> Yeah, I

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: > > On 11/6/18 10:20 AM, Andy Lutomirski wrote: > > I almost feel like the right solution is to call into SGX on its own > > private stack or maybe even its own private address space. > > Yeah, I had the same gut feeling. Couldn't the debugger

Re: RFC: userspace exception fixups

2018-11-06 Thread Andy Lutomirski
On Tue, Nov 6, 2018 at 10:41 AM Dave Hansen wrote: > > On 11/6/18 10:20 AM, Andy Lutomirski wrote: > > I almost feel like the right solution is to call into SGX on its own > > private stack or maybe even its own private address space. > > Yeah, I had the same gut feeling. Couldn't the debugger

Re: RFC: userspace exception fixups

2018-11-06 Thread Dave Hansen
On 11/6/18 10:20 AM, Andy Lutomirski wrote: > I almost feel like the right solution is to call into SGX on its own > private stack or maybe even its own private address space. Yeah, I had the same gut feeling. Couldn't the debugger even treat the enclave like its own "thread" with its own stack

Re: RFC: userspace exception fixups

2018-11-06 Thread Dave Hansen
On 11/6/18 10:20 AM, Andy Lutomirski wrote: > I almost feel like the right solution is to call into SGX on its own > private stack or maybe even its own private address space. Yeah, I had the same gut feeling. Couldn't the debugger even treat the enclave like its own "thread" with its own stack

  1   2   >