KVM: PPC: BOOK3S: HV: CMA: Reserve cma region only in hypervisor mode
[deliverable/linux.git] / arch / powerpc / kvm / book3s_hv_builtin.c
index 329d7fdd0a6ab7be8b9e203ac53b1870c1d37b0c..4fdc27c80f4c853d720aea438a88371dc378b950 100644 (file)
@@ -101,7 +101,7 @@ struct kvm_rma_info *kvm_alloc_rma()
        ri = kmalloc(sizeof(struct kvm_rma_info), GFP_KERNEL);
        if (!ri)
                return NULL;
-       page = cma_alloc(kvm_cma, kvm_rma_pages, get_order(kvm_rma_pages));
+       page = cma_alloc(kvm_cma, kvm_rma_pages, order_base_2(kvm_rma_pages));
        if (!page)
                goto err_out;
        atomic_set(&ri->use_count, 1);
@@ -135,12 +135,12 @@ struct page *kvm_alloc_hpt(unsigned long nr_pages)
 {
        unsigned long align_pages = HPT_ALIGN_PAGES;
 
-       VM_BUG_ON(get_order(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT);
+       VM_BUG_ON(order_base_2(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT);
 
        /* Old CPUs require HPT aligned on a multiple of its size */
        if (!cpu_has_feature(CPU_FTR_ARCH_206))
                align_pages = nr_pages;
-       return cma_alloc(kvm_cma, nr_pages, get_order(align_pages));
+       return cma_alloc(kvm_cma, nr_pages, order_base_2(align_pages));
 }
 EXPORT_SYMBOL_GPL(kvm_alloc_hpt);
 
@@ -163,6 +163,12 @@ void __init kvm_cma_reserve(void)
        unsigned long align_size;
        struct memblock_region *reg;
        phys_addr_t selected_size = 0;
+
+       /*
+        * We need CMA reservation only when we are in HV mode
+        */
+       if (!cpu_has_feature(CPU_FTR_HVMODE))
+               return;
        /*
         * We cannot use memblock_phys_mem_size() here, because
         * memblock_analyze() has not been called yet.
This page took 0.025836 seconds and 5 git commands to generate.