From patchwork Thu Feb 20 16:31:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 11394557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14A1F109A for ; Thu, 20 Feb 2020 16:31:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D5F712467A for ; Thu, 20 Feb 2020 16:31:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CabZUIzC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5F712467A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 108EA6B0037; Thu, 20 Feb 2020 11:31:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 095CE6B006C; Thu, 20 Feb 2020 11:31:38 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E07D06B0070; Thu, 20 Feb 2020 11:31:38 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id B85886B006C for ; Thu, 20 Feb 2020 11:31:38 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D58D437E7 for ; Thu, 20 Feb 2020 16:31:37 +0000 (UTC) X-FDA: 76511046234.09.fifth65_2b3339abcde4c X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,peterx@redhat.com,::linux-kernel@vger.kernel.org:bgeffon@google.com:xemul@virtuozzo.com:mike.kravetz@oracle.com:david@redhat.com:peterx@redhat.com:cracauer@cons.org:aarcange@redhat.com:mgorman@suse.de:bobbypowers@gmail.com:rppt@linux.vnet.ibm.com:kirill@shutemov.name:gokhale2@llnl.gov:hannes@cmpxchg.org:mcfadden8@llnl.gov:dplotnikov@virtuozzo.com:hughd@google.com:dgilbert@redhat.com:jglisse@redhat.com,RULES_HIT:30054,0,RBL:207.211.31.81:@redhat.com:.lbl8.mailshell.net-66.10.201.10 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:27,LUA_SUMMARY:none X-HE-Tag: fifth65_2b3339abcde4c X-Filterd-Recvd-Size: 5813 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 16:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582216296; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DQEXT6MRSUFu88yGmCeVHPlWT8BuqmeawAq8UBjgOkA=; b=CabZUIzCV9IvAkuhQjNzOl2jJKUPlfDu9/HkjdoaRXzSRxdocbZrfuB/vQ2f/mF99Foo/Z Z0PV8sj1tYQYRncVW2Ri0rHR2ZvQ4TBQwdMGVYZYE8a2i1a0SMxIEDiDrQf5I6dxzbt4wU 4iwo6GEq+jUi2Lz+wKrUZlZDhwFERPc= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-473-X2YZHVtYN2W5azjJf79fhw-1; Thu, 20 Feb 2020 11:31:33 -0500 Received: by mail-qv1-f71.google.com with SMTP id ce2so2906045qvb.23 for ; Thu, 20 Feb 2020 08:31:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7CcQ3+IAeYTGH9do6IO2FxfgSZnvINmGfGHXGlbg3PU=; b=CXBxHgF4rHWrTlE4vgTFDtn3/vSp2UcE6e1Pa+jPUw/xTlBzlleVJnjcOxn6taM4PF 6nq6jfK5JJWm/+Fvd5ivNYeld3c5pe0Q5z6ccpWxhBlVesjNXLlch9x2UYlqidBGpon/ nKw5G+Mmd3UyNjxN8Jkhw1vErii2Cf3Ze50EdxWCb5ltyCAJdKVs4q708Y4lSuecAr2Y NRhoMWrftKKRGFkbu7Cz4heoS5fil4ccJ7/JLlKKANOeb553+Y4voym6Hmh2n6ohlca0 mQupaheLEFGSBBWkx3zTR626D4H3zynkqrRSBY2H3rrOyI3wYa58F3BW1Ru3UP32foVP 0c4Q== X-Gm-Message-State: APjAAAUGLxo2J0HowIgJwek846eHEM4WWhcwmhpstQ6pI/05f1TbWCRq IXNE4HjH1l8sEXLHGuJ0WK9nLNHDvppfZv5YhzKJ81p+HOrfT6zVBgJnDuM2O5vpvl+35Q6e+xO tYjhggdV9Vkg= X-Received: by 2002:a05:6214:450:: with SMTP id cc16mr26379220qvb.175.1582216291692; Thu, 20 Feb 2020 08:31:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyx1wLJHNN7bX0JIiwvsibPAVG4lfhOifN1KcvsGrtR3sMPF4XG8/cMRjTEzqSZIM61UByx4Q== X-Received: by 2002:a05:6214:450:: with SMTP id cc16mr26379203qvb.175.1582216291482; Thu, 20 Feb 2020 08:31:31 -0800 (PST) Received: from xz-x1.redhat.com ([104.156.64.75]) by smtp.gmail.com with ESMTPSA id l19sm42366qkl.3.2020.02.20.08.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 08:31:30 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Brian Geffon , Pavel Emelyanov , Mike Kravetz , David Hildenbrand , peterx@redhat.com, Martin Cracauer , Andrea Arcangeli , Mel Gorman , Bobby Powers , Mike Rapoport , "Kirill A . Shutemov" , Maya Gokhale , Johannes Weiner , Marty McFadden , Denis Plotnikov , Hugh Dickins , "Dr . David Alan Gilbert" , Jerome Glisse Subject: [PATCH v6 09/19] userfaultfd: wp: add pmd_swp_*uffd_wp() helpers Date: Thu, 20 Feb 2020 11:31:02 -0500 Message-Id: <20200220163112.11409-10-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200220163112.11409-1-peterx@redhat.com> References: <20200220163112.11409-1-peterx@redhat.com> MIME-Version: 1.0 X-MC-Unique: X2YZHVtYN2W5azjJf79fhw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: 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 74f16d7e5b47..75a04ac97ef2 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1427,6 +1427,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 */