From patchwork Fri Mar 4 05:16:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12768466 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 340A3C433EF for ; Fri, 4 Mar 2022 05:18:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C8BA68D0005; Fri, 4 Mar 2022 00:18:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C3AB78D0001; Fri, 4 Mar 2022 00:18:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B02E18D0005; Fri, 4 Mar 2022 00:18:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id A3CD48D0001 for ; Fri, 4 Mar 2022 00:18:54 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5F1BB8249980 for ; Fri, 4 Mar 2022 05:18:54 +0000 (UTC) X-FDA: 79205549388.21.23404F7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id DFCE21C000E for ; Fri, 4 Mar 2022 05:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646371133; 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=Jyv1lzZ4mkTvzdL9kLWgnj86vlKE/ygyLYqVdoUf6Sw=; b=BhbhHQgJ1QeYJQJIsLsTzPlCfMqWkDCFMTX5oelGUlK5Mh6qU9pmP5+Z4MTvZ7IJ6W6Y9o HLpj+ohro4AWpEFW9Uo4W+u4fpYFoUYS6f8RGkmNyT3Sh3HultHdFQStHgeLw59pDU3ua8 CcqENhhiUCpWyHHS59wSGqXzySASIZA= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-MuxeSx1bNFiNfU0Pjm9uEg-1; Fri, 04 Mar 2022 00:18:52 -0500 X-MC-Unique: MuxeSx1bNFiNfU0Pjm9uEg-1 Received: by mail-pj1-f71.google.com with SMTP id lp2-20020a17090b4a8200b001bc449ecbceso6724856pjb.8 for ; Thu, 03 Mar 2022 21:18:52 -0800 (PST) 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=Jyv1lzZ4mkTvzdL9kLWgnj86vlKE/ygyLYqVdoUf6Sw=; b=BEta7E2O4uiQiIRom/GnezbZIBemwFzo8s8d3xxsnccZ2Rla8P035nycdieEv8L6c5 GD9I6BYQak1ezvuWI+N73hlCPkjR77LxcSicjAM1wWGfJCFpi0hu/HAWYPQQVgKtKAGw usBQGi7wXyNcqLsQgvSxzSUAnXF2piN5X1mbmPCHjRRPqH7cfds2+Icsjb5q7X8TjS6m +vBxm2pcFD7/l6xGSlkFM1kVwZbkEd0IP2QuGZzDWQ0/ojjQASEvpA2V6v9ZkZUf+EJy JwMAcqmlGCGFFyF09yP0LuTMqR3tSjcJRP9P6/WudDuRVMlP7zitNxZrg8fghncRxHdK zqRQ== X-Gm-Message-State: AOAM530BoZAu42O711oN95HJHaIIFGSqVJrXVCW5t8ikBgLYe0LTgMbc p+IoYy7mbLKpSQWj99IU8WEueOD520dHGVFOGXFuQung7HzJWteIkG15wUojd+MPRif9qUwx7vT m7FelEZ1/fXphjtWm50cFp7uQCh+m6PmPEZT/mdll7wXxi6R4sJLezx/5yM8F X-Received: by 2002:a63:944:0:b0:374:5324:eea1 with SMTP id 65-20020a630944000000b003745324eea1mr33249213pgj.366.1646371131405; Thu, 03 Mar 2022 21:18:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhisbQFqQkhrO4+7tBm5bGrC3HEMdBg8mxUGWFFpK8iGmzvB3YNBGzza29cCioxbX4vov0sQ== X-Received: by 2002:a63:944:0:b0:374:5324:eea1 with SMTP id 65-20020a630944000000b003745324eea1mr33249184pgj.366.1646371131059; Thu, 03 Mar 2022 21:18:51 -0800 (PST) Received: from localhost.localdomain ([94.177.118.59]) by smtp.gmail.com with ESMTPSA id p16-20020a056a000b5000b004f669806cd9sm4323865pfo.87.2022.03.03.21.18.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Mar 2022 21:18:50 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, Nadav Amit , Hugh Dickins , David Hildenbrand , Axel Rasmussen , Matthew Wilcox , Alistair Popple , Mike Rapoport , Andrew Morton , Jerome Glisse , Mike Kravetz , "Kirill A . Shutemov" , Andrea Arcangeli Subject: [PATCH v7 11/23] mm/hugetlb: Introduce huge pte version of uffd-wp helpers Date: Fri, 4 Mar 2022 13:16:56 +0800 Message-Id: <20220304051708.86193-12-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220304051708.86193-1-peterx@redhat.com> References: <20220304051708.86193-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: DFCE21C000E X-Stat-Signature: azrg7jfwaay6ucsox1wshqstc6y51n1o Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BhbhHQgJ; spf=none (imf20.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1646371133-710910 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 60f9241e5e4a..19c4b4431d27 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)