Re: [PATCH v10 06/18] arm64: fpsimd: Generalise context saving for non-task contexts

2018-05-23 Thread Alex Bennée
Dave Martin writes: > In preparation for allowing non-task (i.e., KVM vcpu) FPSIMD > contexts to be handled by the fpsimd common code, this patch adapts > task_fpsimd_save() to save back the currently loaded context, > removing the explicit dependency on current. > > The

Re: [PATCH v10 08/18] arm64/sve: Refactor user SVE trap maintenance for external use

2018-05-23 Thread Alex Bennée
Dave Martin writes: > In preparation for optimising the way KVM manages switching the > guest and host FPSIMD state, it is necessary to provide a means for > code outside arch/arm64/kernel/fpsimd.c to restore the user trap > configuration for SVE correctly for the current

Re: [PATCH v10 05/18] KVM: arm64: Convert lazy FPSIMD context switch trap to C

2018-05-23 Thread Alex Bennée
Dave Martin writes: > To make the lazy FPSIMD context switch trap code easier to hack on, > this patch converts it to C. > > This is not amazingly efficient, but the trap should typically only > be taken once per host context switch. > > Signed-off-by: Dave Martin

Re: [PATCH 09/14] ARM: spectre-v2: add PSCI based hardening

2018-05-23 Thread Russell King - ARM Linux
On Tue, May 22, 2018 at 06:24:13PM +0100, Marc Zyngier wrote: > On 21/05/18 12:45, Russell King wrote: > > +#ifdef CONFIG_ARM_PSCI > > + if (psci_ops.smccc_version != SMCCC_VERSION_1_0) { > > + struct arm_smccc_res res; > > + > > + switch (psci_ops.conduit) { > > +

Re: [PATCH 09/14] ARM: spectre-v2: add PSCI based hardening

2018-05-23 Thread Marc Zyngier
On Tue, 22 May 2018 18:57:18 +0100, Russell King wrote: > > On Tue, May 22, 2018 at 06:24:13PM +0100, Marc Zyngier wrote: > > On 21/05/18 12:45, Russell King wrote: > > > Add PSCI based hardening for cores that require more complex handling in > > > firmware. > > > > > > Signed-off-by: Russell

Re: [PATCHv4 05/10] arm64/cpufeature: detect pointer authentication

2018-05-23 Thread Suzuki K Poulose
Mark, On 03/05/18 14:20, Mark Rutland wrote: So that we can dynamically handle the presence of pointer authentication functionality, wire up probing code in cpufeature.c. From ARMv8.3 onwards, ID_AA64ISAR1 is no longer entirely RES0, and now has four fields describing the presence of pointer

Re: [PATCH 04/14] arm64: Add ARCH_WORKAROUND_2 probing

2018-05-23 Thread Julien Grall
Hi Marc, On 05/22/2018 04:06 PM, Marc Zyngier wrote: As for Spectre variant-2, we rely on SMCCC 1.1 to provide the discovery mechanism for detecting the SSBD mitigation. A new capability is also allocated for that purpose, and a config option. Signed-off-by: Marc Zyngier

Re: [PATCH 02/14] arm64: Call ARCH_WORKAROUND_2 on transitions between EL0 and EL1

2018-05-23 Thread Julien Grall
Hi Marc, On 05/22/2018 04:06 PM, Marc Zyngier wrote: diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index ec2ee720e33e..f33e6aed3037 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -18,6 +18,7 @@ * along with this program. If not, see

Re: [PATCH 03/14] arm64: Add per-cpu infrastructure to call ARCH_WORKAROUND_2

2018-05-23 Thread Julien Grall
Hi Marc, On 05/22/2018 04:06 PM, Marc Zyngier wrote: In a heterogeneous system, we can end up with both affected and unaffected CPUs. Let's check their status before calling into the firmware. Signed-off-by: Marc Zyngier Reviewed-by: Julien Grall

Re: [PATCH 05/14] arm64: Add 'ssbd' command-line option

2018-05-23 Thread Julien Grall
Hi Marc, On 05/22/2018 04:06 PM, Marc Zyngier wrote: On a system where the firmware implements ARCH_WORKAROUND_2, it may be useful to either permanently enable or disable the workaround for cases where the user decides that they'd rather not get a trap overhead, and keep the mitigation

Re: [PATCHv4 06/10] arm64: add basic pointer authentication support

2018-05-23 Thread Suzuki K Poulose
Hi Mark, On 03/05/18 14:20, Mark Rutland wrote: This patch adds basic support for pointer authentication, allowing userspace to make use of APIAKey. The kernel maintains an APIAKey value for each process (shared by all threads within), which is initialised to a random value at exec() time. To

