Skip to content

Commit 34b43a8

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: pkvm: Fix hyp_pool max order
The EL2 page allocator in protected mode maintains a per-pool max order value to optimize allocations when the memory region it covers is small. However, the max order value is currently under-estimated whenever the number of pages in the region is a power of two. Fix the estimation. Signed-off-by: Quentin Perret <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d58071a commit 34b43a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/arm64/kvm/hyp/nvhe/page_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ int hyp_pool_init(struct hyp_pool *pool, u64 pfn, unsigned int nr_pages,
241241
int i;
242242

243243
hyp_spin_lock_init(&pool->lock);
244-
pool->max_order = min(MAX_ORDER, get_order(nr_pages << PAGE_SHIFT));
244+
pool->max_order = min(MAX_ORDER, get_order((nr_pages + 1) << PAGE_SHIFT));
245245
for (i = 0; i < pool->max_order; i++)
246246
INIT_LIST_HEAD(&pool->free_area[i]);
247247
pool->range_start = phys;

0 commit comments

Comments
 (0)