Skip to content

vITS save/restore

Eric Auger kvm kvmarm linux-arm-kernel 12 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 posting 2/24 patches 4 repliesApplied
  2. v7 Latest24 patches 30 repliesIn review
  3. v6 posting 1/224 patches 47 repliesSuperseded
Earlier versions · 9
VersionPostedPatchesRepliesStatus
v5 RFC posting 2/24 patches10 repliesSuperseded
v5 posting 1/222 patches109 repliesSuperseded
v4 RFC posting 2/23 patches0 repliesSuperseded
v3 RFC posting 2/23 patches6 repliesSuperseded
v4 posting 1/222 patches45 repliesSuperseded
v2 RFC posting 2/23 patches5 repliesSuperseded
v3 posting 1/219 patches46 repliesSuperseded
v2 RFC posting 1/219 patches5 repliesSuperseded
v1 RFC4 patches14 repliesSuperseded

Changes in v7 from the cover letter

- small rewording in the ABI spec
- hold its lock during save and restore
- check alignment of the offset also on vgic_its_has_attr_regs
- collected A-b/R-b
- use NR_ITS_ABIS
- mask revision with GITS_IIDR_REV_MASK
- some typo & comment fixes

- the only comment I have not yet taken into account is removal of map_resources().

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/24KVM: arm/arm64: Add ITS save/restore API documentationDocumentation/virtual/kvm/devices/arm-vgic-its.txt+120 -04 replies
2/24KVM: arm/arm64: Add GICV3 pending table save API documentationDocumentation/virtual/kvm/devices/arm-vgic-v3.txt+6 -01 reply
3/24KVM: arm/arm64: vgic-its: rename itte into itevirt/kvm/arm/vgic/vgic-its.c+74 -740 replies
4/24arm/arm64: vgic: turn vgic_find_mmio_region into publicvirt/kvm/arm/vgic/vgic-mmio.c virt/kvm/arm/vgic/vgic-mmio.h+10 -60 replies
5/24KVM: arm64: vgic-its: KVM_DEV_ARM_VGIC_GRP_ITS_REGS grouparch/arm/include/uapi/asm/kvm.h arch/arm64/include/uapi/asm/kvm.h virt/kvm/arm/vgic/vgic-its.c+37 -10 replies
6/24KVM: arm/arm64: vgic: expose (un)lock_all_vcpusvirt/kvm/arm/vgic/vgic-kvm-device.c virt/kvm/arm/vgic/vgic.h+5 -20 replies
7/24KVM: arm64: vgic-its: Implement vgic_its_has_attr_regs and attr_regs_accessvirt/kvm/arm/vgic/vgic-its.c virt/kvm/arm/vgic/vgic-mmio.h+84 -41 reply
8/24KVM: arm64: vgic-its: Implement vgic_mmio_uaccess_write_its_creadrvirt/kvm/arm/vgic/vgic-its.c+40 -20 replies
9/24KVM: arm64: vgic-its: Introduce migration ABI infrastructureinclude/kvm/arm_vgic.h include/linux/irqchip/arm-gic-v3.h virt/kvm/arm/vgic/vgic-its.c+97 -41 reply
10/24KVM: arm64: vgic-its: Implement vgic_mmio_uaccess_write_its_iidrinclude/linux/irqchip/arm-gic-v3.h virt/kvm/arm/vgic/vgic-its.c+25 -31 reply
11/24KVM: arm64: vgic-its: Interpret MAPD Size field and check related errorsinclude/linux/irqchip/arm-gic-v3.h virt/kvm/arm/vgic/vgic-its.c+16 -10 replies
12/24KVM: arm64: vgic-its: Interpret MAPD ITT_addr fieldvirt/kvm/arm/vgic/vgic-its.c+4 -00 replies
13/24KVM: arm64: vgic-its: Check the device id matches TYPER DEVBITS rangevirt/kvm/arm/vgic/vgic-its.c+20 -51 reply
14/24KVM: arm64: vgic-v3: vgic_v3_lpi_sync_pending_statusinclude/linux/irqchip/arm-gic-v3.h virt/kvm/arm/vgic/vgic-its.c virt/kvm/arm/vgic/vgic-v3.c +1 more+49 -42 replies
15/24KVM: arm64: vgic-its: Read config and pending bit in add_lpi()virt/kvm/arm/vgic/vgic-its.c+24 -112 replies
16/24KVM: arm64: vgic-its: KVM_DEV_ARM_ITS_SAVE/RESTORE_TABLESarch/arm/include/uapi/asm/kvm.h arch/arm64/include/uapi/asm/kvm.h virt/kvm/arm/vgic/vgic-its.c+109 -65 replies
17/24KVM: arm64: vgic-its: vgic_its_alloc_ite/devicevirt/kvm/arm/vgic/vgic-its.c+47 -211 reply
18/24KVM: arm64: vgic-its: Add infrastructure for table lookupvirt/kvm/arm/vgic/vgic-its.c+92 -01 reply
19/24KVM: arm64: vgic-its: Collection table save/restorevirt/kvm/arm/vgic/vgic-its.c virt/kvm/arm/vgic/vgic.h+107 -21 reply
20/24KVM: arm64: vgic-its: vgic_its_check_id returns the entry's GPAvirt/kvm/arm/vgic/vgic-its.c+8 -31 reply
21/24KVM: arm64: vgic-its: Device table save/restorevirt/kvm/arm/vgic/vgic-its.c virt/kvm/arm/vgic/vgic.h+199 -53 replies
22/24KVM: arm64: vgic-its: ITT save and restorevirt/kvm/arm/vgic/vgic-its.c virt/kvm/arm/vgic/vgic.h+117 -33 replies
23/24KVM: arm64: vgic-its: Fix pending table syncvirt/kvm/arm/vgic/vgic-its.c+12 -121 reply
24/24KVM: arm64: vgic-v3: KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLESarch/arm/include/uapi/asm/kvm.h arch/arm64/include/uapi/asm/kvm.h virt/kvm/arm/vgic/vgic-kvm-device.c +2 more+74 -01 reply

