aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kvm/mmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/kvm/mmu.c')
-rw-r--r--arch/arm/kvm/mmu.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 80bb1e6c2c29..16f804938b8f 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -42,6 +42,8 @@ static unsigned long hyp_idmap_start;
42static unsigned long hyp_idmap_end; 42static unsigned long hyp_idmap_end;
43static phys_addr_t hyp_idmap_vector; 43static phys_addr_t hyp_idmap_vector;
44 44
45#define pgd_order get_order(PTRS_PER_PGD * sizeof(pgd_t))
46
45#define kvm_pmd_huge(_x) (pmd_huge(_x) || pmd_trans_huge(_x)) 47#define kvm_pmd_huge(_x) (pmd_huge(_x) || pmd_trans_huge(_x))
46 48
47static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa) 49static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
@@ -293,14 +295,14 @@ void free_boot_hyp_pgd(void)
293 if (boot_hyp_pgd) { 295 if (boot_hyp_pgd) {
294 unmap_range(NULL, boot_hyp_pgd, hyp_idmap_start, PAGE_SIZE); 296 unmap_range(NULL, boot_hyp_pgd, hyp_idmap_start, PAGE_SIZE);
295 unmap_range(NULL, boot_hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE); 297 unmap_range(NULL, boot_hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE);
296 kfree(boot_hyp_pgd); 298 free_pages((unsigned long)boot_hyp_pgd, pgd_order);
297 boot_hyp_pgd = NULL; 299 boot_hyp_pgd = NULL;
298 } 300 }
299 301
300 if (hyp_pgd) 302 if (hyp_pgd)
301 unmap_range(NULL, hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE); 303 unmap_range(NULL, hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE);
302 304
303 kfree(init_bounce_page); 305 free_page((unsigned long)init_bounce_page);
304 init_bounce_page = NULL; 306 init_bounce_page = NULL;
305 307
306 mutex_unlock(&kvm_hyp_pgd_mutex); 308 mutex_unlock(&kvm_hyp_pgd_mutex);
@@ -330,7 +332,7 @@ void free_hyp_pgds(void)
330 for (addr = VMALLOC_START; is_vmalloc_addr((void*)addr); addr += PGDIR_SIZE) 332 for (addr = VMALLOC_START; is_vmalloc_addr((void*)addr); addr += PGDIR_SIZE)
331 unmap_range(NULL, hyp_pgd, KERN_TO_HYP(addr), PGDIR_SIZE); 333 unmap_range(NULL, hyp_pgd, KERN_TO_HYP(addr), PGDIR_SIZE);
332 334
333 kfree(hyp_pgd); 335 free_pages((unsigned long)hyp_pgd, pgd_order);
334 hyp_pgd = NULL; 336 hyp_pgd = NULL;
335 } 337 }
336 338
@@ -1024,7 +1026,7 @@ int kvm_mmu_init(void)
1024 size_t len = __hyp_idmap_text_end - __hyp_idmap_text_start; 1026 size_t len = __hyp_idmap_text_end - __hyp_idmap_text_start;
1025 phys_addr_t phys_base; 1027 phys_addr_t phys_base;
1026 1028
1027 init_bounce_page = kmalloc(PAGE_SIZE, GFP_KERNEL); 1029 init_bounce_page = (void *)__get_free_page(GFP_KERNEL);
1028 if (!init_bounce_page) { 1030 if (!init_bounce_page) {
1029 kvm_err("Couldn't allocate HYP init bounce page\n"); 1031 kvm_err("Couldn't allocate HYP init bounce page\n");
1030 err = -ENOMEM; 1032 err = -ENOMEM;
@@ -1050,8 +1052,9 @@ int kvm_mmu_init(void)
1050 (unsigned long)phys_base); 1052 (unsigned long)phys_base);
1051 } 1053 }
1052 1054
1053 hyp_pgd = kzalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL); 1055 hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, pgd_order);
1054 boot_hyp_pgd = kzalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL); 1056 boot_hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, pgd_order);
1057
1055 if (!hyp_pgd || !boot_hyp_pgd) { 1058 if (!hyp_pgd || !boot_hyp_pgd) {
1056 kvm_err("Hyp mode PGD not allocated\n"); 1059 kvm_err("Hyp mode PGD not allocated\n");
1057 err = -ENOMEM; 1060 err = -ENOMEM;