diff options
| -rw-r--r-- | arch/x86/include/asm/pgtable.h | 1 | ||||
| -rw-r--r-- | arch/x86/mm/debug_pagetables.c | 2 | ||||
| -rw-r--r-- | arch/x86/mm/dump_pagetables.c | 30 |
3 files changed, 27 insertions, 6 deletions
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index cc6fa75884e9..03780d5c41c5 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
| @@ -28,6 +28,7 @@ extern pgd_t early_top_pgt[PTRS_PER_PGD]; | |||
| 28 | int __init __early_make_pgtable(unsigned long address, pmdval_t pmd); | 28 | int __init __early_make_pgtable(unsigned long address, pmdval_t pmd); |
| 29 | 29 | ||
| 30 | void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd); | 30 | void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd); |
| 31 | void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd); | ||
| 31 | void ptdump_walk_pgd_level_checkwx(void); | 32 | void ptdump_walk_pgd_level_checkwx(void); |
| 32 | 33 | ||
| 33 | #ifdef CONFIG_DEBUG_WX | 34 | #ifdef CONFIG_DEBUG_WX |
diff --git a/arch/x86/mm/debug_pagetables.c b/arch/x86/mm/debug_pagetables.c index d1449fb6dc7a..8e70c1599e51 100644 --- a/arch/x86/mm/debug_pagetables.c +++ b/arch/x86/mm/debug_pagetables.c | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | static int ptdump_show(struct seq_file *m, void *v) | 6 | static int ptdump_show(struct seq_file *m, void *v) |
| 7 | { | 7 | { |
| 8 | ptdump_walk_pgd_level(m, NULL); | 8 | ptdump_walk_pgd_level_debugfs(m, NULL); |
| 9 | return 0; | 9 | return 0; |
| 10 | } | 10 | } |
| 11 | 11 | ||
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index 690eaf31ca34..17f5b417f95e 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c | |||
| @@ -476,7 +476,7 @@ static inline bool is_hypervisor_range(int idx) | |||
| 476 | } | 476 | } |
| 477 | 477 | ||
| 478 | static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, | 478 | static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, |
| 479 | bool checkwx) | 479 | bool checkwx, bool dmesg) |
| 480 | { | 480 | { |
| 481 | #ifdef CONFIG_X86_64 | 481 | #ifdef CONFIG_X86_64 |
| 482 | pgd_t *start = (pgd_t *) &init_top_pgt; | 482 | pgd_t *start = (pgd_t *) &init_top_pgt; |
| @@ -489,7 +489,7 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, | |||
| 489 | 489 | ||
| 490 | if (pgd) { | 490 | if (pgd) { |
| 491 | start = pgd; | 491 | start = pgd; |
| 492 | st.to_dmesg = true; | 492 | st.to_dmesg = dmesg; |
| 493 | } | 493 | } |
| 494 | 494 | ||
| 495 | st.check_wx = checkwx; | 495 | st.check_wx = checkwx; |
| @@ -527,13 +527,33 @@ static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd, | |||
| 527 | 527 | ||
| 528 | void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd) | 528 | void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd) |
| 529 | { | 529 | { |
| 530 | ptdump_walk_pgd_level_core(m, pgd, false); | 530 | ptdump_walk_pgd_level_core(m, pgd, false, true); |
| 531 | } | ||
| 532 | |||
| 533 | void ptdump_walk_pgd_level_debugfs(struct seq_file *m, pgd_t *pgd) | ||
| 534 | { | ||
| 535 | ptdump_walk_pgd_level_core(m, pgd, false, false); | ||
| 536 | } | ||
| 537 | EXPORT_SYMBOL_GPL(ptdump_walk_pgd_level_debugfs); | ||
| 538 | |||
| 539 | static void ptdump_walk_user_pgd_level_checkwx(void) | ||
| 540 | { | ||
| 541 | #ifdef CONFIG_PAGE_TABLE_ISOLATION | ||
| 542 | pgd_t *pgd = (pgd_t *) &init_top_pgt; | ||
| 543 | |||
| 544 | if (!static_cpu_has(X86_FEATURE_PTI)) | ||
| 545 | return; | ||
| 546 | |||
| 547 | pr_info("x86/mm: Checking user space page tables\n"); | ||
| 548 | pgd = kernel_to_user_pgdp(pgd); | ||
| 549 | ptdump_walk_pgd_level_core(NULL, pgd, true, false); | ||
| 550 | #endif | ||
| 531 | } | 551 | } |
| 532 | EXPORT_SYMBOL_GPL(ptdump_walk_pgd_level); | ||
| 533 | 552 | ||
| 534 | void ptdump_walk_pgd_level_checkwx(void) | 553 | void ptdump_walk_pgd_level_checkwx(void) |
| 535 | { | 554 | { |
| 536 | ptdump_walk_pgd_level_core(NULL, NULL, true); | 555 | ptdump_walk_pgd_level_core(NULL, NULL, true, false); |
| 556 | ptdump_walk_user_pgd_level_checkwx(); | ||
| 537 | } | 557 | } |
| 538 | 558 | ||
| 539 | static int __init pt_dump_init(void) | 559 | static int __init pt_dump_init(void) |
