]> Git Repo - J-linux.git/commitdiff
KVM: arm64: Do not try to map PUDs when they are folded into PMD
authorMarc Zyngier <[email protected]>
Wed, 2 Sep 2020 10:18:29 +0000 (11:18 +0100)
committerMarc Zyngier <[email protected]>
Fri, 4 Sep 2020 09:52:49 +0000 (10:52 +0100)
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: b8e0ba7c8bea ("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]>
arch/arm64/kvm/mmu.c

index 0121ef2c7c8d2f720a9377257058bf090228811c..16b8660ddbccd05d8790ded9a7701b5a4bb77044 100644 (file)
@@ -1964,7 +1964,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
                (fault_status == FSC_PERM &&
                 stage2_is_exec(mmu, fault_ipa, vma_pagesize));
 
-       if (vma_pagesize == PUD_SIZE) {
+       /*
+        * If PUD_SIZE == PMD_SIZE, there is no real PUD level, and
+        * all we have is a 2-level page table. Trying to map a PUD in
+        * this case would be fatally wrong.
+        */
+       if (PUD_SIZE != PMD_SIZE && vma_pagesize == PUD_SIZE) {
                pud_t new_pud = kvm_pfn_pud(pfn, mem_type);
 
                new_pud = kvm_pud_mkhuge(new_pud);
This page took 0.054705 seconds and 4 git commands to generate.