Skip to content

Commit 9f28361

Browse files
Suzuki K PouloseMarc Zyngier
authored andcommitted
KVM: arm64: Clean up the checking for huge mapping
If we are checking whether the stage2 can map PAGE_SIZE, we don't have to do the boundary checks as both the host VMA and the guest memslots are page aligned. Bail the case easily. While we're at it, fixup a typo in the comment below. Signed-off-by: Suzuki K Poulose <[email protected]> Signed-off-by: Zenghui Yu <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 48c963e commit 9f28361

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,10 @@ static bool fault_supports_stage2_huge_mapping(struct kvm_memory_slot *memslot,
16101610
hva_t uaddr_start, uaddr_end;
16111611
size_t size;
16121612

1613+
/* The memslot and the VMA are guaranteed to be aligned to PAGE_SIZE */
1614+
if (map_size == PAGE_SIZE)
1615+
return true;
1616+
16131617
size = memslot->npages * PAGE_SIZE;
16141618

16151619
gpa_start = memslot->base_gfn << PAGE_SHIFT;
@@ -1629,7 +1633,7 @@ static bool fault_supports_stage2_huge_mapping(struct kvm_memory_slot *memslot,
16291633
* |abcde|fgh Stage-1 block | Stage-1 block tv|xyz|
16301634
* +-----+--------------------+--------------------+---+
16311635
*
1632-
* memslot->base_gfn << PAGE_SIZE:
1636+
* memslot->base_gfn << PAGE_SHIFT:
16331637
* +---+--------------------+--------------------+-----+
16341638
* |abc|def Stage-2 block | Stage-2 block |tvxyz|
16351639
* +---+--------------------+--------------------+-----+

0 commit comments

Comments
 (0)