From: sashiko-bot@kernel.org
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: kvm@vger.kernel.org, "Marc Zyngier" <maz@kernel.org>,
kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>
Subject: Re: [PATCH v2 06/13] KVM: arm64: Size the stage-2 memcache from the fault MMU
Date: Mon, 14 Sep 2026 13:26:36 +0000 [thread overview]
Message-ID: <20260914132636.C71771F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260914-kvm-arm-prefault-v2-6-26fb47f74b73@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The pKVM page fault handler `pkvm_mem_abort()` completely omits the mandatory MMU notifier invalidation retry protocol, risking the installation of stale translations.
--
commit caf2d4f716079e3655b6e5fed2957d60fe0bf41c
Author: Lorenzo Stoakes (ARM) <ljs@kernel.org>
KVM: arm64: Size the stage-2 memcache from the fault MMU
This commit updates topup_mmu_memcache() to take the target s2fd->mmu
instead of the faulting vCPU. This allows the caller to control which MMU
is used for sizing the memcache.
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 13541218cadbe..8c23fef4ecf84 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
[ ... ]
> @@ -1755,7 +1755,7 @@ static int pkvm_mem_abort(const struct kvm_s2_fault_desc *s2fd)
> int ret;
>
> hyp_memcache = get_mmu_memcache(vcpu);
> - ret = topup_mmu_memcache(vcpu, hyp_memcache);
> + ret = topup_mmu_memcache(s2fd->mmu, hyp_memcache);
> if (ret)
> return -ENOMEM;
>
[Severity: High]
This is a pre-existing issue, but pkvm_mem_abort() appears to omit the MMU
notifier invalidation retry protocol, risking the installation of stale
translations.
Further down in pkvm_mem_abort(), the physical frame is resolved using
pin_user_pages() without first capturing the global mmu_invalidate_seq
counter:
mmap_read_lock(mm);
ret = pin_user_pages(s2fd->hva, 1, flags, &page);
mmap_read_unlock(mm);
The mapping is then committed to the stage-2 page tables under the lock
without gating the installation on mmu_invalidate_retry():
write_lock(&kvm->mmu_lock);
ret = pkvm_pgtable_stage2_map(pgt, s2fd->fault_ipa, PAGE_SIZE,
page_to_phys(page), KVM_PGTABLE_PROT_RWX,
hyp_memcache, 0);
write_unlock(&kvm->mmu_lock);
Missing the retry check breaks KVM's invalidation retry protocol. Even when
a page is pinned, a concurrent host MMU invalidation (e.g., from
madvise(MADV_DONTNEED) or NUMA balancing) can overlap with the pin.
Does this allow KVM to install stale translations, leading to memory
corruption or guest-visible data leakage?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914-kvm-arm-prefault-v2-0-26fb47f74b73@kernel.org?part=6
next prev parent reply other threads:[~2026-09-14 13:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 12:26 [PATCH v2 00/13] KVM: arm64: Add KVM_PRE_FAULT_MEMORY support Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 01/13] arm64: Add ESR fault helpers Lorenzo Stoakes (ARM)
2026-09-14 12:41 ` sashiko-bot
2026-09-14 12:26 ` [PATCH v2 02/13] KVM: arm64: Use ESR helpers in guest abort handling Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 03/13] KVM: arm64: Propagate and use esr in s2fd when handling guest aborts Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 04/13] KVM: arm64: Propagate and use mmu " Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 05/13] KVM: arm64: Propagate and use kvm_s2_fault_result on S2 fault Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 06/13] KVM: arm64: Size the stage-2 memcache from the fault MMU Lorenzo Stoakes (ARM)
2026-09-14 13:26 ` sashiko-bot [this message]
2026-09-14 12:26 ` [PATCH v2 07/13] KVM: arm64: Propagate EHWPOISON in kvm_s2_fault_pin_pfn() Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 08/13] KVM: arm64: Pass walk flags to kvm_pgtable_get_leaf() Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 09/13] KVM: arm64: Implement KVM_PRE_FAULT_MEMORY Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 10/13] Documentation: KVM: document arm64 KVM_PRE_FAULT_MEMORY Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 11/13] KVM: selftests: Enable pre_fault_memory_test for arm64 Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 12/13] KVM: selftests: Add option for different backing in pre-fault tests Lorenzo Stoakes (ARM)
2026-09-14 12:26 ` [PATCH v2 13/13] KVM: selftests: Add nested pre-fault test for arm64 Lorenzo Stoakes (ARM)
2026-09-22 9:58 ` [PATCH v2 00/13] KVM: arm64: Add KVM_PRE_FAULT_MEMORY support Aneesh Kumar K.V
2026-09-22 12:52 ` Lorenzo Stoakes (ARM)
2026-09-22 13:07 ` Aneesh Kumar K.V
2026-09-22 13:53 ` Lorenzo Stoakes (ARM)
2026-09-22 14:22 ` Aneesh Kumar K.V
2026-09-22 14:26 ` Lorenzo Stoakes (ARM)
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=20260914132636.C71771F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=ljs@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox