[RFC v2 04/19] KVM: arm64: ITS: KVM_DEV_ARM_VGIC_GRP_ITS_REGS group

2017-02-08 Thread Eric Auger
The ITS KVM device exposes a new KVM_DEV_ARM_VGIC_GRP_ITS_REGS group which allows the userspace to save/restore ITS registers. At this stage the get/set/has operations are not yet implemented. Signed-off-by: Eric Auger --- arch/arm/include/uapi/asm/kvm.h | 1 +

[RFC v2 05/19] KVM: arm64: ITS: Implement vgic_its_has_attr_regs and attr_regs_access

2017-02-08 Thread Eric Auger
This patch implements vgic_its_has_attr_regs and vgic_its_attr_regs_access upon the MMIO framework. VGIC ITS KVM device KVM_DEV_ARM_VGIC_GRP_ITS_REGS group becomes functional. At least GITS_CREADR requires to differentiate a guest write action from a user access. As such let's introduce a new

[RFC v2 01/19] KVM: arm/arm64: Add vITS save/restore API documentation

2017-02-08 Thread Eric Auger
Add description for how to access vITS registers and how to flush/restore vITS tables into/from memory Signed-off-by: Eric Auger --- v1 -> v2: - DTE and ITE now are 8 bytes - DTE and ITE now indexed by deviceid/eventid - use ITE name instead of ITTE - mentions ITT_addr

[RFC v2 02/19] KVM: arm/arm64: rename itte into ite

2017-02-08 Thread Eric Auger
The actual abbreviation for the interrupt translation table entry is ITE. Let's rename all itte instances by ite. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic/vgic-its.c | 148 +-- 1 file changed, 74 insertions(+), 74

[RFC v2 06/19] KVM: arm64: ITS: Implement vgic_mmio_uaccess_write_its_creadr

2017-02-08 Thread Eric Auger
GITS_CREADR needs to be restored so let's implement the associated uaccess_write_its callback. Signed-off-by: Eric Auger --- --- virt/kvm/arm/vgic/vgic-its.c | 22 +- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git

[RFC v2 00/19] vITS save/restore

2017-02-08 Thread Eric Auger
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

[RFC v2 09/19] KVM: arm64: ITS: Interpret MAPD ITT_addr field

2017-02-08 Thread Eric Auger
Up to now the MAPD ITT_addr had been ignored. We will need it for save/restore. Let's record it in the its_device struct. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic/vgic-its.c | 4 1 file changed, 4 insertions(+) diff --git a/virt/kvm/arm/vgic/vgic-its.c

[RFC v2 07/19] KVM: arm64: ITS: Report the ITE size in GITS_TYPER

2017-02-08 Thread Eric Auger
An ITE size of 8 Bytes is reported to the guest. Combining this information with the number of event IDs the guest wants to support, this latter will be able to allocate each device's ITT with the right size. Signed-off-by: Eric Auger --- v1 -> v2: - correct

[RFC v2 13/19] KVM: arm64: ITS: Sort the device and ITE lists

2017-02-08 Thread Eric Auger
Natively sort the device and ITE lists in ascending deviceId/eventid order. This paves the way to optimized DTE and ITE scan in guest RAM table where entries are chained together using a next ID offset. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic/vgic-its.c | 36

[RFC v2 15/19] KVM: arm64: ITS: Collection table save/restore

2017-02-08 Thread Eric Auger
The flush path copies the collection entries into guest RAM at the GPA specified in the BASER register. This obviously requires the BASER to be set. The last written element is a dummy collection table entry. We do not index by collection ID as the collection entry can fit into 8 bytes while

[RFC v2 12/19] KVM: arm64: ITS: vgic_its_alloc_ite/device

2017-02-08 Thread Eric Auger
Add two new helpers to allocate an its ite and an its device. This will avoid duplication on restore path. Signed-off-by: Eric Auger --- v1 -> v2: - report itt_size fix and remove ITE_SIZE - s/itte/ite/g --- virt/kvm/arm/vgic/vgic-its.c | 70

[RFC v2 14/19] KVM: arm64: ITS: Add infrastructure for table lookup

2017-02-08 Thread Eric Auger
Add a generic lookup_table() helper whose role consists in scanning a contiguous table located in guest RAM and applying a callback on each entry. Entries can be handled as linked lists since the callback may return an offset to the next entry and also tell that an entry is the last one. Helper

[RFC v2 17/19] KVM: arm64: ITS: ITT flush and restore

2017-02-08 Thread Eric Auger
Introduce routines to flush and restore device ITT and their interrupt table entries (ITE). The routines will be called on device table flush and restore. Signed-off-by: Eric Auger --- v2: creation --- virt/kvm/arm/vgic/vgic-its.c | 99

[RFC v2 11/19] KVM: arm64: ITS: KVM_DEV_ARM_VGIC_GRP_ITS_TABLES group

2017-02-08 Thread Eric Auger
Introduce a new group aiming at saving/restoring the ITS tables to/from the guest memory. We hold the its lock during the save and restore to prevent any command from being executed. This also garantees the LPI list is not going to change and no MSI injection can happen during the operation. At

[RFC v2 08/19] KVM: arm64: ITS: Interpret MAPD Size field and check related errors

2017-02-08 Thread Eric Auger
Up to now the MAPD's ITT size field has been ignored. It encodes the number of eventid bit minus 1. It should be used to check the eventid when a MAPTI command is issued on a device. Let's store the nb_eventid_bits in the its_device and do the check on MAPTI. Also make sure the ITT size field does

[RFC v2 16/19] KVM: arm64: ITS: vgic_its_check_id returns the entry's GPA

2017-02-08 Thread Eric Auger
As vgic_its_check_id() computes the device/collection entry's GPA, let's return it so that new callers can retrieve it easily. Signed-off-by: Eric Auger --- v2: new --- virt/kvm/arm/vgic/vgic-its.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff

[RFC v2 10/19] KVM: arm64: ITS: Check the device id matches TYPER DEVBITS range

2017-02-08 Thread Eric Auger
On MAPD we currently check the device id can be stored in the device table. Let's first check it can be encoded within the range defined by TYPER DEVBITS. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic/vgic-its.c | 8 ++-- 1 file changed, 6 insertions(+), 2