Re: [PATCH v10 07/18] arm64: fpsimd: Eliminate task->mm checks

2018-05-23 Thread Christoffer Dall
On Tue, May 22, 2018 at 05:05:08PM +0100, Dave Martin wrote: > Currently the FPSIMD handling code uses the condition task->mm == > NULL as a hint that task has no FPSIMD register context. > > The ->mm check is only there to filter out tasks that cannot > possibly have FPSIMD context loaded, for

Re: [PATCH 07/14] arm64: ssbd: Skip apply_ssbd if not using dynamic mitigation

2018-05-23 Thread Julien Grall
Hi Marc, On 05/22/2018 04:06 PM, Marc Zyngier wrote: In order to avoid checking arm64_ssbd_callback_required on each kernel entry/exit even if no mitigation is required, let's add yet another alternative that by default jumps over the mitigation, and that gets nop'ed out if we're doing dynamic

Re: [PATCH 08/14] arm64: ssbd: Disable mitigation on CPU resume if required by user

2018-05-23 Thread Julien Grall
Hi, On 05/22/2018 04:06 PM, Marc Zyngier wrote: On a system where firmware can dynamically change the state of the mitigation, the CPU will always come up with the mitigation enabled, including when coming back from suspend. If the user has requested "no mitigation" via a command line option,

Re: [PATCH 13/14] ARM: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling

2018-05-23 Thread Marc Zyngier
On 21/05/18 12:45, Russell King wrote: > We want SMCCC_ARCH_WORKAROUND_1 to be fast. As fast as possible. > So let's intercept it as early as we can by testing for the > function call number as soon as we've identified a HVC call > coming from the guest. > > Signed-off-by: Russell King

Re: [PATCH 06/14] arm64: ssbd: Add global mitigation state accessor

2018-05-23 Thread Julien Grall
Hi Marc, On 05/22/2018 04:06 PM, Marc Zyngier wrote: We're about to need the mitigation state in various parts of the kernel in order to do the right thing for userspace and guests. Let's expose an accessor that will let other subsystems know about the state. Signed-off-by: Marc Zyngier

Re: [PATCH] arm64: kvm: use -fno-jump-tables with clang

2018-05-23 Thread Andrey Konovalov
On Tue, May 22, 2018 at 8:28 PM, Nick Desaulniers wrote: > On Fri, May 18, 2018 at 11:13 AM Marc Zyngier wrote: >> > - you have checked that with a released version of the compiler, you > > On Tue, May 22, 2018 at 10:58 AM Andrey Konovalov

Re: [PATCH v10 02/18] thread_info: Add update_thread_flag() helpers

2018-05-23 Thread Alex Bennée
Dave Martin writes: > There are a number of bits of code sprinkled around the kernel to > set a thread flag if a certain condition is true, and clear it > otherwise. > > To help make those call sites terser and less cumbersome, this > patch adds a new family of thread flag

Re: [PATCH v10 01/18] arm64: fpsimd: Fix TIF_FOREIGN_FPSTATE after invalidating cpu regs

2018-05-23 Thread Catalin Marinas
On Tue, May 22, 2018 at 05:05:02PM +0100, Dave P Martin wrote: > fpsimd_last_state.st is set to NULL as a way of indicating that > current's FPSIMD registers are no longer loaded in the cpu. In > particular, this is done when the kernel temporarily uses or > clobbers the FPSIMD registers for its

Re: [PATCH v10 03/18] arm64: Use update{,_tsk}_thread_flag()

2018-05-23 Thread Alex Bennée
Dave Martin writes: > This patch uses the new update_thread_flag() helpers to simplify a > couple of if () set; else clear; constructs. > > No functional change. > > Signed-off-by: Dave Martin > Acked-by: Marc Zyngier > Acked-by:

Re: [PATCH v10 04/18] KVM: arm/arm64: Introduce kvm_arch_vcpu_run_pid_change

2018-05-23 Thread Alex Bennée
Dave Martin writes: > From: Christoffer Dall > > KVM/ARM differs from other architectures in having to maintain an > additional virtual address space from that of the host and the > guest, because we split the execution of KVM across both EL1

Re: [PATCH v10 07/18] arm64: fpsimd: Eliminate task->mm checks

2018-05-23 Thread Dave Martin
On Wed, May 23, 2018 at 01:48:12PM +0200, Christoffer Dall wrote: > On Tue, May 22, 2018 at 05:05:08PM +0100, Dave Martin wrote: > > Currently the FPSIMD handling code uses the condition task->mm == > > NULL as a hint that task has no FPSIMD register context. > > > > The ->mm check is only there

