Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1106316imu; Fri, 11 Jan 2019 15:21:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN76pPLU3DOQAEE8sV9u+1dXzcoTeGAWzuD3bRK158M6IKvdFGXoXZ/k82q7PPd5WXl0n/AK X-Received: by 2002:a17:902:4401:: with SMTP id k1mr16654106pld.307.1547248878806; Fri, 11 Jan 2019 15:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547248878; cv=none; d=google.com; s=arc-20160816; b=tgMrMwQP3We9DToxuaai4wMUWHxQQbz58Nc76kBgKwx5W0rw2pvMcYOIAsSDUoooYL u+H4wmsA/DkmrJedOwuwMgwI3MNP8C86y5yIMCTf0XMk8W1iFJtz43LcFQvx4iVF7sDs sRLqAzNFJ9YqCHTUU0k0DCh+REoTSELx3UW/ACRwYXMAxoAvQN91+U7hnNnpPQzs4whF xzISGYKBAtiNsd1RaAcK5kgTGcwDz3wu852GDl3+qMZp9gwF/f1Du5/Ge35Ue/wChkji p7m+KZSG8luts6Ze5UkLfEiCw0U6RjdAYUobs6ENSgiDN9jJ4+81Xw+boAWm8V+A+83m WfKg== 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=T1+g09d0r3nm2C3U08m/rEJcs4ueftQy7osWpPXUVWU=; b=ibA5BAssjie1JEIYU3v6UZVDmUfAHOqYtRsTEf1dT685+PKed7S+pKHMTfmh8vMe51 s6/1W1DuHfSV2AO6B8kgbFHvD04OVBHBI6ugpgdbd2X/oAN5LznJw2dn/Nfj58bk++8H j/abTHdOjD8jZa7Sugd5mfU6o1WlZFc9yLV9G89c4olpMfTg/+wEJinaN4zUbd8OZDI8 c1A1jiXbiAe+ucBanHg2pokVWSdpKZ9q2K4YR15q5YhWdlOVdO7m8yZr0M5P2fayr/J3 2OvVQyG4IWpZGOsLYM+xsJOSV47G4fcGU3/8lCkZ5eM1yZRIGr6lYcfr8C7LmGLTT3wg FzyQ== 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 v141si80219063pfc.260.2019.01.11.15.21.03; Fri, 11 Jan 2019 15:21:18 -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 S1726383AbfAKXT6 (ORCPT + 99 others); Fri, 11 Jan 2019 18:19:58 -0500 Received: from mga17.intel.com ([192.55.52.151]:32059 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbfAKXT6 (ORCPT ); Fri, 11 Jan 2019 18:19:58 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jan 2019 15:19:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,467,1539673200"; d="scan'208";a="117460767" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.154]) by orsmga003.jf.intel.com with ESMTP; 11 Jan 2019 15:19:56 -0800 Date: Fri, 11 Jan 2019 15:19:56 -0800 From: Sean Christopherson To: Jarkko Sakkinen Cc: Andy Lutomirski , "Huang, Kai" , Jethro Beekman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "x86@kernel.org" , Dave Hansen , Peter Zijlstra , "H. Peter Anvin" , "linux-kernel@vger.kernel.org" , "linux-sgx@vger.kernel.org" , Josh Triplett , Haitao Huang , "Dr . Greg Wettstein" Subject: Re: x86/sgx: uapi change proposal Message-ID: <20190111231956.GB29769@linux.intel.com> References: <20181219091148.GA5121@linux.intel.com> <613c6814-4e71-38e5-444a-545f0e286df8@fortanix.com> <20181219144515.GA30909@linux.intel.com> <20181221162825.GB26865@linux.intel.com> <105F7BF4D0229846AF094488D65A0989355A45B6@PGSMSX112.gar.corp.intel.com> <20190108220946.GA30462@linux.intel.com> <20190109163135.GA1821@linux.intel.com> <20190111125826.GA5400@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190111125826.GA5400@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 Fri, Jan 11, 2019 at 02:58:26PM +0200, Jarkko Sakkinen wrote: > On Wed, Jan 09, 2019 at 08:31:37AM -0800, Sean Christopherson wrote: > > On Tue, Jan 08, 2019 at 02:54:11PM -0800, Andy Lutomirski wrote: > > > On Tue, Jan 8, 2019 at 2:09 PM Sean Christopherson > > > wrote: > > > > > > > > Cleaner in the sense that it's faster to get basic support up and running > > > > since there are fewer touchpoints, but there are long term ramifications > > > > to cramming EPC management in KVM. > > > > > > > > And at this point I'm not stating any absolutes, e.g. how EPC will be > > > > handled by KVM. What I'm pushing for is to not eliminate the possibility > > > > of having the SGX subsystem own all EPC management, e.g. don't tie > > > > /dev/sgx to a single enclave. > > > > > > I haven't gone and re-read all the relevant SDM bits, so I'll just > > > ask: what, if anything, are the actual semantics of mapping "raw EPC" > > > like this? You can't actually do anything with the mapping from user > > > mode unless you actually get an enclave created and initialized in it > > > and have it mapped at the correct linear address, right? I still > > > think you have the right idea, but it is a bit unusual. > > > > Correct, the EPC is inaccessible until a range is "mapped" with ECREATE. > > But I'd argue that it's not unusual, just different. And really it's not > > all that different than userspace mmap'ing /dev/sgx/enclave prior to > > ioctl(ENCLAVE_CREATE). In that case, userspace can still (attempt to) > > access the "raw" EPC, i.e. generate a #PF, the kernel/driver just happens > > to consider any faulting EPC address without an associated enclave as > > illegal, e.g. signals SIGBUS. > > > > The /dev/sgx/epc case simply has different semantics for moving pages in > > and out of the EPC, i.e. different fault and eviction semantics. Yes, > > this allows the guest kernel to directly access the "raw" EPC, but that's > > conceptually in line with hardware where priveleged software can directly > > "access" the EPC (or rather, the abort page for all intents and purposes). > > I.e. it's an argument for requiring certain privileges to open /dev/sgx/epc, > > but IMO it's not unusual. > > > > Maybe /dev/sgx/epc is a poor name and is causing confusion, e.g. > > /dev/sgx/virtualmachine might be more appropriate. > > What do you mean by saying "requiring certain privileges"? Are you > saying that "raw EPC" (lets say /dev/vmsgx, which probably the name I > will use for the device *if* it is required) device would require > differet privileged than /dev/sgx? I don't think it would be mandatory, especially if PROVISION and EINITTOKEN attributes are routed through securityfs, but it might be nice to have since the functionality provided by /dev/vmsgx would be different than /dev/sgx. Side topic, what's the reasoning for doing /dev/sgx and /dev/vmsgx instead of /dev/sgx/{enclave,vm,etc...}?