Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1676799ybt; Thu, 25 Jun 2020 11:24:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycYuHxOadLxSAU3ruEnvwmiqlc2+iLKAUwxGGriXI8Ong/vyldhaY8Sg85JmFhlyBZAQyu X-Received: by 2002:a05:6402:144f:: with SMTP id d15mr33022589edx.114.1593109461175; Thu, 25 Jun 2020 11:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593109461; cv=none; d=google.com; s=arc-20160816; b=CKy2g4ieTfnaTqLAHBxwR1xQGTz/iuZ0IB77aznHWtVY6ZKPleykHy5lphKHSXJXa5 k1hTiRm45XtbV4/WvJgmtOsLFHbC0l4chiSYIaxKwMU7boGP54pv33T6FXOuyYWEuZAZ gvY8BEU6X8U7yWqPJ/bPea/tEL3bTHYG+QbGp9j4iwxxyw6MqsrCiUnLOzrYgHjtuXoU ocZdn+M2eHewbUVYHOvUj4iKVXPmpm5zcQUqsZJMixkLTltx2dVRCGbS+MncjqSAj3Vf Un/u7z1fcQa+uAQS3bBQvbN9vNLShUZAkVZ2sA/QCCv3zA+zbTsy7i2+VJ0Qq2I1+iOM Igiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Mz+5XiJg/4gIbNnFRXTUvB5IcOGglq3P9cG4urMJ7vU=; b=Gu68yrgmL1sUIPhit2KJ9s8MGbAsIO3PkQ4JQqSpWhL7A6G/kC3erN00oSASmtlL81 bXGb5GxGGwlIdxLqYNSIK/ST5jjyPPieNNr5idlYJAMb53ryQo84rZIC2dj7e8EBAu9c BMhI43VP7ZlQjumrruPnLouMZi9kE1eFBy7ZOvzx1NOgUxIr/XD3DS2GUuyu3DiVQB6A uOXsrwyGtzSTYVeuDhr1IwLEDOpkzxbSwS6WxKR8Ido28VZ1g6sXyfzQNuCkQfbFgLzi 4e9IURhlVvSnCMAzM+aUWnDL/vtKuP9ZWbGLMdORkKjF3Om1CxGGv0sZFscte5qidQDx JExA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=EBvs8dVZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w22si35941ejb.729.2020.06.25.11.23.57; Thu, 25 Jun 2020 11:24:21 -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; dkim=pass header.i=@alien8.de header.s=dkim header.b=EBvs8dVZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404435AbgFYRG4 (ORCPT + 99 others); Thu, 25 Jun 2020 13:06:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404317AbgFYRGz (ORCPT ); Thu, 25 Jun 2020 13:06:55 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE21DC08C5C1; Thu, 25 Jun 2020 10:06:55 -0700 (PDT) Received: from zn.tnic (p200300ec2f0ed10035c3b797f40e07e6.dip0.t-ipconnect.de [IPv6:2003:ec:2f0e:d100:35c3:b797:f40e:7e6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 0DE871EC0105; Thu, 25 Jun 2020 19:06:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1593104814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=Mz+5XiJg/4gIbNnFRXTUvB5IcOGglq3P9cG4urMJ7vU=; b=EBvs8dVZOaWaDuc/gmJa2Bc0TxHA4tvP0dlRrrmW8TvNyIt6SjeMoWS3Pea6bE0zAXaiGN DUqHYuo4KMyxvUedS9DfQn3hzSPQwTINHJ3HO/puwU8P3cUbx8PBp518oDjvxLWdy8S6/b p0jtl3j9Ri4qysa/tgRLeq0mXif4RBk= Date: Thu, 25 Jun 2020 19:06:48 +0200 From: Borislav Petkov To: Jarkko Sakkinen 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: <20200625170648.GH20319@zn.tnic> References: <20200617220844.57423-1-jarkko.sakkinen@linux.intel.com> <20200617220844.57423-10-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200617220844.57423-10-jarkko.sakkinen@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette