From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 556ACC43387 for ; Fri, 11 Jan 2019 12:58:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28DC120836 for ; Fri, 11 Jan 2019 12:58:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731550AbfAKM6k (ORCPT ); Fri, 11 Jan 2019 07:58:40 -0500 Received: from mga01.intel.com ([192.55.52.88]:22054 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731592AbfAKM6j (ORCPT ); Fri, 11 Jan 2019 07:58:39 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jan 2019 04:58:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,465,1539673200"; d="scan'208";a="113940173" Received: from gandrejc-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.254.144]) by fmsmga007.fm.intel.com with ESMTP; 11 Jan 2019 04:58:29 -0800 Date: Fri, 11 Jan 2019 14:58:26 +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: <20190111125826.GA5400@linux.intel.com> References: <598cd050-f0b5-d18c-96a0-915f02525e3e@fortanix.com> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190109163135.GA1821@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-sgx-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org 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? /Jarkko