Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp343634ybm; Thu, 28 May 2020 04:21:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHeKPVq0c7xSK46crPr6Ja4eg+xJ4DSUoXnV+q57hOLknep//lDXSI+cNGHppPcleCc9j1 X-Received: by 2002:a17:906:5795:: with SMTP id k21mr2628723ejq.374.1590664901273; Thu, 28 May 2020 04:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590664901; cv=none; d=google.com; s=arc-20160816; b=Svt1fbsVHZb1kD9N8g23z4AdM8odA94TNmp9Fadtwz89stIrfjKs3L0/M87wuv1N89 H/YOL3Dnojt/s1Tz9+BB0SUTH187dN9L00/KE97IX+jBkE8r8YW1omD5wXR8P7uRVZtD iIX5D9qcenPDONrvTKKo5aINi/aJp2a1yWeW/Hxunkb9VrUX4Ns+02V0gY5qp+vnMzAk efSyapUwy/2Xojt3mimYiyrZzzT/M+79ltF4nu5zvG0hhSIMFHwOQr6OHyjUnfMviJfr F0WO0pkZy/lc+FBUQvUSNkCzPIDd7m3pv0BsSO6QD0/okDOZ5zoDz8t1+Urx6guzMIuD q/BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=Un9nMxgpigRs47XlzTgYB81nZOfV2dv/FsqosaPdarM=; b=gLIZaAnOmnazf4rx3RmP+DoF19QTJzDdnx0qPCgjayH0xtoq9xZu23AjVknnug/eqz selrYf+Uj18By2q0Z2Fv03Q9nqX0w0I0K/W6vV0r26ibpQLeQFYP3keJXB/gyH5stG9U wtS/Pr8atYpzyRwVf7JDDu/OVaRUbKvNSWgTXlvI3+YL7hNmFHr01fvdBZDtU2cgETFK 42/UaRpcUv5NKZfo0/T4OBjWgqH9sMsqOJGg/kR3kd0MTPdB2JWTJq5vSrOZMSI13q3h y1NuW9c8HJQyNwO7hJ6fNmUXc0KQ2U+LyVXkOYOlUMliL+tEaPlEyUtk3fRU4QzdJlBX SYZw== 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 ha12si2084135ejb.228.2020.05.28.04.21.17; Thu, 28 May 2020 04:21:41 -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 S2388203AbgE1LTZ (ORCPT + 99 others); Thu, 28 May 2020 07:19:25 -0400 Received: from mga12.intel.com ([192.55.52.136]:36251 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388038AbgE1LTY (ORCPT ); Thu, 28 May 2020 07:19:24 -0400 IronPort-SDR: a2Gr9VjhyEnuXE0OSeAVrS8MXO9GzgdNkGE5eGw5P7uOZTuHc2sazFiQjeTHxPMCx2hDs0q8Xr YT2E59GGp91w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 04:19:23 -0700 IronPort-SDR: NWs0ZnOclAos6PZfcotoMSyvxsfh1+yP9kzS1I2Ca34B0tzLlZUNTIW+urXAEwJCq8+po82Qg7 xRwHP1+gpwMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,444,1583222400"; d="scan'208";a="442913106" Received: from dmescala-mobl1.amr.corp.intel.com (HELO localhost) ([10.252.59.102]) by orsmga005.jf.intel.com with ESMTP; 28 May 2020 04:19:13 -0700 Date: Thu, 28 May 2020 14:19:10 +0300 From: Jarkko Sakkinen To: Sean Christopherson Cc: Haitao Huang , Nathaniel McCallum , 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: <20200528111910.GB1666298@linux.intel.com> References: <20200421215316.56503-1-jarkko.sakkinen@linux.intel.com> <20200506221422.GK3329@linux.intel.com> <20200507193459.GA24519@linux.intel.com> <20200508002555.GA24964@linux.intel.com> <20200528111507.GA1666298@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200528111507.GA1666298@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 02:15:18PM +0300, Jarkko Sakkinen wrote: > On Thu, May 07, 2020 at 05:25:55PM -0700, Sean Christopherson wrote: > > Ah, fudge. shmem_zero_setup() triggers shmem_acct_size() and thus > > __vm_enough_memory(). Which I should have rememered because I've stared > > at that code several times when dealing with the enclave's backing store. > > I wasn't seeing the issue because I happened to use MAP_PRIVATE. > > > > So, bad analysis, good conclusion, i.e. the kernel is still doing the > > right thing, it's just not ideal for userspace. > > > > > > Jarkko, we should update the docs and selftest to recommend and use > > > > PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS > > > > or > > > > PROT_NONE, MAP_SHARED | MAP_NORESERVE | MAP_ANONYMOUS" > > > > when carving out ELRANGE, with an explicit comment that all the normal > > rules for mapping memory still apply. > > Ugh, had forgotten this. > > OK, I guess this comment explains it all: > > " > /* > * shmem_file_setup pre-accounts the whole fixed size of a VM object, > * for shared memory and for shared anonymous (/dev/zero) mappings > * (unless MAP_NORESERVE and sysctl_overcommit_memory <= 1), > * consistent with the pre-accounting of private mappings ... > */ > static inline int shmem_acct_size(unsigned long flags, loff_t size) > " Do not agree though that any documentation should be produced but the selftest should have correct parameters, yes. Instructions on how to reserve a range of addresses simply does not belong to SGX documentation because it is not SGX related in the first place. The patterns you showed are universal. I'll fix just the selftest for v31. /Jarkko