]> git.ipfire.org Git - thirdparty/kernel/stable.git/blob - arch/arm/include/asm/stage2_pgtable.h
Merge tag 'clang-format-for-linus-v5.1-rc5' of git://github.com/ojeda/linux
[thirdparty/kernel/stable.git] / arch / arm / include / asm / stage2_pgtable.h
1 /*
2 * Copyright (C) 2016 - ARM Ltd
3 *
4 * stage2 page table helpers
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef __ARM_S2_PGTABLE_H_
20 #define __ARM_S2_PGTABLE_H_
21
22 /*
23 * kvm_mmu_cache_min_pages() is the number of pages required
24 * to install a stage-2 translation. We pre-allocate the entry
25 * level table at VM creation. Since we have a 3 level page-table,
26 * we need only two pages to add a new mapping.
27 */
28 #define kvm_mmu_cache_min_pages(kvm) 2
29
30 #define stage2_pgd_none(kvm, pgd) pgd_none(pgd)
31 #define stage2_pgd_clear(kvm, pgd) pgd_clear(pgd)
32 #define stage2_pgd_present(kvm, pgd) pgd_present(pgd)
33 #define stage2_pgd_populate(kvm, pgd, pud) pgd_populate(NULL, pgd, pud)
34 #define stage2_pud_offset(kvm, pgd, address) pud_offset(pgd, address)
35 #define stage2_pud_free(kvm, pud) pud_free(NULL, pud)
36
37 #define stage2_pud_none(kvm, pud) pud_none(pud)
38 #define stage2_pud_clear(kvm, pud) pud_clear(pud)
39 #define stage2_pud_present(kvm, pud) pud_present(pud)
40 #define stage2_pud_populate(kvm, pud, pmd) pud_populate(NULL, pud, pmd)
41 #define stage2_pmd_offset(kvm, pud, address) pmd_offset(pud, address)
42 #define stage2_pmd_free(kvm, pmd) pmd_free(NULL, pmd)
43
44 #define stage2_pud_huge(kvm, pud) pud_huge(pud)
45
46 /* Open coded p*d_addr_end that can deal with 64bit addresses */
47 static inline phys_addr_t
48 stage2_pgd_addr_end(struct kvm *kvm, phys_addr_t addr, phys_addr_t end)
49 {
50 phys_addr_t boundary = (addr + PGDIR_SIZE) & PGDIR_MASK;
51
52 return (boundary - 1 < end - 1) ? boundary : end;
53 }
54
55 #define stage2_pud_addr_end(kvm, addr, end) (end)
56
57 static inline phys_addr_t
58 stage2_pmd_addr_end(struct kvm *kvm, phys_addr_t addr, phys_addr_t end)
59 {
60 phys_addr_t boundary = (addr + PMD_SIZE) & PMD_MASK;
61
62 return (boundary - 1 < end - 1) ? boundary : end;
63 }
64
65 #define stage2_pgd_index(kvm, addr) pgd_index(addr)
66
67 #define stage2_pte_table_empty(kvm, ptep) kvm_page_empty(ptep)
68 #define stage2_pmd_table_empty(kvm, pmdp) kvm_page_empty(pmdp)
69 #define stage2_pud_table_empty(kvm, pudp) false
70
71 static inline bool kvm_stage2_has_pud(struct kvm *kvm)
72 {
73 return false;
74 }
75
76 #define S2_PMD_MASK PMD_MASK
77 #define S2_PMD_SIZE PMD_SIZE
78 #define S2_PUD_MASK PUD_MASK
79 #define S2_PUD_SIZE PUD_SIZE
80
81 static inline bool kvm_stage2_has_pmd(struct kvm *kvm)
82 {
83 return true;
84 }
85
86 #endif /* __ARM_S2_PGTABLE_H_ */