]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: nv: Inject SEA if guest VNCR isn't normal memory
authorOliver Upton <oupton@kernel.org>
Thu, 18 Jun 2026 23:42:05 +0000 (16:42 -0700)
committerMarc Zyngier <maz@kernel.org>
Mon, 22 Jun 2026 09:43:25 +0000 (10:43 +0100)
When constructing an L1 VNCR mapping, KVM unconditionally uses cacheable
memory attributes, even if the underlying PFN isn't memory. This gets
particularly hairy if the endpoint doesn't support cacheable memory
attributes, potentially throwing an SError on writeback...

While KVM does permit cacheable memory attributes on certain PFNMAP
VMAs, kvm_translate_vncr() isn't currently grabbing the VMA. So do the
simpler thing for now and just reject everything that isn't memory.

Cc: stable@vger.kernel.org
Fixes: 2a359e072596 ("KVM: arm64: nv: Handle mapping of VNCR_EL2 at EL2")
Signed-off-by: Oliver Upton <oupton@kernel.org>
Link: https://patch.msgid.link/20260618234207.1063941-5-oupton@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/nested.c

index 7fffd86eee94458a37b7f9909ec2131a17f240e0..d4c9a9b05e3ff289184013ee9d013438609fd994 100644 (file)
@@ -1419,6 +1419,17 @@ static int kvm_translate_vncr(struct kvm_vcpu *vcpu, bool *is_gmem)
                writable = !(memslot->flags & KVM_MEM_READONLY);
        }
 
+       /*
+        * FIXME: This check is too restrictive as KVM allows cacheable memory
+        * attributes for PFNMAP VMAs that have cacheable attributes in host
+        * stage-1.
+        */
+       if (!pfn_is_map_memory(pfn)) {
+               kvm_release_faultin_page(vcpu->kvm, page, true, false);
+               fail_s1_walk(&vt->wr, ESR_ELx_FSC_EXTABT, false);
+               return -EINVAL;
+       }
+
        scoped_guard(write_lock, &vcpu->kvm->mmu_lock) {
                if (mmu_invalidate_retry(vcpu->kvm, mmu_seq)) {
                        kvm_release_faultin_page(vcpu->kvm, page, true, false);