Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3301760imu; Mon, 17 Dec 2018 17:33:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/UvOx49jSAm3gpF0qyOabrlLRBmGvHKvbQP38EvL0UpX9xaUO+G/2JAUwc8gOrh4XXCk04y X-Received: by 2002:a62:2b8b:: with SMTP id r133mr14877648pfr.246.1545096787166; Mon, 17 Dec 2018 17:33:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545096787; cv=none; d=google.com; s=arc-20160816; b=rBZaGNtZN2DlmHXL9+dhZvwiwK+1jDsAxzDkYFz9za0t1MrG1HRbhLbbjJ0No0IOlw JjViHyaxmyhBlA9OycnibjmbQcELPjDrnbU5ak15pqyRMneeNKp78n5CGOu3BTZ9P3RN fsaAxbn/jPFMjCV6S2xwyixrohbemM5BlhlMKWaTHJIAdxTLNLuTUh3PRpc80ed+He5r 7bBHDaZaqn9LW/5muZhQKF/OIohUH2ixzpAaCwuan3zArutKZ+OY8cko66QILxd3JYdG WAi1CNMrghAZe1rV8FBK8K1gbjIyIcK/7fUQpR77wTSO7UAWUtq/MYUfEdLIpMaX5tTm niwQ== 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=c+GyliCa0gLr1aErHO0j/zJZOJo6YlinrrYSXGDpfBM=; b=ROQHeiYvpkgc6XQf2f9YmwC5Rbqs/bY/K5rnB0Qr8ya6ee4LDbl+pEq0+gP6ew0F2X x4bTWFU4aHl21pwNM433LQKV9T6dLzwcVCx1rwAUDNL/rpvN4dyShMDHCayDE1DlV4/p jdaTZI/i81DvKtPRhCBUipA19Nfr8QVjnen9lZB1FCDIfVV8NsASuvOF++X059T4KH6k xFfOWvDFSoo/7W0pxGNffTuUVPQ4/WOuaWFddmkLELJBeggsU05d98m/nggMvsBg3LkE ZeSYNBkYV4SYgaNeOjC4pNfO2RU/B9+c8mF7Fa4ZRAlFZPdhYw6KjhEgxnAb0/MsMs9r WuYw== 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 b10si11664179plz.233.2018.12.17.17.32.50; Mon, 17 Dec 2018 17:33:07 -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 S1726419AbeLRBb6 (ORCPT + 99 others); Mon, 17 Dec 2018 20:31:58 -0500 Received: from mga07.intel.com ([134.134.136.100]:54391 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbeLRBb6 (ORCPT ); Mon, 17 Dec 2018 20:31:58 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2018 17:31:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,367,1539673200"; d="scan'208";a="101455411" Received: from unknown (HELO localhost) ([10.249.254.218]) by orsmga006.jf.intel.com with ESMTP; 17 Dec 2018 17:31:46 -0800 Date: Tue, 18 Dec 2018 03:31:44 +0200 From: Jarkko Sakkinen To: Andy Lutomirski Cc: Dave Hansen , Sean Christopherson , X86 ML , Platform Driver , linux-sgx@vger.kernel.org, nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, Haitao Huang , Andy Shevchenko , Thomas Gleixner , "Svahn, Kai" , mark.shanahan@intel.com, Suresh Siddha , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Darren Hart , Andy Shevchenko , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v17 18/23] platform/x86: Intel SGX driver Message-ID: <20181218013144.GB333@linux.intel.com> References: <20181116010412.23967-1-jarkko.sakkinen@linux.intel.com> <20181116010412.23967-19-jarkko.sakkinen@linux.intel.com> <7d5cde02-4649-546b-0f03-2d6414bb80b5@intel.com> <20181217180102.GA12560@linux.intel.com> <20181217183613.GD12491@linux.intel.com> <20181217184333.GA26920@linux.intel.com> <20181218011725.GA333@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181218011725.GA333@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 Tue, Dec 18, 2018 at 03:17:25AM +0200, Jarkko Sakkinen wrote: > On Mon, Dec 17, 2018 at 11:12:21AM -0800, Andy Lutomirski wrote: > > I'm going to ask an obnoxious high-level question: why does an enclave > > even refer to a specific mm? > > The reason is that it has not been yet in focus in the review process > and there has been other concerns. > > At least the code is fairly stable i.e. working code is usually good > starting point for making something different (ignoring the recent > regression caused by the shmem to VMA migration). > > > If I were designing this thing, and if I hadn't started trying to > > implement it, my first thought would be that an enclave tracks its > > linear address range, which is just a pair of numbers, and also keeps > > track of a whole bunch of physical EPC pages, data structures, etc. > > And that mmap() gets rejected unless the requested virtual address > > matches the linear address range that the enclave wants and, aside > > from that, just creates a VMA that keeps a reference to the enclave. > > (And, for convenience, I suppose that the first mmap() call done > > before any actual enclave setup happens could choose any address and > > then cause the enclave to lock itself to that address, although a > > regular anonymous PROT_NONE MAP_NORESERVE mapping would do just fine, > > too.) And the driver would explicitly allow multiple different mms to > > have the same enclave mapped. More importantly, a daemon could set up > > an enclave without necessarily mapping it at all and then SCM_RIGHTS > > the enclave over to the process that plans to run it. > > The current SGX_IOC_ENCLAVE_CREATE ioctl would be trivial to change to > use this approach. Instead looking up VMA with an enclave instance it > would create a new enclave instance. > > Then we could have SGX_IOC_ENCLAVE_ATTACH to attach an enclave to a VMA. > > This does not sound too complicated. > > > Now I'm sure this has all kinds of problems, such as the ISA possibly > > making it rather obnoxious to add pages to the enclave without having > > it mapped. But these operations could, in principle, be done by > > We do EADD in a kthread. What this would require to put current->mm > into a request that it is processed by that thread. This would be > doable with mmget(). Correction here. We need mm just for vm_insert_pfn(), which would be removed, no need to pass mm. /Jarkko