2019-06-03 07:44:50 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2016-05-31 14:49:01 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 ARM Ltd.
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_PTDUMP_H
|
|
|
|
#define __ASM_PTDUMP_H
|
|
|
|
|
2024-09-09 12:47:18 +00:00
|
|
|
#include <linux/ptdump.h>
|
|
|
|
|
2025-02-26 17:54:04 +05:30
|
|
|
#ifdef CONFIG_PTDUMP
|
2016-05-31 14:49:01 +01:00
|
|
|
|
|
|
|
#include <linux/mm_types.h>
|
2016-10-27 09:27:31 -07:00
|
|
|
#include <linux/seq_file.h>
|
2016-05-31 14:49:01 +01:00
|
|
|
|
|
|
|
struct addr_marker {
|
|
|
|
unsigned long start_address;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ptdump_info {
|
|
|
|
struct mm_struct *mm;
|
|
|
|
const struct addr_marker *markers;
|
|
|
|
unsigned long base_addr;
|
|
|
|
};
|
|
|
|
|
2024-09-09 12:47:18 +00:00
|
|
|
struct ptdump_prot_bits {
|
2025-04-07 11:01:13 +05:30
|
|
|
ptdesc_t mask;
|
|
|
|
ptdesc_t val;
|
2024-09-09 12:47:18 +00:00
|
|
|
const char *set;
|
|
|
|
const char *clear;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ptdump_pg_level {
|
|
|
|
const struct ptdump_prot_bits *bits;
|
|
|
|
char name[4];
|
|
|
|
int num;
|
2025-04-07 11:01:13 +05:30
|
|
|
ptdesc_t mask;
|
2024-09-09 12:47:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The page dumper groups page table entries of the same type into a single
|
|
|
|
* description. It uses pg_state to track the range information while
|
|
|
|
* iterating over the pte entries. When the continuity is broken it then
|
|
|
|
* dumps out a description of the range.
|
|
|
|
*/
|
|
|
|
struct ptdump_pg_state {
|
|
|
|
struct ptdump_state ptdump;
|
2024-09-09 12:47:19 +00:00
|
|
|
struct ptdump_pg_level *pg_level;
|
2024-09-09 12:47:18 +00:00
|
|
|
struct seq_file *seq;
|
|
|
|
const struct addr_marker *marker;
|
|
|
|
const struct mm_struct *mm;
|
|
|
|
unsigned long start_address;
|
|
|
|
int level;
|
2025-04-07 11:01:13 +05:30
|
|
|
ptdesc_t current_prot;
|
2024-09-09 12:47:18 +00:00
|
|
|
bool check_wx;
|
|
|
|
unsigned long wx_pages;
|
|
|
|
unsigned long uxn_pages;
|
|
|
|
};
|
|
|
|
|
2020-02-03 17:36:29 -08:00
|
|
|
void ptdump_walk(struct seq_file *s, struct ptdump_info *info);
|
2024-09-09 12:47:18 +00:00
|
|
|
void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
|
2025-04-07 11:01:11 +05:30
|
|
|
pteval_t val);
|
|
|
|
void note_page_pte(struct ptdump_state *st, unsigned long addr, pte_t pte);
|
|
|
|
void note_page_pmd(struct ptdump_state *st, unsigned long addr, pmd_t pmd);
|
|
|
|
void note_page_pud(struct ptdump_state *st, unsigned long addr, pud_t pud);
|
|
|
|
void note_page_p4d(struct ptdump_state *st, unsigned long addr, p4d_t p4d);
|
|
|
|
void note_page_pgd(struct ptdump_state *st, unsigned long addr, pgd_t pgd);
|
|
|
|
void note_page_flush(struct ptdump_state *st);
|
2020-02-03 17:36:29 -08:00
|
|
|
#ifdef CONFIG_PTDUMP_DEBUGFS
|
2022-10-11 02:35:07 +01:00
|
|
|
#define EFI_RUNTIME_MAP_END DEFAULT_MAP_WINDOW_64
|
2021-03-30 13:54:49 +08:00
|
|
|
void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name);
|
2016-05-31 14:49:01 +01:00
|
|
|
#else
|
2019-01-22 15:41:11 +01:00
|
|
|
static inline void ptdump_debugfs_register(struct ptdump_info *info,
|
|
|
|
const char *name) { }
|
2024-09-09 12:47:18 +00:00
|
|
|
#endif /* CONFIG_PTDUMP_DEBUGFS */
|
|
|
|
#else
|
|
|
|
static inline void note_page(struct ptdump_state *pt_st, unsigned long addr,
|
2025-04-07 11:01:11 +05:30
|
|
|
int level, pteval_t val) { }
|
|
|
|
static inline void note_page_pte(struct ptdump_state *st, unsigned long addr, pte_t pte) { }
|
|
|
|
static inline void note_page_pmd(struct ptdump_state *st, unsigned long addr, pmd_t pmd) { }
|
|
|
|
static inline void note_page_pud(struct ptdump_state *st, unsigned long addr, pud_t pud) { }
|
|
|
|
static inline void note_page_p4d(struct ptdump_state *st, unsigned long addr, p4d_t p4d) { }
|
|
|
|
static inline void note_page_pgd(struct ptdump_state *st, unsigned long addr, pgd_t pgd) { }
|
|
|
|
static inline void note_page_flush(struct ptdump_state *st) { }
|
2025-02-26 17:54:04 +05:30
|
|
|
#endif /* CONFIG_PTDUMP */
|
2016-10-27 09:27:34 -07:00
|
|
|
|
2016-05-31 14:49:01 +01:00
|
|
|
#endif /* __ASM_PTDUMP_H */
|