forked fromtorvalds/linux
- Notifications
You must be signed in to change notification settings - Fork1
Commitb6bdb75
mm/vmalloc: add interfaces to free unmapped page table
On architectures with CONFIG_HAVE_ARCH_HUGE_VMAP set, ioremap() maycreate pud/pmd mappings. A kernel panic was observed on arm64 systemswith Cortex-A75 in the following steps as described by Hanjun Guo. 1. ioremap a 4K size, valid page table will build, 2. iounmap it, pte0 will set to 0; 3. ioremap the same address with 2M size, pgd/pmd is unchanged, then set the a new value for pmd; 4. pte0 is leaked; 5. CPU may meet exception because the old pmd is still in TLB, which will lead to kernel panic.This panic is not reproducible on x86. INVLPG, called from iounmap,purges all levels of entries associated with purged address on x86. x86still has memory leak.The patch changes the ioremap path to free unmapped page table(s) sincedoing so in the unmap path has the following issues: - The iounmap() path is shared with vunmap(). Since vmap() only supports pte mappings, making vunmap() to free a pte page is an overhead for regular vmap users as they do not need a pte page freed up. - Checking if all entries in a pte page are cleared in the unmap path is racy, and serializing this check is expensive. - The unmap path calls free_vmap_area_noflush() to do lazy TLB purges. Clearing a pud/pmd entry before the lazy TLB purges needs extra TLB purge.Add two interfaces, pud_free_pmd_page() and pmd_free_pte_page(), whichclear a given pud/pmd entry and free up a page for the lower levelentries.This patch implements their stub functions on x86 and arm64, which workas workaround.[akpm@linux-foundation.org: fix typo in pmd_free_pte_page() stub]Link:http://lkml.kernel.org/r/20180314180155.19492-2-toshi.kani@hpe.comFixes:e61ce6a ("mm: change ioremap to set up huge I/O mappings")Reported-by: Lei Li <lious.lilei@hisilicon.com>Signed-off-by: Toshi Kani <toshi.kani@hpe.com>Cc: Catalin Marinas <catalin.marinas@arm.com>Cc: Wang Xuefeng <wxf.wang@hisilicon.com>Cc: Will Deacon <will.deacon@arm.com>Cc: Hanjun Guo <guohanjun@huawei.com>Cc: Michal Hocko <mhocko@suse.com>Cc: Thomas Gleixner <tglx@linutronix.de>Cc: Ingo Molnar <mingo@redhat.com>Cc: "H. Peter Anvin" <hpa@zytor.com>Cc: Borislav Petkov <bp@suse.de>Cc: Matthew Wilcox <willy@infradead.org>Cc: Chintan Pandya <cpandya@codeaurora.org>Cc: <stable@vger.kernel.org>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent1705f7c commitb6bdb75
4 files changed
+48
-2
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
972 | 972 |
| |
973 | 973 |
| |
974 | 974 |
| |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
702 | 702 |
| |
703 | 703 |
| |
704 | 704 |
| |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
705 | 729 |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
983 | 983 |
| |
984 | 984 |
| |
985 | 985 |
| |
| 986 | + | |
| 987 | + | |
986 | 988 |
| |
987 | 989 |
| |
988 | 990 |
| |
| |||
1008 | 1010 |
| |
1009 | 1011 |
| |
1010 | 1012 |
| |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
1011 | 1021 |
| |
1012 | 1022 |
| |
1013 | 1023 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
91 | 91 |
| |
92 | 92 |
| |
93 | 93 |
| |
94 |
| - | |
| 94 | + | |
| 95 | + | |
95 | 96 |
| |
96 | 97 |
| |
97 | 98 |
| |
| |||
117 | 118 |
| |
118 | 119 |
| |
119 | 120 |
| |
120 |
| - | |
| 121 | + | |
| 122 | + | |
121 | 123 |
| |
122 | 124 |
| |
123 | 125 |
| |
|
0 commit comments
Comments
(0)