[PATCH] arm64: KVM: Only skip MMIO insn once

2019-08-21 Thread Andrew Jones
If after an MMIO exit to userspace a VCPU is immediately run with an immediate_exit request, such as when a signal is delivered or an MMIO emulation completion is needed, then the VCPU completes the MMIO emulation and immediately returns to userspace. As the exit_reason does not get changed from

Re: [RESEND PATCH] KVM: arm: VGIC: properly initialise private IRQ affinity

2019-08-21 Thread Zenghui Yu
On 2019/8/22 1:00, Andre Przywara wrote: At the moment we initialise the target *mask* of a virtual IRQ to the VCPU it belongs to, even though this mask is only defined for GICv2 and quickly runs out of bits for many GICv3 guests. This behaviour triggers an UBSAN complaint for more than 32

Re: [RESEND PATCH] KVM: arm: VGIC: properly initialise private IRQ affinity

2019-08-21 Thread Marc Zyngier
On 21/08/2019 18:01, Julien Grall wrote: > Hi Andre, > > On 21/08/2019 18:00, Andre Przywara wrote: >> At the moment we initialise the target *mask* of a virtual IRQ to the >> VCPU it belongs to, even though this mask is only defined for GICv2 and >> quickly runs out of bits for many GICv3

Re: [RESEND PATCH] KVM: arm: VGIC: properly initialise private IRQ affinity

2019-08-21 Thread Julien Grall
Hi Andre, On 21/08/2019 18:00, Andre Przywara wrote: At the moment we initialise the target *mask* of a virtual IRQ to the VCPU it belongs to, even though this mask is only defined for GICv2 and quickly runs out of bits for many GICv3 guests. This behaviour triggers an UBSAN complaint for more

[RESEND PATCH] KVM: arm: VGIC: properly initialise private IRQ affinity

2019-08-21 Thread Andre Przywara
At the moment we initialise the target *mask* of a virtual IRQ to the VCPU it belongs to, even though this mask is only defined for GICv2 and quickly runs out of bits for many GICv3 guests. This behaviour triggers an UBSAN complaint for more than 32 VCPUs: -- [ 5659.462377] UBSAN: Undefined

[PATCH v3 07/10] KVM: arm64: Provide a PV_TIME device to user space

2019-08-21 Thread Steven Price
Allow user space to inform the KVM host where in the physical memory map the paravirtualized time structures should be located. A device is created which provides the base address of an array of Stolen Time (ST) structures, one for each VCPU. There must be (64 * total number of VCPUs) bytes of

[PATCH v3 09/10] arm/arm64: Make use of the SMCCC 1.1 wrapper

2019-08-21 Thread Steven Price
Rather than directly choosing which function to use based on psci_ops.conduit, use the new arm_smccc_1_1 wrapper instead. In some cases we still need to do some operations based on the conduit, but the code duplication is removed. No functional change. Signed-off-by: Steven Price ---

[PATCH v3 08/10] arm/arm64: Provide a wrapper for SMCCC 1.1 calls

2019-08-21 Thread Steven Price
SMCCC 1.1 calls may use either HVC or SMC depending on the PSCI conduit. Rather than coding this in every call site provide a macro which uses the correct instruction. The macro also handles the case where no PSCI conduit is configured returning a not supported error in res, along with returning

[PATCH v3 10/10] arm64: Retrieve stolen time as paravirtualized guest

2019-08-21 Thread Steven Price
Enable paravirtualization features when running under a hypervisor supporting the PV_TIME_ST hypercall. For each (v)CPU, we ask the hypervisor for the location of a shared page which the hypervisor will use to report stolen time to us. We set pv_time_ops to the stolen time function which simply

[PATCH v3 05/10] KVM: arm64: Support stolen time reporting via shared structure

2019-08-21 Thread Steven Price
Implement the service call for configuring a shared structure between a VCPU and the hypervisor in which the hypervisor can write the time stolen from the VCPU's execution time by other tasks on the host. The hypervisor allocates memory which is placed at an IPA chosen by user space. The

[PATCH v3 06/10] KVM: Allow kvm_device_ops to be const

2019-08-21 Thread Steven Price
Currently a kvm_device_ops structure cannot be const without triggering compiler warnings. However the structure doesn't need to be written to and, by marking it const, it can be read-only in memory. Add some more const keywords to allow this. Signed-off-by: Steven Price ---

[PATCH v3 04/10] KVM: Implement kvm_put_guest()

2019-08-21 Thread Steven Price
kvm_put_guest() is analogous to put_user() - it writes a single value to the guest physical address. The implementation is built upon put_user() and so it has the same single copy atomic properties. Signed-off-by: Steven Price --- include/linux/kvm_host.h | 24 1 file

[PATCH v3 02/10] KVM: arm/arm64: Factor out hypercall handling from PSCI code

2019-08-21 Thread Steven Price
From: Christoffer Dall We currently intertwine the KVM PSCI implementation with the general dispatch of hypercall handling, which makes perfect sense because PSCI is the only category of hypercalls we support. However, as we are about to support additional hypercalls, factor out this

[PATCH v3 03/10] KVM: arm64: Implement PV_FEATURES call

2019-08-21 Thread Steven Price
This provides a mechanism for querying which paravirtualized features are available in this hypervisor. Also add the header file which defines the ABI for the paravirtualized clock features we're about to add. Signed-off-by: Steven Price --- arch/arm/include/asm/kvm_host.h | 6 ++

[PATCH v3 01/10] KVM: arm64: Document PV-time interface

2019-08-21 Thread Steven Price
Introduce a paravirtualization interface for KVM/arm64 based on the "Arm Paravirtualized Time for Arm-Base Systems" specification DEN 0057A. This only adds the details about "Stolen Time" as the details of "Live Physical Time" have not been fully agreed. User space can specify a reserved area of

[PATCH v3 00/10] arm64: Stolen time support

2019-08-21 Thread Steven Price
This series add support for paravirtualized time for arm64 guests and KVM hosts following the specification in Arm's document DEN 0057A: https://developer.arm.com/docs/den0057/a It implements support for stolen time, allowing the guest to identify time when it is forcibly not executing. It

Re: [PATCH 16/59] KVM: arm64: nv: Save/Restore vEL2 sysregs

2019-08-21 Thread Alexandru Elisei
On 6/21/19 10:38 AM, Marc Zyngier wrote: > From: Andre Przywara > > Whenever we need to restore the guest's system registers to the CPU, we > now need to take care of the EL2 system registers as well. Most of them > are accessed via traps only, but some have an immediate effect and also > a guest

Re: [PATCH v2 4/9] KVM: arm64: Support stolen time reporting via shared structure

2019-08-21 Thread Steven Price
On 19/08/2019 17:40, Marc Zyngier wrote: > Hi Steven, > > On 19/08/2019 15:04, Steven Price wrote: >> Implement the service call for configuring a shared structure between a >> VCPU and the hypervisor in which the hypervisor can write the time >> stolen from the VCPU's execution time by other