Skip to content

Some fixes about vgic-its

Jing Zhang kvm kvmarm linux-arm-kernel oe-kbuild-all 2 versions – Applied

Status from this message: Applied to kvmarm/next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest5 patches 5 repliesApplied
  2. v34 patches 6 repliesSuperseded

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/5KVM: selftests: aarch64: Add VGIC selftest for save/restore ITS table mappingstools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/aarch64/vgic_its_tables.c tools/testing/selftests/kvm/include/aarch64/gic_v3_its.h +2 more+591 -60 replies
2/5KVM: arm64: vgic-its: Add read/write helpers on ITS table entries.arch/arm64/kvm/vgic/vgic.h+23 -01 reply
3/5KVM: arm64: vgic-its: Add a data length check in vgic_its_save_*arch/arm64/kvm/vgic/vgic-its.c+8 -110 replies
4/5KVM: arm64: vgic-its: Clear DTE when MAPD unmaps a devicearch/arm64/kvm/vgic/vgic-its.c+4 -20 replies
5/5KVM: arm64: vgic-its: Clear ITE when DISCARD frees an ITEarch/arm64/kvm/vgic/vgic-its.c+5 -13 replies

Reviews trailers per patch

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

Read the v4 thread

Cover letter [PATCH v4 0/5] Some fixes about vgic-its

This patch series addresses a critical issue in the VGIC ITS tables' save/restore mechanism, accompanied by a comprehensive selftest for bug reproduction and verification.

The fix is originally from Kunkun Jiang at [1].

The identified bug manifests as a failure in VM suspend/resume operations. The root cause lies in the repeated suspend attempts often required for successful VM suspension, coupled with concurrent device interrupt registration and freeing. This concurrency leads to inconsistencies in ITS mappings before the save operation, potentially leaving orphaned Device Translation Entries (DTEs) and Interrupt Translation Entries (ITEs) in the respective tables.

During the subsequent restore operation, encountering these orphaned entries can result in two error scenarios:
* EINVAL Error: If an orphaned entry lacks a corresponding collection ID, the restore operation fails with an EINVAL error.
* Mapping Corruption: If an orphaned entry possesses a valid collection ID, the restore operation may succeed but with incorrect or lost mappings, compromising system integrity.

The provided selftest facilitates the reproduction of both error scenarios:
* EINVAL Reproduction: Execute ./vgic_its_tables without any options.
* Mapping Corruption Reproduction: Execute ./vgic_its_tables -s The -s option enforces identical collection IDs for all mappings.
* A workaround within the selftest involves clearing the tables before the save operation using the command ./vgic_its_tables -c. With this, we can run the the selftest successfully on host w/o the fix.

---

* v3 -> v4:
- Added two helper functions for table entry read/write in guest memory.
- Move selftest as the first patch to easily run on a host without the fix.

* v2 -> v3:
- Rebased to v6.12-rc6
- Fixed some typos
- Added a selftest for bug reproduction and verification

* v1 -> v2:
- Replaced BUG_ON() with KVM_BUG_ON()

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]

---

Jing Zhang (2):
KVM: selftests: aarch64: Add VGIC selftest for save/restore ITS table
mappings
KVM: arm64: vgic-its: Add read/write helpers on ITS table entries.

Kunkun Jiang (3):
KVM: arm64: vgic-its: Add a data length check in vgic_its_save_*
KVM: arm64: vgic-its: Clear DTE when MAPD unmaps a device
KVM: arm64: vgic-its: Clear ITE when DISCARD frees an ITE

 arch/arm64/kvm/vgic/vgic-its.c                |  31 +-
 arch/arm64/kvm/vgic/vgic.h                    |  23 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/aarch64/vgic_its_tables.c   | 565 ++++++++++++++++++
 .../kvm/include/aarch64/gic_v3_its.h          |   3 +-
 .../testing/selftests/kvm/include/kvm_util.h  |   4 +-
 .../selftests/kvm/lib/aarch64/gic_v3_its.c    |  24 +-
 7 files changed, 631 insertions(+), 20 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/aarch64/vgic_its_tables.c

base-commit: 59b723cd2adbac2a34fc8e12c74ae26ae45bf230

Signature · 1 line
2.47.0.277.g8800431eea-goog