Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3691586imu; Sat, 24 Nov 2018 09:09:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/WSvxFIHVzAl6G1SC+HakLfb2J107LDnkFQLkMZCD1c+Aq5ai+dHBjjZbvnUefsnpjyx0AQ X-Received: by 2002:a65:4049:: with SMTP id h9mr18288945pgp.304.1543079342863; Sat, 24 Nov 2018 09:09:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543079342; cv=none; d=google.com; s=arc-20160816; b=QkfMTHG+Dxgdn1bXCnUIZ8TlTJv6Yo8Z1Isn8JDckwStPb1VcQJfMRCsdTs58Y/p7i DS3qGOsvfSu2yD2yyEXZcZeKhfKLiaFfsrHpY0grzAJJmYAILtqrXKl7g2OB9wgYYIFP gpRlRkjfDLoCw9jDZW/JAOVLE9K8iojR5HjtKBEQtJuA9j/nvr920BcGlb/529mihLGy v0sY+oOKUSLHlyCb8IybiBkaQj1iHgmcPJKbSSDELkp3LdoFhJKS48HGBxxtfpbXaf3L b6vndehnmmp+IQbsCqDkl5IluWR5rUMFY/zzteyM8rYKYucxLP897XBtN2ZdbnWQIRzj l9Ow== 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=Z9bJMv0b7Eaij9/5F3eRXCl4uo8r0Kow+3/MS+9+08c=; b=JCPeZkNwBt+TlBJ/135aQS3xYpUpVZWRvN+wSyK4xfqPn2+HVnOVMrgntkDf6kCiCs 1FSwl+FDXaJGcdYH0alTHlFslaKLiE54NT13sDf5fEN1Ju70oe2S3/M2S2hLq1BdI8bw HhydyzER7JPWTODVtBJEk2dzoTPfSmfqeKnJb/gFk5Qe3MFnKzZVGely7Bi1Hrt6VLJx GL5dBhZHq5XTeHbjxrBXIQFcjB/KThAZROco/ie7q3gXtk1CdVM8hPnDcxOTYihnIDhh +vgkpkafJ5mq0ElIgCMaVuf0NycnL9ICkaagKTwL7W85E7ZMx1y4EkmOP/hiQHUzoFeh Ui7g== 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 p187-v6si63849651pfb.127.2018.11.24.09.08.47; Sat, 24 Nov 2018 09:09:02 -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 S1726461AbeKYD4z (ORCPT + 99 others); Sat, 24 Nov 2018 22:56:55 -0500 Received: from mga07.intel.com ([134.134.136.100]:10810 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbeKYD4z (ORCPT ); Sat, 24 Nov 2018 22:56:55 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Nov 2018 09:08:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,273,1539673200"; d="scan'208";a="88351753" Received: from moellerb-mobl.ger.corp.intel.com (HELO localhost) ([10.249.254.169]) by fmsmga007.fm.intel.com with ESMTP; 24 Nov 2018 09:07:33 -0800 Date: Sat, 24 Nov 2018 09:07:26 -0800 From: Jarkko Sakkinen To: Jethro Beekman Cc: Andy Lutomirski , Dave Hansen , "Christopherson, Sean J" , 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: <20181124170726.GA32210@linux.intel.com> References: <20181118071548.GA4795@linux.intel.com> <20181119160204.GD13298@linux.intel.com> <20181120101133.GA7319@linux.intel.com> <20181120225518.GE8391@linux.intel.com> <0a78772e-4f42-254b-d91a-f0f80a24ff90@fortanix.com> <20181121151734.GA16564@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181121151734.GA16564@linux.intel.com> 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 Wed, Nov 21, 2018 at 05:17:34PM +0200, Jarkko Sakkinen wrote: > On Wed, Nov 21, 2018 at 05:17:32AM +0000, 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 the exception as a regular signal to the process, or whether to set > > the special registers values for userspace and just continue executing the > > process manually? > > Now we throw SIGSEGV when PF_SGX set, right? In my solution that would > be turned just doing iret to AEP with the extra that three registers get > exception data (type, reason, addr). No decoding or RIP adjusting > involved. > > That would mean that you would actually have to implement AEP handler > than just have enclu there. > > I've also proposed that perhaps for SGX also #UD should be propagated > this way because for some instructions you need outside help to emulate > "non-enclave" environment. > > That is all I have drafted together so far. I'll try to finish v18 this > week with other stuff and refine further next week (unless someone gives > obvious reason why this doesn't work, which might well be because I > haven't went too deep with my analysis yet because of lack of time). The obvious con in this approach is that if you single step the code, the whole AEP handler would single stepped also everytime. Probably big enough con that it is better to go with the vDSO approach anyhow... /Jarkko