Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp31283imu; Thu, 8 Nov 2018 13:17:44 -0800 (PST) X-Google-Smtp-Source: AJdET5fZVcax/EBuRXZDCj3qEzG+Nw/m6cP2rFnhC5ZJPTOdgJie198W/IFGM6I69PwT5LINYYCk X-Received: by 2002:a62:2211:: with SMTP id i17-v6mr6086086pfi.35.1541711864573; Thu, 08 Nov 2018 13:17:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541711864; cv=none; d=google.com; s=arc-20160816; b=Ve5pROGWZ0j1zOJNaCQSv4SM61h6Ciy+lFxHWVAcxVJ0GYCWoqVy9ZWZXhBPIxZIWs MlvLGjrs05tdiYqcYWVA/XzrHomjGZVKpWeaw4I/qWBO479VswFGt8ocVMHrsJ9dktZz sPYec4C6GdSRcznU+iMJdI1eKJPf7UhOSVA0Y+Ir76UwNrELRRVQv8PD5SvBh8cn4im6 8D2tlTkYAUmesg2vDp4PQy4MiY/kyEq7SbW78bRgKF4G4UaiIp+jHuUpAQNDx33Ikfig 7Tm71CjK0v9KcDRRfMMJ0NsBI/9q6ObVMukcvV79Lw756xLBwRzFleyaLHdM3sY1n54X 07Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Xa0jkpCFDLl1P5pjiHwUAajXysDsZ286Kn3zO/G0vdE=; b=z6cZyxRORhIpYYzt/GW/SQ7xs6/7A0mqf7jkL5Wfiq17bcslGbKfmJx28iM1wI0TR7 31zH1KGB8mEYFxEH4lywNtKSJn+0bzZj7tC7eSVUIHcfX5vhOmLlP8dG1z/buUnUX06F P5bl+tJUO/JMtLGxImy96PwWAfpwS9v+eQjp+j1W5hWPJHuzdBytO7r19lO/J9HbcvB9 RoLNIjddsPQxPlulwXYK/2YNnxw9PrJ1cRQRYvmBqCweUyE4/iC5GJviaJAL3uTBvpoL E+a+dFqLnXB0uQfmANgA+9caeIF5gVFaW9iXWUBsUGT5w3s0NAjoHxQQNzDJCvH1s3SI wbtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1-v6si5529100pll.233.2018.11.08.13.17.27; Thu, 08 Nov 2018 13:17:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727360AbeKIGxU (ORCPT + 99 others); Fri, 9 Nov 2018 01:53:20 -0500 Received: from mga05.intel.com ([192.55.52.43]:61568 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726182AbeKIGxU (ORCPT ); Fri, 9 Nov 2018 01:53:20 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Nov 2018 13:16:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,480,1534834800"; d="scan'208";a="102760809" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.154]) by fmsmga002.fm.intel.com with ESMTP; 08 Nov 2018 13:16:00 -0800 Date: Thu, 8 Nov 2018 13:16:00 -0800 From: Sean Christopherson 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 , Ingo Molnar , Borislav Petkov , Carlos O'Donell , adhemerval.zanella@linaro.org Subject: Re: RFC: userspace exception fixups 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 Content-Disposition: inline In-Reply-To: <7027c3dc-addb-1b96-027e-a57fccf1f812@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.