Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kvm-arm: arm32: Introduce stage2 page table helpers

Define the page table helpers for walking the stage2 pagetable
for arm. Since both hyp and stage2 have the same number of levels,
as that of the host we reuse the host helpers.

The exceptions are the p.d_addr_end routines which have to deal
with IPA > 32bit, hence we use the open coded version of their host helpers
which supports 64bit.

Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>

authored by

Suzuki K Poulose and committed by
Christoffer Dall
b1ae9a30 77b56651

+62
+1
arch/arm/include/asm/kvm_mmu.h
··· 47 47 #include <linux/highmem.h> 48 48 #include <asm/cacheflush.h> 49 49 #include <asm/pgalloc.h> 50 + #include <asm/stage2_pgtable.h> 50 51 51 52 int create_hyp_mappings(void *from, void *to); 52 53 int create_hyp_io_mappings(void *from, void *to, phys_addr_t);
+61
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 + #define stage2_pgd_none(pgd) pgd_none(pgd) 23 + #define stage2_pgd_clear(pgd) pgd_clear(pgd) 24 + #define stage2_pgd_present(pgd) pgd_present(pgd) 25 + #define stage2_pgd_populate(pgd, pud) pgd_populate(NULL, pgd, pud) 26 + #define stage2_pud_offset(pgd, address) pud_offset(pgd, address) 27 + #define stage2_pud_free(pud) pud_free(NULL, pud) 28 + 29 + #define stage2_pud_none(pud) pud_none(pud) 30 + #define stage2_pud_clear(pud) pud_clear(pud) 31 + #define stage2_pud_present(pud) pud_present(pud) 32 + #define stage2_pud_populate(pud, pmd) pud_populate(NULL, pud, pmd) 33 + #define stage2_pmd_offset(pud, address) pmd_offset(pud, address) 34 + #define stage2_pmd_free(pmd) pmd_free(NULL, pmd) 35 + 36 + #define stage2_pud_huge(pud) pud_huge(pud) 37 + 38 + /* Open coded p*d_addr_end that can deal with 64bit addresses */ 39 + static inline phys_addr_t stage2_pgd_addr_end(phys_addr_t addr, phys_addr_t end) 40 + { 41 + phys_addr_t boundary = (addr + PGDIR_SIZE) & PGDIR_MASK; 42 + 43 + return (boundary - 1 < end - 1) ? boundary : end; 44 + } 45 + 46 + #define stage2_pud_addr_end(addr, end) (end) 47 + 48 + static inline phys_addr_t stage2_pmd_addr_end(phys_addr_t addr, phys_addr_t end) 49 + { 50 + phys_addr_t boundary = (addr + PMD_SIZE) & PMD_MASK; 51 + 52 + return (boundary - 1 < end - 1) ? boundary : end; 53 + } 54 + 55 + #define stage2_pgd_index(addr) pgd_index(addr) 56 + 57 + #define stage2_pte_table_empty(ptep) kvm_page_empty(ptep) 58 + #define stage2_pmd_table_empty(pmdp) kvm_page_empty(pmdp) 59 + #define stage2_pud_table_empty(pudp) false 60 + 61 + #endif /* __ARM_S2_PGTABLE_H_ */