The replacement of <asm/pgrable.h> with <linux/pgtable.h> made the include of the latter in the middle of asm includes. Fix this up with the aid of the below script and manual adjustments here and there. import sys import re if len(sys.argv) is not 3: print "USAGE: %s <file> <header>" % (sys.argv[0]) sys.exit(1) hdr_to_move="#include <linux/%s>" % sys.argv[2] moved = False in_hdrs = False with open(sys.argv[1], "r") as f: lines = f.readlines() for _line in lines: line = _line.rstrip(' ') if line == hdr_to_move: continue if line.startswith("#include <linux/"): in_hdrs = True elif not moved and in_hdrs: moved = True print hdr_to_move print line Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Cain <bcain@codeaurora.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Zankel <chris@zankel.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greentime Hu <green.hu@gmail.com> Cc: Greg Ungerer <gerg@linux-m68k.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Cc: Guo Ren <guoren@kernel.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Helge Deller <deller@gmx.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Ley Foon Tan <ley.foon.tan@intel.com> Cc: Mark Salter <msalter@redhat.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Matt Turner <mattst88@gmail.com> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Nick Hu <nickhu@andestech.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Richard Weinberger <richard@nod.at> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Stafford Horne <shorne@gmail.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Vincent Chen <deanbo422@gmail.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Will Deacon <will@kernel.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Link: http://lkml.kernel.org/r/20200514170327.31389-4-rppt@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
168 lines
4.3 KiB
C
168 lines
4.3 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2018, Christophe Leroy CS S.I.
|
|
* <christophe.leroy@c-s.fr>
|
|
*
|
|
* This dumps the content of BATS
|
|
*/
|
|
|
|
#include <linux/pgtable.h>
|
|
#include <asm/debugfs.h>
|
|
#include <asm/cpu_has_feature.h>
|
|
|
|
#include "ptdump.h"
|
|
|
|
static char *pp_601(int k, int pp)
|
|
{
|
|
if (pp == 0)
|
|
return k ? " " : "rwx";
|
|
if (pp == 1)
|
|
return k ? "r x" : "rwx";
|
|
if (pp == 2)
|
|
return "rwx";
|
|
return "r x";
|
|
}
|
|
|
|
static void bat_show_601(struct seq_file *m, int idx, u32 lower, u32 upper)
|
|
{
|
|
u32 blpi = upper & 0xfffe0000;
|
|
u32 k = (upper >> 2) & 3;
|
|
u32 pp = upper & 3;
|
|
phys_addr_t pbn = PHYS_BAT_ADDR(lower);
|
|
u32 bsm = lower & 0x3ff;
|
|
u32 size = (bsm + 1) << 17;
|
|
|
|
seq_printf(m, "%d: ", idx);
|
|
if (!(lower & 0x40)) {
|
|
seq_puts(m, " -\n");
|
|
return;
|
|
}
|
|
|
|
seq_printf(m, "0x%08x-0x%08x ", blpi, blpi + size - 1);
|
|
#ifdef CONFIG_PHYS_64BIT
|
|
seq_printf(m, "0x%016llx ", pbn);
|
|
#else
|
|
seq_printf(m, "0x%08x ", pbn);
|
|
#endif
|
|
pt_dump_size(m, size);
|
|
|
|
seq_printf(m, "Kernel %s User %s", pp_601(k & 2, pp), pp_601(k & 1, pp));
|
|
|
|
seq_puts(m, lower & _PAGE_WRITETHRU ? "w " : " ");
|
|
seq_puts(m, lower & _PAGE_NO_CACHE ? "i " : " ");
|
|
seq_puts(m, lower & _PAGE_COHERENT ? "m " : " ");
|
|
seq_puts(m, "\n");
|
|
}
|
|
|
|
#define BAT_SHOW_601(_m, _n, _l, _u) bat_show_601(_m, _n, mfspr(_l), mfspr(_u))
|
|
|
|
static int bats_show_601(struct seq_file *m, void *v)
|
|
{
|
|
seq_puts(m, "---[ Block Address Translation ]---\n");
|
|
|
|
BAT_SHOW_601(m, 0, SPRN_IBAT0L, SPRN_IBAT0U);
|
|
BAT_SHOW_601(m, 1, SPRN_IBAT1L, SPRN_IBAT1U);
|
|
BAT_SHOW_601(m, 2, SPRN_IBAT2L, SPRN_IBAT2U);
|
|
BAT_SHOW_601(m, 3, SPRN_IBAT3L, SPRN_IBAT3U);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void bat_show_603(struct seq_file *m, int idx, u32 lower, u32 upper, bool is_d)
|
|
{
|
|
u32 bepi = upper & 0xfffe0000;
|
|
u32 bl = (upper >> 2) & 0x7ff;
|
|
u32 k = upper & 3;
|
|
phys_addr_t brpn = PHYS_BAT_ADDR(lower);
|
|
u32 size = (bl + 1) << 17;
|
|
|
|
seq_printf(m, "%d: ", idx);
|
|
if (k == 0) {
|
|
seq_puts(m, " -\n");
|
|
return;
|
|
}
|
|
|
|
seq_printf(m, "0x%08x-0x%08x ", bepi, bepi + size - 1);
|
|
#ifdef CONFIG_PHYS_64BIT
|
|
seq_printf(m, "0x%016llx ", brpn);
|
|
#else
|
|
seq_printf(m, "0x%08x ", brpn);
|
|
#endif
|
|
pt_dump_size(m, size);
|
|
|
|
if (k == 1)
|
|
seq_puts(m, "User ");
|
|
else if (k == 2)
|
|
seq_puts(m, "Kernel ");
|
|
else
|
|
seq_puts(m, "Kernel/User ");
|
|
|
|
if (lower & BPP_RX)
|
|
seq_puts(m, is_d ? "r " : " x ");
|
|
else if (lower & BPP_RW)
|
|
seq_puts(m, is_d ? "rw " : " x ");
|
|
else
|
|
seq_puts(m, is_d ? " " : " ");
|
|
|
|
seq_puts(m, lower & _PAGE_WRITETHRU ? "w " : " ");
|
|
seq_puts(m, lower & _PAGE_NO_CACHE ? "i " : " ");
|
|
seq_puts(m, lower & _PAGE_COHERENT ? "m " : " ");
|
|
seq_puts(m, lower & _PAGE_GUARDED ? "g " : " ");
|
|
seq_puts(m, "\n");
|
|
}
|
|
|
|
#define BAT_SHOW_603(_m, _n, _l, _u, _d) bat_show_603(_m, _n, mfspr(_l), mfspr(_u), _d)
|
|
|
|
static int bats_show_603(struct seq_file *m, void *v)
|
|
{
|
|
seq_puts(m, "---[ Instruction Block Address Translation ]---\n");
|
|
|
|
BAT_SHOW_603(m, 0, SPRN_IBAT0L, SPRN_IBAT0U, false);
|
|
BAT_SHOW_603(m, 1, SPRN_IBAT1L, SPRN_IBAT1U, false);
|
|
BAT_SHOW_603(m, 2, SPRN_IBAT2L, SPRN_IBAT2U, false);
|
|
BAT_SHOW_603(m, 3, SPRN_IBAT3L, SPRN_IBAT3U, false);
|
|
if (mmu_has_feature(MMU_FTR_USE_HIGH_BATS)) {
|
|
BAT_SHOW_603(m, 4, SPRN_IBAT4L, SPRN_IBAT4U, false);
|
|
BAT_SHOW_603(m, 5, SPRN_IBAT5L, SPRN_IBAT5U, false);
|
|
BAT_SHOW_603(m, 6, SPRN_IBAT6L, SPRN_IBAT6U, false);
|
|
BAT_SHOW_603(m, 7, SPRN_IBAT7L, SPRN_IBAT7U, false);
|
|
}
|
|
|
|
seq_puts(m, "\n---[ Data Block Address Translation ]---\n");
|
|
|
|
BAT_SHOW_603(m, 0, SPRN_DBAT0L, SPRN_DBAT0U, true);
|
|
BAT_SHOW_603(m, 1, SPRN_DBAT1L, SPRN_DBAT1U, true);
|
|
BAT_SHOW_603(m, 2, SPRN_DBAT2L, SPRN_DBAT2U, true);
|
|
BAT_SHOW_603(m, 3, SPRN_DBAT3L, SPRN_DBAT3U, true);
|
|
if (mmu_has_feature(MMU_FTR_USE_HIGH_BATS)) {
|
|
BAT_SHOW_603(m, 4, SPRN_DBAT4L, SPRN_DBAT4U, true);
|
|
BAT_SHOW_603(m, 5, SPRN_DBAT5L, SPRN_DBAT5U, true);
|
|
BAT_SHOW_603(m, 6, SPRN_DBAT6L, SPRN_DBAT6U, true);
|
|
BAT_SHOW_603(m, 7, SPRN_DBAT7L, SPRN_DBAT7U, true);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int bats_open(struct inode *inode, struct file *file)
|
|
{
|
|
if (IS_ENABLED(CONFIG_PPC_BOOK3S_601))
|
|
return single_open(file, bats_show_601, NULL);
|
|
|
|
return single_open(file, bats_show_603, NULL);
|
|
}
|
|
|
|
static const struct file_operations bats_fops = {
|
|
.open = bats_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = single_release,
|
|
};
|
|
|
|
static int __init bats_init(void)
|
|
{
|
|
debugfs_create_file("block_address_translation", 0400,
|
|
powerpc_debugfs_root, NULL, &bats_fops);
|
|
return 0;
|
|
}
|
|
device_initcall(bats_init);
|