debug_pagetables.c 997 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <linux/debugfs.h>
  2. #include <linux/module.h>
  3. #include <linux/seq_file.h>
  4. #include <asm/pgtable.h>
  5. static int ptdump_show(struct seq_file *m, void *v)
  6. {
  7. ptdump_walk_pgd_level(m, NULL);
  8. return 0;
  9. }
  10. static int ptdump_open(struct inode *inode, struct file *filp)
  11. {
  12. return single_open(filp, ptdump_show, NULL);
  13. }
  14. static const struct file_operations ptdump_fops = {
  15. .owner = THIS_MODULE,
  16. .open = ptdump_open,
  17. .read = seq_read,
  18. .llseek = seq_lseek,
  19. .release = single_release,
  20. };
  21. static struct dentry *pe;
  22. static int __init pt_dump_debug_init(void)
  23. {
  24. pe = debugfs_create_file("kernel_page_tables", S_IRUSR, NULL, NULL,
  25. &ptdump_fops);
  26. if (!pe)
  27. return -ENOMEM;
  28. return 0;
  29. }
  30. static void __exit pt_dump_debug_exit(void)
  31. {
  32. debugfs_remove_recursive(pe);
  33. }
  34. module_init(pt_dump_debug_init);
  35. module_exit(pt_dump_debug_exit);
  36. MODULE_LICENSE("GPL");
  37. MODULE_AUTHOR("Arjan van de Ven <arjan@linux.intel.com>");
  38. MODULE_DESCRIPTION("Kernel debugging helper that dumps pagetables");