Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1366720ybi; Wed, 19 Jun 2019 19:24:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyT9fWHCjNs+RNQKoOwaQ88IeXf/VMe84jhJar15bO3AdLMO60BNfh3n0970P2igZ8Y6cw1 X-Received: by 2002:a63:5c19:: with SMTP id q25mr10856207pgb.215.1560997450462; Wed, 19 Jun 2019 19:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560997450; cv=none; d=google.com; s=arc-20160816; b=BzhwtUTwPGV0GN6iHnH/hdQCoPd85zTULuz1ei2NfHdWcFvsJQniWknxNA15fP4qCO oh5I0JSSXSiHJxJ3WRKgeWpAhG/ovyHROJXdGMNwgTm+uPgEYWCFEeCKHXXDVbxaTkDa SZii50MKKx0M0W+AFUh3S+CS+yYdgGY3nNb8IjZhIpRQst1hE63s20X6SiVly58SmOvw p0xA+lRiQ1Xe4AAc91ft3V6t6h02pNf/oH9Evj6640qlaU0e0KFIQa0RadFIoPt3ltpk doGP5+GdrTtbcIj2/0aLjCnPXu9W+f+yPh/FJA57Fh8KZ9d2+Cptwv6SLnLQInSZfWqJ bb8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OA/gE3dA9KiTq0wwEszkXEbgJHTkBwyZNwfY7oPqmEc=; b=BxVPmOtTzTkfP/szyi0HXXcSfbAICuWiIk9+VGtlrv1HnjqirynQcgK3DZsZY+KANf n5vqDRsd0SJ+o4Y9UHTFgMnMq8QB53hXVGtUtaQRNWu2m1C8LnVVgu/Fu3H8LIu+I1Oe favKf/XDjFRlbJ/uGRoURW+U8iv4SfDUuuKw5gVkr8uR1w7IYgPj+0k2CO4g39qtFIDc Px1ZW8xg1WJ+lTC8UJpvPyQFUXKeZj/VmuAEo8wxU0nd+X4H2nfg2snMEf42wU79m5QA ejEgd6gCmdiw1xNDmlYKEl/zo67Cli2p9/0taCKrrb1WxQ4C3l28cPt19otmW79wRKqE x7/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si4350607pgs.168.2019.06.19.19.23.54; Wed, 19 Jun 2019 19:24:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731520AbfFTCXR (ORCPT + 99 others); Wed, 19 Jun 2019 22:23:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44196 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbfFTCXR (ORCPT ); Wed, 19 Jun 2019 22:23:17 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AAF6B30018D7; Thu, 20 Jun 2019 02:23:16 +0000 (UTC) Received: from xz-x1.redhat.com (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74DB11001DC3; Thu, 20 Jun 2019 02:23:04 +0000 (UTC) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: David Hildenbrand , Hugh Dickins , Maya Gokhale , Jerome Glisse , Pavel Emelyanov , Johannes Weiner , peterx@redhat.com, Martin Cracauer , Denis Plotnikov , Shaohua Li , Andrea Arcangeli , Mike Kravetz , Marty McFadden , Mike Rapoport , Mel Gorman , "Kirill A . Shutemov" , "Dr . David Alan Gilbert" Subject: [PATCH v5 14/25] userfaultfd: wp: add pmd_swp_*uffd_wp() helpers Date: Thu, 20 Jun 2019 10:19:57 +0800 Message-Id: <20190620022008.19172-15-peterx@redhat.com> In-Reply-To: <20190620022008.19172-1-peterx@redhat.com> References: <20190620022008.19172-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 20 Jun 2019 02:23:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding these missing helpers for uffd-wp operations with pmd swap/migration entries. Reviewed-by: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- arch/x86/include/asm/pgtable.h | 15 +++++++++++++++ include/asm-generic/pgtable_uffd.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 5b254b851082..0120fa671914 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1421,6 +1421,21 @@ static inline pte_t pte_swp_clear_uffd_wp(pte_t pte) { return pte_clear_flags(pte, _PAGE_SWP_UFFD_WP); } + +static inline pmd_t pmd_swp_mkuffd_wp(pmd_t pmd) +{ + return pmd_set_flags(pmd, _PAGE_SWP_UFFD_WP); +} + +static inline int pmd_swp_uffd_wp(pmd_t pmd) +{ + return pmd_flags(pmd) & _PAGE_SWP_UFFD_WP; +} + +static inline pmd_t pmd_swp_clear_uffd_wp(pmd_t pmd) +{ + return pmd_clear_flags(pmd, _PAGE_SWP_UFFD_WP); +} #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_WP */ #define PKRU_AD_BIT 0x1 diff --git a/include/asm-generic/pgtable_uffd.h b/include/asm-generic/pgtable_uffd.h index 643d1bf559c2..828966d4c281 100644 --- a/include/asm-generic/pgtable_uffd.h +++ b/include/asm-generic/pgtable_uffd.h @@ -46,6 +46,21 @@ static __always_inline pte_t pte_swp_clear_uffd_wp(pte_t pte) { return pte; } + +static inline pmd_t pmd_swp_mkuffd_wp(pmd_t pmd) +{ + return pmd; +} + +static inline int pmd_swp_uffd_wp(pmd_t pmd) +{ + return 0; +} + +static inline pmd_t pmd_swp_clear_uffd_wp(pmd_t pmd) +{ + return pmd; +} #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_WP */ #endif /* _ASM_GENERIC_PGTABLE_UFFD_H */ -- 2.21.0