Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Fuad Tabba <fuad.tabba@linux.dev>
Cc: Oliver Upton <oupton@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>, Will Deacon <will@kernel.org>,
	Sascha Bischoff <sascha.bischoff@arm.com>,
	Sebastian Ene <sebastianene@google.com>,
	kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/4] KVM: arm64: vgic-its: Don't save collections the table cannot hold
Date: Tue, 18 Aug 2026 17:06:32 +0100	[thread overview]
Message-ID: <86bjaz5s6v.wl-maz@kernel.org> (raw)
In-Reply-To: <CA+EHjTy90YP8dzUy724VQ7vzVusr+mGocFxyHoQZ2c4OJnpBcQ@mail.gmail.com>

On Mon, 17 Aug 2026 19:21:24 +0100,
Fuad Tabba <fuad.tabba@linux.dev> wrote:
> 
> Hi Marc,
> 
> Sorry for the slow reply, I was away.

No worries.

> 
> On Sat, 8 Aug 2026 at 09:09, Marc Zyngier <maz@kernel.org> wrote:
> ...
> > > A guest that disables the ITS and rewrites GITS_BASER with fewer pages,
> > > VALID still set, keeps every collection it mapped against the larger
> > > table: KVM stores the new BASER unconditionally and frees the list only
> > > when VALID is cleared.
> >
> > But isn't that the *real* problem? Shouldn't we instead nuke the
> > collections entirely and go through a reload sequence?
> 
> Agreed, that is the problem. The fix belongs in vgic_mmio_write_its_baser().
> 
> Should it drop everything, or only the collections that no longer fit?
> On a shrink in place the low ICIDs are still in the table. Or is no
> realistic guest doing this, so the simpler rule wins? I can do the
> unconditional drop if you prefer.

Whatever is the simplest thing. I don't think it is common to update
the BASER registers (Linux certainly does it exactly once), and if
that means there will be a small hickup on things like kexec handover,
so be it.

Thinking of it a bit more: the format of the table is not architected.
So a write to the register with a different value is allowed to result
in data loss (for all the guest knows, this could be a linked list
starting from the last page...). So purging all collections (and
therefore all mappings) would be acceptable, as there no guarantee
this is now fit for purpose.

This would make both save and restore succeed, and be really quick!

> > > Validate each collection against the current table with
> > > vgic_its_check_id() and return -EINVAL, as vgic_its_save_device_tables()
> > > does for devices. Collection IDs are unique and the collection table is
> > > never indirect, so the check also bounds the walk.
> >
> > I think returning -EINVAL here was a mistake, as it aborts the save
> > procedure that userspace should be able to issue reliably, even if
> > that means the state is crap. I don't think we should expand that
> > behaviour any further.
> 
> Fair enough. Either way the check goes with the fix rather than being
> expanded: MAPC, MAPTI and the restore path already validate against
> the current table.
> 
> vgic_its_save_device_tables() is harder: with an indirect table the
> guest can invalidate an L1 entry without touching GITS_BASER, so that
> check can still fire. Skip the device rather than fail the save?

Skipping the devices that fall into an unmapped page looks fine. After
all, the guest is messing with itself, and I have no sympathy for it.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.


  reply	other threads:[~2026-08-18 16:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 10:40 [PATCH v2 0/4] KVM: arm64: vgic: Fixes for ITS table save and init retry Fuad Tabba
2026-08-07 10:40 ` [PATCH v2 1/4] KVM: arm64: vgic-its: Don't dereference a NULL collection on ITT save Fuad Tabba
2026-08-14 12:36   ` Eric Auger
2026-08-15  0:18     ` Fuad Tabba
2026-08-17  9:00       ` Eric Auger
2026-08-07 10:41 ` [PATCH v2 2/4] KVM: arm64: vgic: Don't leak the SPI array when init is retried Fuad Tabba
2026-08-07 10:41 ` [PATCH v2 3/4] KVM: arm64: vgic-its: Don't save collections the table cannot hold Fuad Tabba
2026-08-08  8:10   ` Marc Zyngier
2026-08-17 18:21     ` Fuad Tabba
2026-08-18 16:06       ` Marc Zyngier [this message]
2026-08-07 10:41 ` [PATCH v2 4/4] KVM: arm64: vgic-its: Point saved ITEs at the next valid entry Fuad Tabba
2026-08-08 18:35 ` [PATCH v2 0/4] KVM: arm64: vgic: Fixes for ITS table save and init retry Oliver Upton

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=86bjaz5s6v.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=fuad.tabba@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oupton@kernel.org \
    --cc=sascha.bischoff@arm.com \
    --cc=sebastianene@google.com \
    --cc=seiden@linux.ibm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /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