Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp195731ybm; Wed, 27 May 2020 23:57:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVN4i8kGZ/CzNyh5BhLM19Q1tJIpxIdsOLETNWK8wjEE6PCln2bPEBM6VwoizvG/NXmUlp X-Received: by 2002:aa7:dad0:: with SMTP id x16mr1653896eds.354.1590649033692; Wed, 27 May 2020 23:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590649033; cv=none; d=google.com; s=arc-20160816; b=DxVhsNluTZLEgsukDGrr2q9UlJ/xlNROM/SkoBWxXMfQ4231172ZU8D419nnKXeUpQ bGy2mvXENTb5ZQ8KBS6kwmQvRLdZGclWmgfllZFK8CSu5UUxMXibrkBI9yq9IhBsobTL gfARmzU9wjYGhgBAWzgIG/zezJbHoVtije6P+6O0f83ST3gVE+P3sAvrgJG5l2J294Mc 7gL8Vk5GPQQ69IAf/ETKXIqtHq98udxKahm8jlX+8RJBMoXEjxHqT5a5W5Y7xZEHhxHv AmYgoGzu8FWc0KtPF0DhvW2pIyhnvdh8jn0YQLAPelOkcbAZnGnCB5ijcxRQYaa1DnGv UKRA== 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=zIX6nMyN4Qc/Gd2Na0DUlDDjKGylzhu5UXtJdt2uwrI=; b=jDWyKHn57LbX5pfC20taDCYTphoCRqfqN1tXeOHpuYlsj0ZGvn4+uoAMu10fGAQQtr Mn2kyEyodiAgBRMt7sUcgSYQ9Vz3paMelygpRV+T6/4s7n0tm7VfQUjt7z0RBJv5Lp/j cWtIUTTZaSrOo5nQgcu8mtpWyMUzrc/niWsISZOK0izUcI3M4Bzcdx7IAoFDVsYamzhP uE4uvPONJal6oRJq0L9+TRTocJlDM1bRcmdgb7zUpFRP9xIt5wSTChu39HfR9lv15Eb0 shxzuJF+YKG3g90N0gANpalrAtFE/P6bVru+Mh98QkLumXWnkewD5RxSJ4LgH2dz6jYn U0kw== 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 pw15si3395824ejb.583.2020.05.27.23.56.50; Wed, 27 May 2020 23:57:13 -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 S1725846AbgE1Gwe (ORCPT + 99 others); Thu, 28 May 2020 02:52:34 -0400 Received: from mga03.intel.com ([134.134.136.65]:58192 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbgE1Gwe (ORCPT ); Thu, 28 May 2020 02:52:34 -0400 IronPort-SDR: Yf/wrz06MIODuTzxQlsrdd7eEGI4rM98fnCL15l+6FCbc3mugp38njZUq4YD0fszJ/GTBJhCJ5 EUE1r1s+uIXw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2020 23:52:34 -0700 IronPort-SDR: nzLoNI+bhUndUVmfUQVSmr6S/Nufin6J4EAut0UP3tpxQTZ+D4kuCH22koxCHN+FxYSTnaE5FF J7Ah1wkgzeKw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,443,1583222400"; d="scan'208,217";a="267116787" Received: from dmescala-mobl1.amr.corp.intel.com (HELO localhost) ([10.252.59.102]) by orsmga003.jf.intel.com with ESMTP; 27 May 2020 23:52:25 -0700 Date: Thu, 28 May 2020 09:52:23 +0300 From: Jarkko Sakkinen To: Sean Christopherson Cc: Borislav Petkov , linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, nhorman@redhat.com, npmccallum@redhat.com, haitao.huang@intel.com, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, kai.svahn@intel.com, josh@joshtriplett.org, luto@kernel.org, kai.huang@intel.com, rientjes@google.com, cedric.xing@intel.com, puiterwijk@redhat.com, Jethro Beekman Subject: Re: [PATCH v30 08/20] x86/sgx: Add functions to allocate and free EPC pages Message-ID: <20200528065223.GB188849@linux.intel.com> References: <20200515004410.723949-1-jarkko.sakkinen@linux.intel.com> <20200515004410.723949-9-jarkko.sakkinen@linux.intel.com> <20200526125207.GE28228@zn.tnic> <20200527042111.GI31696@linux.intel.com> <20200527204638.GG1721@zn.tnic> <20200528012319.GA7577@linux.intel.com> <20200528013617.GD25962@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200528013617.GD25962@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 Wed, May 27, 2020 at 06:36:18PM -0700, Sean Christopherson wrote: > On Thu, May 28, 2020 at 04:23:19AM +0300, Jarkko Sakkinen wrote: > > On Wed, May 27, 2020 at 10:46:38PM +0200, Borislav Petkov wrote: > > > On Tue, May 26, 2020 at 09:21:11PM -0700, Sean Christopherson wrote: > > > > In other words, sgx_alloc_epc_section() is poorly named. It doesn't > > > > actually allocate EPC, it allocates kernel structures to map and track EPC. > > > > sgx_(un)map_epc_section() would be more accurate and would hopefully > > > > alleviate some of the confusion. > > ... > > > I'm not sure I follow fully Sean's reasoning but the way alloc is used > > mostly in Linux is to ask through some API the used kernel memory > > allocator to give memory for some kernel data structures. > > Function names are usually some form of > > __ > > where 'object' is the target of the 'verb'. So sgx_alloc_epc_section() > is most likely going to be read as "SGX, allocate an EPC section". But > that code doesn't allocate an EPC section, it maps an EPC section, and on > success, adds the section's pages to the unsanitized list, i.e. what > effectively becomes the pool of EPC pages. The allocation part is a side > effect of how we track EPC pages, it's not the primary purpose of the > function. > > Maybe sgx_add_epc_section() and sgx_remove_epc_section() would be better > than map/unmap? > > Eliminating the misnamed sgx_alloc_epc_section() frees up the "alloc" verb > for use in the actual EPC page allocation paths, i.e. avoids having to > rename those to "grab". IMO, "alloc" is the best name as it most closely > aligns with the nomenclature for regular pages, e.g. "grab" is most often > used to elevate refcounts. I'm thinking that you are over-engineering something this :-) Naming is never perfect. But I do get the original comment about sgx_alloc_page(). /Jarkko