Reviews trailers per patch

22 of 24 patches have a Reviewed-by or Acked-by.

PatchMarc ZyngierChristoffer DallAndre Przywara
1/24
2/24A-b A-b
3/24A-b A-b
4/24A-b A-b R-b
5/24A-b R-b R-b
6/24A-b A-b
7/24R-b R-b
8/24A-b R-b
9/24R-b
10/24R-b
11/24R-b R-b
12/24R-b R-b
13/24R-b R-b
14/24R-b R-b
15/24R-b R-b
16/24A-b R-b
17/24R-b R-b
18/24R-b R-b
19/24R-b R-b
20/24A-b A-b
21/24
22/24R-b
23/24A-b R-b
24/24A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v7 thread

Cover letter [PATCH v7 00/24] vITS save/restore

This series specifies and implements an API aimed at saving and restoring the state of the in-kernel emulated ITS device.

The ITS is programmed through registers and tables. Those latter are allocated by the guest. Their base address is programmed in registers or table entries before the ITS is enabled.

The ITS is free to use some of them to flush its internal caches. This is likely to be used when entering low power state.

Therefore, for save/restore use case, it looks natural to use this guest RAM allocated space to save the table related data. However, currently, The ITS in-kernel emulated device does not use all of those tables and for those it uses, it does not always sync them with its cached data. Additional sync must happen for:
- the collection table
- the device table
- the per-device translation tables
- the LPI pending tables.

The LPI configuration table and the command queues do not need extra syncs.

Best Regards

Eric

Git: complete series available at
https://github.com/eauger/linux/tree/v4.11-its-mig-v7

* Testing:
- on Cavium ThunderX using a virtio-net-pci guest, virsh save/restore commands and virt-manager live migration. Tested with 1 and 2 stage device table.

History:
v6 -> v7:
- small rewording in the ABI spec
- hold its lock during save and restore
- check alignment of the offset also on vgic_its_has_attr_regs
- collected A-b/R-b
- use NR_ITS_ABIS
- mask revision with GITS_IIDR_REV_MASK
- some typo & comment fixes

- the only comment I have not yet taken into account is removal of map_resources().

v5 -> v6:
- address Christoffer's comments:
- add restore sequence in the doc
- sync with pending and config tables in its_add_lpi
- change in return values when scanning the tables
- several bug fixes pointed out by Christoffer
- see full details in individual logs

v4 -> v5:
- user API changes:
- ITS table save/restore triggered through ITS KVM device KVM_DEV_ARM_VGIC_GRP_CTRL group, KVM_DEV_ARM_ITS_SAVE_TABLES, KVM_DEV_ARM_ITS_RESTORE_TABLES
- RDIST pending table flush triggered through GICV3 KVM device KVM_DEV_ARM_VGIC_GRP_CTRL/KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES
- Introduce an ABI infrastructure, entry size report using this infra
- IIDR reports ABI chosen set by userspace if any
- pending table save moved to vgic-v3.c
- use optimisation in pending table save
- check target_addr when restore cte
- pending table sync called from restore_tables
- added KVM: arm64: vgic-its: Fix pending table sync
- simplify loopup_table and use kvm_read_guest()
- sort the device and ITE list on save
- add defines for shifts and masks, GIC_ENCODE_SZ macro

