Patch "powerpc/mm: dump segment registers on book3s/32" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    powerpc/mm: dump segment registers on book3s/32

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     powerpc-mm-dump-segment-registers-on-book3s-32.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8f066e89dffcf8a6e82e3025ac11e42fdb988270
Author: Christophe Leroy <christophe.leroy@xxxxxx>
Date:   Fri Nov 16 17:06:43 2018 +0000

    powerpc/mm: dump segment registers on book3s/32
    
    [ Upstream commit 0261a508c9fcb33e60f09cac42032f85c31e2039 ]
    
    This patch creates a debugfs file to see content of
    segment registers
    
      # cat /sys/kernel/debug/segment_registers
      ---[ User Segments ]---
      0x00000000-0x0fffffff Kern key 1 User key 1 VSID 0xade2b0
      0x10000000-0x1fffffff Kern key 1 User key 1 VSID 0xade3c1
      0x20000000-0x2fffffff Kern key 1 User key 1 VSID 0xade4d2
      0x30000000-0x3fffffff Kern key 1 User key 1 VSID 0xade5e3
      0x40000000-0x4fffffff Kern key 1 User key 1 VSID 0xade6f4
      0x50000000-0x5fffffff Kern key 1 User key 1 VSID 0xade805
      0x60000000-0x6fffffff Kern key 1 User key 1 VSID 0xade916
      0x70000000-0x7fffffff Kern key 1 User key 1 VSID 0xadea27
      0x80000000-0x8fffffff Kern key 1 User key 1 VSID 0xadeb38
      0x90000000-0x9fffffff Kern key 1 User key 1 VSID 0xadec49
      0xa0000000-0xafffffff Kern key 1 User key 1 VSID 0xaded5a
      0xb0000000-0xbfffffff Kern key 1 User key 1 VSID 0xadee6b
    
      ---[ Kernel Segments ]---
      0xc0000000-0xcfffffff Kern key 0 User key 1 VSID 0x000ccc
      0xd0000000-0xdfffffff Kern key 0 User key 1 VSID 0x000ddd
      0xe0000000-0xefffffff Kern key 0 User key 1 VSID 0x000eee
      0xf0000000-0xffffffff Kern key 0 User key 1 VSID 0x000fff
    
    Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxx>
    [mpe: Move it under /sys/kernel/debug/powerpc, make sr_init() __init]
    Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
    Stable-dep-of: 66b2ca086210 ("powerpc/64s/radix: Fix soft dirty tracking")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index 3c844bdd16c4e..d2784730c0e5d 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -47,7 +47,7 @@ ifdef CONFIG_PPC_PTDUMP
 obj-$(CONFIG_4xx)		+= dump_linuxpagetables-generic.o
 obj-$(CONFIG_PPC_8xx)		+= dump_linuxpagetables-8xx.o
 obj-$(CONFIG_PPC_BOOK3E_MMU)	+= dump_linuxpagetables-generic.o
-obj-$(CONFIG_PPC_BOOK3S_32)	+= dump_linuxpagetables-generic.o
+obj-$(CONFIG_PPC_BOOK3S_32)	+= dump_linuxpagetables-generic.o dump_sr.o
 obj-$(CONFIG_PPC_BOOK3S_64)	+= dump_linuxpagetables-book3s64.o
 endif
 obj-$(CONFIG_PPC_HTDUMP)	+= dump_hashpagetable.o
diff --git a/arch/powerpc/mm/dump_sr.c b/arch/powerpc/mm/dump_sr.c
new file mode 100644
index 0000000000000..501843664bb91
--- /dev/null
+++ b/arch/powerpc/mm/dump_sr.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018, Christophe Leroy CS S.I.
+ * <christophe.leroy@xxxxxx>
+ *
+ * This dumps the content of Segment Registers
+ */
+
+#include <asm/debugfs.h>
+
+static void seg_show(struct seq_file *m, int i)
+{
+	u32 val = mfsrin(i << 28);
+
+	seq_printf(m, "0x%01x0000000-0x%01xfffffff ", i, i);
+	seq_printf(m, "Kern key %d ", (val >> 30) & 1);
+	seq_printf(m, "User key %d ", (val >> 29) & 1);
+	if (val & 0x80000000) {
+		seq_printf(m, "Device 0x%03x", (val >> 20) & 0x1ff);
+		seq_printf(m, "-0x%05x", val & 0xfffff);
+	} else {
+		if (val & 0x10000000)
+			seq_puts(m, "No Exec ");
+		seq_printf(m, "VSID 0x%06x", val & 0xffffff);
+	}
+	seq_puts(m, "\n");
+}
+
+static int sr_show(struct seq_file *m, void *v)
+{
+	int i;
+
+	seq_puts(m, "---[ User Segments ]---\n");
+	for (i = 0; i < TASK_SIZE >> 28; i++)
+		seg_show(m, i);
+
+	seq_puts(m, "\n---[ Kernel Segments ]---\n");
+	for (; i < 16; i++)
+		seg_show(m, i);
+
+	return 0;
+}
+
+static int sr_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, sr_show, NULL);
+}
+
+static const struct file_operations sr_fops = {
+	.open		= sr_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static int __init sr_init(void)
+{
+	struct dentry *debugfs_file;
+
+	debugfs_file = debugfs_create_file("segment_registers", 0400,
+					   powerpc_debugfs_root, NULL, &sr_fops);
+	return debugfs_file ? 0 : -ENOMEM;
+}
+device_initcall(sr_init);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux