From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92A43C433FF for ; Wed, 31 Jul 2019 15:46:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63D18206B8 for ; Wed, 31 Jul 2019 15:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729051AbfGaPqM (ORCPT ); Wed, 31 Jul 2019 11:46:12 -0400 Received: from foss.arm.com ([217.140.110.172]:49452 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbfGaPqM (ORCPT ); Wed, 31 Jul 2019 11:46:12 -0400 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 96268344; Wed, 31 Jul 2019 08:46:11 -0700 (PDT) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0A2D43F694; Wed, 31 Jul 2019 08:46:08 -0700 (PDT) From: Steven Price To: linux-mm@kvack.org Cc: Steven Price , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , "Liang, Kan" , Andrew Morton Subject: [PATCH v10 00/22] Generic page walk and ptdump Date: Wed, 31 Jul 2019 16:45:41 +0100 Message-Id: <20190731154603.41797-1-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a slight reworking and extension of my previous patch set (Convert x86 & arm64 to use generic page walk), but I've continued the version numbering as most of the changes are the same. In particular this series ends with a generic PTDUMP implemention for arm64 and x86. Many architectures current have a debugfs file for dumping the kernel page tables. Currently each architecture has to implement custom functions for this because the details of walking the page tables used by the kernel are different between architectures. This series extends the capabilities of walk_page_range() so that it can deal with the page tables of the kernel (which have no VMAs and can contain larger huge pages than exist for user space). A generic PTDUMP implementation is the implemented making use of the new functionality of walk_page_range() and finally arm64 and x86 are switch to using it, removing the custom table walkers. To enable a generic page table walker to walk the unusual mappings of the kernel we need to implement a set of functions which let us know when the walker has reached the leaf entry. After a suggestion from Will Deacon I've chosen the name p?d_leaf() as this (hopefully) describes the purpose (and is a new name so has no historic baggage). Some architectures have p?d_large macros but this is easily confused with "large pages". Mostly this is a clean up and there should be very little functional change. The exceptions are: * x86 PTDUMP debugfs output no longer display pages which aren't present (patch 14). * arm64 has the ability to efficiently process KASAN pages (which previously only x86 implemented). This means that the combination of KASAN and DEBUG_WX is now useable. Also available as a git tree: git://linux-arm.org/linux-sp.git walk_page_range/v10 Changes since v9: https://lore.kernel.org/lkml/20190722154210.42799-1-steven.price@arm.com/ * Moved generic macros to first page in the series and explained the macro naming in the commit message. * mips: Moved macros to pgtable.h as they are now valid for both 32 and 64 bit * x86: Dropped patch which changed the debugfs output for x86, instead we have... * new patch adding 'depth' parameter to pte_hole. This is used to provide the necessary information to output lines for 'holes' in the debugfs files * new patch changing arm64 debugfs output to include holes to match x86 * generic ptdump KASAN handling has been simplified and now works with CONFIG_DEBUG_VIRTUAL. Changes since v8: https://lore.kernel.org/lkml/20190403141627.11664-1-steven.price@arm.com/ * Rename from p?d_large() to p?d_leaf() * Dropped patches migrating arm64/x86 custom walkers to walk_page_range() in favour of adding a generic PTDUMP implementation and migrating arm64/x86 to that instead. * Rebased to v5.3-rc1 Steven Price (22): mm: Add generic p?d_leaf() macros arc: mm: Add p?d_leaf() definitions arm: mm: Add p?d_leaf() definitions arm64: mm: Add p?d_leaf() definitions mips: mm: Add p?d_leaf() definitions powerpc: mm: Add p?d_leaf() definitions riscv: mm: Add p?d_leaf() definitions s390: mm: Add p?d_leaf() definitions sparc: mm: Add p?d_leaf() definitions x86: mm: Add p?d_leaf() definitions mm: pagewalk: Add p4d_entry() and pgd_entry() mm: pagewalk: Allow walking without vma mm: pagewalk: Add test_p?d callbacks mm: pagewalk: Add 'depth' parameter to pte_hole x86: mm: Point to struct seq_file from struct pg_state x86: mm+efi: Convert ptdump_walk_pgd_level() to take a mm_struct x86: mm: Convert ptdump_walk_pgd_level_debugfs() to take an mm_struct x86: mm: Convert ptdump_walk_pgd_level_core() to take an mm_struct mm: Add generic ptdump x86: mm: Convert dump_pagetables to use walk_page_range arm64: mm: Convert mm/dump.c to use walk_page_range() arm64: mm: Display non-present entries in ptdump arch/arc/include/asm/pgtable.h | 1 + arch/arm/include/asm/pgtable-2level.h | 1 + arch/arm/include/asm/pgtable-3level.h | 1 + arch/arm64/Kconfig | 1 + arch/arm64/Kconfig.debug | 19 +- arch/arm64/include/asm/pgtable.h | 2 + arch/arm64/include/asm/ptdump.h | 8 +- arch/arm64/mm/Makefile | 4 +- arch/arm64/mm/dump.c | 144 +++----- arch/arm64/mm/mmu.c | 4 +- arch/arm64/mm/ptdump_debugfs.c | 2 +- arch/mips/include/asm/pgtable.h | 5 + arch/powerpc/include/asm/book3s/64/pgtable.h | 30 +- arch/riscv/include/asm/pgtable-64.h | 7 + arch/riscv/include/asm/pgtable.h | 7 + arch/s390/include/asm/pgtable.h | 2 + arch/sparc/include/asm/pgtable_64.h | 2 + arch/x86/Kconfig | 1 + arch/x86/Kconfig.debug | 20 +- arch/x86/include/asm/pgtable.h | 10 +- arch/x86/mm/Makefile | 4 +- arch/x86/mm/debug_pagetables.c | 8 +- arch/x86/mm/dump_pagetables.c | 332 +++++-------------- arch/x86/platform/efi/efi_32.c | 2 +- arch/x86/platform/efi/efi_64.c | 4 +- drivers/firmware/efi/arm-runtime.c | 2 +- fs/proc/task_mmu.c | 4 +- include/asm-generic/pgtable.h | 20 ++ include/linux/mm.h | 35 +- include/linux/ptdump.h | 19 ++ mm/Kconfig.debug | 21 ++ mm/Makefile | 1 + mm/hmm.c | 2 +- mm/migrate.c | 1 + mm/mincore.c | 1 + mm/pagewalk.c | 107 ++++-- mm/ptdump.c | 151 +++++++++ 37 files changed, 544 insertions(+), 441 deletions(-) create mode 100644 include/linux/ptdump.h create mode 100644 mm/ptdump.c -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E3AEC32751 for ; Wed, 31 Jul 2019 15:46:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 45C7120C01 for ; Wed, 31 Jul 2019 15:46:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mg+cQ1+M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45C7120C01 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+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=jyNOIRDEC3VqSN+hD6F1tMdREnhJ9GoOIMdrtbCghPQ=; b=mg+cQ1+Mag/v4y NsevC+fiWS9EzRJDOzYcrzhIceV5XHXupWxoQUpNoLylih/aFXgF34CKifDJDg/RobHtnYJ9K31Sp qv6f0npzG8gH/1yhZqPfYXjCouK7uOvvvGy8zR/QSIlAWfjY6XXGGM7RzX5yJgCPHq7V6q01KEVN+ 5Ckah0/MWTbPJylxgWtu6VWrwojWp2cIv92GCYt/yRk0g8AweS9JW+0/4sJvP20lwroFaMI58S5Di AaN2cfkuopSwmR7tfCSOre8ydfJmynIlses5eNp8Zl0b6tbb2LHLH7VRlVBODmzOSGGBg3GXOWIvo 8m/Cif0bCNWmZtLERqXA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsqnv-0005CJ-Oh; Wed, 31 Jul 2019 15:46:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hsqns-0005Bi-41 for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2019 15:46:13 +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 96268344; Wed, 31 Jul 2019 08:46:11 -0700 (PDT) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0A2D43F694; Wed, 31 Jul 2019 08:46:08 -0700 (PDT) From: Steven Price To: linux-mm@kvack.org Subject: [PATCH v10 00/22] Generic page walk and ptdump Date: Wed, 31 Jul 2019 16:45:41 +0100 Message-Id: <20190731154603.41797-1-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190731_084612_250595_ECA1BDFD X-CRM114-Status: GOOD ( 19.69 ) 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: Mark Rutland , x86@kernel.org, Arnd Bergmann , Ard Biesheuvel , Peter Zijlstra , Catalin Marinas , Dave Hansen , linux-kernel@vger.kernel.org, Steven Price , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , James Morse , Thomas Gleixner , Will Deacon , Andrew Morton , linux-arm-kernel@lists.infradead.org, "Liang, Kan" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is a slight reworking and extension of my previous patch set (Convert x86 & arm64 to use generic page walk), but I've continued the version numbering as most of the changes are the same. In particular this series ends with a generic PTDUMP implemention for arm64 and x86. Many architectures current have a debugfs file for dumping the kernel page tables. Currently each architecture has to implement custom functions for this because the details of walking the page tables used by the kernel are different between architectures. This series extends the capabilities of walk_page_range() so that it can deal with the page tables of the kernel (which have no VMAs and can contain larger huge pages than exist for user space). A generic PTDUMP implementation is the implemented making use of the new functionality of walk_page_range() and finally arm64 and x86 are switch to using it, removing the custom table walkers. To enable a generic page table walker to walk the unusual mappings of the kernel we need to implement a set of functions which let us know when the walker has reached the leaf entry. After a suggestion from Will Deacon I've chosen the name p?d_leaf() as this (hopefully) describes the purpose (and is a new name so has no historic baggage). Some architectures have p?d_large macros but this is easily confused with "large pages". Mostly this is a clean up and there should be very little functional change. The exceptions are: * x86 PTDUMP debugfs output no longer display pages which aren't present (patch 14). * arm64 has the ability to efficiently process KASAN pages (which previously only x86 implemented). This means that the combination of KASAN and DEBUG_WX is now useable. Also available as a git tree: git://linux-arm.org/linux-sp.git walk_page_range/v10 Changes since v9: https://lore.kernel.org/lkml/20190722154210.42799-1-steven.price@arm.com/ * Moved generic macros to first page in the series and explained the macro naming in the commit message. * mips: Moved macros to pgtable.h as they are now valid for both 32 and 64 bit * x86: Dropped patch which changed the debugfs output for x86, instead we have... * new patch adding 'depth' parameter to pte_hole. This is used to provide the necessary information to output lines for 'holes' in the debugfs files * new patch changing arm64 debugfs output to include holes to match x86 * generic ptdump KASAN handling has been simplified and now works with CONFIG_DEBUG_VIRTUAL. Changes since v8: https://lore.kernel.org/lkml/20190403141627.11664-1-steven.price@arm.com/ * Rename from p?d_large() to p?d_leaf() * Dropped patches migrating arm64/x86 custom walkers to walk_page_range() in favour of adding a generic PTDUMP implementation and migrating arm64/x86 to that instead. * Rebased to v5.3-rc1 Steven Price (22): mm: Add generic p?d_leaf() macros arc: mm: Add p?d_leaf() definitions arm: mm: Add p?d_leaf() definitions arm64: mm: Add p?d_leaf() definitions mips: mm: Add p?d_leaf() definitions powerpc: mm: Add p?d_leaf() definitions riscv: mm: Add p?d_leaf() definitions s390: mm: Add p?d_leaf() definitions sparc: mm: Add p?d_leaf() definitions x86: mm: Add p?d_leaf() definitions mm: pagewalk: Add p4d_entry() and pgd_entry() mm: pagewalk: Allow walking without vma mm: pagewalk: Add test_p?d callbacks mm: pagewalk: Add 'depth' parameter to pte_hole x86: mm: Point to struct seq_file from struct pg_state x86: mm+efi: Convert ptdump_walk_pgd_level() to take a mm_struct x86: mm: Convert ptdump_walk_pgd_level_debugfs() to take an mm_struct x86: mm: Convert ptdump_walk_pgd_level_core() to take an mm_struct mm: Add generic ptdump x86: mm: Convert dump_pagetables to use walk_page_range arm64: mm: Convert mm/dump.c to use walk_page_range() arm64: mm: Display non-present entries in ptdump arch/arc/include/asm/pgtable.h | 1 + arch/arm/include/asm/pgtable-2level.h | 1 + arch/arm/include/asm/pgtable-3level.h | 1 + arch/arm64/Kconfig | 1 + arch/arm64/Kconfig.debug | 19 +- arch/arm64/include/asm/pgtable.h | 2 + arch/arm64/include/asm/ptdump.h | 8 +- arch/arm64/mm/Makefile | 4 +- arch/arm64/mm/dump.c | 144 +++----- arch/arm64/mm/mmu.c | 4 +- arch/arm64/mm/ptdump_debugfs.c | 2 +- arch/mips/include/asm/pgtable.h | 5 + arch/powerpc/include/asm/book3s/64/pgtable.h | 30 +- arch/riscv/include/asm/pgtable-64.h | 7 + arch/riscv/include/asm/pgtable.h | 7 + arch/s390/include/asm/pgtable.h | 2 + arch/sparc/include/asm/pgtable_64.h | 2 + arch/x86/Kconfig | 1 + arch/x86/Kconfig.debug | 20 +- arch/x86/include/asm/pgtable.h | 10 +- arch/x86/mm/Makefile | 4 +- arch/x86/mm/debug_pagetables.c | 8 +- arch/x86/mm/dump_pagetables.c | 332 +++++-------------- arch/x86/platform/efi/efi_32.c | 2 +- arch/x86/platform/efi/efi_64.c | 4 +- drivers/firmware/efi/arm-runtime.c | 2 +- fs/proc/task_mmu.c | 4 +- include/asm-generic/pgtable.h | 20 ++ include/linux/mm.h | 35 +- include/linux/ptdump.h | 19 ++ mm/Kconfig.debug | 21 ++ mm/Makefile | 1 + mm/hmm.c | 2 +- mm/migrate.c | 1 + mm/mincore.c | 1 + mm/pagewalk.c | 107 ++++-- mm/ptdump.c | 151 +++++++++ 37 files changed, 544 insertions(+), 441 deletions(-) create mode 100644 include/linux/ptdump.h create mode 100644 mm/ptdump.c -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel