Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp106671ybt; Thu, 25 Jun 2020 16:35:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxq5yVU1RfIm/Rn3u7EkndC3zu3lm3EBGh6hwFw8IK1TFP/TjTApdHPxJI9OCEGumPU549z X-Received: by 2002:aa7:da4f:: with SMTP id w15mr651499eds.384.1593128143866; Thu, 25 Jun 2020 16:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593128143; cv=none; d=google.com; s=arc-20160816; b=dB9d9M8CASs97XPaRFH+ngUlYss0+NwhA34PQmIdDSL3I4V0h69Yo7qAlKTQUMVdvj Eep13RHEbktr4xVT52/CG+q4s9DmATAqEDBt5qrtmyuBMIQbl5zWg31ctMmgO1y/Ro/j 0xbr8J64Eed0dpSU5xwjCynretAs0cH9fP1S0GmtjOjc6VAXFloqKw9RRptOVwUME8gq WUuB1k9d6BictLjb5ZYosbP2fECiabQeW9/ldNOYkiekh2YZGucOk3DwpQCQrlJOwEQe fwN2wYz56z1x02rSe+9aD95tPZbrFLmSXup3CUrqw6bdrL0EuvvHYXsKfUj5g8Z0ndL9 Ch4g== 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=KZm/oDaB5rvsM83XsC3/UJmTqFo/4ZsJ3qaLZ6RiTGg=; b=tAOruY1suDNHGiBUsF4cfyvWdHG7qj/QWQi9BYpjOG5MnzI/QnK5inD/3wm7uPiPCd zgVStfeojBLNmi7fhvx5Trqfd5h8ib9T8h/jwztn1+/UrMjbLzI56+irqF0wRkMP4LOy ZDKNk0vi5hbP/6G8CbQ5fFHp9cV1C64LnIxgR9utWoIdp3m6bGPZltl/q1e7M1E3SPaX NfDZc7kuRETzqyMpfZpJ9xmWouiY3FIBc/n/IQ8SoasNiDvORsKyQ2yoI9/SmX7L3gk7 BYKc3kRr/7eOKfjVviWDjYkNz2W6J6JjCZmGrZizVYgCZovAqts0sMu8vMNZ7qQusleL A0bA== 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 y24si16340730edu.80.2020.06.25.16.35.18; Thu, 25 Jun 2020 16:35:43 -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 S2405401AbgFYUz2 (ORCPT + 99 others); Thu, 25 Jun 2020 16:55:28 -0400 Received: from mga05.intel.com ([192.55.52.43]:59156 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405184AbgFYUz1 (ORCPT ); Thu, 25 Jun 2020 16:55:27 -0400 IronPort-SDR: 3Sem9uUCndJnPauK8KKqZO9ZjjETWW875nGGPmXcJMdvd89i/x0sBkAgCEVUW6s0XXgwhTRI7P s1VZ9voSeobA== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="229804796" X-IronPort-AV: E=Sophos;i="5.75,280,1589266800"; d="scan'208";a="229804796" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2020 13:55:26 -0700 IronPort-SDR: H2kX/ypC4IrLeOWQfnoGzaLLbEEfEX8H3LnF0hIq1Olox27cM/jkWYvQNCXBStALC6gfGqaLvt DvEMyuswu+Kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,280,1589266800"; d="scan'208";a="479775209" Received: from drews-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.49.247]) by fmsmga005.fm.intel.com with ESMTP; 25 Jun 2020 13:55:16 -0700 Date: Thu, 25 Jun 2020 23:55:05 +0300 From: Jarkko Sakkinen To: Borislav Petkov Cc: x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Jethro Beekman , Sean Christopherson , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v33 09/21] x86/sgx: Add __sgx_alloc_epc_page() and sgx_free_epc_page() Message-ID: <20200625205505.GD15394@linux.intel.com> References: <20200617220844.57423-1-jarkko.sakkinen@linux.intel.com> <20200617220844.57423-10-jarkko.sakkinen@linux.intel.com> <20200625170648.GH20319@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200625170648.GH20319@zn.tnic> 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, Jun 25, 2020 at 07:06:48PM +0200, Borislav Petkov wrote: > On Thu, Jun 18, 2020 at 01:08:31AM +0300, Jarkko Sakkinen wrote: > > Add __sgx_alloc_epc_page(), which iterates through EPC sections and borrows > > a page structure that is not used by anyone else. When a page is no longer > > needed it must be released with sgx_free_epc_page(). This function > > implicitly calls ENCLS[EREMOVE], which will return the page to the > > uninitialized state (i.e. not required from caller part). > > > > Acked-by: Jethro Beekman > > Co-developed-by: Sean Christopherson > > Signed-off-by: Sean Christopherson > > Signed-off-by: Jarkko Sakkinen > > --- > > arch/x86/kernel/cpu/sgx/main.c | 61 ++++++++++++++++++++++++++++++++++ > > arch/x86/kernel/cpu/sgx/sgx.h | 3 ++ > > 2 files changed, 64 insertions(+) > > > > diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c > > index c5831e3db14a..b776d249289f 100644 > > --- a/arch/x86/kernel/cpu/sgx/main.c > > +++ b/arch/x86/kernel/cpu/sgx/main.c > > @@ -83,6 +83,67 @@ static bool __init sgx_page_reclaimer_init(void) > > return true; > > } > > > > +static struct sgx_epc_page *__sgx_alloc_epc_page_from_section(struct sgx_epc_section *section) > > +{ > > + struct sgx_epc_page *page; > > + > > + if (list_empty(§ion->page_list)) > > + return NULL; > > + > > + page = list_first_entry(§ion->page_list, struct sgx_epc_page, list); > > + list_del_init(&page->list); > > <---- newline here. > > > + return page; > > +} > > Otherwise looks good; nice comments. Thanks! > > Thx. > > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette /Jarko