|
4 | 4 | * included by both the compressed kernel and the regular kernel.
|
5 | 5 | */
|
6 | 6 |
|
| 7 | +static void free_pte(struct x86_mapping_info *info, pmd_t *pmd) |
| 8 | +{ |
| 9 | + pte_t *pte = pte_offset_kernel(pmd, 0); |
| 10 | + |
| 11 | + info->free_pgt_page(pte, info->context); |
| 12 | +} |
| 13 | + |
| 14 | +static void free_pmd(struct x86_mapping_info *info, pud_t *pud) |
| 15 | +{ |
| 16 | + pmd_t *pmd = pmd_offset(pud, 0); |
| 17 | + int i; |
| 18 | + |
| 19 | + for (i = 0; i < PTRS_PER_PMD; i++) { |
| 20 | + if (!pmd_present(pmd[i])) |
| 21 | + continue; |
| 22 | + |
| 23 | + if (pmd_leaf(pmd[i])) |
| 24 | + continue; |
| 25 | + |
| 26 | + free_pte(info, &pmd[i]); |
| 27 | + } |
| 28 | + |
| 29 | + info->free_pgt_page(pmd, info->context); |
| 30 | +} |
| 31 | + |
| 32 | +static void free_pud(struct x86_mapping_info *info, p4d_t *p4d) |
| 33 | +{ |
| 34 | + pud_t *pud = pud_offset(p4d, 0); |
| 35 | + int i; |
| 36 | + |
| 37 | + for (i = 0; i < PTRS_PER_PUD; i++) { |
| 38 | + if (!pud_present(pud[i])) |
| 39 | + continue; |
| 40 | + |
| 41 | + if (pud_leaf(pud[i])) |
| 42 | + continue; |
| 43 | + |
| 44 | + free_pmd(info, &pud[i]); |
| 45 | + } |
| 46 | + |
| 47 | + info->free_pgt_page(pud, info->context); |
| 48 | +} |
| 49 | + |
| 50 | +static void free_p4d(struct x86_mapping_info *info, pgd_t *pgd) |
| 51 | +{ |
| 52 | + p4d_t *p4d = p4d_offset(pgd, 0); |
| 53 | + int i; |
| 54 | + |
| 55 | + for (i = 0; i < PTRS_PER_P4D; i++) { |
| 56 | + if (!p4d_present(p4d[i])) |
| 57 | + continue; |
| 58 | + |
| 59 | + free_pud(info, &p4d[i]); |
| 60 | + } |
| 61 | + |
| 62 | + if (pgtable_l5_enabled()) |
| 63 | + info->free_pgt_page(p4d, info->context); |
| 64 | +} |
| 65 | + |
| 66 | +void kernel_ident_mapping_free(struct x86_mapping_info *info, pgd_t *pgd) |
| 67 | +{ |
| 68 | + int i; |
| 69 | + |
| 70 | + for (i = 0; i < PTRS_PER_PGD; i++) { |
| 71 | + if (!pgd_present(pgd[i])) |
| 72 | + continue; |
| 73 | + |
| 74 | + free_p4d(info, &pgd[i]); |
| 75 | + } |
| 76 | + |
| 77 | + info->free_pgt_page(pgd, info->context); |
| 78 | +} |
| 79 | + |
7 | 80 | static void ident_pmd_init(struct x86_mapping_info *info, pmd_t *pmd_page,
|
8 | 81 | unsigned long addr, unsigned long end)
|
9 | 82 | {
|
|
0 commit comments