Skip to content

KVM: arm64: vgic: Fixes for ITS table save and init retry

Fuad Tabba kvmarm linux-arm-kernel lkml sashiko-reviews 2 versions – Applied

Status from this message: Applied to next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 12 repliesApplied
  2. v13 patches 3 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/4KVM: arm64: vgic-its: Don't dereference a NULL collection on ITT savearch/arm64/kvm/vgic/vgic-its.c+8 -03 replies
2/4KVM: arm64: vgic: Don't leak the SPI array when init is retriedarch/arm64/kvm/vgic/vgic-init.c+3 -05 replies
3/4KVM: arm64: vgic-its: Don't save collections the table cannot holdarch/arm64/kvm/vgic/vgic-its.c+3 -03 replies
4/4KVM: arm64: vgic-its: Point saved ITEs at the next valid entryarch/arm64/kvm/vgic/vgic-its.c+8 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] KVM: arm64: vgic: Fixes for ITS table save and init retry

Hi folks,

Respinning today since I am travelling until the 17th and will be slow to reply.

Changes since v1 [1]:
- Patch 3: check the collection ID with vgic_its_check_id() instead of bounding the walk by the table size, so a collection the table cannot address is not saved either. Retitled to match. (sashiko)
- New patch 4: skip the ITEs that are saved as invalid when computing an ITE's next-event offset. (Oliver)

Three unrelated vgic fixes, and one follow-up to the first of them.

The first is the one that matters the most. A guest that issues MAPD, MAPTI and then MAPC(V=0) leaves an ITE mapped with no collection, and the next KVM_DEV_ARM_ITS_SAVE_TABLES from the VMM oopses the host. That is three ITS commands and an ordinary migration save, with no race and no allocation failure.

The other two are weaker and come after it. The init fix stops the SPI array leaking when userspace retries KVM_DEV_ARM_VGIC_CTRL_INIT after a failure. The collection table fix stops the save writing past the end of the table, and stops it saving a collection the destination will reject.

Patch 4 is not a fix. It makes the restore scan skip the invalid entries patch 1 writes instead of stepping through them one at a time.

Patch 1 is unchanged. Oliver also suggested deleting the ITEs when their collection goes away, but I do not think it removes the need for the check here: vgic_its_free_collection_list() reaches the same state with the ITTs intact, and that path is not UNPREDICTABLE.

Patches 1 and 3 are reproduced, each with a selftest that fails on an unfixed kernel and passes on a fixed one. Those are not part of this series, happy to post them separately if they are worth having.

Based on Linux 7.2-rc6 (075b74841bd00).

Cheers,
/fuad

[1] https://lore.kernel.org/all/[email protected]/

Fuad Tabba (4):
KVM: arm64: vgic-its: Don't dereference a NULL collection on ITT save
KVM: arm64: vgic: Don't leak the SPI array when init is retried
KVM: arm64: vgic-its: Don't save collections the table cannot hold
KVM: arm64: vgic-its: Point saved ITEs at the next valid entry

 arch/arm64/kvm/vgic/vgic-init.c |  3 +++
 arch/arm64/kvm/vgic/vgic-its.c  | 26 +++++++++++++++++++-------
 2 files changed, 22 insertions(+), 7 deletions(-)

base-commit: 075b74841bd0065a3bda3440873c747938e69b68

Signature · 1 line
2.39.5