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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4021EC433EF for ; Fri, 15 Oct 2021 23:20:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D30C261151 for ; Fri, 15 Oct 2021 23:20:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D30C261151 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 135406B006C; Fri, 15 Oct 2021 19:20:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E6C66B0072; Fri, 15 Oct 2021 19:20:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F17B0900002; Fri, 15 Oct 2021 19:20:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id DF4D66B006C for ; Fri, 15 Oct 2021 19:20:31 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A88FA32346 for ; Fri, 15 Oct 2021 23:20:31 +0000 (UTC) X-FDA: 78700243062.38.CDA0E3B Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf02.hostedemail.com (Postfix) with ESMTP id 49669700177A for ; Fri, 15 Oct 2021 23:20:28 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10138"; a="251453340" X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="251453340" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 16:19:54 -0700 X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="492747609" Received: from agluck-desk2.sc.intel.com (HELO agluck-desk2.amr.corp.intel.com) ([10.3.52.146]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 16:19:53 -0700 Date: Fri, 15 Oct 2021 16:19:52 -0700 From: "Luck, Tony" To: Sean Christopherson Cc: "Rafael J. Wysocki" , naoya.horiguchi@nec.com, Andrew Morton , Jarkko Sakkinen , Dave Hansen , Cathy Zhang , linux-sgx@vger.kernel.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, Reinette Chatre Subject: Re: [PATCH v9 4/7] x86/sgx: Add SGX infrastructure to recover from poison Message-ID: References: <20211001164724.220532-1-tony.luck@intel.com> <20211011185924.374213-1-tony.luck@intel.com> <20211011185924.374213-5-tony.luck@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 49669700177A X-Stat-Signature: ja5uzbqm8j96hsgwecnut91zmszhd639 Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf02.hostedemail.com: domain of tony.luck@intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=tony.luck@intel.com X-HE-Tag: 1634340028-508308 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 Fri, Oct 15, 2021 at 11:10:32PM +0000, Sean Christopherson wrote: > On Mon, Oct 11, 2021, Tony Luck wrote: > > + section = &sgx_epc_sections[page->section]; > > + node = section->node; > > + > > + spin_lock(&node->lock); > > + > > + /* Already poisoned? Nothing more to do */ > > + if (page->poison) > > + goto out; > > + > > + page->poison = 1; > > + > > + /* > > + * If flags is zero, then the page is on a free list. > > + * Move it to the poison page list. > > + */ > > + if (!page->flags) { > > If the flag is inverted, this becomes > > if (page->flags & SGX_EPC_PAGE_FREE) { I like the inversion. I'll switch to SGX_EPC_PAGE_FREE > > > + list_del(&page->list); > > + list_add(&page->list, &sgx_poison_page_list); > > list_move(), and needs the same protection for sgx_poison_page_list. Didn't know list_move() existed. Will change all the lis_del+list_add into list_move. Also change the sgx_poison_page_list from global to per-node. Then the adds will be safe (accessed while holding the node->lock). Thanks for the review. -Tony