Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3208092imu; Fri, 18 Jan 2019 06:39:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN4br4vkoifEdR0cVHPXZX3yyimPntvLDytfmqWhIrGQaMb6OXBFApjhPLUTAuNFB9g5mnPx X-Received: by 2002:a63:2744:: with SMTP id n65mr17885104pgn.65.1547822360007; Fri, 18 Jan 2019 06:39:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547822359; cv=none; d=google.com; s=arc-20160816; b=K2b+vKoYZiaaZAkzmzh2HwAY5LjP8I98uc9id0n0eCFXeauhTgXbZHCeeQg7o42onh w9OdAiSa6ETsFSTGAbjU+G75TWCmjaIqboIg+yse6IchU9hmpGJ1vt5GeUZ6sF1WtbAo JioaIlikWfUyH6nXUp/ZhEaRaaee0W74AoYXZI0ZMN/LtbkgFw0//4fXjNntq0lZfwvU LGZBOz+Zn70XmG8eFrgbfvsTxnNIwTAbTYAL7nxX+cEBQ50phXtZgQkUKFkI5x+r4JC9 tNaw/wpHMI2KcFu3XaDOV17plm+XFezcil4qQLay6rUjNNTD6IfNHSRGLmrfoUH+Xa0j QDog== 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=bKDwY3j0QKB8sL5Aq6GHKp3r8BG7mFMO4Hyw8Rt5jLs=; b=ADkhaGcGjwwZlHRr9Wp4IJiN1/h5+BzV7DWyxMgHTJ3nyUQ3UHOD8jwRw1M1LAy+Ml cA4uICG5A95aMdNbvgLT4WkE8n/Tlcohxjh30mKu1V9mQbTS5ypd6BTcNnonb7nCnXqv XezrlWR44LtOqidc2bOWsZL2CO8uSrpKCngso0+2ofSUgA29L7h31CYNMb6bC2CpEfmP tuNT/wtEfUKy1xN3t+YnT++q1Dq8+IcaODgnPhnghivp33j5HQhw0Y5ycAjBeAVTMt8i 5YiVhTKpsgDAX5J86Y0TSuGXvxOjluvNG0ftrfajIAhmZbyi8/lghbrm1akxjE9ZEs96 Y7zA== 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 h8si4607379plr.343.2019.01.18.06.39.03; Fri, 18 Jan 2019 06:39:19 -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 S1727580AbfAROhX (ORCPT + 99 others); Fri, 18 Jan 2019 09:37:23 -0500 Received: from mga18.intel.com ([134.134.136.126]:65054 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727177AbfAROhW (ORCPT ); Fri, 18 Jan 2019 09:37:22 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2019 06:37:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,491,1539673200"; d="scan'208";a="268157714" Received: from unknown (HELO localhost) ([10.249.254.249]) by orsmga004.jf.intel.com with ESMTP; 18 Jan 2019 06:37:14 -0800 Date: Fri, 18 Jan 2019 16:37:11 +0200 From: Jarkko Sakkinen To: Sean Christopherson 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: <20190118143711.GC4080@linux.intel.com> References: <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> <20190111231956.GB29769@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190111231956.GB29769@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 Fri, Jan 11, 2019 at 03:19:56PM -0800, Sean Christopherson wrote: > 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...}? I don't see we having more than two devices. Directory hierarchies would make sense if there was variable numer of stuff initialized. /Jarkko