From: Vincent Donnefort <vdonnefort@google.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvmarm@lists.linux.dev, Oliver Upton <oupton@kernel.org>,
Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH v1] KVM: arm64: Fix protected VMs fault on system with pages larger than 4K
Date: Sun, 13 Sep 2026 21:32:36 +0100 [thread overview]
Message-ID: <aqcIZCglQ2B7LPnH@google.com> (raw)
In-Reply-To: <20260913175105.A57AC1F000FF@smtp.kernel.org>
On Sun, Sep 13, 2026 at 05:51:05PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] gmem_abort() passes an unaligned fault_ipa to kvm_pgtable_stage2_map(), which triggers the new -EINVAL check on pKVM hosts.
> --
>
> commit 724c2b0f8e554f59f7c409467796ff8e9acf590b
> Author: Vincent Donnefort <vdonnefort@google.com>
> Subject: KVM: arm64: Fix protected VMs fault on system with pages larger than 4K
>
> This commit aligns the fault IPA down to the page size for protected VMs
> in pkvm_mem_abort(), similar to previous fixes for non-protected VMs.
> It also adds a strict page-alignment check to pkvm_pgtable_stage2_map()
> which returns -EINVAL if the address, size, or physical address are unaligned.
>
> [ ... ]
>
> > diff --git a/arch/arm64/kvm/pkvm.c b/arch/arm64/kvm/pkvm.c
> > index 8e4c6e4bec123..1ca27d01a3ec6 100644
> > --- a/arch/arm64/kvm/pkvm.c
> > +++ b/arch/arm64/kvm/pkvm.c
> > @@ -414,6 +414,9 @@ int pkvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size,
> > u64 end = addr + size;
> > int ret;
> >
> > + if (!PAGE_ALIGNED(addr | size | phys))
> > + return -EINVAL;
> > +
>
> [Severity: High]
> Does this new check break non-protected VMs using guest_memfd on a pKVM host?
>
> When gmem_abort() handles page faults for guest_memfd slots, it passes
> s2fd->fault_ipa directly to kvm_pgtable_stage2_map() without aligning it
> down to the page size:
>
> arch/arm64/kvm/mmu.c:gmem_abort() {
> ...
> } else {
> ret = KVM_PGT_FN(kvm_pgtable_stage2_map)(pgt, s2fd->fault_ipa,
> PAGE_SIZE,
> __pfn_to_phys(pfn),
> prot, memcache, flags);
> }
> ...
> }
Ha right...
And actually I will do gfn_to_gpa(gfn)... that fits better the series I have
sent for the protected VM huge pages.
--
Vincent
>
> Since HPFAR_EL2 only aligns to 4K, on a 16K or 64K page host, the fault_ipa
> passed from gmem_abort() will fail this new PAGE_ALIGNED check and return
> -EINVAL. This prevents memory mapping and causes the VM fault handling to
> abort.
>
> Should gmem_abort() also be updated to apply ALIGN_DOWN to s2fd->fault_ipa,
> just like pkvm_mem_abort() was fixed in this patch?
>
> > lockdep_assert_held_write(&kvm->mmu_lock);
> > mapping = pkvm_mapping_iter_first(&pgt->pkvm_mappings, addr, end - 1);
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260913173516.3122436-1-vdonnefort@google.com?part=1
prev parent reply other threads:[~2026-09-13 20:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 17:35 [PATCH v1] KVM: arm64: Fix protected VMs fault on system with pages larger than 4K Vincent Donnefort
2026-09-13 17:51 ` sashiko-bot
2026-09-13 20:32 ` Vincent Donnefort [this message]
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=aqcIZCglQ2B7LPnH@google.com \
--to=vdonnefort@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox