From patchwork Mon Jul 6 00:48:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 11644789 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 A09E992A for ; Mon, 6 Jul 2020 00:51:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6840820739 for ; Mon, 6 Jul 2020 00:51:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b2OkUAAO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6840820739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wmD82Vg9vuyfCzW5NhhF8Iu1wLJ6m+Yxoap3dgNKj9Y=; b=b2OkUAAOi3WVtjSLYpP07cG8HB JMfqVLz6+jhyQ41XVA3DQ7b1o/c2AyYZBCRi3nUKIWEgXql2mqgVQsq2Yx2F0MBTbknjzyEwJOP4x CWaqL63SUuOtGqsHO+vlnCgQpEzD4snVU5i/02AD9OuZcekc2SiMzdvgqIZur7shtPyXCUdnv16V6 +i1kvB2Py6vsdu+x2QX8kX+JXv3/78vOS6PRRumDL33/ZKfCk++OWpfV5wPOTrhifulG3xAxghdjJ DSXsmTkUgKaFJD2ms2RmpJ4R9agBX3/XMZAqUvQ8oT7AFsp1d0fu7j94sp4UUA+Dr8FrQzAe5bQWu 4LoDUKng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsFKm-0006n4-8z; Mon, 06 Jul 2020 00:50:12 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsFKY-0006hq-ME; Mon, 06 Jul 2020 00:50:06 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BF0CD30E; Sun, 5 Jul 2020 17:49:56 -0700 (PDT) Received: from p8cg001049571a15.arm.com (unknown [10.163.84.195]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C61E33F718; Sun, 5 Jul 2020 17:49:46 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org Subject: [PATCH V4 4/4] Documentation/mm: Add descriptions for arch page table helpers Date: Mon, 6 Jul 2020 06:18:36 +0530 Message-Id: <1593996516-7186-5-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593996516-7186-1-git-send-email-anshuman.khandual@arm.com> References: <1593996516-7186-1-git-send-email-anshuman.khandual@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200705_204958_943180_8F4A77B7 X-CRM114-Status: GOOD ( 17.56 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, Benjamin Herrenschmidt , Heiko Carstens , Paul Mackerras , "H. Peter Anvin" , linux-riscv@lists.infradead.org, Will Deacon , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Jonathan Corbet , Michael Ellerman , x86@kernel.org, Mike Rapoport , Christian Borntraeger , Ingo Molnar , Catalin Marinas , linux-snps-arc@lists.infradead.org, Vasily Gorbik , Anshuman Khandual , Borislav Petkov , Paul Walmsley , "Kirill A . Shutemov" , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Vineet Gupta , linux-kernel@vger.kernel.org, Palmer Dabbelt , Andrew Morton , linuxppc-dev@lists.ozlabs.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This adds a specific description file for all arch page table helpers which is in sync with the semantics being tested via CONFIG_DEBUG_VM_PGTABLE. All future changes either to these descriptions here or the debug test should always remain in sync. Cc: Jonathan Corbet Cc: Andrew Morton Cc: Mike Rapoport Cc: Vineet Gupta Cc: Catalin Marinas Cc: Will Deacon Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Christian Borntraeger Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Kirill A. Shutemov Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: linux-snps-arc@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-s390@vger.kernel.org Cc: linux-riscv@lists.infradead.org Cc: x86@kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Acked-by: Mike Rapoport Suggested-by: Mike Rapoport Signed-off-by: Anshuman Khandual --- Documentation/vm/arch_pgtable_helpers.rst | 258 ++++++++++++++++++++++ mm/debug_vm_pgtable.c | 6 + 2 files changed, 264 insertions(+) create mode 100644 Documentation/vm/arch_pgtable_helpers.rst diff --git a/Documentation/vm/arch_pgtable_helpers.rst b/Documentation/vm/arch_pgtable_helpers.rst new file mode 100644 index 000000000000..cd7609b05446 --- /dev/null +++ b/Documentation/vm/arch_pgtable_helpers.rst @@ -0,0 +1,258 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. _arch_page_table_helpers: + +=============================== +Architecture Page Table Helpers +=============================== + +Generic MM expects architectures (with MMU) to provide helpers to create, access +and modify page table entries at various level for different memory functions. +These page table helpers need to conform to a common semantics across platforms. +Following tables describe the expected semantics which can also be tested during +boot via CONFIG_DEBUG_VM_PGTABLE option. All future changes in here or the debug +test need to be in sync. + +====================== +PTE Page Table Helpers +====================== + +-------------------------------------------------------------------------------- +| pte_same | Tests whether both PTE entries are the same | +-------------------------------------------------------------------------------- +| pte_bad | Tests a non-table mapped PTE | +-------------------------------------------------------------------------------- +| pte_present | Tests a valid mapped PTE | +-------------------------------------------------------------------------------- +| pte_young | Tests a young PTE | +-------------------------------------------------------------------------------- +| pte_dirty | Tests a dirty PTE | +-------------------------------------------------------------------------------- +| pte_write | Tests a writable PTE | +-------------------------------------------------------------------------------- +| pte_special | Tests a special PTE | +-------------------------------------------------------------------------------- +| pte_protnone | Tests a PROT_NONE PTE | +-------------------------------------------------------------------------------- +| pte_devmap | Tests a ZONE_DEVICE mapped PTE | +-------------------------------------------------------------------------------- +| pte_soft_dirty | Tests a soft dirty PTE | +-------------------------------------------------------------------------------- +| pte_swp_soft_dirty | Tests a soft dirty swapped PTE | +-------------------------------------------------------------------------------- +| pte_mkyoung | Creates a young PTE | +-------------------------------------------------------------------------------- +| pte_mkold | Creates an old PTE | +-------------------------------------------------------------------------------- +| pte_mkdirty | Creates a dirty PTE | +-------------------------------------------------------------------------------- +| pte_mkclean | Creates a clean PTE | +-------------------------------------------------------------------------------- +| pte_mkwrite | Creates a writable PTE | +-------------------------------------------------------------------------------- +| pte_mkwrprotect | Creates a write protected PTE | +-------------------------------------------------------------------------------- +| pte_mkspecial | Creates a special PTE | +-------------------------------------------------------------------------------- +| pte_mkdevmap | Creates a ZONE_DEVICE mapped PTE | +-------------------------------------------------------------------------------- +| pte_mksoft_dirty | Creates a soft dirty PTE | +-------------------------------------------------------------------------------- +| pte_clear_soft_dirty | Clears a soft dirty PTE | +-------------------------------------------------------------------------------- +| pte_swp_mksoft_dirty | Creates a soft dirty swapped PTE | +-------------------------------------------------------------------------------- +| pte_swp_clear_soft_dirty | Clears a soft dirty swapped PTE | +-------------------------------------------------------------------------------- +| pte_mknotpresent | Invalidates a mapped PTE | +-------------------------------------------------------------------------------- +| ptep_get_and_clear | Clears a PTE | +-------------------------------------------------------------------------------- +| ptep_get_and_clear_full | Clears a PTE | +-------------------------------------------------------------------------------- +| ptep_test_and_clear_young | Clears young from a PTE | +-------------------------------------------------------------------------------- +| ptep_set_wrprotect | Converts into a write protected PTE | +-------------------------------------------------------------------------------- +| ptep_set_access_flags | Converts into a more permissive PTE | +-------------------------------------------------------------------------------- + +====================== +PMD Page Table Helpers +====================== + +-------------------------------------------------------------------------------- +| pmd_same | Tests whether both PMD entries are the same | +-------------------------------------------------------------------------------- +| pmd_bad | Tests a non-table mapped PMD | +-------------------------------------------------------------------------------- +| pmd_leaf | Tests a leaf mapped PMD | +-------------------------------------------------------------------------------- +| pmd_huge | Tests a HugeTLB mapped PMD | +-------------------------------------------------------------------------------- +| pmd_trans_huge | Tests a Transparent Huge Page (THP) at PMD | +-------------------------------------------------------------------------------- +| pmd_present | Tests a valid mapped PMD | +-------------------------------------------------------------------------------- +| pmd_young | Tests a young PMD | +-------------------------------------------------------------------------------- +| pmd_dirty | Tests a dirty PMD | +-------------------------------------------------------------------------------- +| pmd_write | Tests a writable PMD | +-------------------------------------------------------------------------------- +| pmd_special | Tests a special PMD | +-------------------------------------------------------------------------------- +| pmd_protnone | Tests a PROT_NONE PMD | +-------------------------------------------------------------------------------- +| pmd_devmap | Tests a ZONE_DEVICE mapped PMD | +-------------------------------------------------------------------------------- +| pmd_soft_dirty | Tests a soft dirty PMD | +-------------------------------------------------------------------------------- +| pmd_swp_soft_dirty | Tests a soft dirty swapped PMD | +-------------------------------------------------------------------------------- +| pmd_mkyoung | Creates a young PMD | +-------------------------------------------------------------------------------- +| pmd_mkold | Creates an old PMD | +-------------------------------------------------------------------------------- +| pmd_mkdirty | Creates a dirty PMD | +-------------------------------------------------------------------------------- +| pmd_mkclean | Creates a clean PMD | +-------------------------------------------------------------------------------- +| pmd_mkwrite | Creates a writable PMD | +-------------------------------------------------------------------------------- +| pmd_mkwrprotect | Creates a write protected PMD | +-------------------------------------------------------------------------------- +| pmd_mkspecial | Creates a special PMD | +-------------------------------------------------------------------------------- +| pmd_mkdevmap | Creates a ZONE_DEVICE mapped PMD | +-------------------------------------------------------------------------------- +| pmd_mksoft_dirty | Creates a soft dirty PMD | +-------------------------------------------------------------------------------- +| pmd_clear_soft_dirty | Clears a soft dirty PMD | +-------------------------------------------------------------------------------- +| pmd_swp_mksoft_dirty | Creates a soft dirty swapped PMD | +-------------------------------------------------------------------------------- +| pmd_swp_clear_soft_dirty | Clears a soft dirty swapped PMD | +-------------------------------------------------------------------------------- +| pmd_mkinvalid | Invalidates a mapped PMD [1] | +-------------------------------------------------------------------------------- +| pmd_set_huge | Creates a PMD huge mapping | +-------------------------------------------------------------------------------- +| pmd_clear_huge | Clears a PMD huge mapping | +-------------------------------------------------------------------------------- +| pmdp_get_and_clear | Clears a PMD | +-------------------------------------------------------------------------------- +| pmdp_get_and_clear_full | Clears a PMD | +-------------------------------------------------------------------------------- +| pmdp_test_and_clear_young | Clears young from a PMD | +-------------------------------------------------------------------------------- +| pmdp_set_wrprotect | Converts into a write protected PMD | +-------------------------------------------------------------------------------- +| pmdp_set_access_flags | Converts into a more permissive PMD | +-------------------------------------------------------------------------------- + +====================== +PUD Page Table Helpers +====================== + +-------------------------------------------------------------------------------- +| pud_same | Tests whether both PUD entries are the same | +-------------------------------------------------------------------------------- +| pud_bad | Tests a non-table mapped PUD | +-------------------------------------------------------------------------------- +| pud_leaf | Tests a leaf mapped PUD | +-------------------------------------------------------------------------------- +| pud_huge | Tests a HugeTLB mapped PUD | +-------------------------------------------------------------------------------- +| pud_trans_huge | Tests a Transparent Huge Page (THP) at PUD | +-------------------------------------------------------------------------------- +| pud_present | Tests a valid mapped PUD | +-------------------------------------------------------------------------------- +| pud_young | Tests a young PUD | +-------------------------------------------------------------------------------- +| pud_dirty | Tests a dirty PUD | +-------------------------------------------------------------------------------- +| pud_write | Tests a writable PUD | +-------------------------------------------------------------------------------- +| pud_devmap | Tests a ZONE_DEVICE mapped PUD | +-------------------------------------------------------------------------------- +| pud_mkyoung | Creates a young PUD | +-------------------------------------------------------------------------------- +| pud_mkold | Creates an old PUD | +-------------------------------------------------------------------------------- +| pud_mkdirty | Creates a dirty PUD | +-------------------------------------------------------------------------------- +| pud_mkclean | Creates a clean PUD | +-------------------------------------------------------------------------------- +| pud_mkwrite | Creates a writable PMD | +-------------------------------------------------------------------------------- +| pud_mkwrprotect | Creates a write protected PMD | +-------------------------------------------------------------------------------- +| pud_mkdevmap | Creates a ZONE_DEVICE mapped PMD | +-------------------------------------------------------------------------------- +| pud_mkinvalid | Invalidates a mapped PUD [1] | +-------------------------------------------------------------------------------- +| pud_set_huge | Creates a PUD huge mapping | +-------------------------------------------------------------------------------- +| pud_clear_huge | Clears a PUD huge mapping | +-------------------------------------------------------------------------------- +| pudp_get_and_clear | Clears a PUD | +-------------------------------------------------------------------------------- +| pudp_get_and_clear_full | Clears a PUD | +-------------------------------------------------------------------------------- +| pudp_test_and_clear_young | Clears young from a PUD | +-------------------------------------------------------------------------------- +| pudp_set_wrprotect | Converts into a write protected PUD | +-------------------------------------------------------------------------------- +| pudp_set_access_flags | Converts into a more permissive PUD | +-------------------------------------------------------------------------------- + +========================== +HugeTLB Page Table Helpers +========================== + +-------------------------------------------------------------------------------- +| pte_huge | Tests a HugeTLB | +-------------------------------------------------------------------------------- +| pte_mkhuge | Creates a HugeTLB | +-------------------------------------------------------------------------------- +| huge_pte_dirty | Tests a dirty HugeTLB | +-------------------------------------------------------------------------------- +| huge_pte_write | Tests a writable HugeTLB | +-------------------------------------------------------------------------------- +| huge_pte_mkdirty | Creates a dirty HugeTLB | +-------------------------------------------------------------------------------- +| huge_pte_mkwrite | Creates a writable HugeTLB | +-------------------------------------------------------------------------------- +| huge_pte_mkwrprotect | Creates a write protected HugeTLB | +-------------------------------------------------------------------------------- +| huge_ptep_get_and_clear | Clears a HugeTLB | +-------------------------------------------------------------------------------- +| huge_ptep_set_wrprotect | Converts into a write protected HugeTLB | +-------------------------------------------------------------------------------- +| huge_ptep_set_access_flags | Converts into a more permissive HugeTLB | +-------------------------------------------------------------------------------- + +======================== +SWAP Page Table Helpers +======================== + +-------------------------------------------------------------------------------- +| __pte_to_swp_entry | Creates a swapped entry (arch) from a mapepd PTE | +-------------------------------------------------------------------------------- +| __swp_to_pte_entry | Creates a mapped PTE from a swapped entry (arch) | +-------------------------------------------------------------------------------- +| __pmd_to_swp_entry | Creates a swapped entry (arch) from a mapepd PMD | +-------------------------------------------------------------------------------- +| __swp_to_pmd_entry | Creates a mapped PMD from a swapped entry (arch) | +-------------------------------------------------------------------------------- +| is_migration_entry | Tests a migration (read or write) swapped entry | +-------------------------------------------------------------------------------- +| is_write_migration_entry | Tests a write migration swapped entry | +-------------------------------------------------------------------------------- +| make_migration_entry_read | Converts into read migration swapped entry | +-------------------------------------------------------------------------------- +| make_migration_entry | Creates a migration swapped entry (read or write)| +-------------------------------------------------------------------------------- + +[1] https://lore.kernel.org/linux-mm/20181017020930.GN30832@redhat.com/ diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c index a9ae8cb7e832..4f0a61f6aff5 100644 --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -31,6 +31,12 @@ #include #include +/* + * Please refer Documentation/vm/arch_pgtable_helpers.rst for the semantics + * expectations that are being validated here. All future changes in here + * or the documentation need to be in sync. + */ + #define VMFLAGS (VM_READ|VM_WRITE|VM_EXEC) /*