Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3191439rwl; Tue, 27 Dec 2022 05:47:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXsWc9k9b9QLhBSVGaL5byl6JfmpaCu+GxGCnC/0KrOFo1O/squNTA3w00CKMC+3lAHJG6RR X-Received: by 2002:a17:906:78c:b0:7ad:e52c:12e6 with SMTP id l12-20020a170906078c00b007ade52c12e6mr18059218ejc.41.1672148829881; Tue, 27 Dec 2022 05:47:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672148829; cv=none; d=google.com; s=arc-20160816; b=ITnAM7aC8KbLgAROp+LjwU9m4KZgFD1DeZz+1P+tXMLIinWbB4dRShbp1g+tnyJBtd C4dm1lOK3RQ12Lw6ZsCkLOiUtp29+oyLFmfVcLv7rjC/zPAAciWHRpT7V6UHWDFazo3p fekq5dF6gtLpqmWEHnjWp1GuJH/gHgWLmPgKyMMYThiT2aUm70/vg8z1jjN0AWLy+C83 isNGLS5CWbIzXsFFLs4xGZ1TCgY7iQtBfxb+Gmg9h/rl4GeFhG6zNU5OQB7/mQ7E2aVS BJUN5Ea5t6X0G7/3UlOraQxpM63lUFkj66aoUVN+6TD8FxxwROx5rguoi7h6gUcaLJUt MLkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2imUoMui1724dAGSPFR9b+ZOTCSq0FVhRuTrmE4wohM=; b=unmhj5RAcNOiSW9TSgfSD/pdH+xzA2QyPO9SCNU4+hBSMsP1IhWjUWt2YXyKAX4g6b x1EzDAubuqqSgENcSGBd1nRMiMrV0Og9KZTrD8ow2Brf5OPc/SmChW3qlxRe71TsM9FB VqkDOxiTRFw6IjBkAhAD+inrdJobIt6OokuFLNMPxamiAHNtbJp+WiyT/JdGA5P4z6Iq Re9ryPXoXBOqzTVjahIG+88bA0+SimSxc3GkLxX55yZcWhnMto5+2uvYDPS6U0lHctCj dePsMw80fG5mlI4oT1aflU20+t7uLWslP1X2xV6dYTiUNVphk1qZZL2/6CKtZF8adrfZ kGHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ayWrv+PA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y14-20020a17090668ce00b007c17665c404si9028617ejr.960.2022.12.27.05.46.54; Tue, 27 Dec 2022 05:47:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ayWrv+PA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229533AbiL0N1A (ORCPT + 66 others); Tue, 27 Dec 2022 08:27:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231318AbiL0N0h (ORCPT ); Tue, 27 Dec 2022 08:26:37 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8CA77657; Tue, 27 Dec 2022 05:26:36 -0800 (PST) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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