From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD147C4363D for ; Tue, 22 Sep 2020 14:04:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5EBFE20719 for ; Tue, 22 Sep 2020 14:04:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EBFE20719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D9C55900063; Tue, 22 Sep 2020 10:04:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D71056B00EB; Tue, 22 Sep 2020 10:04:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3833900063; Tue, 22 Sep 2020 10:04:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id A5A076B00E6 for ; Tue, 22 Sep 2020 10:04:09 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 679AA8249980 for ; Tue, 22 Sep 2020 14:04:09 +0000 (UTC) X-FDA: 77290866618.11.taste06_3704a9d2714e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 493F0180FA17D for ; Tue, 22 Sep 2020 14:04:01 +0000 (UTC) X-HE-Tag: taste06_3704a9d2714e X-Filterd-Recvd-Size: 4463 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 14:03:59 +0000 (UTC) IronPort-SDR: s1YimN14WbQyD8P7YNh0kfPJ7VLmKbhm443xSz+B4q9fRzh/alLV1DmB8dQLL8yXFbXJxUJaR3 m2DSv0fxGBcQ== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="224753754" X-IronPort-AV: E=Sophos;i="5.77,290,1596524400"; d="scan'208";a="224753754" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2020 07:03:35 -0700 IronPort-SDR: //JSbquJ3crr4TnUhHSTmhoc61lX1lZnrVo/7i0jEjzvAlM9YcztaO3dOz1MyPS+XOyldSh/i7 Jgkt4gJvsYXA== X-IronPort-AV: E=Sophos;i="5.77,290,1596524400"; d="scan'208";a="485970502" Received: from haijindi-mobl.ger.corp.intel.com (HELO localhost) ([10.249.47.132]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2020 07:03:25 -0700 Date: Tue, 22 Sep 2020 17:03:23 +0300 From: Jarkko Sakkinen To: Borislav Petkov Cc: x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jethro Beekman , Jordan Hand , Nathaniel McCallum , Chunyang Hui , Seth Moore , 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, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v38 16/24] x86/sgx: Add a page reclaimer Message-ID: <20200922140314.GA164527@linux.intel.com> References: <20200915112842.897265-1-jarkko.sakkinen@linux.intel.com> <20200915112842.897265-17-jarkko.sakkinen@linux.intel.com> <20200922104538.GE22660@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200922104538.GE22660@zn.tnic> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Sep 22, 2020 at 12:45:38PM +0200, Borislav Petkov wrote: > > + * %SGX_ENCL_PAGE_VA_OFFSET_MASK: Holds the offset in the Version Array > > + * (VA) page for a swapped page. > > * %SGX_ENCL_PAGE_ADDR_MASK: Holds the virtual address of the page. > > * > > * The page address for SECS is zero and is used by the subsystem to recognize > > ... So what's wrong over here? > > @@ -86,24 +123,34 @@ static int sgx_encl_create(struct sgx_encl *encl, struct sgx_secs *secs) > > { > > unsigned long encl_size = secs->size + PAGE_SIZE; > > struct sgx_epc_page *secs_epc; > > + struct sgx_va_page *va_page; > > struct sgx_pageinfo pginfo; > > struct sgx_secinfo secinfo; > > struct file *backing; > > long ret; > > > > + va_page = sgx_encl_grow(encl); > > + if (IS_ERR(va_page)) > > + return PTR_ERR(va_page); > > + else if (va_page) > > Not "else" simply? > > AFAICT, sgx_encl_grow() would either return an ERR_PTR or the actual > page... > > Also, should the growing happen *after* the SECS validation? Yes, it would make sense. I'll move it. > Let's add some comment blurb about "Write back/invalidate an EPC page" > to at least start to explain what that "ewb" is. OK, I'll try to write something understandable. > > + spin_lock(&sgx_active_page_list_lock); > > + for (i = 0; i < SGX_NR_TO_SCAN; i++) { > > + if (list_empty(&sgx_active_page_list)) > > Isn't it enough to do this once, i.e., not in the loop? You're holding > sgx_active_page_list_lock... I think that would make sense. Distantly analogous to the EINIT discussion. Too complex code for yet to be known problem workloads I'd say. > > static void sgx_sanitize_section(struct sgx_epc_section *section) > > ... Is this about documenting this function? > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette Thanks, this was valuable feedback. /Jarkko