Re: [PATCH v10 02/18] thread_info: Add update_thread_flag() helpers

2018-05-23 Thread Alex Bennée
Dave Martin writes: > On Wed, May 23, 2018 at 02:46:52PM +0100, Alex Bennée wrote: >> >> Dave Martin writes: >> >> > There are a number of bits of code sprinkled around the kernel to >> > set a thread flag if a certain condition is true, and clear it

Re: [PATCH v10 04/18] KVM: arm/arm64: Introduce kvm_arch_vcpu_run_pid_change

2018-05-23 Thread Dave Martin
On Wed, May 23, 2018 at 03:34:20PM +0100, Alex Bennée wrote: > > Dave Martin writes: > > > From: Christoffer Dall > > > > KVM/ARM differs from other architectures in having to maintain an > > additional virtual address space from that of the

Re: [PATCH v10 14/18] KVM: arm64: Save host SVE context as appropriate

2018-05-23 Thread Catalin Marinas
On Tue, May 22, 2018 at 05:05:15PM +0100, Dave P Martin wrote: > This patch adds SVE context saving to the hyp FPSIMD context switch > path. This means that it is no longer necessary to save the host > SVE state in advance of entering the guest, when in use. > > In order to avoid adding

Re: [PATCH v10 07/18] arm64: fpsimd: Eliminate task->mm checks

2018-05-23 Thread Dave Martin
On Wed, May 23, 2018 at 03:56:57PM +0100, Catalin Marinas wrote: > On Wed, May 23, 2018 at 02:31:59PM +0100, Dave P Martin wrote: > > On Wed, May 23, 2018 at 01:48:12PM +0200, Christoffer Dall wrote: > > > On Tue, May 22, 2018 at 05:05:08PM +0100, Dave Martin wrote: > > > > This is true by

Re: [PATCH v10 07/18] arm64: fpsimd: Eliminate task->mm checks

2018-05-23 Thread Catalin Marinas
On Wed, May 23, 2018 at 04:03:37PM +0100, Dave P Martin wrote: > On Wed, May 23, 2018 at 03:56:57PM +0100, Catalin Marinas wrote: > > On Wed, May 23, 2018 at 02:31:59PM +0100, Dave P Martin wrote: > > > On Wed, May 23, 2018 at 01:48:12PM +0200, Christoffer Dall wrote: > > > > On Tue, May 22, 2018

Re: [PATCH v10 01/18] arm64: fpsimd: Fix TIF_FOREIGN_FPSTATE after invalidating cpu regs

2018-05-23 Thread Alex Bennée
Dave Martin writes: > fpsimd_last_state.st is set to NULL as a way of indicating that > current's FPSIMD registers are no longer loaded in the cpu. In > particular, this is done when the kernel temporarily uses or > clobbers the FPSIMD registers for its own purposes, as in

Re: [PATCH v10 02/18] thread_info: Add update_thread_flag() helpers

2018-05-23 Thread Dave Martin
On Wed, May 23, 2018 at 02:46:52PM +0100, Alex Bennée wrote: > > Dave Martin writes: > > > There are a number of bits of code sprinkled around the kernel to > > set a thread flag if a certain condition is true, and clear it > > otherwise. > > > > To help make those call

Re: [PATCH v10 07/18] arm64: fpsimd: Eliminate task->mm checks

2018-05-23 Thread Catalin Marinas
On Wed, May 23, 2018 at 02:31:59PM +0100, Dave P Martin wrote: > On Wed, May 23, 2018 at 01:48:12PM +0200, Christoffer Dall wrote: > > On Tue, May 22, 2018 at 05:05:08PM +0100, Dave Martin wrote: > > > This is true by construction however: TIF_FOREIGN_FPSTATE is never > > > cleared except when

Re: [PATCH] arm64: kvm: use -fno-jump-tables with clang

2018-05-23 Thread Nick Desaulniers
On Wed, May 23, 2018 at 4:54 AM Andrey Konovalov wrote: > On Tue, May 22, 2018 at 8:28 PM, Nick Desaulniers > wrote: > > On Fri, May 18, 2018 at 11:13 AM Marc Zyngier wrote: > >> > - you have checked that with a released

Re: [PATCH] arm64: kvm: use -fno-jump-tables with clang

2018-05-23 Thread Andrey Konovalov
On Wed, May 23, 2018 at 7:47 PM, Nick Desaulniers wrote: > On Wed, May 23, 2018 at 4:54 AM Andrey Konovalov > wrote: >> On Tue, May 22, 2018 at 8:28 PM, Nick Desaulniers >> wrote: >> > On Fri, May 18, 2018 at 11:13 AM Marc