Re: [PATCH v3 07/12] ACPI / APEI: Make the nmi_fixmap_idx per-ghes to allow multiple in_nmi() users

2018-05-08 Thread James Morse
Hi Borislav, On 05/05/18 13:27, Borislav Petkov wrote: > On Fri, Apr 27, 2018 at 04:35:05PM +0100, James Morse wrote: >> Arm64 has multiple NMI-like notifications, but ghes.c only has one >> in_nmi() path, risking deadlock if one NMI-like notification can >> interrupt another. >> >> To support

Re: [PATCH v5 03/14] KVM: arm/arm64: Introduce kvm_arch_vcpu_run_pid_change

2018-05-08 Thread Marc Zyngier
On 04/05/18 17:05, Dave Martin wrote: > 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 and >

Re: [PATCH v5 06/14] KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashing

2018-05-08 Thread Dave Martin
On Tue, May 08, 2018 at 10:58:04AM +0100, Marc Zyngier wrote: > On 04/05/18 17:05, Dave Martin wrote: > > This patch refactors KVM to align the host and guest FPSIMD > > save/restore logic with each other for arm64. This reduces the > > number of redundant save/restore operations that must occur,

Re: [PATCH v5 05/14] arm64: fpsimd: Generalise context saving for non-task contexts

2018-05-08 Thread Marc Zyngier
On 04/05/18 17:05, Dave Martin wrote: > 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 v5 10/14] KVM: arm64: Save host SVE context as appropriate

2018-05-08 Thread Marc Zyngier
On 08/05/18 12:25, Dave Martin wrote: > On Tue, May 08, 2018 at 11:38:05AM +0100, Marc Zyngier wrote: >> On 04/05/18 17:05, Dave 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

Re: [PATCH v5 13/14] KVM: arm64: Fold redundant exit code checks out of fixup_guest_exit()

2018-05-08 Thread Dave Martin
On Tue, May 08, 2018 at 11:59:25AM +0100, Marc Zyngier wrote: > On 04/05/18 17:05, Dave Martin wrote: > > The entire tail of fixup_guest_exit() is contained in if statements > > of the form if (x && *exit_code == ARM_EXCEPTION_TRAP). As a result, > > we can check just once and bail out of the

Re: [PATCH v5 13/14] KVM: arm64: Fold redundant exit code checks out of fixup_guest_exit()

2018-05-08 Thread Marc Zyngier
On 08/05/18 12:30, Dave Martin wrote: > On Tue, May 08, 2018 at 11:59:25AM +0100, Marc Zyngier wrote: >> On 04/05/18 17:05, Dave Martin wrote: >>> The entire tail of fixup_guest_exit() is contained in if statements >>> of the form if (x && *exit_code == ARM_EXCEPTION_TRAP). As a result, >>> we

Re: [PATCH v5 10/14] KVM: arm64: Save host SVE context as appropriate

2018-05-08 Thread Dave Martin
On Tue, May 08, 2018 at 11:38:05AM +0100, Marc Zyngier wrote: > On 04/05/18 17:05, Dave 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

Re: [PATCH v5 14/14] KVM: arm64: Invoke FPSIMD context switch trap from C

2018-05-08 Thread Marc Zyngier
On 04/05/18 17:05, Dave Martin wrote: > The conversion of the FPSIMD context switch trap code to C has added > some overhead to calling it, due to the need to save registers that > the procedure call standard defines as caller-saved. > > So, perhaps it is no longer worth invoking this trap

Re: [PATCH v2 11/17] kvm: arm64: Configure VTCR per VM

2018-05-08 Thread Suzuki K Poulose
On 03/05/18 15:39, James Morse wrote: Hi Suzuki, On 27/03/18 14:15, Suzuki K Poulose wrote: We set VTCR_EL2 very early during the stage2 init and don't touch it ever. This is fine as we had a fixed IPA size. This patch changes the behavior to set the VTCR for a given VM, depending on its

Re: [PATCH v5 13/14] KVM: arm64: Fold redundant exit code checks out of fixup_guest_exit()

2018-05-08 Thread Dave Martin
On Tue, May 08, 2018 at 12:59:39PM +0100, Marc Zyngier wrote: > On 08/05/18 12:30, Dave Martin wrote: > > On Tue, May 08, 2018 at 11:59:25AM +0100, Marc Zyngier wrote: > >> On 04/05/18 17:05, Dave Martin wrote: [...] > >>> diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c >

Re: [PATCH v5 10/14] KVM: arm64: Save host SVE context as appropriate

2018-05-08 Thread Dave Martin
On Tue, May 08, 2018 at 12:57:56PM +0100, Marc Zyngier wrote: > On 08/05/18 12:25, Dave Martin wrote: > > On Tue, May 08, 2018 at 11:38:05AM +0100, Marc Zyngier wrote: > >> On 04/05/18 17:05, Dave Martin wrote: > >>> This patch adds SVE context saving to the hyp FPSIMD context switch > >>> path.

[PATCH v6 00/15] KVM: arm64: Optimise FPSIMD context switching

2018-05-08 Thread Dave Martin
Note: Most of these patches are Arm-specific. People not Cc'd on the whole series can find it in the linux-arm-kernel archive [3]. This series aims to improve the way FPSIMD context is handled by KVM. Only minor changes have been made since the previous v5 [1]. The changes are summarised in the

