Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp203718ybj; Wed, 6 May 2020 15:17:10 -0700 (PDT) X-Google-Smtp-Source: APiQypJnFcOsKLQHEOaEmjfeGDByNiQD+NdwVpKCEmveAJWeysJZXdYmx4zoOO2S5567dZkzCaCa X-Received: by 2002:a17:906:1690:: with SMTP id s16mr8753736ejd.339.1588803430350; Wed, 06 May 2020 15:17:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588803430; cv=none; d=google.com; s=arc-20160816; b=lVU8nkk43N8As4AEqSMwqaGagKBZfk2Lc/yRwwwQh5JTGU5AOTnFZiI3F6/P7J0+RF RJmbGydhag+ofl819k+z19bUGbA7LfdBJ5D6+c1TFtm6jZijxK+NgbQ8YVIfUeCP/Iba 7CZlp+IUx7XodJScFeuos28oM77yp+h0JU5TQhOZAqWZ4FI1+sPKZjacGd74dzZLgrEG ifaGvFsff1+dNWQDtaow0kez6ikTM0F2N5uFsHg6oJIabNuvR/XJjkOYW7Wm9Plfom1z NiE2DdNKbM46eYkEwggVrOssZk7eH3lZVrz7Y89XvH1iRbuOVJNScN2u6JpWEFtDtc5z jh5Q== 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:ironport-sdr:ironport-sdr; bh=ww/72mboi2fEVu4aAH9jCbKNxMqqrmfivRnKnrKkI4c=; b=jumH0mGpLLUfnA5EDnpQop4BjG6/4924UDShFhO7T9dIAbngLwA8q79h+C+TN0VtHF OVEoNVNRyQxQtBPcKX8X7IZtWchJsbFsENvE8ULOkb6u8bYJ0dwJg2oeAkN/EHlEXwr5 zNw1Bm1XuTwFxmDQTTui27Ry6vqt+5u2vslflRAjWJkmDZ8DDY/l+ItwlmAMekfYSsCm /wu5nT1edcPS8DO1iIY4YzXlbt5Q1PLWsLkO1hYCdNqULJS9Z13JyRsejmn8HbYL5Fnd WnV05LSrIaja/zJa87oSY79iWCl3Ea33t0kQcAnt2TFcxCJyQ+AU/v+JD5FSp6yn1DX1 ijEA== 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 dv11si2068209ejb.136.2020.05.06.15.16.47; Wed, 06 May 2020 15:17:10 -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 S1729967AbgEFWOY (ORCPT + 99 others); Wed, 6 May 2020 18:14:24 -0400 Received: from mga02.intel.com ([134.134.136.20]:5914 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729907AbgEFWOY (ORCPT ); Wed, 6 May 2020 18:14:24 -0400 IronPort-SDR: MqlXIOF+p6TBh/uiJTNVxso8C9alj+KzpJynjm2p7heVK3cEy9NT6DtBigF4sAOYz+Ft9DWZSW FTOJhVySdNnw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2020 15:14:23 -0700 IronPort-SDR: Uneb1M7Psi3ugumKhUNct7/f26jE2pWT5+4AbHUaJmznhT/LdWVnTzyBAxCk0K46oz1mbrEcmn 1vP8utLkNd9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,360,1583222400"; d="scan'208";a="369930304" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by fmsmga001.fm.intel.com with ESMTP; 06 May 2020 15:14:22 -0700 Date: Wed, 6 May 2020 15:14:22 -0700 From: Sean Christopherson To: Nathaniel McCallum Cc: 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 Message-ID: <20200506221422.GK3329@linux.intel.com> References: <20200421215316.56503-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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. > If we want to keep this mmap() strategy, we probably don't want to > advise mmap(ANON) if it allocates all the memory for the enclave ahead > of time, even if it won't be used. This would be wasteful. > > OTOH, having to mmap("/dev/zero") seems a bit awkward.