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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 90D5BC433E6 for ; Tue, 26 Jan 2021 12:35:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A63423129 for ; Tue, 26 Jan 2021 12:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403895AbhAZMfV (ORCPT ); Tue, 26 Jan 2021 07:35:21 -0500 Received: from mail.skyhub.de ([5.9.137.197]:37846 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403968AbhAZKY5 (ORCPT ); Tue, 26 Jan 2021 05:24:57 -0500 Received: from zn.tnic (p200300ec2f0d1100bcf83db545f09974.dip0.t-ipconnect.de [IPv6:2003:ec:2f0d:1100:bcf8:3db5:45f0:9974]) (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 CB2CF1EC04DE; Tue, 26 Jan 2021 11:24:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1611656648; 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=gmVhkBSNYh2tQM3hLJDqtgcOU5M+oLAy/Q1t/J7w2Gk=; b=FbU5kNmHpPusFNCpBVV5pBGxok6dOmS9QwJ6bVkKdPfT7PHs705uVSTLAyXV8gGzlJ8ux6 gUOiHGr/iUmtLqd1K9d8Y+Nk80FL78ISu5YOtpOcY0Tc8Zmt0wPfsOsYp34A402Kxg9lZA GWVwADHhKN+WmOmtyVVFjcQe2CSNW4o= Date: Tue, 26 Jan 2021 11:24:04 +0100 From: Borislav Petkov To: "Yu, Yu-cheng" 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 , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu Subject: Re: [PATCH v17 11/26] x86/mm: Update ptep_set_wrprotect() and pmdp_set_wrprotect() for transition from _PAGE_DIRTY to _PAGE_COW Message-ID: <20210126102404.GA6514@zn.tnic> References: <20201229213053.16395-1-yu-cheng.yu@intel.com> <20201229213053.16395-12-yu-cheng.yu@intel.com> <20210125182709.GC23290@zn.tnic> <8084836b-4990-90e8-5c9a-97a920f0239e@intel.com> <20210125215558.GK23070@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 25, 2021 at 02:18:37PM -0800, Yu, Yu-cheng wrote: > For example, when a thread reads a W=1, D=0 PTE and before changing it to > W=0,D=0, another thread could have written to the page and the PTE is W=1, > D=1 now. When try_cmpxchg() detects the difference, old_pte is read again. None of that is mentioned in the comment above it and if anything, *that* is what should be explained there - not some guarantee about some processors which doesn't even apply here. Also, add the fact that try_cmpxchg() will update old_pte with any modified bits - D=1 for example - when it fails. As Peter just explained to me on IRC. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette