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 CDAA2C433F5 for ; Fri, 15 Oct 2021 22:57:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42CDB610D1 for ; Fri, 15 Oct 2021 22:57:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 42CDB610D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id BAF5D6B006C; Fri, 15 Oct 2021 18:57:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5EBB6B0072; Fri, 15 Oct 2021 18:57:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4DA0900002; Fri, 15 Oct 2021 18:57:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 952216B006C for ; Fri, 15 Oct 2021 18:57:23 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3DB3B3A8CD for ; Fri, 15 Oct 2021 22:57:23 +0000 (UTC) X-FDA: 78700184766.26.FA7ADCA Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf03.hostedemail.com (Postfix) with ESMTP id DCA3930000A9 for ; Fri, 15 Oct 2021 22:57:21 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id nn3-20020a17090b38c300b001a03bb6c4ebso8378371pjb.1 for ; Fri, 15 Oct 2021 15:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3MWGSo8J4w0RXdtVwqVMm4uYTHYEHoeo+tcCsWTKSxY=; b=VZHeZzCY3PL4avtmU8lGuY1CvtpVh+tipHevkUmcXAteh4Dobxc3LNJKbXfdW3Afeg 0ZGUGU++NEpP/uTKsyiQaARblf1QCbYOWBGVQCSR+AvKnRxlDtxiRMQHet5qfZ5qYPWg qDV2tH/ubCcZwygo9bw+twYt/FIwJZ8hDUEMMhTlypPSwAAAmCj1UlqGNeiYwXNOUm4p 9n1azARmndnl/R2ZbOht6441KMS/w5CruDP6RlKoE4LUd5rMCik3biKxV6xjY95Oteys Pkm4ZLzJD9gtSDKC3l8IArbE8CrsHWDKy6jJ3m9NijRIN69QLbSu58a5bwH0Gf+dqGWq VFYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3MWGSo8J4w0RXdtVwqVMm4uYTHYEHoeo+tcCsWTKSxY=; b=GBpKQix78eysBS9a463X7bUq/x/CQxK23sbx7jRlZo9V0BuI7RV167O6hSL6faaWwk kVHTvMV+BEYRO3UzCx4ePJDQQC/ZJCD9Mb3A91HFwDVyl636+nktNFRrYa+xKOFxxstE i93hJ7CPez3nLA19hKbamd0HQxR1ANklSX/zwE0dQEL0X0Dtrbf/yh5N0yAeFI+RQH98 5E9fs32OQaTb0iPx5InavSpwK1Ima5Dw6T1FDdDzg3UIa9QYPFHs5Tvymy0zFPIheheV ORUEd02cSHdmcBD/GU3Whrk0NaB+sB9XbcrWvov4iVK76MqlyJd33+jyUBjsd9vo8AtM C69A== X-Gm-Message-State: AOAM531cpyekNBjCPwFm5RH2NrSGd9nfbb3s5sW1us3sV7ttrD67cLWs w219/5QbCmxFZRNXQ7mNEOw7rA== X-Google-Smtp-Source: ABdhPJzDiTg12tYXR/PBHuS6tQb0K8WgqbJknwYLtFfXcCkEwyvPA0Aa3zGr1lqiSa8BFBqwmi26dg== X-Received: by 2002:a17:902:ed0b:b0:13f:4318:491a with SMTP id b11-20020a170902ed0b00b0013f4318491amr13483327pld.4.1634338641488; Fri, 15 Oct 2021 15:57:21 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id x15sm5665489pgo.48.2021.10.15.15.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 15:57:21 -0700 (PDT) Date: Fri, 15 Oct 2021 22:57:17 +0000 From: Sean Christopherson To: Tony Luck 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 1/7] x86/sgx: Add new sgx_epc_page flag bit to mark in-use pages Message-ID: References: <20211001164724.220532-1-tony.luck@intel.com> <20211011185924.374213-1-tony.luck@intel.com> <20211011185924.374213-2-tony.luck@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211011185924.374213-2-tony.luck@intel.com> Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=VZHeZzCY; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of seanjc@google.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=seanjc@google.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: DCA3930000A9 X-Stat-Signature: 8m6jzedn7bdrn4qdc66wmo16e6u9rc3c X-HE-Tag: 1634338641-79920 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 Mon, Oct 11, 2021, Tony Luck wrote: > SGX EPC pages go through the following life cycle: > > DIRTY ---> FREE ---> IN-USE --\ > ^ | > \-----------------/ > > Recovery action for poison for a DIRTY or FREE page is simple. Just > make sure never to allocate the page. IN-USE pages need some extra > handling. > > Add a new flag bit SGX_EPC_PAGE_IN_USE that is set when a page > is allocated and cleared when the page is freed. > > Notes: > > 1) These transitions are made while holding the node->lock so that > future code that checks the flags while holding the node->lock > can be sure that if the SGX_EPC_PAGE_IN_USE bit is set, then the > page is on the free list. > > 2) Initially while the pages are on the dirty list the > SGX_EPC_PAGE_IN_USE bit is set. This needs to state _why_ pages are marked as IN_USE from the get-go. Ignoring the "Notes", the whole changelog clearly states the the DIRTY state does _not_ require special handling, but then "Add SGX infrastructure to recover from poison" goes and relies on it being set. Alternatively, why not invert it and have SGX_EPC_PAGE_FREE? That would have clear semantics, the poison recovery code wouldn't have to assume that !flags means "free", and the whole changelog becomes: Add a flag to explicitly track whether or not an EPC page is on a free list, memory failure recovery code needs to be able to detect if a poisoned page is free so that recovery can know if it's safe to "steal" the page.