Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2143897imu; Wed, 21 Nov 2018 07:18:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ugm5eT27Xrm6VHVFUVm99zZIYK3l/Uusfib2uOAH8o7d5LVlHJaGlpUnxWfKOwZeC3q8TT X-Received: by 2002:a65:520a:: with SMTP id o10mr6614483pgp.276.1542813522793; Wed, 21 Nov 2018 07:18:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542813522; cv=none; d=google.com; s=arc-20160816; b=mxJnimrslScS1fHTwQ4s1VgSg4fsUtFu0xB6iQeyy5KQ/WNFaqDZud6M+DZlb/hhlh rvGdKlzgeSaND4yLkr+A9DHC8501Q0izYep6uj9XQobIiZBP+TAIqWNMRrd23Mv2CRpF THlUMNxTNjH/CI5/QXSWEb7BNMn3fI0Tu7ZQXTno+g7K/GJnJOICvfgpyRCB6djZiuFa KWBZqjfaXF9njfdFKWfXrN6OfWllxEKQPP/uvWgE2LEfa2B3MVuCGpe7CxusDFk6GNV2 9MsS8stG4AJjujay0JdOiQuPNMjizQzOkLm+V5WfV7ixnyMqEWbYCvrVok2tKdO7fbBD mdbQ== 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=Ib5Z0x4Z72om2uvLfuouVAkbjDlQYZzEI88OVs8V2J4=; b=OFg/UW149/v6m9BrsdsvC/eMT6Y8rz4kuoFz+QriPTuYiaLr+x8dp/Q8sUVVWBiPmf aXo1HL7DUSWeGA6QrhUNX4TnPoPkFnqsqqkH8IaQPEqu46AATFuDfAVA/U1Ch3s1bNMu k5ktluLd1w0BFPlKVQ5YVaUZeq3r2+BEi3RyCEV0QIIlYXxznyqy72d+LAINkMR1yvRy QeAkmowpzvqVexF7CsFsR73mN+alzT1aZzx4W5GzHGcw32JlC5I6RbMRKbjBRMy2zZA2 7hsjC3Gmpoi8+lZ9iLY8RVXxiOk30Dlk69hanlFzwBSfCU6raPNytBOgoe6m3UtcW848 CyeA== 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 e89si7550597plb.401.2018.11.21.07.18.18; Wed, 21 Nov 2018 07:18:42 -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 S1731078AbeKVBwb (ORCPT + 99 others); Wed, 21 Nov 2018 20:52:31 -0500 Received: from mga07.intel.com ([134.134.136.100]:2377 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726849AbeKVBwb (ORCPT ); Wed, 21 Nov 2018 20:52:31 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Nov 2018 07:17:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,261,1539673200"; d="scan'208";a="108164078" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.177]) by fmsmga004.fm.intel.com with ESMTP; 21 Nov 2018 07:17:35 -0800 Date: Wed, 21 Nov 2018 17:17:34 +0200 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: <20181121151734.GA16564@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0a78772e-4f42-254b-d91a-f0f80a24ff90@fortanix.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: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). /Jarkko