[PATCH v6 07/15] KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashing

2018-05-08 Thread Dave Martin
This patch refactors KVM to align the host and guest FPSIMD save/restore logic with each other for arm64. This reduces the number of redundant save/restore operations that must occur, and reduces the common-case IRQ blackout time during guest exit storms by saving the host state lazily and

[PATCH v6 08/15] arm64/sve: Move read_zcr_features() out of cpufeature.h

2018-05-08 Thread Dave Martin
Having read_zcr_features() inline in cpufeature.h results in that header requiring #includes which make it hard to include elsewhere without triggering header inclusion cycles. This is not a hot-path function and arguably should not be in cpufeature.h in the first place, so this patch moves it

[PATCH v6 10/15] arm64/sve: Move sve_pffr() to fpsimd.h and make inline

2018-05-08 Thread Dave Martin
In order to make sve_save_state()/sve_load_state() more easily reusable and to get rid of a potential branch on context switch critical paths, this patch makes sve_pffr() inline and moves it to fpsimd.h. must be included in fpsimd.h in order to make this work, and this creates an #include cycle

[PATCH v6 09/15] arm64/sve: Switch sve_pffr() argument from task to thread

2018-05-08 Thread Dave Martin
sve_pffr(), which is used to derive the base address used for low-level SVE save/restore routines, currently takes the relevant task_struct as an argument. The only accessed fields are actually part of thread_struct, so this patch changes the argument type accordingly. This is done in

Re: [PATCH v6 01/15] thread_info: Add update_thread_flag() helpers

2018-05-08 Thread Steven Rostedt
On Tue, 8 May 2018 17:44:46 +0100 Dave Martin wrote: > 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

[PATCH v6 02/15] arm64: Use update{,_tsk}_thread_flag()

2018-05-08 Thread Dave Martin
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 Cc: Catalin Marinas Cc: Will Deacon ---

[PATCH v6 04/15] KVM: arm64: Convert lazy FPSIMD context switch trap to C

2018-05-08 Thread Dave Martin
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 Reviewed-by: Marc Zyngier

[PATCH v6 03/15] KVM: arm/arm64: Introduce kvm_arch_vcpu_run_pid_change

2018-05-08 Thread Dave Martin
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 and EL2. This results in a need to explicitly map

[PATCH v6 01/15] thread_info: Add update_thread_flag() helpers

2018-05-08 Thread Dave Martin
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 manipulators update*_thread_flag([...,] flag,

[PATCH v6 14/15] KVM: arm64: Fold redundant exit code checks out of fixup_guest_exit()

2018-05-08 Thread Dave Martin
The entire tail of fixup_guest_exit() is contained in if statements of the form if (x && *exit_code == ARM_EXCEPTION_TRAP). As a result, we can check just once and bail out of the function early, allowing the remaining if conditions to be simplified. The only awkward case is where *exit_code is

[PATCH v6 15/15] KVM: arm64: Invoke FPSIMD context switch trap from C

2018-05-08 Thread Dave Martin
The conversion of the FPSIMD context switch trap code to C has added some overhead to calling it, due to the need to save registers that the procedure call standard defines as caller-saved. So, perhaps it is no longer worth invoking this trap handler quite so early. Instead, we can invoke it

[PATCH v6 05/15] arm64: fpsimd: Generalise context saving for non-task contexts

2018-05-08 Thread Dave Martin
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 relevant storage to write back to in memory is now found

[PATCH v6 06/15] KVM: arm64: Repurpose vcpu_arch.debug_flags for general-purpose flags

2018-05-08 Thread Dave Martin
In struct vcpu_arch, the debug_flags field is used to store debug- related flags about the vcpu state. Since we are about to add some more flags related to FPSIMD and SVE, it makes sense to add them to the existing flags field rather than adding new fields. Since there is only one debug_flags

[PATCH v6 11/15] KVM: arm64: Save host SVE context as appropriate

2018-05-08 Thread Dave Martin
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 pointless complexity to the code, VHE is assumed if SVE is in use. VHE is an

[PATCH v6 13/15] KVM: arm64: Remove redundant *exit_code changes in fpsimd_guest_exit()

2018-05-08 Thread Dave Martin
In fixup_guest_exit(), there are a couple of cases where after checking what the exit code was, we assign it explicitly with the value it already had. Assuming this is not indicative of a bug, these assignments are not needed. This patch removes the redundant assignments simplifies some if-

[PATCH v6 12/15] KVM: arm64: Remove eager host SVE state saving

2018-05-08 Thread Dave Martin
Now that the host SVE context can be saved on demand from Hyp, there is no longer any need to save this state in advance before entering the guest. This patch removes the relevant call to kvm_fpsimd_flush_cpu_state(). Since the problem that function was intended to solve now no longer exists,

Re: [PATCH v2 05/17] arm64: Helper for parange to PASize

2018-05-08 Thread Suzuki K Poulose
On 03/05/18 15:39, James Morse wrote: Hi Suzuki, Nit: KVM in the subject line? Well, the helper is generic and its just that KVM makes use of it. On 27/03/18 14:15, Suzuki K Poulose wrote: Add a helper to convert ID_AA64MMFR0_EL1:PARange to they physical size shift. Limit the size to the