Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3577826rwb; Mon, 3 Oct 2022 17:58:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Q9loxg0N1u3FNKMPoxHo0jUE+4cZAq0Y+R0eAICuEfzfyvP0NV50cQLMFTZ9L0IoAiyQv X-Received: by 2002:a05:6402:410:b0:451:ea13:4ed7 with SMTP id q16-20020a056402041000b00451ea134ed7mr21939490edv.262.1664845112234; Mon, 03 Oct 2022 17:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664845112; cv=none; d=google.com; s=arc-20160816; b=ofqzNQpotk26PT7+SHICZ+RdMNPIS1P0O+xx0s+x/USNLF0uXKbbhaRcvFhg9uWETr QqW9kguRMYCF1aeRoD5zM9pRRkiBpmvNNqVHsNji+1VhsM9qDnp/sNBfVZTnqw45oALO YsqJi29l6GyFrlfVG33F6h5yrAxBrM/3WCRk3pVg8J8DRxrUj38XgeYuI6WOakwgbnNC y5TKJCpk6Y/6pwdEUX7ZUzyIthBJQPvgxvIZ08FA4Z8/Oi8asGUEBC5uVJ9pNHxmwlRy KlRfsVrjpHcmFX/gtXwbGqE/mr3ec/pXVQ02oa28gOXLj901xf8zurkQLsqvSXoUi1h9 HESw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=+/Mka7TP1STCGf7CSP8aOzP/j3ypJV5FS9jSff6Kndw=; b=RY4z4J3g8vQsJ/BffmvAom86wnviLo+C/WBZtML02YrexCnvoDxx00/RaeEK0G2CaO 8dnKJ07mdhpBorz2PKG0REDDhydwstoaH86nYCLoFz5VkiInqwcU4gz6D0sLxKs9EzlU uRrTGhmgXD/3SRA0PBJJ0rBn8Kpzrp+2qbEIHy5KbtgKe7zvtczCsyJRxyP6+nOdWHs0 gC9wwdPl6tryp0yXetfpoMWyZGfH025nNDf256omIgRrkBr6BK9inSWwFRPE7J6tHJvT +mZf7LHEboVd1O0RLQJ1Z4D7Ia50McpozlHlcYjw0onkm0dhQeSpcEjTlYKWr6ONk+vY EQDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pqGdfqbW; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw18-20020a170906479200b0077b83f3dc20si10433538ejc.63.2022.10.03.17.58.06; Mon, 03 Oct 2022 17:58:32 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=pqGdfqbW; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbiJDAkm (ORCPT + 99 others); Mon, 3 Oct 2022 20:40:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiJDAki (ORCPT ); Mon, 3 Oct 2022 20:40:38 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B6FA2AC73; Mon, 3 Oct 2022 17:40:37 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so16907710pjq.3; Mon, 03 Oct 2022 17:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date; bh=+/Mka7TP1STCGf7CSP8aOzP/j3ypJV5FS9jSff6Kndw=; b=pqGdfqbWYJvqI2Of+PeOx1WBv1PrdAmEktEt7KtFjMrkdmsQC2jJJ4M8vwN1VzfOC/ cJJbBHE6qti1z5u6bdoOqHQoT3YaUiozafzRvBx+uOVs+FEl3qJcdMnNCeeoLV8gIgff GJjNkTGx9eG2X0YsJzb+B5nmJIHSHB7MYnI3XMTIVBzMFilMBSCTBGYSP0GirTgQ72Bl sh++kqoZKYfpQepDCFQHl6FJ8WLD49clt5FXCIwPVk4bMiDiYsCfPPFDISO6Sq8xBxtS peDXEHcnp0mmAzaIfMx9s1sh1KTB27TXbSIun9uHTiFK9aDcdWIkJtybIe5iYgve+/6F RclA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=+/Mka7TP1STCGf7CSP8aOzP/j3ypJV5FS9jSff6Kndw=; b=4QkSS2rNbphzkNJhy2m8HWQOowZJnc6mLWzw3dMCxm5UQQljBpBoAD1hBIq2So/Ff+ uDkX+L8O4jo6Wrldm98S9VCWoQgRNiBwXg0odgV7cfoa46LoAIfBRMS7ysPTk7e1Hds3 lFl4OC+/8J9MGRmADrBXm8DL9Br2eXBb+e2d0czBMA+HabaambDXwE9Yp1nw+RUmGSrl Ysd2ff9AZHyp1lUTY8mnmD8nZhm30aKtbJBgTIQN9bhm8TVXrhKCJI1J9pTiLL4eUDHW DSQ0bigJWM3KHU7LSlT+ag/TQaea5dPADlkJLy+ZDpbPp/L0t2Ob1v5QQ+115O/Touel tbhQ== X-Gm-Message-State: ACrzQf1G6mNSey5OptafjdzFUoY8m7SodF90yZt0KLlEjki+YK6xu2km Tv6kZWSJ1kpIGzJZCqDfeGI= X-Received: by 2002:a17:902:d48d:b0:178:306d:f75c with SMTP id c13-20020a170902d48d00b00178306df75cmr24637584plg.73.1664844036518; Mon, 03 Oct 2022 17:40:36 -0700 (PDT) Received: from smtpclient.apple ([66.170.99.2]) by smtp.gmail.com with ESMTPSA id c202-20020a624ed3000000b005616fd75a22sm2855137pfb.112.2022.10.03.17.40.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Oct 2022 17:40:36 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: [PATCH v2 12/39] x86/mm: Update ptep_set_wrprotect() and pmdp_set_wrprotect() for transition from _PAGE_DIRTY to _PAGE_COW From: Nadav Amit In-Reply-To: <547f2a8a87c255c58dbf2350013f72649dfcdc10.camel@intel.com> Date: Mon, 3 Oct 2022 17:40:33 -0700 Cc: "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "peterz@infradead.org" , "rdunlap@infradead.org" , "keescook@chromium.org" , "Yu, Yu-cheng" , "Eranian, Stephane" , "kirill.shutemov@linux.intel.com" , "dave.hansen@linux.intel.com" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "jannh@google.com" , "dethoma@microsoft.com" , "kcc@google.com" , "linux-arch@vger.kernel.org" , "pavel@ucw.cz" , "oleg@redhat.com" , "hjl.tools@gmail.com" , "Yang, Weijiang" , Andy Lutomirski , "jamorris@linux.microsoft.com" , "arnd@arndb.de" , "Moreira, Joao" , Thomas Gleixner , "bp@alien8.de" , "mike.kravetz@oracle.com" , "x86@kernel.org" , "linux-doc@vger.kernel.org" , "rppt@kernel.org" , "john.allen@amd.com" , "mingo@redhat.com" , "Shankar, Ravi V" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-13-rick.p.edgecombe@intel.com> <64313344833c3b1701002a347d539e69276b66fb.camel@intel.com> <35EEB9F0-D99A-4664-9628-27029B52CFD1@gmail.com> <65CF3B29-BF53-4BA3-89D9-5398CEB7F813@gmail.com> <547f2a8a87c255c58dbf2350013f72649dfcdc10.camel@intel.com> To: "Edgecombe, Rick P" X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 On Oct 3, 2022, at 4:38 PM, Edgecombe, Rick P = wrote: > I think the HW dirty bit will not be set here. How it works is, > pte_mkdirty() will not actually set the HW dirty bit, but instead the > software COW bit. Here is the relevant snippet: >=20 > static inline pte_t pte_mkdirty(pte_t pte) > { > pteval_t dirty =3D _PAGE_DIRTY; >=20 > /* Avoid creating Dirty=3D1,Write=3D0 PTEs */ > if (cpu_feature_enabled(X86_FEATURE_SHSTK) && !pte_write(pte)) > dirty =3D _PAGE_COW; >=20 > return pte_set_flags(pte, dirty | _PAGE_SOFT_DIRTY); > } >=20 > So for a !VM_WRITE vma, you end up with Write=3D0,Cow=3D1 PTE passed > into ptep_set_access_flags(). Does it make sense? Thanks for your patience with me. I should have read the series in = order.