ptdump.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2014 ARM Ltd.
  4. */
  5. #ifndef __ASM_PTDUMP_H
  6. #define __ASM_PTDUMP_H
  7. #include <linux/ptdump.h>
  8. DECLARE_STATIC_KEY_FALSE(arm64_ptdump_lock_key);
  9. #ifdef CONFIG_PTDUMP
  10. #include <linux/mm_types.h>
  11. #include <linux/seq_file.h>
  12. struct addr_marker {
  13. unsigned long start_address;
  14. char *name;
  15. };
  16. struct ptdump_info {
  17. struct mm_struct *mm;
  18. const struct addr_marker *markers;
  19. unsigned long base_addr;
  20. };
  21. struct ptdump_prot_bits {
  22. ptdesc_t mask;
  23. ptdesc_t val;
  24. const char *set;
  25. const char *clear;
  26. };
  27. struct ptdump_pg_level {
  28. const struct ptdump_prot_bits *bits;
  29. char name[4];
  30. int num;
  31. ptdesc_t mask;
  32. };
  33. /*
  34. * The page dumper groups page table entries of the same type into a single
  35. * description. It uses pg_state to track the range information while
  36. * iterating over the pte entries. When the continuity is broken it then
  37. * dumps out a description of the range.
  38. */
  39. struct ptdump_pg_state {
  40. struct ptdump_state ptdump;
  41. struct ptdump_pg_level *pg_level;
  42. struct seq_file *seq;
  43. const struct addr_marker *marker;
  44. const struct mm_struct *mm;
  45. unsigned long start_address;
  46. int level;
  47. ptdesc_t current_prot;
  48. bool check_wx;
  49. unsigned long wx_pages;
  50. unsigned long uxn_pages;
  51. };
  52. void ptdump_walk(struct seq_file *s, struct ptdump_info *info);
  53. void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
  54. pteval_t val);
  55. void note_page_pte(struct ptdump_state *st, unsigned long addr, pte_t pte);
  56. void note_page_pmd(struct ptdump_state *st, unsigned long addr, pmd_t pmd);
  57. void note_page_pud(struct ptdump_state *st, unsigned long addr, pud_t pud);
  58. void note_page_p4d(struct ptdump_state *st, unsigned long addr, p4d_t p4d);
  59. void note_page_pgd(struct ptdump_state *st, unsigned long addr, pgd_t pgd);
  60. void note_page_flush(struct ptdump_state *st);
  61. #ifdef CONFIG_PTDUMP_DEBUGFS
  62. #define EFI_RUNTIME_MAP_END DEFAULT_MAP_WINDOW_64
  63. void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name);
  64. #else
  65. static inline void ptdump_debugfs_register(struct ptdump_info *info,
  66. const char *name) { }
  67. #endif /* CONFIG_PTDUMP_DEBUGFS */
  68. #else
  69. static inline void note_page(struct ptdump_state *pt_st, unsigned long addr,
  70. int level, pteval_t val) { }
  71. static inline void note_page_pte(struct ptdump_state *st, unsigned long addr, pte_t pte) { }
  72. static inline void note_page_pmd(struct ptdump_state *st, unsigned long addr, pmd_t pmd) { }
  73. static inline void note_page_pud(struct ptdump_state *st, unsigned long addr, pud_t pud) { }
  74. static inline void note_page_p4d(struct ptdump_state *st, unsigned long addr, p4d_t p4d) { }
  75. static inline void note_page_pgd(struct ptdump_state *st, unsigned long addr, pgd_t pgd) { }
  76. static inline void note_page_flush(struct ptdump_state *st) { }
  77. #endif /* CONFIG_PTDUMP */
  78. #endif /* __ASM_PTDUMP_H */