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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C043DC46467 for ; Tue, 27 Dec 2022 13:27:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F41008E0002; Tue, 27 Dec 2022 08:27:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF0CD8E0001; Tue, 27 Dec 2022 08:27:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D91648E0002; Tue, 27 Dec 2022 08:27:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CB53F8E0001 for ; Tue, 27 Dec 2022 08:27:00 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9807E120A3D for ; Tue, 27 Dec 2022 13:27:00 +0000 (UTC) X-FDA: 80288161800.08.A5E3377 Received: from mail.skyhub.de (unknown [5.9.137.197]) by imf20.hostedemail.com (Postfix) with ESMTP id 73A3F1C0004 for ; Tue, 27 Dec 2022 13:26:51 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=temperror ("DNS error when getting key") header.d=alien8.de header.s=dkim header.b=ayWrv+PA; spf=temperror (imf20.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de; dmarc=temperror reason="server fail" header.from=alien8.de (policy=temperror) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672147619; h=from:from:sender: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:dkim-signature; bh=2imUoMui1724dAGSPFR9b+ZOTCSq0FVhRuTrmE4wohM=; b=5dKb3zBRVT/Enwf8nj4s6P7vNvnB0haFBkSHIV0oq9QWxbkxV3L6pqwEIz1Zj/xglAEXFa of8Q91DqgRSOKWR2jW/xM8IgVOo0Ox/IGrAqsykDUNPuUuB+TJIERfdJbkcZDKyGGCJxvH i5cAKHTcjk9H3+zLEuqoaUl5nP7uXfI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=temperror ("DNS error when getting key") header.d=alien8.de header.s=dkim header.b=ayWrv+PA; spf=temperror (imf20.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de; dmarc=temperror reason="server fail" header.from=alien8.de (policy=temperror) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672147619; a=rsa-sha256; cv=none; b=oo0YC5PGFxWjCICBLmkRT0qKfgl4+JKl/1SQiWre5tmR3pnZI3Y9Fczu+Vc9l0+eU6hj1n hqdFxNblq5vDRrfqchCkyikO0N530A7gt6mjYq6Vo3dj7l21FHDTou/PCp16yU7pzxv6c5 4U5lTmVbq33G5770IbkbfYFNFHOODK0= Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (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 2A2FE1EC0662; Tue, 27 Dec 2022 14:26:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1672147595; 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=2imUoMui1724dAGSPFR9b+ZOTCSq0FVhRuTrmE4wohM=; b=ayWrv+PAgEhPD7nCG1JRpZ8rTirCBHp49hpCOP0uc67nnPJpoQhKjpAsuInX2LO5les70s NVGmDTkdtc/E4b6FON8pSbk/qlYjDrIM2VsBfuTCI1Fc57sa/znpXZhTI6H5Q1ZAJnVEZt 1hvRyJRtaggSDl2/NjbOrr7FKnswlIE= Date: Tue, 27 Dec 2022 14:26:30 +0100 From: Borislav Petkov To: Rick Edgecombe Cc: x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, Yu-cheng Yu Subject: Re: [PATCH v4 12/39] x86/mm: Update ptep_set_wrprotect() and pmdp_set_wrprotect() for transition from _PAGE_DIRTY to _PAGE_COW Message-ID: References: <20221203003606.6838-1-rick.p.edgecombe@intel.com> <20221203003606.6838-13-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221203003606.6838-13-rick.p.edgecombe@intel.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 73A3F1C0004 X-Stat-Signature: 31774ar4ryswqj86fexxer1rkaqswnhp X-Rspam-User: X-HE-Tag: 1672147611-829500 X-HE-Meta: U2FsdGVkX1+VTA5R97nOkO/CQdsIXVKWvbRRWuXGU062aXQyOsuyiTpCnTV90v3Cjd6cNaQr1MWm9+dYrxzusdWltO6hY4Q0m+RA6mJv9F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version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Just textual improvements: On Fri, Dec 02, 2022 at 04:35:39PM -0800, Rick Edgecombe wrote: > From: Yu-cheng Yu > > When Shadow Stack is in use, Write=0,Dirty=1 PTE are reserved for shadow Pls, no caps. > stack. Copy-on-write PTes then have Write=0,Cow=1. "... are preserved for shadow stack pages." > > When a PTE goes from Write=1,Dirty=1 to Write=0,Cow=1, it could > become a transient shadow stack PTE in two cases: 1. Some processors ... 2. When _PAGE_DIRTY ... > The first case is that some processors can start a write but end up seeing > a Write=0 PTE by the time they get to the Dirty bit, creating a transient > shadow stack PTE. However, this will not occur on processors supporting > Shadow Stack, and a TLB flush is not necessary. > > The second case is that when _PAGE_DIRTY is replaced with _PAGE_COW non- > atomically, a transient shadow stack PTE can be created as a result. > Thus, prevent that with cmpxchg. > > In the case of pmdp_set_wrprotect(), for nopmd configs the ->pmd operated > on does not exist and the logic would need to be different. Although the > extra functionality will normally be optimized out when user shadow > stacks are not configured, also exclude it in the preprocessor stage so > that it will still compile. User shadow stack is not supported there by > Linux anyway. Leave the cpu_feature_enabled() check so that the > functionality also disables based on runtime detection of the feature. "... also gets disabled ..." Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette