From patchwork Mon Dec 4 17:26:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13478802 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 5A11BC4167B for ; Mon, 4 Dec 2023 17:27:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E960D6B02AF; Mon, 4 Dec 2023 12:27:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E46866B02B3; Mon, 4 Dec 2023 12:27:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0DF16B02B6; Mon, 4 Dec 2023 12:27:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C00096B02AF for ; Mon, 4 Dec 2023 12:27:11 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 97C7C1402E0 for ; Mon, 4 Dec 2023 17:27:11 +0000 (UTC) X-FDA: 81529816662.28.7B5A7EC Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf28.hostedemail.com (Postfix) with ESMTP id C65D4C0009 for ; Mon, 4 Dec 2023 17:27:09 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=d2iSXqg7; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 37AtuZQoKCO0YiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=37AtuZQoKCO0YiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701710829; 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=WhY7K21fTuleJoRqinTH8FQOk8orwGh5uZOpWymHf1Q=; b=s41UoV2cG8vnTFsXoi3fzoh5S7YT2sqdp5SapWxg8Xy7XJa/vEaoRTzswzQ/Tc4+E8mD/r wm2l0SXmndmYYiw4BB8Oqiysy3IAa7Z40qzIHEqJsLbkcMNL6BSmWhFeLOVZVT3xvAY8Wa UWvq5shENsyexIP8CCVoPybXAqKjUH8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=d2iSXqg7; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf28.hostedemail.com: domain of 37AtuZQoKCO0YiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=37AtuZQoKCO0YiWdjVWidcVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--jthoughton.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701710829; a=rsa-sha256; cv=none; b=CuxUJuD/79p14Mac+9Dvu7tf/09g0z0eV91ItR8Y5FIZ23/5edWD80DyS1UK8vLhoiHsTW JH/frLdgGuurYjkBoinjsuojgL0RCeJA1FAjKyZU/shxzwSF+Gg9ZbvhOmEiJcY2mXAX1n P99Z5PQnhCSITgDSLSza6WCROr7VUZw= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5d3cdd6f132so58980207b3.2 for ; Mon, 04 Dec 2023 09:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701710829; x=1702315629; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WhY7K21fTuleJoRqinTH8FQOk8orwGh5uZOpWymHf1Q=; b=d2iSXqg7AlUxl6eOt+Wz73G0wcVWwG0v8sw47AEM6w+OunkfXJLHVO59hv2iUWdz6i nKvv+NwpXkp2AvNcPZZMQJ81o60VDMOWxKlIPsHOzZW5V53DfFg5KOKJSlYVmUy0KCSk IIxMweNy2BRy2TuFmfdyIFZ/R7u3sgLmb0FATewUr3qgAlJtEy4q6xxHt1L7ze4hcVUc +bchlUxHMmeRVrRrhyX6Z+90YCzsIspINCeufP9zC6L6g0xbusWu1X08L3ZHuhDeROYI Dgz70/q0CPDvJTA/ihMgPP8Y9OwaVwgQQRCepw0khfrWuIF73peQmhdCdRC6VF7GQs8K N26g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701710829; x=1702315629; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WhY7K21fTuleJoRqinTH8FQOk8orwGh5uZOpWymHf1Q=; b=MKUJdUpKRv38uuilQmYT4tlgKChpj3cUXumFBXY0YVkkC2+lSZQwODAqGRtUVLIkaD b+R5c1cfqXxqV7gUFSd7qnkYUV9zrEESLWigJr4d7stA7IhLMKd9benoS2zwx1k8vxlt P/9VOr6OVSF4p8d69eUw3CAUdc+pZfjc6dN1PQ5nJmOR7uX5Mw8M2F0wzBiNm+iAj3CS fAfxUnEMB93uJeEBsx0zU3JpDNu51WxFFpJ4wkW7jPiH/3ehiIQmA+6nA1GmHdGUb3Tf obYJm9Awm5WdvBfa4Q8ULOLPSCmfssqwo2ke9I8rDJ1sVUGRXJQh4qcvOzOLj4FKMvJb azSA== X-Gm-Message-State: AOJu0Yw/g5HYrdlL25y6NIyi+r/g87lVV18YqaMiBlKIemFkVLAwjOWj JRnKRWJ4fZOFKV3rmiP2z72prGn2gCkh39rv X-Google-Smtp-Source: AGHT+IEhvePiHl3xyV55jaT6gG1N1cwFNsflp2+fj8EBDZAd96hh+3/YkVm099+dmC2eTTOXHiutCQyCzt5QJhnb X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a81:b61d:0:b0:5d3:84d4:eb35 with SMTP id u29-20020a81b61d000000b005d384d4eb35mr358241ywh.3.1701710828830; Mon, 04 Dec 2023 09:27:08 -0800 (PST) Date: Mon, 4 Dec 2023 17:26:45 +0000 In-Reply-To: <20231204172646.2541916-1-jthoughton@google.com> Mime-Version: 1.0 References: <20231204172646.2541916-1-jthoughton@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Message-ID: <20231204172646.2541916-2-jthoughton@google.com> Subject: [PATCH 1/2] arm64: hugetlb: Distinguish between hw and sw dirtiness in __cont_access_flags_changed From: James Houghton To: Steve Capper , Will Deacon , Andrew Morton Cc: Mike Kravetz , Muchun Song , Anshuman Khandual , Catalin Marinas , Ryan Roberts , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton , stable@vger.kernel.org X-Rspamd-Queue-Id: C65D4C0009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 57pj8ryc5ae3mq4gxadedj1zunk3er5a X-HE-Tag: 1701710829-218348 X-HE-Meta: U2FsdGVkX1/CAEHqr1J2rUGyTd6jxWw+f1xQQxjdwW2Oa8JDlsu1UEPUfJXMq0JIC7xVKaJxjDhGcItKYtFktVM8LX+sJKaJstMn68gxlWs5XiSxkXEaI+8c7h+UC6zyziQ2U5Wrpa2YV9Ts9C5xsrdpee96cxAQ1EMtg8qwuxhOZdCrdO50ce+gHw4d1l1iVEgMNmE7on0qshQ9T1hr3R1QO14tqbv04sOk5VPxLXH8nQCqFxqAnPXkcVzNT8+lWfSDzh08MTcIzp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aYQ8k1bGGXnt2L+mURHW4uBEx1iG8DhIUgkbMhhNT0+9rH9y0ZuChh0X/gjeO8gy9i7hDxiRNMfjZUZdZ9kKuwPfqhHc4rvVQRaJP0Sh7Tmc7ns/U7/Q4U8Ukx+8y5SWAtyL+LHzG7nmqY5iHIMKahr7wIumrunLK2BZ4KAsZHLpPj/iticsMWD21EkIdKwhqcmibO/w6P5GNPvl6XG2GRcPjY7Pgq5mgGwHKhNZbq1RvqGu6uWisuu0wO/vogXOUvd5OW3HELYzy4rFPENZUfoLcydpq016DQdOwwQrFxMWSE8Wqxvsa9+xGK21Xaj8Ml6M+PSXdhjrI9+FsFORWLAP5YRGZTQ5o51mjnh6rVXLz1bYbmN7S3z99sJuNfAeTs9rDjTiVwvGA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000269, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: __cont_access_flags_changed was originally introduced to avoid making unnecessary changes to the PTEs. Consider the following case: all the PTEs in the contiguous group have PTE_DIRTY | PTE_RDONLY | PTE_WRITE, and we are running on a system without HAFDBS. When writing via these PTEs, we will get a page fault, and hugetlb_fault will (rightly) attempt to update the PTEs with PTE_DIRTY | PTE_WRITE, but, as both the original PTEs and the new PTEs are pte_dirty(), __cont_access_flags_changed prevents the pgprot update from occurring. To avoid the page fault loop that we get ourselves into, distinguish between hardware-dirty and software-dirty for this check. Non-contiguous PTEs aren't broken in the same way, as we will always write a new PTE unless the new PTE is exactly equal to the old one. Fixes: 031e6e6b4e12 ("arm64: hugetlb: Avoid unnecessary clearing in huge_ptep_set_access_flags") Signed-off-by: James Houghton Cc: diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index f5aae342632c..87a9564976fa 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -437,7 +437,10 @@ static int __cont_access_flags_changed(pte_t *ptep, pte_t pte, int ncontig) for (i = 0; i < ncontig; i++) { pte_t orig_pte = ptep_get(ptep + i); - if (pte_dirty(pte) != pte_dirty(orig_pte)) + if (pte_sw_dirty(pte) != pte_sw_dirty(orig_pte)) + return 1; + + if (pte_hw_dirty(pte) != pte_hw_dirty(orig_pte)) return 1; if (pte_young(pte) != pte_young(orig_pte)) From patchwork Mon Dec 4 17:26:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13478803 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 42B77C46CA0 for ; Mon, 4 Dec 2023 17:27:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3B6A6B02B6; Mon, 4 Dec 2023 12:27:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A9C5C6B02D1; Mon, 4 Dec 2023 12:27:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93EC16B02D8; Mon, 4 Dec 2023 12:27:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 814016B02B6 for ; Mon, 4 Dec 2023 12:27:14 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5B7911A02C0 for ; Mon, 4 Dec 2023 17:27:14 +0000 (UTC) X-FDA: 81529816788.27.AD9EBC7 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf24.hostedemail.com (Postfix) with ESMTP id A7430180014 for ; Mon, 4 Dec 2023 17:27:12 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=esCxaBMz; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 37wtuZQoKCPAblZgmYZlgfYggYdW.Ugedafmp-eecnSUc.gjY@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=37wtuZQoKCPAblZgmYZlgfYggYdW.Ugedafmp-eecnSUc.gjY@flex--jthoughton.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701710832; a=rsa-sha256; cv=none; b=DN3xBZkr3mSZUiVwawOslO6iSvV89dORUdIGIO651OGiOFS4gpWCUX2igekYLySN83bLsE SFiEcB7oqRd17Bcynfio1e19JT8gvrxxpeIwqZLuznArDsxpdlioPHB1y1I36Y+ox2K0Iy anDNmz8YJ1vt7BOo8OyJV1bvhArOakM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=esCxaBMz; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of 37wtuZQoKCPAblZgmYZlgfYggYdW.Ugedafmp-eecnSUc.gjY@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=37wtuZQoKCPAblZgmYZlgfYggYdW.Ugedafmp-eecnSUc.gjY@flex--jthoughton.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701710832; 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=BIP1VBSrHfriGjh5Ogk9INZtbtmoj9c5sEQfKrkJBSE=; b=5tlD05Trc54ngxZ43k/C3NUmTerrXWf7pAvM/fcF9wh4J0T5UyiI8mNKRbdUNuGYb/lyze WmB5htQHM4Lwf8UdqoeZhjuiQ6LLBE+vIPxXQv219HqHlS1w8QNisRFigMxaNHU8/fJWtM MJ/xKrrAXbMSpA7e0VdReqfuyn2F9O0= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5ce16bc121aso78038607b3.1 for ; Mon, 04 Dec 2023 09:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701710832; x=1702315632; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BIP1VBSrHfriGjh5Ogk9INZtbtmoj9c5sEQfKrkJBSE=; b=esCxaBMzXfLERo32K4kWiVLAsdinaccwJXveL6mbn7p2/0/WOoUVjnnkh8u0i0MZme ZfWkHVXupYBI+97H3jaDYliB09uVM6RmBdZ3ahUOy8PpIhbD9RUw4Ue+8lW+y1gtvTs6 fT68Xxygeh7Gvj5BYT0KHC32L1Ij83qMLHoglMx7Hwguri4CaXBJGDHueqf1JXmnmuaO /S8/KyB01XdQuX6Ui7o3vOi668GZgQdzLglTSlrg5loY0Fr1P+tpgASunIuhLeXh0S4I nSGCHkYUMp0BpMW8FrBvROtyDyGxCIjREMOxKLRCbf/nFXeD3rwT0uyV7CU76lctlF1g gX9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701710832; x=1702315632; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BIP1VBSrHfriGjh5Ogk9INZtbtmoj9c5sEQfKrkJBSE=; b=UdV9X8GD8t3gOgi9tlozchHeUXoyGwyeMcU823UExwvlbIT49qBxwwtigKk7OYk8iO r0oVCrDMTfAgUzx+Y/5LWEsMlWsZT9A/bkwNnXWnrXe7xq8kUklhdKUTXZk+0aQXR3Ix MErzRoFnu8vchJTiylfHm6CxBzXkRKfSET3OI2ay2xbeSMzClfe2GBYPr4ep773RTzei jfs32PdFZxCIGCJ4TcHJFKn/NwgWXDMGKj4e4MdljFIvumpuwPkxvkd74+gTxSHfJvls vT0ZWxoLIYL+bUyvJ8VBInI1aaNcwy+ls7nmoeKTqgsTt0lgd0MEuPlh9IbrQA3f8zG1 t/EA== X-Gm-Message-State: AOJu0YywIHK8y/2UL79SnXIsgMBusOz306ictTYOSsmx1KAnLO1awR4l OKPwWh0/HeAX0G4jbMLps1wnggtNHTiSWMq0 X-Google-Smtp-Source: AGHT+IFq88uu4hPlgv5GbGd/ux88m4iUlZ64ATBmq3rePqIk98p8cvyl0w6nJZb3uZTHk5FQwmgEwV0mbM4oM1P0 X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:690c:2710:b0:5d5:5183:ebd7 with SMTP id dy16-20020a05690c271000b005d55183ebd7mr222984ywb.7.1701710831851; Mon, 04 Dec 2023 09:27:11 -0800 (PST) Date: Mon, 4 Dec 2023 17:26:46 +0000 In-Reply-To: <20231204172646.2541916-1-jthoughton@google.com> Mime-Version: 1.0 References: <20231204172646.2541916-1-jthoughton@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Message-ID: <20231204172646.2541916-3-jthoughton@google.com> Subject: [PATCH 2/2] arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify From: James Houghton To: Steve Capper , Will Deacon , Andrew Morton Cc: Mike Kravetz , Muchun Song , Anshuman Khandual , Catalin Marinas , Ryan Roberts , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: A7430180014 X-Stat-Signature: 88d7krioqxdmjnehnj9ycsraj6ru61if X-HE-Tag: 1701710832-763869 X-HE-Meta: U2FsdGVkX1888M9OmFBNv8tzdXeGRoqiTVfEmmURRMJmogTQdci/4EpH0ivgAoXeBGgZoHqbzbjmKTslX95EXFnuLQzmBE2s1fKWRDmeO+MPwC6WijatAlJwQmmPcTal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LiHGC+GUbS0I4e/b8SCrB+8v4uXeACylE6iA7b+Bu9XgZEBlRq4hGkY6N3k/HvTBQUcn5s/YeNiXlmMU+0Asb9zGQ1iWqQAenqJkHie6/5jC3YYPxloe3dHQuAdyGT06Uj1rPbxUhtoYnmvy9RpBLDmhVcrCAg2ajYf5L3TJgBHQpZTmZ6bFB+jZ/Y+GX487YllQA2Hk5XfSpRIc4tbmif3IWUMJ0CXqDTj7eZp+tjk1TH0UtndK8/Jn+2+kpc/ejO1N3MuiCmxskzyDPZV4TqgRWrcKXpcB7Zirzf0wBJvec/0lhWL0/F59mhwQUdNnwqpQ7qXrgFw2d6vJfH8YKZMxpXl6fC9hfQdsch6qNmjMtP8diDMq18SXR+eeMnoEVq/jcr5heR0BrFMEnZAb2zS/Wt4B1hlfkjSoZluJKo//c+vSQ9u97rn0Q30Vkt7BQmgDah6s7xp1zzCvS9U= X-Bogosity: Ham, tests=bogofilter, spamicity=0.015920, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Make it impossible to create a sw-dirty, hw-clean PTE with pte_modify. Such a PTE should be impossible to create, and there may be places that assume that pte_dirty() implies pte_hw_dirty(). Signed-off-by: James Houghton Reviewed-by: Ryan Roberts diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index b19a8aee684c..79ce70fbb751 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -834,6 +834,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) pte = set_pte_bit(pte, __pgprot(PTE_DIRTY)); pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask); + /* + * If we end up clearing hw dirtiness for a sw-dirty PTE, set hardware + * dirtiness again. + */ + if (pte_sw_dirty(pte)) + pte = pte_mkdirty(pte); return pte; }