Re: [PATCH 1/2] arm/kvm: survive unknown traps from guests

2017-03-06 Thread Marc Zyngier
On Mon, Mar 06 2017 at 5:33:30 pm GMT, Mark Rutland wrote: > On Mon, Mar 06, 2017 at 07:08:03AM -0800, Christoffer Dall wrote: >> On Mon, Feb 20, 2017 at 12:30:11PM +, Mark Rutland wrote: >> > static exit_handle_fn arm_exit_handlers[] = { >> > + [0 ... HSR_EC_MAX] = kvm_handle_unknown

[PATCH V3 2/4] KVM: arm/arm64: Enable KVM_CAP_NR_MEMSLOTS on arm/arm64

2017-03-06 Thread linucherian
From: Linu Cherian Return KVM_USER_MEM_SLOTS for userspace capability query on NR_MEMSLOTS. Signed-off-by: Linu Cherian --- arch/arm/kvm/arm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 9d74464..b64b47f 100644 --- a/arch/arm/kvm/arm.c +

[PATCH V3 3/4] KVM: arm/arm64: Remove KVM_PRIVATE_MEM_SLOTS definition that are unused

2017-03-06 Thread linucherian
From: Linu Cherian Signed-off-by: Linu Cherian --- arch/arm/include/asm/kvm_host.h | 1 - arch/arm64/include/asm/kvm_host.h | 1 - 2 files changed, 2 deletions(-) diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index d5423ab..b9b39f0 100644 --- a/arch/arm/inclu

[PATCH V3 4/4] KVM: arm64: Increase number of user memslots to 512

2017-03-06 Thread linucherian
From: Linu Cherian Having only 32 memslots is a real constraint for the maximum number of PCI devices that can be assigned to a single guest. Assuming each PCI device/virtual function having two memory BAR regions, we could assign only 15 devices/virtual functions to a guest. Hence increase KVM_

[PATCH V3 1/4] KVM: Add documentation for KVM_CAP_NR_MEMSLOTS

2017-03-06 Thread linucherian
From: Linu Cherian Signed-off-by: Linu Cherian --- Documentation/virtual/kvm/api.txt | 4 1 file changed, 4 insertions(+) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index 03145b7..7b82f1c 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documen

[PATCH V3 0/4] KVM: arm64: Increase number of user memslots

2017-03-06 Thread linucherian
From: Linu Cherian v2 -> v3: - Added documentation for KVM_CAP_NR_MEMSLOTS - Removed KVM_PRIVATE_MEM_SLOTS which is unused - KVM_USER_MEM_SLOTS changed to 512 from 508 v1 -> v2: - Enabling KVM_CAP_NR_MEMSLOTS for arm/arm64 moved to separate patch. - Updated commit message so that what is repor

Re: [PATCH V12 07/10] efi: print unrecognized CPER section

2017-03-06 Thread Joe Perches
On Mon, 2017-03-06 at 13:45 -0700, Tyler Baicar wrote: > UEFI spec allows for non-standard section in Common Platform Error > Record. This is defined in section N.2.3 of UEFI version 2.5. > > Currently if the CPER section's type (UUID) does not match with > one of the section types that the kernel

[PATCH V12 10/10] arm/arm64: KVM: add guest SEA support

2017-03-06 Thread Tyler Baicar
Currently external aborts are unsupported by the guest abort handling. Add handling for SEAs so that the host kernel reports SEAs which occur in the guest kernel. Signed-off-by: Tyler Baicar --- arch/arm/include/asm/kvm_arm.h | 10 ++ arch/arm/include/asm/system_misc.h | 5 +

[PATCH V12 08/10] ras: acpi / apei: generate trace event for unrecognized CPER section

2017-03-06 Thread Tyler Baicar
UEFI spec allows for non-standard section in Common Platform Error Record. This is defined in section N.2.3 of UEFI version 2.5. Currently if the CPER section's type (UUID) does not match with any section type that the kernel knows how to parse, trace event is not generated for such section. And t

[PATCH V12 09/10] trace, ras: add ARM processor error trace event

2017-03-06 Thread Tyler Baicar
Currently there are trace events for the various RAS errors with the exception of ARM processor type errors. Add a new trace event for such errors so that the user will know when they occur. These trace events are consistent with the ARM processor error section type defined in UEFI 2.6 spec section

[PATCH V12 06/10] acpi: apei: panic OS with fatal error status block

2017-03-06 Thread Tyler Baicar
From: "Jonathan (Zhixiong) Zhang" Even if an error status block's severity is fatal, the kernel does not honor the severity level and panic. With the firmware first model, the platform could inform the OS about a fatal hardware error through the non-NMI GHES notification type. The OS should pani

[PATCH V12 07/10] efi: print unrecognized CPER section

2017-03-06 Thread Tyler Baicar
UEFI spec allows for non-standard section in Common Platform Error Record. This is defined in section N.2.3 of UEFI version 2.5. Currently if the CPER section's type (UUID) does not match with one of the section types that the kernel knows how to parse, the section is skipped. Therefore, user is n

[PATCH V12 05/10] acpi: apei: handle SEA notification type for ARMv8

2017-03-06 Thread Tyler Baicar
ARM APEI extension proposal added SEA (Synchronous External Abort) notification type for ARMv8. Add a new GHES error source handling function for SEA. If an error source's notification type is SEA, then this function can be registered into the SEA exception handler. That way GHES will parse and rep

[PATCH V12 02/10] ras: acpi/apei: cper: generic error data entry v3 per ACPI 6.1

2017-03-06 Thread Tyler Baicar
Currently when a RAS error is reported it is not timestamped. The ACPI 6.1 spec adds the timestamp field to the generic error data entry v3 structure. The timestamp of when the firmware generated the error is now being reported. Signed-off-by: Tyler Baicar CC: Jonathan (Zhixiong) Zhang Reviewed-

[PATCH V12 03/10] efi: parse ARM processor error

2017-03-06 Thread Tyler Baicar
Add support for ARM Common Platform Error Record (CPER). UEFI 2.6 specification adds support for ARM specific processor error information to be reported as part of the CPER records. This provides more detail on for processor error logs. Signed-off-by: Tyler Baicar CC: Jonathan (Zhixiong) Zhang R

[PATCH V12 04/10] arm64: exception: handle Synchronous External Abort

2017-03-06 Thread Tyler Baicar
SEA exceptions are often caused by an uncorrected hardware error, and are handled when data abort and instruction abort exception classes have specific values for their Fault Status Code. When SEA occurs, before killing the process, report the error in the kernel logs. Update fault_info[] with spec

[PATCH V12 00/10] Add UEFI 2.6 and ACPI 6.1 updates for RAS on ARM64

2017-03-06 Thread Tyler Baicar
When a memory error, CPU error, PCIe error, or other type of hardware error that's covered by RAS occurs, firmware should populate the shared GHES memory location with the proper GHES structures to notify the OS of the error. For example, platforms that implement firmware first handling may impleme

[PATCH V12 01/10] acpi: apei: read ack upon ghes record consumption

2017-03-06 Thread Tyler Baicar
A RAS (Reliability, Availability, Serviceability) controller may be a separate processor running in parallel with OS execution, and may generate error records for consumption by the OS. If the RAS controller produces multiple error records, then they may be overwritten before the OS has consumed th

Re: [PATCH v2] KVM: arm/arm64: Let vcpu thread modify its own active state

2017-03-06 Thread Jintack Lim
Hi Christoffer, thanks for submitting this patch. On Mon, Mar 6, 2017 at 8:42 AM, Christoffer Dall wrote: > From: Jintack Lim > > Currently, if a vcpu thread tries to change the active state of an > interrupt which is already on the same vcpu's AP list, "it'll loop forever" is remove accidenta

Re: [PATCH 1/2] arm/kvm: survive unknown traps from guests

2017-03-06 Thread Mark Rutland
On Mon, Mar 06, 2017 at 07:08:03AM -0800, Christoffer Dall wrote: > On Mon, Feb 20, 2017 at 12:30:11PM +, Mark Rutland wrote: > > static exit_handle_fn arm_exit_handlers[] = { > > + [0 ... HSR_EC_MAX] = kvm_handle_unknown_ec, > > Cool stuff, didn't know you could do this in C. Strictl

[kvm-unit-tests PATCH] arm/arm64: gic: Test changing active state of interrupts

2017-03-06 Thread Christoffer Dall
From: Christoffer Dall We found a deadlock when changing the active state of an interrupt while the interrupt is queued on the LR of the running VCPU. Defend KVM against this bug in the future now when we've introduced a fix. Signed-off-by: Christoffer Dall --- Sending with the right subject p

Re: [PATCH 1/2] arm/kvm: survive unknown traps from guests

2017-03-06 Thread Christoffer Dall
On Mon, Feb 20, 2017 at 12:30:11PM +, Mark Rutland wrote: > Currently we BUG() if we see a HSR.EC value we don't recognise. As > configurable disables/enables are added to the architecture (controlled > by RES1/RES0 bits respectively), with associated synchronous exceptions, > it may be possibl

Re: [PATCH 2/2] arm64/kvm: survive unknown traps from guests

2017-03-06 Thread Christoffer Dall
On Mon, Feb 20, 2017 at 12:30:12PM +, Mark Rutland wrote: > Currently we BUG() if we see an ESR_EL2.EC value we don't recognise. As > configurable disables/enables are added to the architecture (controlled > by RES1/RES0 bits respectively), with associated synchronous exceptions, > it may be po

Re: [PATCH v2] KVM: arm/arm64: Let vcpu thread modify its own active state

2017-03-06 Thread Marc Zyngier
On Mon, Mar 06 2017 at 1:42:37 pm GMT, Christoffer Dall wrote: > From: Jintack Lim > > Currently, if a vcpu thread tries to change the active state of an > interrupt which is already on the same vcpu's AP list, Since the VGIC > mmio handler is called after a vcpu has already synced back the LR

[PATCH v3 23/25] ARM: hyp-stub/KVM: Kill __hyp_get_vectors

2017-03-06 Thread Marc Zyngier
Nobody is using __hyp_get_vectors anymore, so let's remove both implementations (hyp-stub and KVM). Signed-off-by: Marc Zyngier --- arch/arm/include/asm/virt.h | 10 -- arch/arm/kernel/hyp-stub.S | 13 + arch/arm/kvm/init.S | 7 +-- arch/arm/kvm/interrupts.S |

[PATCH v3 25/25] arm/arm64: Add hyp-stub API documentation

2017-03-06 Thread Marc Zyngier
In order to help people understanding the hyp-stub API that exists between the host kernel and the hypervisor mode (whether a hypervisor has been installed or not), let's document said API. As as with any form of documentation, I expect it to become obsolete and completely misleading within 20 min

[PATCH v3 24/25] arm64: hyp-stub/KVM: Kill __hyp_get_vectors

2017-03-06 Thread Marc Zyngier
Nobody is using __hyp_get_vectors anymore, so let's remove both implementations (hyp-stub and KVM). Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/virt.h | 12 arch/arm64/kernel/hyp-stub.S | 15 +-- arch/arm64/kvm/hyp-init.S | 7 +-- arch/arm64/kvm/hyp.

[PATCH v3 17/25] ARM: KVM: Convert __cpu_reset_hyp_mode to using __hyp_reset_vectors

2017-03-06 Thread Marc Zyngier
We are now able to use the hyp stub to reset HYP mode. Time to kiss __kvm_hyp_reset goodbye, and use __hyp_reset_vectors. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_asm.h | 2 -- arch/arm/include/asm/kvm_host.h | 2 +- arch/arm/kvm/init.S | 2 -- 3 files changed, 1 ins

[PATCH v3 19/25] arm/arm64: KVM: Use __hyp_reset_vectors() directly

2017-03-06 Thread Marc Zyngier
__cpu_reset_hyp_mode doesn't need to be passed any argument now, as the hyp-stub implementations are self-contained, and is now reduced to just calling __hyp_reset_vectors(). Let's drop the wrapper and use the stub hypercall directly. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_host

[PATCH v3 20/25] arm/arm64: KVM: Remove kvm_get_idmap_start

2017-03-06 Thread Marc Zyngier
With __cpu_reset_hyp_mode having become fairly dumb, there is no need for kvm_get_idmap_start anymore. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_mmu.h | 1 - arch/arm/kvm/mmu.c | 5 - arch/arm64/include/asm/kvm_mmu.h | 1 - 3 files changed, 7 deletions(-) diff

[PATCH v3 18/25] ARM: KVM: Implement HVC_SOFT_RESTART in the init code

2017-03-06 Thread Marc Zyngier
Another missing stub hypercall is HVC_SOFT_RESTART. It turns out that it is pretty easy to implement in terms of HVC_RESET_VECTORS (since it needs to turn the MMU off). Signed-off-by: Marc Zyngier --- arch/arm/kvm/init.S | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/ar

[PATCH v3 22/25] ARM: decompressor: Remove __hyp_get_vectors usage

2017-03-06 Thread Marc Zyngier
When the compressed image needs to be relocated to avoid being overwritten by the decompression process, we need to relocate the hyp vectors as well so that we can find them once the decompression has taken effect. For that, we perform the following calculation: u32 v = __hyp_get_vectors()

[PATCH v3 21/25] arm/arm64: KVM: Use HVC_RESET_VECTORS to reinit HYP mode

2017-03-06 Thread Marc Zyngier
Instead of trying to compare the value given by __hyp_get_vectors(), which doesn't offer any real guarantee to be the stub's address, use HVC_RESET_VECTORS to make sure we're in a sane state to reinstall KVM across PM events. Signed-off-by: Marc Zyngier --- arch/arm/kvm/arm.c | 24 +-

[PATCH v3 11/25] ARM: hyp-stub: Use r1 for the soft-restart address

2017-03-06 Thread Marc Zyngier
It is not really obvious why the restart address should be in r3 when communicated to the hyp-stub. r1 should be perfectly adequate, and consistent with the rest of the code. Signed-off-by: Marc Zyngier --- arch/arm/kernel/hyp-stub.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) di

[PATCH v3 16/25] ARM: KVM: Allow the main HYP code to use the init hyp stub implementation

2017-03-06 Thread Marc Zyngier
We now have a full hyp-stub implementation in the KVM init code, but the main KVM code only supports HVC_GET_VECTORS, which is not enough. Instead of reinventing the wheel, let's reuse the init implementation by branching to the idmap page when called with a hyp-stub hypercall. Signed-off-by: Mar

[PATCH v3 14/25] ARM: KVM: Implement HVC_RESET_VECTORS stub hypercall

2017-03-06 Thread Marc Zyngier
In order to restore HYP mode to its original condition, KVM currently implements __kvm_hyp_reset(). As we're moving towards a hyp-stub defined API, it becomes necessary to implement HVC_RESET_VECTORS. This patch adds the HVC_RESET_VECTORS hypercall to the KVM init code, which so far lacked any for

[PATCH v3 15/25] ARM: KVM: Implement HVC_GET_VECTORS in the init code

2017-03-06 Thread Marc Zyngier
Now that we have an infrastructure to handle hypercalls in the KVM init code, let's implement HVC_GET_VECTORS there. Signed-off-by: Marc Zyngier --- arch/arm/kvm/init.S | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S index 9b0c7

[PATCH v3 05/25] arm64: KVM: Convert __cpu_reset_hyp_mode to using __hyp_reset_vectors

2017-03-06 Thread Marc Zyngier
We are now able to use the hyp stub to reset HYP mode. Time to kiss __kvm_hyp_reset goodbye, and use __hyp_reset_vectors. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_asm.h | 1 - arch/arm64/include/asm/kvm_host.h | 3 +-- arch/arm64/kvm/hyp-init.S | 2 -- arch/arm64/kv

[PATCH v3 13/25] ARM: hyp-stub: Implement HVC_RESET_VECTORS stub hypercall

2017-03-06 Thread Marc Zyngier
Let's define a new stub hypercall that resets the HYP configuration to its default: hyp-stub vectors, and MMU disabled. Of course, for the hyp-stub itself, this is a trivial no-op. Hypervisors will have a bit more work to do. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/virt.h | 3 +++

[PATCH v3 12/25] ARM: Expose the VA/IDMAP offset

2017-03-06 Thread Marc Zyngier
The KVM code needs to be able to compute the address of symbols in its idmap page (the equivalent of a virt_to_idmap() call). Unfortunately, virt_to_idmap is slightly complicated, depending on the use of arch_phys_to_idmap_offset or not, and none of that is readily available at HYP. Instead, expos

[PATCH v3 06/25] arm64: KVM: Implement HVC_SOFT_RESTART in the init code

2017-03-06 Thread Marc Zyngier
Another missing stub hypercall is HVC_SOFT_RESTART. It turns out that it is pretty easy to implement in terms of HVC_RESET_VECTORS (since it needs to turn the MMU off). Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp-init.S | 31 +++ 1 file changed, 23 insertions(+

[PATCH v3 09/25] ARM: KVM: Convert KVM to use HVC_GET_VECTORS

2017-03-06 Thread Marc Zyngier
The conversion of the HYP stub ABI to something similar to arm64 left the KVM code broken, as it doesn't know about the new stub numbering. Let's move the various #defines to virt.h, and let KVM use HVC_GET_VECTORS. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/virt.h | 8 arch/

[PATCH v3 07/25] ARM: hyp-stub: improve ABI

2017-03-06 Thread Marc Zyngier
From: Russell King Improve the hyp-stub ABI to allow it to do more than just get/set the vectors. We follow the example in ARM64, where r0 is used as an opcode with the other registers as an argument. Signed-off-by: Russell King Signed-off-by: Marc Zyngier --- arch/arm/kernel/hyp-stub.S | 27

[PATCH v3 00/25] arm/arm64: KVM: Rework the hyp-stub API

2017-03-06 Thread Marc Zyngier
As noticed by RMK in this thread[1], the hyp-stub API on 32bit ARM could do with some TLC (it cannot perform a soft-restart at HYP, and has holes in the hyp-stub support in a number of places). In general, it would be desirable for the 32bit behaviour to align on 64bit, if only to ease maintenance.

[PATCH v3 08/25] ARM: soft-reboot into same mode that we entered the kernel

2017-03-06 Thread Marc Zyngier
From: Russell King When we soft-reboot (eg, kexec) from one kernel into the next, we need to ensure that we enter the new kernel in the same processor mode as when we were entered, so that (eg) the new kernel can install its own hypervisor - the old kernel's hypervisor will have been overwritten.

[PATCH v3 10/25] ARM: Update cpu_v7_reset documentation

2017-03-06 Thread Marc Zyngier
cpu_v7_reset() now takes a second parameter indicating whether we should reboot in HYP or not. Update the documentation to reflect this. Signed-off-by: Marc Zyngier --- arch/arm/mm/proc-v7.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm

[PATCH v3 04/25] arm64: KVM: Allow the main HYP code to use the init hyp stub implementation

2017-03-06 Thread Marc Zyngier
We now have a full hyp-stub implementation in the KVM init code, but the main KVM code only supports HVC_GET_VECTORS, which is not enough. Instead of reinventing the wheel, let's reuse the init implementation by branching to the idmap page when called with a hyp-stub hypercall. Signed-off-by: Mar

[PATCH v3 02/25] arm64: KVM: Implement HVC_RESET_VECTORS stub hypercall

2017-03-06 Thread Marc Zyngier
In order to restore HYP mode to its original condition, KVM currently implements __kvm_hyp_reset(). As we're moving towards a hyp-stub defined API, it becomes necessary to implement HVC_RESET_VECTORS. This patch adds the HVC_RESET_VECTORS hypercall to the KVM init code, which so far lacked any for

[PATCH v3 01/25] arm64: hyp-stub: Implement HVC_RESET_VECTORS stub hypercall

2017-03-06 Thread Marc Zyngier
Let's define a new stub hypercall that resets the HYP configuration to its default: hyp-stub vectors, and MMU disabled. Of course, for the hyp-stub itself, this is a trivial no-op. Hypervisors will have a bit more work to do. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/virt.h | 9 ++

[PATCH v3 03/25] arm64: KVM: Implement HVC_GET_VECTORS in the init code

2017-03-06 Thread Marc Zyngier
Now that we have an infrastructure to handle hypercalls in the KVM init code, let's implement HVC_GET_VECTORS there. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp-init.S | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-

[kvmtool PATCH] arm/arm64: gic: Test changing active state of interrupts

2017-03-06 Thread Christoffer Dall
From: Christoffer Dall We found a deadlock when changing the active state of an interrupt while the interrupt is queued on the LR of the running VCPU. Defend KVM against this bug in the future now when we've introduced a fix. Signed-off-by: Christoffer Dall --- arm/gic.c | 43

Re: [PATCH V11 10/10] arm/arm64: KVM: add guest SEA support

2017-03-06 Thread Baicar, Tyler
Hello James, On 3/6/2017 3:28 AM, James Morse wrote: On 28/02/17 19:43, Baicar, Tyler wrote: On 2/24/2017 3:42 AM, James Morse wrote: On 21/02/17 21:22, Tyler Baicar wrote: Currently external aborts are unsupported by the guest abort handling. Add handling for SEAs so that the host kernel re

Re: [PATCH v2] arm64: kvm: Use has_vhe() instead of hyp_alternate_select()

2017-03-06 Thread Shanker Donthineni
Hi Marc, On 03/06/2017 02:34 AM, Marc Zyngier wrote: Hi Shanker, On Mon, Mar 06 2017 at 2:33:18 am GMT, Shanker Donthineni wrote: Now all the cpu_hwcaps features have their own static keys. We don't need a separate function hyp_alternate_select() to patch the vhe/nvhe code. We can achieve

[PATCH v2] KVM: arm/arm64: Let vcpu thread modify its own active state

2017-03-06 Thread Christoffer Dall
From: Jintack Lim Currently, if a vcpu thread tries to change the active state of an interrupt which is already on the same vcpu's AP list, Since the VGIC mmio handler is called after a vcpu has already synced back the LR state to the struct vgic_irq, we can just let it proceed safely. Signed-of

[PATCH v3 19/19] KVM: arm64: ITS: Pending table save/restore

2017-03-06 Thread Eric Auger
Save and restore the pending tables. Pending table restore obviously requires the pendbaser to be already set. Signed-off-by: Eric Auger --- v1 -> v2: - do not care about the 1st KB which should be zeroed according to the spec. --- virt/kvm/arm/vgic/vgic-its.c | 71 +

[PATCH v3 18/19] KVM: arm64: ITS: Device table save/restore

2017-03-06 Thread Eric Auger
This patch flushes the device table entries into guest RAM. Both flat table and 2 stage tables are supported. DeviceId indexing is used. For each device listed in the device table, we also flush the translation table using the vgic_its_flush/restore_itt routines. On restore, devices are re-alloc

[PATCH v3 17/19] KVM: arm64: ITS: ITT flush and restore

2017-03-06 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 -> v3: - add return 0 in vgic_its_restore_ite (was in subsequent patch) v2: creation --- virt/kvm/arm/vgi

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

2017-03-06 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 --git a/virt/kvm/arm/vgi

[PATCH v3 13/19] KVM: arm64: ITS: Sort the device and ITE lists

2017-03-06 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 +

[PATCH v3 14/19] KVM: arm64: ITS: Add infrastructure for table lookup

2017-03-06 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 fu

[PATCH v3 15/19] KVM: arm64: ITS: Collection table save/restore

2017-03-06 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 conta

[PATCH v3 12/19] KVM: arm64: ITS: vgic_its_alloc_ite/device

2017-03-06 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 +--- 1 file

[PATCH v3 07/19] KVM: arm64: ITS: Report the ITE size in GITS_TYPER

2017-03-06 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 ITT_ENTRY_SIZE field - remove ITE_SI

[PATCH v3 11/19] KVM: arm64: ITS: KVM_DEV_ARM_VGIC_GRP_ITS_TABLES group

2017-03-06 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 t

[PATCH v3 02/19] KVM: arm/arm64: rename itte into ite

2017-03-06 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 deletions(-) diff --git a/virt/kvm

[PATCH v3 06/19] KVM: arm64: ITS: Implement vgic_mmio_uaccess_write_its_creadr

2017-03-06 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 a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vg

[PATCH v3 01/19] KVM: arm/arm64: Add vITS save/restore API documentation

2017-03-06 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 matches bits [51:8] of th

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

2017-03-06 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 deletions(-) diff --git a/virt/k

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

2017-03-06 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

[PATCH v3 05/19] KVM: arm64: ITS: Implement vgic_its_has_attr_regs and attr_regs_access

2017-03-06 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 uacc

[PATCH v3 09/19] KVM: arm64: ITS: Interpret MAPD ITT_addr field

2017-03-06 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 b/virt/kvm/arm/vgic/vgic-its.c

[PATCH v3 00/19] vITS save/restore

2017-03-06 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 en

[PATCH v3 04/19] KVM: arm64: ITS: KVM_DEV_ARM_VGIC_GRP_ITS_REGS group

2017-03-06 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 + arch/arm64/include/uapi/asm/kv

[PATCH v3 03/19] arm/arm64: vgic: turn vgic_find_mmio_region into public

2017-03-06 Thread Eric Auger
We plan to use vgic_find_mmio_region in vgic-its.c so let's turn it into a public function. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic/vgic-mmio.c | 3 +-- virt/kvm/arm/vgic/vgic-mmio.h | 5 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b

Re: [PATCH V11 10/10] arm/arm64: KVM: add guest SEA support

2017-03-06 Thread James Morse
Hi Tyler, On 28/02/17 19:43, Baicar, Tyler wrote: > On 2/24/2017 3:42 AM, James Morse wrote: >> On 21/02/17 21:22, Tyler Baicar wrote: >>> Currently external aborts are unsupported by the guest abort >>> handling. Add handling for SEAs so that the host kernel reports >>> SEAs which occur in the gu

[PATCH] KVM: arm/arm64: Let vcpu thread modify its own active state

2017-03-06 Thread Christoffer Dall
From: Jintack Lim Currently, if a vcpu thread tries to change its own active state when the irq is already in AP list, it'll loop forever. Since the VCPU thread has already synced back LR state to the struct vgic_irq, let it modify its own state safely. Signed-off-by: Jintack Lim --- virt/kvm/

Re: [PATCH v2] arm64: kvm: Use has_vhe() instead of hyp_alternate_select()

2017-03-06 Thread Marc Zyngier
Hi Shanker, On Mon, Mar 06 2017 at 2:33:18 am GMT, Shanker Donthineni wrote: > Now all the cpu_hwcaps features have their own static keys. We don't > need a separate function hyp_alternate_select() to patch the vhe/nvhe > code. We can achieve the same functionality by using has_vhe(). It > impr