]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Fix block mapping validity check in stage-1 walker
authorWei-Lin Chang <weilin.chang@arm.com>
Fri, 5 Jun 2026 18:52:55 +0000 (19:52 +0100)
committerMarc Zyngier <maz@kernel.org>
Sun, 7 Jun 2026 14:10:59 +0000 (15:10 +0100)
For the 64K granule size, FEAT_LPA determines whether a level 1 mapping
is allowed. Using the result of has_52bit_pa() is too restrictive, as it
also checks the selected output addressi size in TCR.(I)PS. Fix it by
only checking FEAT_LPA.

Fixes: 5da3a3b27a01 ("KVM: arm64: Expand valid block mappings to FEAT_LPA/LPA2 support")
Signed-off-by: Wei-Lin Chang <weilin.chang@arm.com>
Link: https://patch.msgid.link/20260605185255.2431996-1-weilin.chang@arm.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/at.c

index 4d4285e60fce5636739d16afcb9b39f52c9f2edb..7663df5e03b75b4ec7e360ac73c26f41227782d3 100644 (file)
@@ -495,15 +495,18 @@ static int walk_s1(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
        /* Block mapping, check the validity of the level */
        if (!(desc & BIT(1))) {
                bool valid_block = false;
+               bool lpa = kvm_has_feat_enum(vcpu->kvm, ID_AA64MMFR0_EL1, PARANGE, 52);
 
                switch (BIT(wi->pgshift)) {
                case SZ_4K:
                        valid_block = level == 1 || level == 2 || (wi->pa52bit && level == 0);
                        break;
                case SZ_16K:
-               case SZ_64K:
                        valid_block = level == 2 || (wi->pa52bit && level == 1);
                        break;
+               case SZ_64K:
+                       valid_block = level == 2 || (lpa && level == 1);
+                       break;
                }
 
                if (!valid_block)