Skip to content

Commit 3fb884f

Browse files
author
Marc Zyngier
committed
KVM: arm64: Do not try to map PUDs when they are folded into PMD
For the obscure cases where PMD and PUD are the same size (64kB pages with 42bit VA, for example, which results in only two levels of page tables), we can't map anything as a PUD, because there is... erm... no PUD to speak of. Everything is either a PMD or a PTE. So let's only try and map a PUD when its size is different from that of a PMD. Cc: [email protected] Fixes: b8e0ba7 ("KVM: arm64: Add support for creating PUD hugepages at stage 2") Reported-by: Gavin Shan <[email protected]> Reported-by: Eric Auger <[email protected]> Reviewed-by: Alexandru Elisei <[email protected]> Reviewed-by: Gavin Shan <[email protected]> Tested-by: Gavin Shan <[email protected]> Tested-by: Eric Auger <[email protected]> Tested-by: Alexandru Elisei <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent 004a012 commit 3fb884f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
19641964
(fault_status == FSC_PERM &&
19651965
stage2_is_exec(mmu, fault_ipa, vma_pagesize));
19661966

1967-
if (vma_pagesize == PUD_SIZE) {
1967+
/*
1968+
* If PUD_SIZE == PMD_SIZE, there is no real PUD level, and
1969+
* all we have is a 2-level page table. Trying to map a PUD in
1970+
* this case would be fatally wrong.
1971+
*/
1972+
if (PUD_SIZE != PMD_SIZE && vma_pagesize == PUD_SIZE) {
19681973
pud_t new_pud = kvm_pfn_pud(pfn, mem_type);
19691974

19701975
new_pud = kvm_pud_mkhuge(new_pud);

0 commit comments

Comments
 (0)