From patchwork Tue Apr 5 01:48:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12800967 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 E9623C433EF for ; Tue, 5 Apr 2022 01:53:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 353586B0081; Mon, 4 Apr 2022 21:49:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D9DC6B0082; Mon, 4 Apr 2022 21:49:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17C4D6B0083; Mon, 4 Apr 2022 21:49:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 0B7ED6B0081 for ; Mon, 4 Apr 2022 21:49:14 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CF8EC22DD6 for ; Tue, 5 Apr 2022 01:49:03 +0000 (UTC) X-FDA: 79321142166.10.DBB93BD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 4A6D3180011 for ; Tue, 5 Apr 2022 01:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649123342; 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=1OYbScRjTNz5QBi4xGatPlRbPmUiT0LOinB85jUkB/M=; b=ZsMtWDH5rRH5nZ19PJUAMIR0xbZ1BIC/pi4MJGD3BF5JxHsmQJwrWAvoKzYSEcBB1gYCLn sfaG6efPKqM/iudAPxQF6qV/EhF/BnsAt5zsFc187xOjwzcQ+YaT7UX15+T8egyPlNOQKN QO9M/NQWa3BzzbtzkKgg3jr4T3tF6vc= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-CCH8UBC-N5OSY1Bo_McK3Q-1; Mon, 04 Apr 2022 21:49:01 -0400 X-MC-Unique: CCH8UBC-N5OSY1Bo_McK3Q-1 Received: by mail-il1-f198.google.com with SMTP id o2-20020a056e02114200b002ca3429fc20so3407998ill.11 for ; Mon, 04 Apr 2022 18:49:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1OYbScRjTNz5QBi4xGatPlRbPmUiT0LOinB85jUkB/M=; b=bxjnH4Ic2yWWan+VEX5VXhfie8+uXb8UgjhHR9njHBVW2wWdKvfk+mHfHMTaqy6H4o 1aUje7/OWHuy95QQLdZQV4gfQmw7VrT7+Ug0PJvMdnMfpgvP3p11OepK+yOrZCwMKId6 WXL1eeZhU2JOqJTK8tdU1r2ZAytTu/cGJclcLlASajRDNb18Ud/O/e51uwbTlaI70iqi bnRn9+TyX1RWfIRDnT+rMZ1udIgiJD2r1lMIKW9Vb/vnNHbnvcxS0x4eUKeRoATbLyCK FGedirqTNk7zMKGhn9a2ls1etghXYPhIsbv0SjTuY13vlclSYmSfuGRGKT46FnlaBpjj EdjQ== X-Gm-Message-State: AOAM532rqOmbASULru01gFpt2yM45oJ2yZhRBZFYcSsXMd0Z94j2xCC5 3nQ1+yYrCaT1LSPAgDT/rFRwQMI+z9ZPonUKQgCnpT7DvtubOSdmGIzBb8KIv9zoNWBBm0MIaE7 woAib5UWOkJE= X-Received: by 2002:a05:6638:a3a:b0:323:5c6d:ae20 with SMTP id 26-20020a0566380a3a00b003235c6dae20mr735137jao.80.1649123341174; Mon, 04 Apr 2022 18:49:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMAeWuW/3+txDsVV62vki1LADOgkDFuyCvrbdc9Pj11bhRHmjppURbT8nshi8PLqZuUQv4iQ== X-Received: by 2002:a05:6638:a3a:b0:323:5c6d:ae20 with SMTP id 26-20020a0566380a3a00b003235c6dae20mr735120jao.80.1649123340991; Mon, 04 Apr 2022 18:49:00 -0700 (PDT) Received: from localhost.localdomain (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id l14-20020a05660227ce00b00645ebb013c1sm8287007ios.45.2022.04.04.18.48.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 04 Apr 2022 18:49:00 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Kravetz , Nadav Amit , Matthew Wilcox , Mike Rapoport , David Hildenbrand , Hugh Dickins , Jerome Glisse , "Kirill A . Shutemov" , Andrea Arcangeli , Andrew Morton , Axel Rasmussen , Alistair Popple , peterx@redhat.com Subject: [PATCH v8 11/23] mm/hugetlb: Introduce huge pte version of uffd-wp helpers Date: Mon, 4 Apr 2022 21:48:58 -0400 Message-Id: <20220405014858.14531-1-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220405014646.13522-1-peterx@redhat.com> References: <20220405014646.13522-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: 81smmbgexaydskbmfekozwp73wtc739z Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZsMtWDH5; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf06.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 4A6D3180011 X-HE-Tag: 1649123343-954923 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: They will be used in the follow up patches to either check/set/clear uffd-wp bit of a huge pte. So far it reuses all the small pte helpers. Archs can overwrite these versions when necessary (with __HAVE_ARCH_HUGE_PTE_UFFD_WP* macros) in the future. Signed-off-by: Peter Xu --- arch/s390/include/asm/hugetlb.h | 15 +++++++++++++++ include/asm-generic/hugetlb.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h index bea47e7cc6a0..be99eda87f4d 100644 --- a/arch/s390/include/asm/hugetlb.h +++ b/arch/s390/include/asm/hugetlb.h @@ -115,6 +115,21 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) return pte_modify(pte, newprot); } +static inline pte_t huge_pte_mkuffd_wp(pte_t pte) +{ + return pte; +} + +static inline pte_t huge_pte_clear_uffd_wp(pte_t pte) +{ + return pte; +} + +static inline int huge_pte_uffd_wp(pte_t pte) +{ + return 0; +} + static inline bool gigantic_page_runtime_supported(void) { return true; diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h index f39cad20ffc6..896f341f614d 100644 --- a/include/asm-generic/hugetlb.h +++ b/include/asm-generic/hugetlb.h @@ -35,6 +35,21 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) return pte_modify(pte, newprot); } +static inline pte_t huge_pte_mkuffd_wp(pte_t pte) +{ + return pte_mkuffd_wp(pte); +} + +static inline pte_t huge_pte_clear_uffd_wp(pte_t pte) +{ + return pte_clear_uffd_wp(pte); +} + +static inline int huge_pte_uffd_wp(pte_t pte) +{ + return pte_uffd_wp(pte); +} + #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep, unsigned long sz)