Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Karl Mehltretter" <kmehltretter@gmail.com>
Cc: "Oliver Upton" <oupton@kernel.org>,
	kvmarm@lists.linux.dev, "Marc Zyngier" <maz@kernel.org>,
	kvm@vger.kernel.org
Subject: Re: [PATCH v2 1/5] KVM: arm64: vgic-v3: Undo assignment on iodev registration failure
Date: Wed, 19 Aug 2026 22:54:40 +0000	[thread overview]
Message-ID: <20260819225441.33CEF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260819224229.82948-2-kmehltretter@gmail.com>

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

Pre-existing issues:
- [High] Incomplete rollback in `vgic_register_all_redist_iodevs` fails to clear `base_addr`, permanently breaking rolled-back vCPUs on retry.
--

--- Patch [1]: [PATCH v2 1/5] KVM: arm64: vgic-v3: Undo assignment on iodev registration failure ---
commit 1ddcb102c04536e66942920259e184122195f9ff
Author: Karl Mehltretter <kmehltretter@gmail.com>

KVM: arm64: vgic-v3: Undo assignment on iodev registration failure

This commit introduces vgic_unassign_redist_iodev() to clear rdreg and base_addr
when kvm_io_bus_register_dev() fails during redistributor iodev registration.
This prevents reusing a slot that remains assigned to a vCPU and fixes the
state leak for the current failing vCPU.

> diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> index 5913a20d83019..c75caadbd1d3c 100644
> --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c
> @@ -766,6 +766,18 @@ unsigned int vgic_v3_init_dist_iodev(struct vgic_io_device *dev)
[ ... ]
> @@ -818,16 +830,17 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)
[ ... ]
>  	ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, rd_base,
>  				      2 * SZ_64K, &rd_dev->dev);
>  	if (ret)
> -		return ret;
> +		vgic_unassign_redist_iodev(vcpu);

[Severity: High]
This is a pre-existing issue, but does the rollback loop in
vgic_register_all_redist_iodevs() also need to use this new unassign helper?

If vgic_register_redist_iodev() fails, the rollback loop in
vgic_register_all_redist_iodevs() handles previously processed vCPUs by calling
vgic_unregister_redist_iodev():

arch/arm64/kvm/vgic/vgic-mmio-v3.c:vgic_register_all_redist_iodevs() {
    ...
	if (ret) {
		/* The current c failed, so iterate over the previous ones. */
		int i;

		for (i = 0; i < c; i++) {
			vcpu = kvm_get_vcpu(kvm, i);
			vgic_unregister_redist_iodev(vcpu);
		}
	}
    ...
}

Because vgic_unregister_redist_iodev() only unregisters the bus device, it
does not clear base_addr or reset rdreg. These rolled-back vCPUs remain
assigned but are removed from the MMIO bus.

If userspace retries the ioctl, vgic_register_redist_iodev() will see that
base_addr is no longer VGIC_ADDR_UNDEF and skip registration.

Will this leave the guest permanently missing MMIO mappings for those
earlier vCPUs, breaking guest execution?

>  
> -	/* Protected by slots_lock */
> -	rdreg->free_index++;
> -	return 0;
> +	return ret;
>  
>  out_unlock:
>  	mutex_unlock(&kvm->arch.config_lock);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260819224229.82948-1-kmehltretter@gmail.com?part=1

  reply	other threads:[~2026-08-19 22:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19 22:42 [PATCH v2 0/5] KVM: arm64: fix VGICv3 redistributor rollback Karl Mehltretter
2026-08-19 22:42 ` [PATCH v2 1/5] KVM: arm64: vgic-v3: Undo assignment on iodev registration failure Karl Mehltretter
2026-08-19 22:54   ` sashiko-bot [this message]
2026-08-19 22:42 ` [PATCH v2 2/5] KVM: arm64: vgic-v3: Reset assignments after failed region setup Karl Mehltretter
2026-08-19 22:58   ` sashiko-bot
2026-08-19 22:42 ` [PATCH v2 3/5] KVM: arm64: vgic-v3: Unregister redistributors before freeing regions Karl Mehltretter
2026-08-19 22:42 ` [PATCH v2 4/5] KVM: arm64: selftests: Pass guest code to vm_gic_create_with_vcpus() Karl Mehltretter
2026-08-19 22:50   ` sashiko-bot
2026-08-19 22:42 ` [PATCH v2 5/5] KVM: arm64: selftests: Test VGICv3 redistributor region retry Karl Mehltretter

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=20260819225441.33CEF1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kmehltretter@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox