Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1123138ybj; Thu, 7 May 2020 15:34:02 -0700 (PDT) X-Google-Smtp-Source: APiQypIPsPcsuSKOmVm0S2xvGxP84goj5NsuHcmn54f//EUOM/mxbZ3+bTDaNKFtTyZMNdtdWiBE X-Received: by 2002:aa7:cdce:: with SMTP id h14mr14143340edw.51.1588890842708; Thu, 07 May 2020 15:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588890842; cv=none; d=google.com; s=arc-20160816; b=yVOrLKNwYGTtGWqOqv/WU410KaFncyhnOBZcZ4QD8IqA9Scw1VuXdEzQsyhCklOgye Zh+C8Gm5zHA7lOrFxHWFji+YlEafMmmBHLbXVUoZhxWwjPWhoYW8EO5jEjzjs4wVzY4h QKEXgd+1T+f7y7R5uc6TmBQJ0O8xiYw06mTDQLYvIYOekKR+6rihD7gCucZU7CNfK821 WMAB/qSDptMQK2bJRZIEDHKY1nYNqZlPYRxw0ZoC8jgAY1juPTGWJD1+rwi3+zfyTELM /qLbRT6hEz+XgIxRw2ZfW89wcCRh1VK9TV4XTZ/J/zbEhv8bbUKsBq9yu4YrmIaVhtAq QRxw== 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:message-id :organization:from:content-transfer-encoding:mime-version:date :references:subject:cc:to:ironport-sdr:ironport-sdr; bh=yYMIMouVjTZ9Es6StVOir/hU604DmxChLzHi67MqqoE=; b=vHKajzLIA/HIQKwZEtYPKCmPccywyKjwQWpoJHhpZ4MEdqqprmBL4I2wepjTRxCdWb CqgvCugYt1Fd36ZPJf8UkxVqP2nRSoiQRaL2GpI54znlT1eUihyYQ4cLvECSMTLeMYpW 0/1jvRXDDgar6zPpRK5cYZ1EARwoZEH0/qsu8Z2ou+qQ57NDzZm0H3dRYsMoHsCqBwxJ YZpB3kmcEGvhuNQF3RotQuOJb8Mbdfhi6k7tIFBlfUaw8/tIdVuBEaRdbYVmh3Xo7cTj kzUtAMoB8CdAb/UlXQyOr2W79ObLPD3OHFEc4fqdzUlFQdgghzedNBhZDfc822ITQdE5 69eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id c16si3830737edw.172.2020.05.07.15.33.39; Thu, 07 May 2020 15:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726598AbgEGWbn (ORCPT + 99 others); Thu, 7 May 2020 18:31:43 -0400 Received: from mga03.intel.com ([134.134.136.65]:9417 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbgEGWbm (ORCPT ); Thu, 7 May 2020 18:31:42 -0400 IronPort-SDR: x0JDDpSAGYmdhzYLe3Vva7k0tQ8LO0nx1PXMSs9o4eAv2HFE1URSZ4dAyEIwkpKkfdoFTFsClh eVObjR+cWYVw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2020 15:31:42 -0700 IronPort-SDR: kbLRHyo+0ltdd62PrMP06uUWWD7UTdnXadny6XTSmUCZ/fuGQZkBhI1s7viP8JAV8O+0Lr8udz Q97adQ9VwPxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,365,1583222400"; d="scan'208";a="295879649" Received: from hhuan26-mobl1.amr.corp.intel.com ([10.255.72.181]) by fmsmga002.fm.intel.com with ESMTP; 07 May 2020 15:31:40 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Nathaniel McCallum" Cc: "Sean Christopherson" , "Jarkko Sakkinen" , linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, "Neil Horman" , "Huang, Haitao" , andriy.shevchenko@linux.intel.com, tglx@linutronix.de, "Svahn, Kai" , bp@alien8.de, "Josh Triplett" , luto@kernel.org, kai.huang@intel.com, "David Rientjes" , "Xing, Cedric" , "Patrick Uiterwijk" Subject: Re: [PATCH v29 00/20] Intel SGX foundations References: <20200421215316.56503-1-jarkko.sakkinen@linux.intel.com> <20200506221422.GK3329@linux.intel.com> Date: Thu, 07 May 2020 17:31:39 -0500 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Haitao Huang" Organization: Intel Corp Message-ID: In-Reply-To: User-Agent: Opera Mail/1.0 (Win32) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 07 May 2020 11:49:15 -0500, Nathaniel McCallum wrote: > On Thu, May 7, 2020 at 1:03 AM Haitao Huang > wrote: >> >> On Wed, 06 May 2020 17:14:22 -0500, Sean Christopherson >> wrote: >> >> > On Wed, May 06, 2020 at 05:42:42PM -0400, Nathaniel McCallum wrote: >> >> Tested on Enarx. This requires a patch[0] for v29 support. >> >> >> >> Tested-by: Nathaniel McCallum >> >> >> >> However, we did uncover a small usability issue. See below. >> >> >> >> [0]: >> >> >> https://github.com/enarx/enarx/pull/507/commits/80da2352aba46aa7bc6b4d1fccf20fe1bda58662 >> > >> > ... >> > >> >> > * Disallow mmap(PROT_NONE) from /dev/sgx. Any mapping (e.g. >> >> anonymous) can >> >> > be used to reserve the address range. Now /dev/sgx supports only >> >> opaque >> >> > mappings to the (initialized) enclave data. >> >> >> >> The statement "Any mapping..." isn't actually true. >> >> >> >> Enarx creates a large enclave (currently 64GiB). This worked when we >> >> created a file-backed mapping on /dev/sgx/enclave. However, switching >> >> to an anonymous mapping fails with ENOMEM. We suspect this is because >> >> the kernel attempts to allocate all the pages and zero them but there >> >> is insufficient RAM available. We currently work around this by >> >> creating a shared mapping on /dev/zero. >> > >> > Hmm, the kernel shouldn't actually allocate physical pages unless >> they're >> > written. I'll see if I can reproduce. >> > >> >> For larger size mmap, I think it requires enabling vm overcommit mode 1: >> echo 1 | sudo tee /proc/sys/vm/overcommit_memory > > Which means the default experience isn't good. > Yes, it is not good default. But this is not sgx specific IIUC. Normal applications would have the same issue if they ask for large mapping than whatever limit kernel enforces by default.