Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1347081imu; Sat, 17 Nov 2018 23:16:52 -0800 (PST) X-Google-Smtp-Source: AJdET5eQDXT41H+7LSSXEfib7cckTQ8AkHBIUqtmvgjqtEij89PfOBh7NLOb9igh9Q6ENYkZ2zBQ X-Received: by 2002:a62:647:: with SMTP id 68-v6mr18756433pfg.42.1542525412439; Sat, 17 Nov 2018 23:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542525412; cv=none; d=google.com; s=arc-20160816; b=Ck5cKedL+XojSC4rbZQeB8YxfbE3wonJwc5bPmvZWY4gxKieHatfEC3mJYtLvUEidG 63atlIXChiDR2NTHhReVWirt+qzdi9nbyD+PFleBDcwz7BwKnZgZEzwhjk1ufNNopt2b Ofj7mJkkyeBiQ0/fLAy6PW4OFnl6mDyOZ2G9vHSS7IWVAWWm6CKmnb39k9gLdKdJm9zR A6DrQNvDLsuDcZ+7cTYEzxR1nifTa5/Kg8ALPJwJ+UzrRgAr93rV7IB8fzQwz9P5+k9s FDJ4wYrCIuaBzagaosgDWclXtYK2s1TezgSp0kpSmSPNfHoJKugTBk5QFH6aI8a4uhDn er6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=MXaCrRhx/REtM9mpP5D9kHOXEOAUMe9qaKP1L9SSe5o=; b=pf0QcnnOfOx7kaBetzqwSjejVh/4yrGWpRUz4aHmaZvapWzWzpWpTVRsvDZfLNs0eL virhUrwBDJrUy6Af6jmWbtsbKPDyGg4WE0E8D8KaFsfszsVuifyFts+UbFCADnBlpxY2 TU56HGUNRSilloIaU68vqIMHQmil5JmQ1lFDtS7zX8OrpDxJXDnZ82/v4taCNRiT8+aX OoH6n1ScAzqKQL4d7bxnb9NDTOO/0HAq0uHU10Vlgy0tZEjqrJKOJgcOmv2AtZUFj5aB 5nSb4Fnmcrhb7rNT/luEPfX2C4SIEivzyQ7xm41eGDfjD7YLVjIxwMhVhxXU2ff1dQAY 6MNg== 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 y12si6091295pgf.527.2018.11.17.23.16.37; Sat, 17 Nov 2018 23:16:52 -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 S1726964AbeKRRf2 (ORCPT + 99 others); Sun, 18 Nov 2018 12:35:28 -0500 Received: from mga09.intel.com ([134.134.136.24]:44865 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725915AbeKRRf2 (ORCPT ); Sun, 18 Nov 2018 12:35:28 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2018 23:16:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,247,1539673200"; d="scan'208";a="87333249" Received: from kaczmarx-mobl.ger.corp.intel.com (HELO localhost) ([10.249.254.89]) by fmsmga008.fm.intel.com with ESMTP; 17 Nov 2018 23:15:50 -0800 Date: Sun, 18 Nov 2018 09:15:48 +0200 From: Jarkko Sakkinen To: Andy Lutomirski Cc: Dave Hansen , "Christopherson, Sean J" , Jethro Beekman , Florian Weimer , Linux API , Jann Horn , Linus Torvalds , X86 ML , linux-arch , LKML , Peter Zijlstra , Rich Felker , 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 Subject: Re: RFC: userspace exception fixups Message-ID: <20181118071548.GA4795@linux.intel.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 highly likely to be used from a library, and signal handling in > libraries is unpleasant at best. > > There's been some discussion of adding a vDSO entry point to wrap > EENTER and do something sensible with the exceptions, but I'm > wondering if a more general mechanism would be helpful. I haven't really followed all of this discussion because I've been busy working on the patch set but for me all of these approaches look awfully complicated. I'll throw my own suggestion and apologize if this has been already suggested and discarded: return-to-AEP. My idea is to do just a small extension to SGX AEX handling. At the moment hardware will RAX, RBX and RCX with ERESUME parameters. We can fill extend this by filling other three spare registers with exception information. AEP handler can then do whatever it wants to do with this information or just do ERESUME. In some ways this dummied version of Sean's suggestion. I think whatever the solution is it should be lightweight and this is such solution. Why? Because exception handling could be then used to implement other stuff than just error hadling like syscall wrapper for the enclaves in nice and lean way. /Jarkko