Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1237232imu; Tue, 11 Dec 2018 15:31:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/UJbJBvUwE+E9EdKDAYtetL0dWfEdEp7G+QCkd1v30RvF6mk9ekHaGCKr+pXOYXhgUoMFGC X-Received: by 2002:a62:c683:: with SMTP id x3mr17775150pfk.10.1544571063389; Tue, 11 Dec 2018 15:31:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544571063; cv=none; d=google.com; s=arc-20160816; b=UX1zmNNQN3DxRQc6LMzIDXpmiXXwJnJUolXeeFebAQiG/UNZrreeHg7tIgcV6aff3r TPmwFbEmsLFl4nT5E8MNNwmIpamryxPkEMlW+8ranTlfjX3p0pXuuT5UMbdHlQnJ4Riq tdT7cqHKrO5JuONNQRlrvmCCmMHM/f+o2UQjTLWqGY7ahPIvFYpQwX/o24k5Pc7UhCQb RrUPsi8VFBJAgjY8VNMcUQQe59nEqBolAnOsoJynUjNaaPpTbF4ndVYqd+rL+HpVaZYb 0VldJobIACLRfvgflc2935y32z/aNE+4Lfn8hHgPuJoxWyl+wFLrC+glp5xiMGgIcfHq xjSw== 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=t3RDh1Z04X6LiuQ+sezM9JQJDUstMMkD6Q4FWtEGxIM=; b=AiNt2hSvtaGyZ4+mf/ZYOFS8mBN2SCfYDsBjvTIrjdejOYFMskZuYRH3QxfVrnLX0/ 3R5/kiA6UbK4iqYonAafUpsoR6gEvu8vL6qEz+IaH3MBteKIlO845vn0RDFLsWeVOB07 cEaqihSDgPgpOXGurKs0zoQNidU7GFogisktcgjQoyOYfIkpGEaTb78ao+4bv76H0t5D RhvGXn9bE6rVbFByFVWjpLM6m4p1SdBkSasPHSpucVkEs+bGH9LC13TLgDKCjIEbzF3D bsfLC2NBc0npxx8s5gNItMVVyhfjZDA6dbjv349bhycy40bnWMjAYVwbMtcVr+l3RYZ2 UnVg== 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 n1si14393337pfh.96.2018.12.11.15.30.48; Tue, 11 Dec 2018 15:31:03 -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 S1726230AbeLKX3x (ORCPT + 99 others); Tue, 11 Dec 2018 18:29:53 -0500 Received: from mga02.intel.com ([134.134.136.20]:34190 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbeLKX3w (ORCPT ); Tue, 11 Dec 2018 18:29:52 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Dec 2018 15:29:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,343,1539673200"; d="scan'208";a="125057550" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.154]) by fmsmga002.fm.intel.com with ESMTP; 11 Dec 2018 15:29:51 -0800 Date: Tue, 11 Dec 2018 15:29:51 -0800 From: Sean Christopherson To: Andy Lutomirski Cc: Josh Triplett , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , Jarkko Sakkinen , Dave Hansen , Peter Zijlstra , "H. Peter Anvin" , LKML , linux-sgx@vger.kernel.org, Haitao Huang , Jethro Beekman , "Dr. Greg Wettstein" Subject: Re: [RFC PATCH v3 0/4] x86: Add exception fixup for SGX ENCLU Message-ID: <20181211232951.GK14731@linux.intel.com> References: <20181210232141.5425-1-sean.j.christopherson@intel.com> <20181210232449.GA11843@localhost> <20181211165253.GB14731@linux.intel.com> <20181211222312.GI14731@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, Dec 11, 2018 at 03:10:52PM -0800, Andy Lutomirski wrote: > On Tue, Dec 11, 2018 at 2:23 PM Sean Christopherson > wrote: > > > > On Tue, Dec 11, 2018 at 09:58:19AM -0800, Andy Lutomirski wrote: > > > > On Dec 11, 2018, at 8:52 AM, Sean Christopherson wrote: > > > > > > > >> On Tue, Dec 11, 2018 at 07:41:27AM -0800, Andy Lutomirski wrote: > > > >> > > > >> > > > >>>> On Dec 10, 2018, at 3:24 PM, Josh Triplett wrote: > > > >>>> > > > >>>> On Mon, Dec 10, 2018 at 03:21:37PM -0800, Sean Christopherson wrote: > > > >>>> At that point I realized it's a hell of a lot easier to simply provide > > > >>>> an IOCTL via /dev/sgx that allows userspace to register a per-process > > > >>>> ENCLU exception handler. At a high level, the basic idea is the same > > > >>>> as the vDSO approach: provide a hardcoded fixup handler for ENCLU and > > > >>>> attempt to fixup select unhandled exceptions that occurred in user code. > > > >>> > > > >>> So, on the one hand, this is *absolutely* much cleaner than the VDSO > > > >>> approach. On the other hand, this is global process state and has some > > > >>> of the same problems as a signal handler as a result. > > > >> > > > >> I liked the old version better for this reason > > > > > > > > This isn't fundamentally different than forcing all EENTER calls through > > > > the vDSO, which is also per-process. Technically this is more flexible > > > > in that regard since userspace gets to choose where their one ENCLU gets > > > > to reside. Userspace can have per-enclave entry flows so long as the > > > > actual ENLU[EENTER] is common, same as vDSO. > > > > > > Right. The problem is that user libraries have a remarkably hard time > > > agreeing on where their one copy of anything lives. > > > > Are you concerned about userspace shooting themselves in the foot, e.g. > > unknowingly overwriting their handler? Requiring unregister->register > > to change the handler would mitigate that issue for the most part. Or > > we could even say it's a write-once property. > > > > That obviously doesn't solve the issue of a userspace application > > deliberately using two different libraries to run enclaves in a single > > process, but I have a hard time envisioning a scenario where someone > > would want to use two different *SGX* libraries in a single process. > > Don't most of the signal issue arise due to loading multiple libraries > > that provide *different* services needing to handle signals? > > I can easily imagine two SGX libraries that know nothing about each > other running in the same process. One or both could be PKCS#11 > modules, for example. Argh, wasn't thinking about loading other libraries that would also be using SGX.