public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/mm: don't free p4d table when it is folded at runtime.
@ 2018-06-25 10:24 Andrey Ryabinin
  2018-06-25 11:50 ` Kirill A. Shutemov
  2018-06-26 10:33 ` [tip:x86/urgent] x86/mm: Don't free P4D " tip-bot for Andrey Ryabinin
  0 siblings, 2 replies; 6+ messages in thread
From: Andrey Ryabinin @ 2018-06-25 10:24 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86
  Cc: Kirill A. Shutemov, linux-kernel, Andrey Ryabinin

When the p4d page table layer is folded at runtime, the p4d_free()
should do nothing, the same as in <asm-generic/pgtable-nop4d.h>.

It seems this bug should cause double-free in efi_call_phys_epilog(),
but I don't know how to trigger that code path, so I can't confirm that
by testing.

Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime")
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 arch/x86/include/asm/pgalloc.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
index ada6410fd2ec..fbd578daa66e 100644
--- a/arch/x86/include/asm/pgalloc.h
+++ b/arch/x86/include/asm/pgalloc.h
@@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)
 
 static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d)
 {
+	if (!pgtable_l5_enabled())
+		return;
+
 	BUG_ON((unsigned long)p4d & (PAGE_SIZE-1));
 	free_page((unsigned long)p4d);
 }
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-26 23:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-25 10:24 [PATCH] x86/mm: don't free p4d table when it is folded at runtime Andrey Ryabinin
2018-06-25 11:50 ` Kirill A. Shutemov
2018-06-26  7:40   ` Baoquan He
2018-06-26 10:00     ` Kirill A. Shutemov
2018-06-26 23:08       ` Baoquan He
2018-06-26 10:33 ` [tip:x86/urgent] x86/mm: Don't free P4D " tip-bot for Andrey Ryabinin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox