Re: [PATCH v3 17/20] KVM: arm/arm64: Move phys_timer_emulate function

2017-10-10 Thread Marc Zyngier
On Sat, Sep 23 2017 at 2:42:04 am BST, Christoffer Dall wrote: > We are about to call phys_timer_emulate() from kvm_timer_update_state() > and modify phys_timer_emulate() at the same time. Moving the function > and modifying it in a single patch makes the diff hard to read,

Re: [PATCH v3 19/20] KVM: arm/arm64: Get rid of kvm_timer_flush_hwstate

2017-10-10 Thread Marc Zyngier
On Sat, Sep 23 2017 at 2:42:06 am BST, Christoffer Dall wrote: > Now when both the vtimer and the ptimer when using both the in-kernel > vgic emulation and a userspace IRQ chip are driven by the timer signals > and at the vcpu load/put boundaries, instead of recomputing the

Re: [PATCH v3 14/20] KVM: arm/arm64: Avoid timer save/restore in vcpu entry/exit

2017-10-10 Thread Marc Zyngier
On Sat, Sep 23 2017 at 2:42:01 am BST, Christoffer Dall wrote: > We don't need to save and restore the hardware timer state and examine > if it generates interrupts on on every entry/exit to the guest. The > timer hardware is perfectly capable of telling us when it has

Re: [PATCH v3 15/20] KVM: arm/arm64: Support EL1 phys timer register access in set/get reg

2017-10-10 Thread Marc Zyngier
On Sat, Sep 23 2017 at 2:42:02 am BST, Christoffer Dall wrote: > Add suport for the physical timer registers in kvm_arm_timer_set_reg and > kvm_arm_timer_get_reg so that these functions can be reused to interact > with the rest of the system. > > Note that this paves part of

Re: [PATCH v3 18/20] KVM: arm/arm64: Avoid phys timer emulation in vcpu entry/exit

2017-10-10 Thread Marc Zyngier
On Sat, Sep 23 2017 at 2:42:05 am BST, Christoffer Dall wrote: > There is no need to schedule and cancel a hrtimer when entering and > exiting the guest, because we know when the physical timer is going to > fire when the guest programs it, and we can simply program the

Re: [PATCH 2/5] KVM: arm/arm64: replace power_off with mp_state=STOPPED

2017-10-10 Thread Andrew Jones
On Thu, Oct 05, 2017 at 09:32:02AM +0100, Marc Zyngier wrote: > On 29/09/17 12:30, Andrew Jones wrote: > > This prepares for more MP states to be used. > > > > Signed-off-by: Andrew Jones > > --- > > arch/arm/include/asm/kvm_host.h | 6 -- > >

Re: [PATCH 5/5] KVM: arm/arm64: kvm_arch_vcpu_runnable: don't miss injected irqs

2017-10-10 Thread Andrew Jones
On Thu, Oct 05, 2017 at 10:37:32AM +0100, Marc Zyngier wrote: > On 29/09/17 12:30, Andrew Jones wrote: > > When the vPMU is in use if a VCPU's perf event overflow handler > > were to fire after the VCPU started waiting, then the wake up > > done by the kvm_vcpu_kick() call in the handler would do

[PATCH v3 19/28] arm64/sve: ptrace and ELF coredump support

2017-10-10 Thread Dave Martin
This patch defines and implements a new regset NT_ARM_SVE, which describes a thread's SVE register state. This allows a debugger to manipulate the SVE state, as well as being included in ELF coredumps for post-mortem debugging. Because the regset size and layout are dependent on the thread's

[PATCH v3 12/28] arm64/sve: Support vector length resetting for new processes

2017-10-10 Thread Dave Martin
It's desirable to be able to reset the vector length to some sane default for new processes, since the new binary and its libraries processes may or may not be SVE-aware. This patch tracks the desired post-exec vector length (if any) in a new thread member sve_vl_onexec, and adds a new thread

[PATCH v3 06/28] arm64/sve: System register and exception syndrome definitions

2017-10-10 Thread Dave Martin
The SVE architecture adds some system registers, ID register fields and a dedicated ESR exception class. This patch adds the appropriate definitions that will be needed by the kernel. Signed-off-by: Dave Martin Reviewed-by: Alex Bennée ---

[PATCH v3 02/28] arm64: KVM: Hide unsupported AArch64 CPU features from guests

2017-10-10 Thread Dave Martin
Currently, a guest kernel sees the true CPU feature registers (ID_*_EL1) when it reads them using MRS instructions. This means that the guest will observe features that are present in the hardware but the host doesn't understand or doesn't provide support for. A guest may legimitately try to use

[RFC PATCH v3 27/28] arm64: signal: Report signal frame size to userspace via auxv

2017-10-10 Thread Dave Martin
Stateful CPU architecture extensions may require the signal frame to grow to a size that exceeds the arch's MINSIGSTKSZ #define. However, changing this #define is an ABI break. To allow userspace the option of determining the signal frame size in a more forwards-compatible way, this patch adds a

[PATCH v3 11/28] arm64/sve: Core task context handling

2017-10-10 Thread Dave Martin
This patch adds the core support for switching and managing the SVE architectural state of user tasks. Calls to the existing FPSIMD low-level save/restore functions are factored out as new functions task_fpsimd_{save,load}(), since SVE now dynamically may or may not need to be handled at these

[PATCH v3 20/28] arm64/sve: Add prctl controls for userspace vector length management

2017-10-10 Thread Dave Martin
This patch adds two arm64-specific prctls, to permit userspace to control its vector length: * PR_SVE_SET_VL: set the thread's SVE vector length and vector length inheritance mode. * PR_SVE_GET_VL: get the same information. Although these calls shadow instruction set features in the SVE

[PATCH v3 23/28] arm64/sve: KVM: Treat guest SVE use as undefined instruction execution

2017-10-10 Thread Dave Martin
When trapping forbidden attempts by a guest to use SVE, we want the guest to see a trap consistent with SVE not being implemented. This patch injects an undefined instruction exception into the guest in response to such an exception. Signed-off-by: Dave Martin Reviewed-by:

[PATCH v3 22/28] arm64/sve: KVM: Prevent guests from using SVE

2017-10-10 Thread Dave Martin
Until KVM has full SVE support, guests must not be allowed to execute SVE instructions. This patch enables the necessary traps, and also ensures that the traps are disabled again on exit from the guest so that the host can still use SVE if it wants to. This patch introduces another instance of

[PATCH v3 18/28] arm64/sve: Preserve SVE registers around EFI runtime service calls

2017-10-10 Thread Dave Martin
The EFI runtime services ABI allows EFI to make free use of the FPSIMD registers during EFI runtime service calls, subject to the callee-save requirements of the AArch64 procedure call standard. However, the SVE architecture allows upper bits of the SVE vector registers to be zeroed as a

[PATCH v3 17/28] arm64/sve: Preserve SVE registers around kernel-mode NEON use

2017-10-10 Thread Dave Martin
Kernel-mode NEON will corrupt the SVE vector registers, due to the way they alias the FPSIMD vector registers in the hardware. This patch ensures that any live SVE register content for the task is saved by kernel_neon_begin(). The data will be restored in the usual way on return to userspace.

[PATCH v3 16/28] arm64/sve: Probe SVE capabilities and usable vector lengths

2017-10-10 Thread Dave Martin
This patch uses the cpufeatures framework to determine common SVE capabilities and vector lengths, and configures the runtime SVE support code appropriately. ZCR_ELx is not really a feature register, but it is convenient to use it as a template for recording the maximum vector length supported by

[PATCH v3 24/28] arm64/sve: KVM: Hide SVE from CPU features exposed to guests

2017-10-10 Thread Dave Martin
KVM guests cannot currently use SVE, because SVE is always configured to trap to EL2. However, a guest that sees SVE reported as present in ID_AA64PFR0_EL1 may legitimately expect that SVE works and try to use it. Instead of working, the guest will receive an injected undef exception, which may

[PATCH v3 25/28] arm64/sve: Detect SVE and activate runtime support

2017-10-10 Thread Dave Martin
This patch enables detection of hardware SVE support via the cpufeatures framework, and reports its presence to the kernel and userspace via the new ARM64_SVE cpucap and HWCAP_SVE hwcap respectively. Userspace can also detect SVE using ID_AA64PFR0_EL1, using the cpufeatures MRS emulation. When

[RFC PATCH v3 28/28] arm64/sve: signal: Include SVE when computing AT_MINSIGSTKSZ

