Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1644060ybt; Mon, 15 Jun 2020 06:00:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHTotiET3gOtgprYOOGjfp1/bw3W/G/KSyPT0jxTbtdMWz3h0pxJBvaXdbhhfPCpiz3MAH X-Received: by 2002:a17:906:1d1a:: with SMTP id n26mr12508280ejh.351.1592226024077; Mon, 15 Jun 2020 06:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592226024; cv=none; d=google.com; s=arc-20160816; b=kI8Yfm0hqVl6mrAh4BYhv8t6OA5JHHhmtPaJImQNxNGr7Mq3L9LsefYVVUcMtB2ZEX 1zjlPu3fQ0YSMflt0XObI8MdLlREYB4cgi+yDsfx2m5B4PBp5W9in1kAVKrBkfUftE4d wif5mrVDt5ByCSSa9WI08gQzWc6a71gV8twa/VMBFwWAP2sP5xkZ043j8ACA4gWFFQhY 4tbEDuMPRgAF40QeMiEBgqqWt+gXiRL2ymf+HBiGPYugLnBINpDCK91GqTc1e3bqnP67 0W6tYUCB2wiv+l4Y57bdsuRq5uwpxa6VJeudxAAhnM6AEX0lJZQjfcLaUIWBNVWE0nhW TwJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=/TAgknEAWyYdoX6urbNukrkYpWVjlUfsdy7A1iwhw30=; b=0aJ3hiSCdw4h2umL04DOGD6LCi0ayLrxOEj8jd6HaiOlY/XXQqxiPE1Y7VoXrxUGS2 k9Wv7OmKLwLzxfbAhV8fFs21kI4e8X1aBN7P1qwqfhB0ImMgOTGUlckcQYpdTpBjUUOv minHBLYCOFjEIG628BrGlpBybt9dsdwtaIlFA2sq9WLzWSA27qSTsUGbtlAxfis1cLhj Lq2UHh16auq2g1sk/KV/Ic62Qk5cfYTS7I3dzNNnajMgL6wg+kS63O/lRMhOEggMLJPT 1hQ6puC3Z/JfkiTpWFNhCd//CuCNChUZLjaniMW2MZsYFMUeGyO5PBE5CN9by6R6p3og S6qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j28si8364004edy.293.2020.06.15.06.00.01; Mon, 15 Jun 2020 06:00:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730227AbgFOM6I (ORCPT + 99 others); Mon, 15 Jun 2020 08:58:08 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:14441 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730129AbgFOM6B (ORCPT ); Mon, 15 Jun 2020 08:58:01 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 49lrwQ0wthz9v1fl; Mon, 15 Jun 2020 14:57:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id aXFx7kJdYhJB; Mon, 15 Jun 2020 14:57:58 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 49lrwQ06Xvz9v1fM; Mon, 15 Jun 2020 14:57:58 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 77D768B796; Mon, 15 Jun 2020 14:57:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 25kJTR5Pyx86; Mon, 15 Jun 2020 14:57:58 +0200 (CEST) Received: from pc16570vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.104]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3308A8B75F; Mon, 15 Jun 2020 14:57:58 +0200 (CEST) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 2DB5265B0E; Mon, 15 Jun 2020 12:57:58 +0000 (UTC) Message-Id: <087fa12b6e920e32315136b998aa834f99242695.1592225558.git.christophe.leroy@csgroup.eu> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH 2/3] mm: Allow arches to provide ptep_get() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Will Deacon , Andrew Morton , "Peter Zijlstra (Intel)" Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org Date: Mon, 15 Jun 2020 12:57:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit 2ab3a0a02905 ("READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses"), it is not possible anymore to use READ_ONCE() to access complex page table entries like the one defined for powerpc 8xx with 16k size pages. Define a ptep_get() helper that architectures can override instead of performing a READ_ONCE() on the page table entry pointer. Fixes: 2ab3a0a02905 ("READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses") Cc: Will Deacon Signed-off-by: Christophe Leroy --- include/asm-generic/hugetlb.h | 2 +- include/linux/pgtable.h | 7 +++++++ mm/gup.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h index 40f85decc2ee..8e1e6244a89d 100644 --- a/include/asm-generic/hugetlb.h +++ b/include/asm-generic/hugetlb.h @@ -122,7 +122,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, #ifndef __HAVE_ARCH_HUGE_PTEP_GET static inline pte_t huge_ptep_get(pte_t *ptep) { - return READ_ONCE(*ptep); + return ptep_get(ptep); } #endif diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 32b6c52d41b9..56c1e8eb7bb0 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -249,6 +249,13 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, } #endif +#ifndef __HAVE_ARCH_PTEP_GET +static inline pte_t ptep_get(pte_t *ptep) +{ + return READ_ONCE(*ptep); +} +#endif + #ifdef CONFIG_TRANSPARENT_HUGEPAGE #ifndef __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, diff --git a/mm/gup.c b/mm/gup.c index 761df4944ef5..6f47697f8fb0 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2196,7 +2196,7 @@ static inline pte_t gup_get_pte(pte_t *ptep) */ static inline pte_t gup_get_pte(pte_t *ptep) { - return READ_ONCE(*ptep); + return ptep_get(ptep); } #endif /* CONFIG_GUP_GET_PTE_LOW_HIGH */ -- 2.25.0