forked from Minki/linux
x86: mm: point to struct seq_file from struct pg_state
mm/dump_pagetables.c passes both struct seq_file and struct pg_state down the chain of walk_*_level() functions to be passed to note_page(). Instead place the struct seq_file in struct pg_state and access it from struct pg_state (which is private to this file) in note_page(). Link: http://lkml.kernel.org/r/20191218162402.45610-17-steven.price@arm.com Signed-off-by: Steven Price <steven.price@arm.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Andy Lutomirski <luto@kernel.org> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David S. Miller <davem@davemloft.net> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Hogan <jhogan@kernel.org> Cc: James Morse <james.morse@arm.com> Cc: Jerome Glisse <jglisse@redhat.com> Cc: "Liang, Kan" <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Paul Burton <paul.burton@mips.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Will Deacon <will@kernel.org> Cc: Zong Li <zong.li@sifive.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
b7a16c7ad7
commit
74d2aaa16f
@ -36,6 +36,7 @@ struct pg_state {
|
|||||||
bool to_dmesg;
|
bool to_dmesg;
|
||||||
bool check_wx;
|
bool check_wx;
|
||||||
unsigned long wx_pages;
|
unsigned long wx_pages;
|
||||||
|
struct seq_file *seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct addr_marker {
|
struct addr_marker {
|
||||||
@ -265,11 +266,12 @@ static void note_wx(struct pg_state *st)
|
|||||||
* of PTE entries; the next one is different so we need to
|
* of PTE entries; the next one is different so we need to
|
||||||
* print what we collected so far.
|
* print what we collected so far.
|
||||||
*/
|
*/
|
||||||
static void note_page(struct seq_file *m, struct pg_state *st,
|
static void note_page(struct pg_state *st, pgprot_t new_prot,
|
||||||
pgprot_t new_prot, pgprotval_t new_eff, int level)
|
pgprotval_t new_eff, int level)
|
||||||
{
|
{
|
||||||
pgprotval_t prot, cur, eff;
|
pgprotval_t prot, cur, eff;
|
||||||
static const char units[] = "BKMGTPE";
|
static const char units[] = "BKMGTPE";
|
||||||
|
struct seq_file *m = st->seq;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have a "break" in the series, we need to flush the state that
|
* If we have a "break" in the series, we need to flush the state that
|
||||||
@ -354,8 +356,8 @@ static inline pgprotval_t effective_prot(pgprotval_t prot1, pgprotval_t prot2)
|
|||||||
((prot1 | prot2) & _PAGE_NX);
|
((prot1 | prot2) & _PAGE_NX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr,
|
static void walk_pte_level(struct pg_state *st, pmd_t addr, pgprotval_t eff_in,
|
||||||
pgprotval_t eff_in, unsigned long P)
|
unsigned long P)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
pte_t *pte;
|
pte_t *pte;
|
||||||
@ -366,7 +368,7 @@ static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr,
|
|||||||
pte = pte_offset_map(&addr, st->current_address);
|
pte = pte_offset_map(&addr, st->current_address);
|
||||||
prot = pte_flags(*pte);
|
prot = pte_flags(*pte);
|
||||||
eff = effective_prot(eff_in, prot);
|
eff = effective_prot(eff_in, prot);
|
||||||
note_page(m, st, __pgprot(prot), eff, 5);
|
note_page(st, __pgprot(prot), eff, 5);
|
||||||
pte_unmap(pte);
|
pte_unmap(pte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,22 +381,20 @@ static void walk_pte_level(struct seq_file *m, struct pg_state *st, pmd_t addr,
|
|||||||
* us dozens of seconds (minutes for 5-level config) while checking for
|
* us dozens of seconds (minutes for 5-level config) while checking for
|
||||||
* W+X mapping or reading kernel_page_tables debugfs file.
|
* W+X mapping or reading kernel_page_tables debugfs file.
|
||||||
*/
|
*/
|
||||||
static inline bool kasan_page_table(struct seq_file *m, struct pg_state *st,
|
static inline bool kasan_page_table(struct pg_state *st, void *pt)
|
||||||
void *pt)
|
|
||||||
{
|
{
|
||||||
if (__pa(pt) == __pa(kasan_early_shadow_pmd) ||
|
if (__pa(pt) == __pa(kasan_early_shadow_pmd) ||
|
||||||
(pgtable_l5_enabled() &&
|
(pgtable_l5_enabled() &&
|
||||||
__pa(pt) == __pa(kasan_early_shadow_p4d)) ||
|
__pa(pt) == __pa(kasan_early_shadow_p4d)) ||
|
||||||
__pa(pt) == __pa(kasan_early_shadow_pud)) {
|
__pa(pt) == __pa(kasan_early_shadow_pud)) {
|
||||||
pgprotval_t prot = pte_flags(kasan_early_shadow_pte[0]);
|
pgprotval_t prot = pte_flags(kasan_early_shadow_pte[0]);
|
||||||
note_page(m, st, __pgprot(prot), 0, 5);
|
note_page(st, __pgprot(prot), 0, 5);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline bool kasan_page_table(struct seq_file *m, struct pg_state *st,
|
static inline bool kasan_page_table(struct pg_state *st, void *pt)
|
||||||
void *pt)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -402,7 +402,7 @@ static inline bool kasan_page_table(struct seq_file *m, struct pg_state *st,
|
|||||||
|
|
||||||
#if PTRS_PER_PMD > 1
|
#if PTRS_PER_PMD > 1
|
||||||
|
|
||||||
static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr,
|
static void walk_pmd_level(struct pg_state *st, pud_t addr,
|
||||||
pgprotval_t eff_in, unsigned long P)
|
pgprotval_t eff_in, unsigned long P)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -416,27 +416,27 @@ static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr,
|
|||||||
prot = pmd_flags(*start);
|
prot = pmd_flags(*start);
|
||||||
eff = effective_prot(eff_in, prot);
|
eff = effective_prot(eff_in, prot);
|
||||||
if (pmd_large(*start) || !pmd_present(*start)) {
|
if (pmd_large(*start) || !pmd_present(*start)) {
|
||||||
note_page(m, st, __pgprot(prot), eff, 4);
|
note_page(st, __pgprot(prot), eff, 4);
|
||||||
} else if (!kasan_page_table(m, st, pmd_start)) {
|
} else if (!kasan_page_table(st, pmd_start)) {
|
||||||
walk_pte_level(m, st, *start, eff,
|
walk_pte_level(st, *start, eff,
|
||||||
P + i * PMD_LEVEL_MULT);
|
P + i * PMD_LEVEL_MULT);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
note_page(m, st, __pgprot(0), 0, 4);
|
note_page(st, __pgprot(0), 0, 4);
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define walk_pmd_level(m,s,a,e,p) walk_pte_level(m,s,__pmd(pud_val(a)),e,p)
|
#define walk_pmd_level(s,a,e,p) walk_pte_level(s,__pmd(pud_val(a)),e,p)
|
||||||
#define pud_large(a) pmd_large(__pmd(pud_val(a)))
|
#define pud_large(a) pmd_large(__pmd(pud_val(a)))
|
||||||
#define pud_none(a) pmd_none(__pmd(pud_val(a)))
|
#define pud_none(a) pmd_none(__pmd(pud_val(a)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PTRS_PER_PUD > 1
|
#if PTRS_PER_PUD > 1
|
||||||
|
|
||||||
static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr,
|
static void walk_pud_level(struct pg_state *st, p4d_t addr, pgprotval_t eff_in,
|
||||||
pgprotval_t eff_in, unsigned long P)
|
unsigned long P)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
pud_t *start, *pud_start;
|
pud_t *start, *pud_start;
|
||||||
@ -450,33 +450,33 @@ static void walk_pud_level(struct seq_file *m, struct pg_state *st, p4d_t addr,
|
|||||||
prot = pud_flags(*start);
|
prot = pud_flags(*start);
|
||||||
eff = effective_prot(eff_in, prot);
|
eff = effective_prot(eff_in, prot);
|
||||||
if (pud_large(*start) || !pud_present(*start)) {
|
if (pud_large(*start) || !pud_present(*start)) {
|
||||||
note_page(m, st, __pgprot(prot), eff, 3);
|
note_page(st, __pgprot(prot), eff, 3);
|
||||||
} else if (!kasan_page_table(m, st, pud_start)) {
|
} else if (!kasan_page_table(st, pud_start)) {
|
||||||
walk_pmd_level(m, st, *start, eff,
|
walk_pmd_level(st, *start, eff,
|
||||||
P + i * PUD_LEVEL_MULT);
|
P + i * PUD_LEVEL_MULT);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
note_page(m, st, __pgprot(0), 0, 3);
|
note_page(st, __pgprot(0), 0, 3);
|
||||||
|
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define walk_pud_level(m,s,a,e,p) walk_pmd_level(m,s,__pud(p4d_val(a)),e,p)
|
#define walk_pud_level(s,a,e,p) walk_pmd_level(s,__pud(p4d_val(a)),e,p)
|
||||||
#define p4d_large(a) pud_large(__pud(p4d_val(a)))
|
#define p4d_large(a) pud_large(__pud(p4d_val(a)))
|
||||||
#define p4d_none(a) pud_none(__pud(p4d_val(a)))
|
#define p4d_none(a) pud_none(__pud(p4d_val(a)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr,
|
static void walk_p4d_level(struct pg_state *st, pgd_t addr, pgprotval_t eff_in,
|
||||||
pgprotval_t eff_in, unsigned long P)
|
unsigned long P)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
p4d_t *start, *p4d_start;
|
p4d_t *start, *p4d_start;
|
||||||
pgprotval_t prot, eff;
|
pgprotval_t prot, eff;
|
||||||
|
|
||||||
if (PTRS_PER_P4D == 1)
|
if (PTRS_PER_P4D == 1)
|
||||||
return walk_pud_level(m, st, __p4d(pgd_val(addr)), eff_in, P);
|
return walk_pud_level(st, __p4d(pgd_val(addr)), eff_in, P);
|
||||||
|
|
||||||
p4d_start = start = (p4d_t *)pgd_page_vaddr(addr);
|
p4d_start = start = (p4d_t *)pgd_page_vaddr(addr);
|
||||||
|
|
||||||
@ -486,13 +486,13 @@ static void walk_p4d_level(struct seq_file *m, struct pg_state *st, pgd_t addr,
|
|||||||
prot = p4d_flags(*start);
|
prot = p4d_flags(*start);
|
||||||
eff = effective_prot(eff_in, prot);
|
eff = effective_prot(eff_in, prot);
|
||||||
if (p4d_large(*start) || !p4d_present(*start)) {
|
if (p4d_large(*start) || !p4d_present(*start)) {
|
||||||
note_page(m, st, __pgprot(prot), eff, 2);
|
note_page(st, __pgprot(prot), eff, 2);
|
||||||
} else if (!kasan_page_table(m, st, p4d_start)) {
|
} else if (!kasan_page_table(st, p4d_start)) {
|
||||||
walk_pud_level(m, st, *start, eff,
|
walk_pud_level(st, *start, eff,
|
||||||
P + i * P4D_LEVEL_MULT);
|
P + i * P4D_LEVEL_MULT);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
note_page(m, st, __pgprot(0), 0, 2);
|
note_page(st, __pgprot(0), 0, 2);
|
||||||
|
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
@ -529,6 +529,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
st.check_wx = checkwx;
|
st.check_wx = checkwx;
|
||||||
|
st.seq = m;
|
||||||
if (checkwx)
|
if (checkwx)
|
||||||
st.wx_pages = 0;
|
st.wx_pages = 0;
|
||||||
|
|
||||||
@ -542,13 +543,13 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
|
|||||||
eff = prot;
|
eff = prot;
|
||||||
#endif
|
#endif
|
||||||
if (pgd_large(*start) || !pgd_present(*start)) {
|
if (pgd_large(*start) || !pgd_present(*start)) {
|
||||||
note_page(m, &st, __pgprot(prot), eff, 1);
|
note_page(&st, __pgprot(prot), eff, 1);
|
||||||
} else {
|
} else {
|
||||||
walk_p4d_level(m, &st, *start, eff,
|
walk_p4d_level(&st, *start, eff,
|
||||||
i * PGD_LEVEL_MULT);
|
i * PGD_LEVEL_MULT);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
note_page(m, &st, __pgprot(0), 0, 1);
|
note_page(&st, __pgprot(0), 0, 1);
|
||||||
|
|
||||||
cond_resched();
|
cond_resched();
|
||||||
start++;
|
start++;
|
||||||
@ -556,7 +557,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
|
|||||||
|
|
||||||
/* Flush out the last page */
|
/* Flush out the last page */
|
||||||
st.current_address = normalize_addr(PTRS_PER_PGD*PGD_LEVEL_MULT);
|
st.current_address = normalize_addr(PTRS_PER_PGD*PGD_LEVEL_MULT);
|
||||||
note_page(m, &st, __pgprot(0), 0, 0);
|
note_page(&st, __pgprot(0), 0, 0);
|
||||||
if (!checkwx)
|
if (!checkwx)
|
||||||
return;
|
return;
|
||||||
if (st.wx_pages)
|
if (st.wx_pages)
|
||||||
|
Loading…
Reference in New Issue
Block a user