From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Christopherson Subject: Re: RFC: userspace exception fixups Date: Thu, 8 Nov 2018 13:16:00 -0800 Message-ID: <20181108211600.GA17167@linux.intel.com> References: <22596E35-F5D1-4935-86AB-B510DCA0FABE@amacapital.net> <1C426267-492F-4AE7-8BE8-C7FE278531F9@amacapital.net> <209cf4a5-eda9-2495-539f-fed22252cf02@intel.com> <9B76E95B-5745-412E-8007-7FAA7F83D6FB@amacapital.net> <20181108195420.GA14715@linux.intel.com> <7027c3dc-addb-1b96-027e-a57fccf1f812@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <7027c3dc-addb-1b96-027e-a57fccf1f812@intel.com> Sender: linux-kernel-owner@vger.kernel.org To: Dave Hansen Cc: Andy Lutomirski , Andrew Lutomirski , Jann Horn , Linus Torvalds , Rich Felker , Dave Hansen , Jethro Beekman , Jarkko Sakkinen , Florian Weimer , Linux API , X86 ML , linux-arch , LKML , Peter Zijlstra , nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, linux-sgx@vger.kernel.org, Andy Shevchenko , Thomas Gleixner List-Id: linux-api@vger.kernel.org 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 the vDSO supplies a normal > > function that takes a struct containing registers that are visible to > > the enclave? This would make it extremely awkward for the enclave to > > use the untrusted stack per se, but it would make it quite easy (I > > think) for the untrusted part of the SDK to allocate some extra memory > > and just tell the enclave that *that* memory is the stack. > > I really think the enclave should keep its grubby mitts off the > untrusted stack. There are lots of ways to get memory, even with > stack-like semantics, that don't involve mucking with the stack itself. > > I have not heard a good, hard argument for why there is an absolute > *need* to store things on the actual untrusted stack. Convenience and performance are the only arguments I've heard, e.g. so that allocating memory doesn't require an extra EEXIT->EENTER round trip. > We could quite easily have the untrusted code just promise to allocate a > stack-sized virtual area (even derived from the stack rlimit size) and > pass that into the enclave for parameter use. I agree more and more the further I dig. AFAIK there is no need to for the enclave to actually load %rsp. The initial EENTER can pass in the base/top of the pseudo-stack and from there the enclave can manage it purely in software.