v3 -> v4:
- update the DTE format (ITT_addr 52 bit support, validity bit addition)
- Document ABI revision and implement check
- iidr save/restore (including a new patch for iidr user write access)
- changed locking: kvm lock + vcpu lock
- fix nb_eventid_bits mixup
- 2 new patches aiming at exposing next_segment() and lock_all_vcpus()
- rework errror handling of lookup_table functions

- I took into account all Andre's comments/suggestions except:
- trigger the save/restore of pending tables from GICV3 KVM device instead of ITS KVM device
- implement ITS flush/restore in KVM_DEV_ARM_VGIC_GRP_CTRL ITS group

See the ML replies for current justifications. In case other people strongly disagree of course I will change the code.

v2 -> v3:
- fix restore ITS ITT_addr bit masking

v1 -> v2:
- rebased on Vijaya's v11
- all entries now are 8 byte large
- devid/eventid indexing for device table and ITT
- support 2 stage device table
- common infra to read indexed tables
- add cpu <-> le64 conversions
- itte renamed into ite
- do not care anymore about pending table 1st KB
(not needed at the moment for coarse mapping)

RFC v1
- creation

Eric Auger (24):
KVM: arm/arm64: Add ITS save/restore API documentation
KVM: arm/arm64: Add GICV3 pending table save API documentation
KVM: arm/arm64: vgic-its: rename itte into ite
arm/arm64: vgic: turn vgic_find_mmio_region into public
KVM: arm64: vgic-its: KVM_DEV_ARM_VGIC_GRP_ITS_REGS group
KVM: arm/arm64: vgic: expose (un)lock_all_vcpus
KVM: arm64: vgic-its: Implement vgic_its_has_attr_regs and
attr_regs_access
KVM: arm64: vgic-its: Implement vgic_mmio_uaccess_write_its_creadr
KVM: arm64: vgic-its: Introduce migration ABI infrastructure
KVM: arm64: vgic-its: Implement vgic_mmio_uaccess_write_its_iidr
KVM: arm64: vgic-its: Interpret MAPD Size field and check related
errors
KVM: arm64: vgic-its: Interpret MAPD ITT_addr field
KVM: arm64: vgic-its: Check the device id matches TYPER DEVBITS range
KVM: arm64: vgic-v3: vgic_v3_lpi_sync_pending_status
KVM: arm64: vgic-its: Read config and pending bit in add_lpi()
KVM: arm64: vgic-its: KVM_DEV_ARM_ITS_SAVE/RESTORE_TABLES
KVM: arm64: vgic-its: vgic_its_alloc_ite/device
KVM: arm64: vgic-its: Add infrastructure for table lookup
KVM: arm64: vgic-its: Collection table save/restore
KVM: arm64: vgic-its: vgic_its_check_id returns the entry's GPA
KVM: arm64: vgic-its: Device table save/restore
KVM: arm64: vgic-its: ITT save and restore
KVM: arm64: vgic-its: Fix pending table sync
KVM: arm64: vgic-v3: KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES

 Documentation/virtual/kvm/devices/arm-vgic-its.txt |  120 ++
 Documentation/virtual/kvm/devices/arm-vgic-v3.txt  |    6 +
 arch/arm/include/uapi/asm/kvm.h                    |    6 +-
 arch/arm64/include/uapi/asm/kvm.h                  |    6 +-
 include/kvm/arm_vgic.h                             |    3 +
 include/linux/irqchip/arm-gic-v3.h                 |   14 +
 virt/kvm/arm/vgic/vgic-its.c                       | 1164 +++++++++++++++++---
 virt/kvm/arm/vgic/vgic-kvm-device.c                |   24 +-
 virt/kvm/arm/vgic/vgic-mmio.c                      |   11 +-
 virt/kvm/arm/vgic/vgic-mmio.h                      |   14 +-
 virt/kvm/arm/vgic/vgic-v3.c                        |   95 ++
 virt/kvm/arm/vgic/vgic.h                           |   28 +
 12 files changed, 1349 insertions(+), 142 deletions(-)
Signature · 1 line
2.5.5