2017-10-10 Thread Dave Martin
The SVE context block in the signal frame needs to be considered too when computing the maximum possible signal frame size. Because the size of this block depends on the vector length, this patch computes the size based not on the thread's current vector length but instead on the maximum possible

[PATCH v3 26/28] arm64/sve: Add documentation

2017-10-10 Thread Dave Martin
This patch adds basic documentation of the user/kernel interface provided by the for SVE. Signed-off-by: Dave Martin Cc: Alex Bennée Cc: Mark Rutland Cc: Alan Hayward --- Changes since v2

[PATCH v3 07/28] arm64/sve: Low-level SVE architectural state manipulation functions

2017-10-10 Thread Dave Martin
Manipulating the SVE architectural state, including the vector and predicate registers, first-fault register and the vector length, requires the use of dedicated instructions added by SVE. This patch adds suitable assembly functions for saving and restoring the SVE registers and querying the

[PATCH v3 08/28] arm64/sve: Kconfig update and conditional compilation support

2017-10-10 Thread Dave Martin
This patch adds CONFIG_ARM64_SVE to control building of SVE support into the kernel, and adds a stub predicate system_supports_sve() to control conditional compilation and runtime SVE support. system_supports_sve() just returns false for now: it will be replaced with a non-trivial implementation

[PATCH v3 09/28] arm64/sve: Signal frame and context structure definition

2017-10-10 Thread Dave Martin
This patch defines the representation that will be used for the SVE register state in the signal frame, and implements support for saving and restoring the SVE registers around signals. The same layout will also be used for the in-kernel task state. Due to the variability of the SVE vector

[PATCH v3 14/28] arm64/sve: Backend logic for setting the vector length

2017-10-10 Thread Dave Martin
This patch implements the core logic for changing a task's vector length on request from userspace. This will be used by the ptrace and prctl frontends that are implemented in later patches. The SVE architecture permits, but does not require, implementations to support vector lengths that are

[PATCH v3 05/28] arm64: fpsimd: Simplify uses of {set, clear}_ti_thread_flag()

2017-10-10 Thread Dave Martin
The existing FPSIMD context switch code contains a couple of instances of {set,clear}_ti_thread(task_thread_info(task)). Since there are thread flag manipulators that operate directly on task_struct, this verbosity isn't strictly needed. For consistency, this patch simplifies the affected calls.

[PATCH v3 10/28] arm64/sve: Low-level CPU setup

2017-10-10 Thread Dave Martin
To enable the kernel to use SVE, SVE traps from EL1 to EL2 must be disabled. To take maximum advantage of the hardware, the full available vector length also needs to be enabled for EL1 by programming ZCR_EL2.LEN. (The kernel will program ZCR_EL1.LEN as required, but this cannot override the

[PATCH v3 21/28] arm64/sve: Add sysctl to set the default vector length for new processes

2017-10-10 Thread Dave Martin
Because of the effect of SVE on the size of the signal frame, the default vector length used for new processes involves a tradeoff between performance of SVE-enabled software on the one hand, and reliability of non-SVE-aware software on the other hand. For this reason, the best choice depends on

[PATCH v3 01/28] regset: Add support for dynamically sized regsets

2017-10-10 Thread Dave Martin
Currently the regset API doesn't allow for the possibility that regsets (or at least, the amount of meaningful data in a regset) may change in size. In particular, this results in useless padding being added to coredumps in a regset's current size is smaller than its theoretical maximum size.

[PATCH v3 03/28] arm64: efi: Add missing Kconfig dependency on KERNEL_MODE_NEON

2017-10-10 Thread Dave Martin
The EFI runtime services ABI permits calls to EFI to clobber certain FPSIMD/NEON registers, as per the AArch64 procedure call standard. Saving/restoring the clobbered registers around such calls needs KERNEL_MODE_NEON, but the dependency is missing from Kconfig. This patch adds the missing

[PATCH v3 00/28] ARM Scalable Vector Extension (SVE)

2017-10-10 Thread Dave Martin
This series implements Linux kernel support for the ARM Scalable Vector Extension (SVE). [1] It supersedes the previous v2: see [3] for link. See the individual patches for details of changes. The patches apply on v4.14-rc4. For convenience, a git tree is available. [4] To reduce spam, some