Merge tag 'linux-kselftest-kunit-fixes-5.11-rc3' of git://git.kernel.org/pub/scm...
[linux/fpc-iii.git] / arch / powerpc / mm / ptdump / segment_regs.c
blobdde2fe8de4b2a867093158981442dab4ac41ef51
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright 2018, Christophe Leroy CS S.I.
4 * <christophe.leroy@c-s.fr>
6 * This dumps the content of Segment Registers
7 */
9 #include <asm/debugfs.h>
11 static void seg_show(struct seq_file *m, int i)
13 u32 val = mfsrin(i << 28);
15 seq_printf(m, "0x%01x0000000-0x%01xfffffff ", i, i);
16 seq_printf(m, "Kern key %d ", (val >> 30) & 1);
17 seq_printf(m, "User key %d ", (val >> 29) & 1);
18 if (val & 0x80000000) {
19 seq_printf(m, "Device 0x%03x", (val >> 20) & 0x1ff);
20 seq_printf(m, "-0x%05x", val & 0xfffff);
21 } else {
22 if (val & 0x10000000)
23 seq_puts(m, "No Exec ");
24 seq_printf(m, "VSID 0x%06x", val & 0xffffff);
26 seq_puts(m, "\n");
29 static int sr_show(struct seq_file *m, void *v)
31 int i;
33 seq_puts(m, "---[ User Segments ]---\n");
34 for (i = 0; i < TASK_SIZE >> 28; i++)
35 seg_show(m, i);
37 seq_puts(m, "\n---[ Kernel Segments ]---\n");
38 for (; i < 16; i++)
39 seg_show(m, i);
41 return 0;
44 static int sr_open(struct inode *inode, struct file *file)
46 return single_open(file, sr_show, NULL);
49 static const struct file_operations sr_fops = {
50 .open = sr_open,
51 .read = seq_read,
52 .llseek = seq_lseek,
53 .release = single_release,
56 static int __init sr_init(void)
58 debugfs_create_file("segment_registers", 0400, powerpc_debugfs_root,
59 NULL, &sr_fops);
60 return 0;
62 device_initcall(sr_init);