segment_regs.c (1136B)
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Copyright 2018, Christophe Leroy CS S.I. 4 * <christophe.leroy@c-s.fr> 5 * 6 * This dumps the content of Segment Registers 7 */ 8 9#include <linux/debugfs.h> 10 11static void seg_show(struct seq_file *m, int i) 12{ 13 u32 val = mfsr(i << 28); 14 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); 25 } 26 seq_puts(m, "\n"); 27} 28 29static int sr_show(struct seq_file *m, void *v) 30{ 31 int i; 32 33 seq_puts(m, "---[ User Segments ]---\n"); 34 for (i = 0; i < TASK_SIZE >> 28; i++) 35 seg_show(m, i); 36 37 seq_puts(m, "\n---[ Kernel Segments ]---\n"); 38 for (; i < 16; i++) 39 seg_show(m, i); 40 41 return 0; 42} 43 44DEFINE_SHOW_ATTRIBUTE(sr); 45 46static int __init sr_init(void) 47{ 48 debugfs_create_file("segment_registers", 0400, arch_debugfs_dir, 49 NULL, &sr_fops); 50 return 0; 51} 52device_initcall(sr_init);