From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796296586; b=wN/iPhIzknbG5kvZxM47RWLrOynfYNV9q33XOafclSjISzSefk+s+awPPORN8+UP6E8G AN+6ZALdov/FsrfT4HzZ60G013rxHv2JChCU8MwR9v7TeYZQuURy+AimYnwjjIpbpPK5x ireTIybUE2/TdYUQFhSzFXjKS70RDNS27YwTe4grjzzO3hVaI1WPVnVHTs0tLpdG4zLI6 VUTV4xgAWBdmfhBZooG62DR0HrGkFBCUtg734iBFhCobrC0OvKs/7ckPvYD+MjuEnREvt qM/WjkWfJhuONiU8yX0f/G0dT7Jb5TQzSPuiZ72SoFg/g9SBqjA9W9R3mdx/SNbnP1w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296586; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=YJ2P9mWxxczfbiE/jdXgpphGOrsoBxKX2XbrYMzWLd4=; b=3XnXg0IH/53G/q12TrQpoNeY0tLVoQtiFs2nK5799GVIyWYxD2nHkU1moPTqBocwL1I2 w6Mp5H/gvv0gZV7owj9EW60Qi9V9Xj3u0pAWPzEHLnP8cPcM/HSBzel9WkZQvLbAG6hxA QeFYEDsWlCeJpm3mvT/AAMyLojshe/LTSeH5rNPi/cInFYODZHbnhuusofSV0dFCx1O1Y W3H0EBzrL52G/fNQNQtGTFQCNORwA5+JQiyM3YPTiEcYXRuuim7+ktQLjOlYrmJ0jNldi OwgbN5jtC3lvUcI+wj3s1dEDn48J03KLvbWPevLOgReJBFdrzE4Fz1yIw3in1tBGLsg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="OIQMc/xc"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2284606A322; Thu, 3 Dec 2026 11:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OIQMc/xc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34E1E1F000C1; Thu, 3 Dec 2026 11:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796296586; bh=YJ2P9mWxxczfbiE/jdXgpphGOrsoBxKX2XbrYMzWLd4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=OIQMc/xcgEzuYs8isrosvQogU2iYzN+M1+6BKE2fINxTpj2LkUKjNBJSf3xanGWTH iChJVksvf0dQv9G7WrzxBbVQC6I3WNTBfOEHry0TUbQawyFeEyPtc2aqAzpfMG3kci Z6oQQidt8zJrKPyKavJb1Z9VKTiWkHordlI8Pud0RdBCMBDDPnAPlqwsdqBJkn/wcC kNAtX44ZFNihKLnV6K1qQCyUf6j9EPHvmnaXv8yDomD4DcLQ5LjiyuQRwPiWGxHMxn umGkQjgQs5hCuQFztMyF/RLvOOCCdAvhg8h0oRkjBBKOw60B6eDjT/LD/edvoq6ZMu l46bJA18mhGTQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 4/4] KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memory Reply-To: sashiko-reviews@lists.linux.dev To: "Jia He" Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, "Oliver Upton" , "Marc Zyngier" In-Reply-To: <20261203105805.165749-5-justin.he@arm.com> References: <20261203105805.165749-1-justin.he@arm.com> <20261203105805.165749-5-justin.he@arm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 11:16:25 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] KVM: arm64: vncr_pfn_is_cacheable() checks VMA prot instead of PTE prot -- commit 08fdf40109728fb074e9e46b68fb679e51daf3c0 Author: Jia He KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memory This commit allows the L1 VNCR page to reside in cacheable VM_PFNMAP or VM_MIXEDMAP memory outside the linear map when the host supports FWB and DIC, and checks the MMU invalidation sequence before injecting an SEA on fault-in or cacheability failures. > diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c > index 867bcdd693828..e29fb1a8a9ba3 100644 > --- a/arch/arm64/kvm/nested.c > +++ b/arch/arm64/kvm/nested.c > @@ -1534,10 +1534,38 @@ static u64 read_vncr_el2(struct kvm_vcpu *vcpu) > return (u64)sign_extend64(__vcpu_sys_reg(vcpu, VNCR_EL2), 48); > } > =20 > +/* > + * Allow a non-memory PFN only if it comes from a cacheable VM_PFNMAP or > + * VM_MIXEDMAP VMA and the system supports cacheable PFNMAP at stage-2. > + */ > +static bool vncr_pfn_is_cacheable(struct kvm_memory_slot *memslot, gfn_t= gfn, > + kvm_pfn_t pfn) > +{ > + struct vm_area_struct *vma; > + unsigned long hva; > + bool ret =3D false; > + > + if (pfn_is_map_memory(pfn)) > + return true; > + > + if (!kvm_supports_cacheable_pfnmap()) > + return false; > + > + hva =3D gfn_to_hva_memslot_prot(memslot, gfn, NULL); > + > + mmap_read_lock(current->mm); > + vma =3D vma_lookup(current->mm, hva); > + if (vma && (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))) > + ret =3D kvm_vma_is_cacheable(vma); > + mmap_read_unlock(current->mm); > + > + return ret; > +} [Severity: High] Can kvm_vma_is_cacheable() misclassify device MMIO or non-cacheable PFNs as cacheable when the backing driver uses vmf_insert_pfn_prot()? kvm_vma_is_cacheable() only inspects vma->vm_page_prot, whereas drivers using vmf_insert_pfn_prot() can leave vma->vm_page_prot cacheable and set non-cacheable PTE attributes on fault. For example, panthor_mmio_vm_fault() maps GPU MMIO with pgprot_noncached(). If userspace backs a memslot with such a VMA and points VNCR_EL2 at it, kvm_map_l1_vncr() will map the device MMIO page into the host EL2 fixmap with PAGE_KERNEL or PAGE_KERNEL_RO attributes. Cacheable accesses or writebacks through the fixmap can then trigger a host EL2 SError. Since follow_pfnmap_start() already resolves the actual PTE pgprot during __kvm_faultin_pfn(), checking the PTE attributes instead of vma->vm_page_prot would avoid this mismatch. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203105805.1657= 49-1-justin.he@arm.com?part=3D4