From patchwork Tue Nov 14 15:49:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13455561 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 D26D2C4332F for ; Tue, 14 Nov 2023 15:50:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D1E56B02DE; Tue, 14 Nov 2023 10:50:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6817C6B02E0; Tue, 14 Nov 2023 10:50:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 570EA6B02E1; Tue, 14 Nov 2023 10:50:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 482AC6B02DE for ; Tue, 14 Nov 2023 10:50:01 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1D8181CB2FF for ; Tue, 14 Nov 2023 15:50:01 +0000 (UTC) X-FDA: 81456995802.12.BF74FFD Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf13.hostedemail.com (Postfix) with ESMTP id 4E7A220021 for ; Tue, 14 Nov 2023 15:49:59 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699976999; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=bfmLlT9q/PoPj1fFS4VpKdg/weZy1yGmPbGeEwEsT08=; b=TtFARAOgkhZ/syRRPsjByeSxf/CWBBuUl/u9yw0uB9xzYQyCxKk9ORe79RDN1plM1zU1e9 O5QX1fTHH31fFNq6sAjd/kiypDdFdPsocRsKJJfvihm6OH5Dhb1lFXJPn8gF9TjWzvogjT 9OictM+kpnxjpxTRRnY5+V4jy/4OJDw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699976999; a=rsa-sha256; cv=none; b=mQoWDW2d3TNI/jSO3APV7UATiHOmWpvtgGO6Q/VR15AxsbsW1lXQ5MnUS4idJyhynhqefd O7uapDzVgQ751vkyKa+RWCIHwGfK2VkIi19O0tKy0oy6zgXDBWQD9J6MP24TvZ8X2f7ShZ ZNEDzFHybowO0VM9YwU8WCyOgAoNATI= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 39FD91FB; Tue, 14 Nov 2023 07:50:43 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 491403F641; Tue, 14 Nov 2023 07:49:57 -0800 (PST) From: Ryan Roberts To: Andrew Morton , "Matthew Wilcox (Oracle)" Cc: Ryan Roberts , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v1] mm: More ptep_get() conversion Date: Tue, 14 Nov 2023 15:49:45 +0000 Message-Id: <20231114154945.490401-1-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 4E7A220021 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: r1twyepeq48j8myrbsxrz1c8tdde39s6 X-HE-Tag: 1699976999-438101 X-HE-Meta: U2FsdGVkX18vAi7vXPv63iRrq+I1zAQfOANvhUeAnhtOMEAW5u84IVgQ8etwmSy9sS2wGQl5s0aDxv4NZm17LZEDbyVbRhgT/BSUkika5cLldAFIccTFS/hs3e4Q9f1MmpgnWa8csrgVoHbm+Fye1A4F37HSp9TGg2UwKGyBduYwp7TSniHrsIRt6txdUoLafG8KTuyuAWZMoIiK9hhPYmrq6vBumozHAwn3YMIHTuo+y52Dv5J4TFZLAITF2B6VQA/wf5gFlubmQEERD8IvBlhj7cDQuQtbSmNBMjDXmV3b7RZqPKInTxKYqlboHyBVIQ8euTJzMY6fW3gXCFN0UB7LQGMrILIGnStNRMjfyD1NVoo76eVC/QAjeFt6YqTcxVZx9znAwWxtw1ztk2ztDE7eoMl7v0gunksBGTOeKZJstS0A8dupFH5IDf/ovPe81sheYfckmB8ySRf3R/lJbu553//6fGsrccaoi2Bc3t1SaFctlnQqaPiGoessooBJboMH/eSrzQfQ0llhRPF07R01TTtFcLPNF3MD5IXoK7XmOvcYPYq0j3Jg5lfmGap7IEbbN67cEYkmhaslSPDciUiXdMPXxVLs/Xyhd5q+NgyNfCmrKBIQP975f3CQID9wvan0yEdaJgP6Ddn5KoqidJpNKPjys2quLx/OV2cfWExEXTceYtUbnyCwvTkWB1HF7GEvXnE3GVuK54xwFJQMprQC9G3aKF6ZV2gcTJtwcEH5GQA4J2/UbQDqVQGy5zoCrJZ0NFXzoHUedOxtlCaEb03sMlyxXAjNAlbn1pa45kMsIbPG69N6N+ESQ5m9avyki8aDxLMPNd2wVI5Xa0f5CC88y4KNRXFaAsnR3JVsW1l3mT9SuZ/JkqnkZXHD+7CaZKCB6o4Z57B5pQC5BwfuS4fTU8FTfpmzSrNBWmgb3o+KfPJAcYsTOpplPrqE+kAQEYD21IUUgjgKc+QtKm+ JKBEa031 Hv/L42wg0eY3ThB3xTkiQqBEpuGjdFkQxwCuGdrmE+O42ekcXX1h1Zte1ACsb7lVfVJ+wDQxD6YZJCfREXVeZ1lg+f3IVIj7SSETjCSQSvxC2cq6OA50KJBz3vJwOURlRUq7fuGSfZ4/b6+nrTuTN+AOSq6cR8g0tC3Dz9W4hcSTFErsNWBMTuE7fW+Pvqn6+K0ALgYM6YSFpnSU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Commit c33c794828f2 ("mm: ptep_get() conversion") converted all (non-arch) call sites to use ptep_get() instead of doing a direct dereference of the pte. Full rationale can be found in that commit's log. Since then, three new call sites have snuck in, which directly dereference the pte, so let's fix those up. Unfortunately there is no reliable automated mechanism to catch these; I'm relying on a combination of Coccinelle (which throws up a lot of false positives) and some compiler magic to force a compiler error on dereference (While this approach finds dereferences, it also yields a non-booting kernel so can't be committed). Signed-off-by: Ryan Roberts --- mm/filemap.c | 2 +- mm/ksm.c | 2 +- mm/userfaultfd.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86 -- 2.25.1 diff --git a/mm/filemap.c b/mm/filemap.c index 9710f43a89ac..32eedf3afd45 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3443,7 +3443,7 @@ static vm_fault_t filemap_map_folio_range(struct vm_fault *vmf, * handled in the specific fault path, and it'll prohibit the * fault-around logic. */ - if (!pte_none(vmf->pte[count])) + if (!pte_none(ptep_get(&vmf->pte[count]))) goto skip; count++; diff --git a/mm/ksm.c b/mm/ksm.c index 7efcc68ccc6e..6a831009b4cb 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -468,7 +468,7 @@ static int break_ksm_pmd_entry(pmd_t *pmd, unsigned long addr, unsigned long nex page = pfn_swap_entry_to_page(entry); } /* return 1 if the page is an normal ksm page or KSM-placed zero page */ - ret = (page && PageKsm(page)) || is_ksm_zero_pte(*pte); + ret = (page && PageKsm(page)) || is_ksm_zero_pte(ptent); pte_unmap_unlock(pte, ptl); return ret; } diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 96d9eae5c7cc..0b6ca553bebe 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -312,7 +312,7 @@ static int mfill_atomic_pte_poison(pmd_t *dst_pmd, ret = -EEXIST; /* Refuse to overwrite any PTE, even a PTE marker (e.g. UFFD WP). */ - if (!pte_none(*dst_pte)) + if (!pte_none(ptep_get(dst_pte))) goto out_unlock; set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte);