Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5898534imu; Mon, 26 Nov 2018 06:39:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/W3+a6yDS4CyNNj4n25dhkY6yD9S0K7mu4GCTgtj5chLkNgW/odvNHPaHM8Ylo1p63upW+t X-Received: by 2002:a63:4665:: with SMTP id v37mr25629153pgk.425.1543243144850; Mon, 26 Nov 2018 06:39:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543243144; cv=none; d=google.com; s=arc-20160816; b=Uk5lOGvVsZ2c8d5yaLSlrVDOcbb8elAKXIQL6g43fPkmfS5aRXzCNqOQuwMyTz5dBn 46mmBpvc0TL0UZfuTFl5DQkVhfEeAdq8PxPPHPECPueZwh/yvYv+2i3f4tmE9fjQfBJf SMFfzQhaxYK9WXSYFD4Z6qu7CR1mWGDwng+bzZFZGiqp4qoJ5irt46FynRsxfSw/6zli uJuz9SGaolCmuih9JWwH4tR1m+kDu13EzuGNFejnfJe6ZBPOmAik32QBW+jeAHcN/I66 1Kw/bS4pBH6bp5UUxQhZY31V4JbhMnNSmc6Q7ryt7bdYSBPDT3lKUmFTeRLkJDGLH4r9 65mw== 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=2aIrsj+VF8LVq7Miey4O8fSYmTwTINWA0EnaJ9q3pjY=; b=Q0wPZq49A03BAfCUljrY/XfKkO8TywlJsG3GvDFc2F80o00D08U6QttRtGeofPMV7p J2sBt76R0zjOMT7iJCihDZXbiLQ10+LE3lmyBhQjKvT//NktFehkEwtG/cQsMlSDuaaN bA6HkgXvbSOjYdyDG8YjmSfR65eG1tyycJT8+QM273dkmamDKPlZaCGRLGskMgk2Q3qB rkwa8bRS7lkQjvX7YQByNHMvPcYsRj/Q/APXtNgfyc3KEfUfCwogICA7jA/fzajnRbhr Nu5kWIdyNUniHviTocRwPX/2N2S2BRKHyBu+S39leMX9mKjwblfgeNlfBecgXraMyBEv cnbw== 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 t20si510200plj.94.2018.11.26.06.38.45; Mon, 26 Nov 2018 06:39:04 -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 S1726567AbeK0B3x (ORCPT + 99 others); Mon, 26 Nov 2018 20:29:53 -0500 Received: from mga18.intel.com ([134.134.136.126]:38238 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbeK0B3x (ORCPT ); Mon, 26 Nov 2018 20:29:53 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2018 06:35:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,282,1539673200"; d="scan'208";a="111623519" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.154]) by fmsmga001.fm.intel.com with ESMTP; 26 Nov 2018 06:35:34 -0800 Date: Mon, 26 Nov 2018 06:35:34 -0800 From: Sean Christopherson To: Jarkko Sakkinen Cc: Jethro Beekman , Andy Lutomirski , Dave Hansen , 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: <20181126143534.GA25719@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> 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 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. And how would you determine the #UD is related to SGX? Hardware doesn't provide any indication that a #UD (or any other fault) is related to SGX or occurred in an enclave. The only fault that is special-cased in a non-virtualized environment is #PF signaled by the EPCM, which gets the PF_SGX bit set in the error code. > 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). > > /Jarkko