All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jia He" <justin.he@arm.com>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	"Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v4 4/4] KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memory
Date: Thu, 03 Dec 2026 11:16:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-247659@kernel.org> (raw)
In-Reply-To: <20261203105805.165749-5-justin.he@arm.com>

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 <justin.he@arm.com>

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);
>  }
>  
> +/*
> + * 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 = false;
> +
> +	if (pfn_is_map_memory(pfn))
> +		return true;
> +
> +	if (!kvm_supports_cacheable_pfnmap())
> +		return false;
> +
> +	hva = gfn_to_hva_memslot_prot(memslot, gfn, NULL);
> +
> +	mmap_read_lock(current->mm);
> +	vma = vma_lookup(current->mm, hva);
> +	if (vma && (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)))
> +		ret = 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.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203105805.165749-1-justin.he@arm.com?part=4

  reply	other threads:[~2026-12-03 11:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 10:58 [PATCH v4 0/4] KVM: arm64: nv: VNCR page mapping fixes Jia He
2026-12-03 10:58 ` [PATCH v4 1/4] KVM: arm64: nv: Locate the VNCR page in the host page from its PA Jia He
2026-12-03 10:58 ` [PATCH v4 2/4] KVM: arm64: nv: Inject an SEA when the VNCR walk cannot set the AF Jia He
2026-12-03 10:58 ` [PATCH v4 3/4] KVM: arm64: selftests: Add a test for VNCR_EL2 translation faults Jia He
2026-12-03 11:16   ` sashiko-bot
2026-12-04  1:46     ` Justin He
2026-12-04  9:12       ` Marc Zyngier
2026-12-04  9:51         ` Justin He
2026-12-03 10:58 ` [PATCH v4 4/4] KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memory Jia He
2026-12-03 11:16   ` sashiko-bot [this message]
2026-12-04  2:59     ` Justin He
2026-12-04 10:24       ` Marc Zyngier
2026-12-04 11:34         ` Justin He
2026-12-04 16:31           ` Marc Zyngier
2026-12-05  1:32             ` Justin He
2026-12-05  9:32               ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-247659@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=justin.he@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.