From patchwork Mon Jan 21 07:57:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 10772821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9DD213BF for ; Mon, 21 Jan 2019 07:59:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC46B29CB1 for ; Mon, 21 Jan 2019 07:59:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C01DF29CBB; Mon, 21 Jan 2019 07:59:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6337729CB1 for ; Mon, 21 Jan 2019 07:59:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F77B8E000A; Mon, 21 Jan 2019 02:59:55 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A6A18E0001; Mon, 21 Jan 2019 02:59:55 -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 5BDAA8E000A; Mon, 21 Jan 2019 02:59:55 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 2DEC38E0001 for ; Mon, 21 Jan 2019 02:59:55 -0500 (EST) Received: by mail-qt1-f197.google.com with SMTP id t18so20335750qtj.3 for ; Sun, 20 Jan 2019 23:59:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=LcMQbdG+ZNPaF5mPUkSU09DPT7VSAN+WniFF4Bj7dqs=; b=ehMrTFX/ZANwMaR4g33rv74QUITAbbah0q8COQ8quvpTzSFsYsxz/nBQYOAEyHIrw0 aPwD4DWv8X9VaNH7CGbNXFNaV+VXBkJg9liYaF0Ix89Bxi8Y8hoUNaKuF+Ulp/lAct4n OnbJvPwlUl5g1VKogclgiVem++OIIBAXpwmyfoLuEPiQCCM3jlhgAUKY8fu+5awtnUXM US4Y5kTItKnuvhpFjB52Lt4X1VoTfDc1ApMMAy7qxQdcA8vdx+jrw2fMZawqivHJhkeq Aixa5RCilgOdxI+0afq1zpsoRfVuWDHXBorFQ69tRk6oA4ln3t2wKF0MllrHE0DH7VE4 Uwtg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukdmx0pxyONPTatSv6bRW0aMY+lMOPASFHqqIfNetu7Yd+YW/ov8 8M29bDy6pAM0xjCtt14lHDH+rkRjEsagQ4N8gKnOsBDRjqGZnvB2CTesoHTyyYzF3serDGPaL8M 5GT2N/sAsJp6itLhblcnjk4O587y9VorW8mItxFlvFzeeaH9On4vL6Ga0PpFr9NLOwA== X-Received: by 2002:a37:4eca:: with SMTP id c193mr23606993qkb.37.1548057594984; Sun, 20 Jan 2019 23:59:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN72os3VwsbbSc77il0y2zIFmid4jxC3Jv/IYunSS/jDJbWAfumWq0rWMPmqKvwRh8Cler4w X-Received: by 2002:a37:4eca:: with SMTP id c193mr23606972qkb.37.1548057594552; Sun, 20 Jan 2019 23:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548057594; cv=none; d=google.com; s=arc-20160816; b=OM8vuqsUwa82E/gzK4ULz7LRFXtDry7DVQb8gJzV1k9fTNq9URYufz1FLMm+X6nawU Xz97KOq7Ym7mMqc1NG8Ap+WaO+iJQdhRV0XLDTcAJ76746gVkcfzs12V2lTwvkJn5v8k P2uL7g8uH+5jwi6LX2ukHckol0MbygUCEJsz5HmXbJnXTffTkpthEdy7uDU2MhE2Ez/3 333gZh+V7v28q4tPUYO2VPZ6vOxSm4KwXjddIcNA4T0XCqcQBG1GOY9k8Gl4pazU8w+H 3+3e34XttMWOSmwG0LH2ZZCHVIdeG4k2qTLhIVTKOKjzdJA+k769ALVQyJ+jDWkmsUOK DiFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=LcMQbdG+ZNPaF5mPUkSU09DPT7VSAN+WniFF4Bj7dqs=; b=G2+TkOJ62ybZNG9Z1mrpTuf1hKZO7gwbI7+kKu6vvnOiEw8cdrZvP4833G4fLs7vgH TV/lpnVSwklY6tyFlsNkx6dA20uDmyXQXyQQGyyHC7jWt+7VQcG3KAbuIzmFmVIg//NN e/rlAUaQiKJXWLT96WCnB0l1YhyFgrinwEcuIg/Thi6NGa+/OXC1pLS56JAjtv+bHLK6 seUxnxOUaj+Lwej7zDf5uL4lCO5sKaPVCT8RZlvEp1kVO/ci6f5ccskK3XLpvgpO37Ae i9BWmVPms+NtEn5sMjMENfbOHPqcz2srGiTs8MysOTGR12NA4i/iLSF1XrJkak5WrSOn 3gVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id d16si610833qvn.7.2019.01.20.23.59.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 23:59:54 -0800 (PST) Received-SPF: pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of peterx@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A9F0B19CF7A; Mon, 21 Jan 2019 07:59:53 +0000 (UTC) Received: from xz-x1.nay.redhat.com (dhcp-14-116.nay.redhat.com [10.66.14.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22340608F3; Mon, 21 Jan 2019 07:59:47 +0000 (UTC) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hugh Dickins , Maya Gokhale , Jerome Glisse , Johannes Weiner , peterx@redhat.com, Martin Cracauer , Denis Plotnikov , Shaohua Li , Andrea Arcangeli , Pavel Emelyanov , Mike Kravetz , Marty McFadden , Mike Rapoport , Mel Gorman , "Kirill A . Shutemov" , "Dr . David Alan Gilbert" Subject: [PATCH RFC 18/24] userfaultfd: wp: add pmd_swp_*uffd_wp() helpers Date: Mon, 21 Jan 2019 15:57:16 +0800 Message-Id: <20190121075722.7945-19-peterx@redhat.com> In-Reply-To: <20190121075722.7945-1-peterx@redhat.com> References: <20190121075722.7945-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 21 Jan 2019 07:59:53 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP Adding these missing helpers for uffd-wp operations with pmd swap/migration entries. 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 7a71158982f4..aa2eb36d7edf 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1401,6 +1401,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 */