Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Oliver Upton" <oupton@kernel.org>
Cc: "Marc Zyngier" <maz@kernel.org>, kvmarm@lists.linux.dev
Subject: Re: [PATCH v3 2/5] KVM: arm64: nv: Inject SEA if kvm_translate_vncr() can't resolve PFN
Date: Thu, 18 Jun 2026 23:57:32 +0000	[thread overview]
Message-ID: <20260618235733.197C01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260618234207.1063941-3-oupton@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Unhandled guest_memfd errors ignore prepared memory fault exits and inject malformed guest exceptions.

Pre-existing issues:
- [High] Host-side PFN resolution errors (e.g., SIGPENDING, HWPOISON) are silently converted into guest Synchronous External Aborts (SEA).
--

commit 68bfda7f1617f64f7121c49b477f4cf4e33b2e10
Author: Oliver Upton <oupton@kernel.org>

KVM: arm64: nv: Inject SEA if kvm_translate_vncr() can't resolve PFN

This commit updates kvm_translate_vncr() to prepare an external abort
when failing to resolve a PFN instead of returning -EFAULT and relying
on kvm_handle_vncr_abort() to BUG_ON() or correctly guess the failure.
It drops the BUG_ON() in the abort handler to safely inject the SEA.

> diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
> index 903ccabca78c5..53dea9c3f14f8 100644
> --- a/arch/arm64/kvm/nested.c
> +++ b/arch/arm64/kvm/nested.c
> @@ -1395,15 +1395,19 @@ static int kvm_translate_vncr(struct kvm_vcpu *vcpu, bool *is_gmem)
>  
>  	gfn = vt->wr.pa >> PAGE_SHIFT;
>  	memslot = gfn_to_memslot(vcpu->kvm, gfn);
> -	if (!memslot)
> +	if (!memslot) {
> +		fail_s1_walk(&vt->wr, ESR_ELx_FSC_EXTABT, false);
>  		return -EFAULT;
> +	}
>  
>  	*is_gmem = kvm_slot_has_gmem(memslot);
>  	if (!*is_gmem) {
>  		pfn = __kvm_faultin_pfn(memslot, gfn, write_fault ? FOLL_WRITE : 0,
>  					&writable, &page);
> -		if (is_error_noslot_pfn(pfn))
> +		if (is_error_noslot_pfn(pfn)) {
> +			fail_s1_walk(&vt->wr, ESR_ELx_FSC_EXTABT, false);
>  			return -EFAULT;
> +		}

[Severity: High]
This is a pre-existing issue, but does this improperly convert host PFN
resolution errors into guest aborts?

If __kvm_faultin_pfn() encounters a pending host signal or poisoned memory,
it can return KVM_PFN_ERR_SIGPENDING or KVM_PFN_ERR_HWPOISON. These are
caught by is_error_noslot_pfn().

By calling fail_s1_walk() and returning -EFAULT here, kvm_handle_vncr_abort()
will inject a Synchronous External Abort (SEA) into the guest instead of
returning to userspace. Will this cause a simple host signal to randomly
crash the VM and break host HWPOISON recovery?

[ ... ]

> @@ -1530,8 +1534,6 @@ int kvm_handle_vncr_abort(struct kvm_vcpu *vcpu)
>  			 * Translation failed, inject the corresponding
>  			 * exception back to EL2.
>  			 */
> -			BUG_ON(!vt->wr.failed);
> -

[Severity: High]
Does removing this BUG_ON() unmask an issue when kvm_gmem_get_pfn() fails
with -EINVAL, -ENOENT, or -EACCES?

In kvm_translate_vncr(), if kvm_gmem_get_pfn() fails, it prepares a memory
fault exit for userspace and returns the error code without calling
fail_s1_walk().

Because kvm_handle_vncr_abort() lacks an 'if (is_gmem) return 0;' check for
-EINVAL, -ENOENT, and -EACCES, it will fall through to the exception injection
path below. Since vt->wr.fst is uninitialized (0), won't KVM ignore the
prepared memory fault exit and inject a malformed exception (FSC=0) into the
guest?

>  			esr &= ~ESR_ELx_FSC;
>  			esr |= FIELD_PREP(ESR_ELx_FSC, vt->wr.fst);
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260618234207.1063941-1-oupton@kernel.org?part=2

  reply	other threads:[~2026-06-18 23:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 23:42 [PATCH v3 0/5] KVM: arm64: nv: Even more VNCR fixes Oliver Upton
2026-06-18 23:42 ` [PATCH v3 1/5] KVM: arm64: nv: Respect read-only PFN when mapping L1 VNCR Oliver Upton
2026-06-19  0:07   ` sashiko-bot
2026-06-22 17:10     ` Oliver Upton
2026-06-18 23:42 ` [PATCH v3 2/5] KVM: arm64: nv: Inject SEA if kvm_translate_vncr() can't resolve PFN Oliver Upton
2026-06-18 23:57   ` sashiko-bot [this message]
2026-06-18 23:42 ` [PATCH v3 3/5] KVM: arm64: nv: Re-translate VNCR before injecting abort Oliver Upton
2026-06-19  0:00   ` sashiko-bot
2026-06-22 17:18     ` Oliver Upton
2026-06-18 23:42 ` [PATCH v3 4/5] KVM: arm64: nv: Inject SEA if guest VNCR isn't normal memory Oliver Upton
2026-06-18 23:42 ` [PATCH v3 5/5] KVM: arm64: nv: Mark VM as bugged for unexpected VNCR abort Oliver Upton
2026-06-23 13:53 ` [PATCH v3 0/5] KVM: arm64: nv: Even more VNCR fixes 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=20260618235733.197C01F000E9@smtp.kernel.org \
    --to=sashiko-bot@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox