[PATCH v2] KVM: arm64: Allow in-atomic injection of SPIs

2020-06-15 Thread Marc Zyngier
On a system that uses SPIs to implement MSIs (as it would be the case on a GICv2 system exposing a GICv2m to its guests), we deny the possibility of injecting SPIs on the in-atomic fast-path. This results in a very large amount of context-switches (roughly equivalent to twice the interrupt rate)

Re: [PATCH v5 0/2] target/arm: kvm: Support for KVM DABT with no valid ISS

2020-06-15 Thread Peter Maydell
On Fri, 29 May 2020 at 12:28, Beata Michalska wrote: > > Some of the ARMv7 & ARMv8 load/store instructions might trigger a data abort > exception with no valid ISS info to be decoded. The lack of decode info > makes it at least tricky to emulate the instruction which is one of the > (many)

Re: [PATCH 0/4] KVM/arm64: Enable PtrAuth on non-VHE KVM

2020-06-15 Thread Dave Martin
On Mon, Jun 15, 2020 at 02:22:19PM +0100, Marc Zyngier wrote: > Hi Dave, > > On 2020-06-15 13:59, Dave Martin wrote: > >On Mon, Jun 15, 2020 at 09:19:50AM +0100, Marc Zyngier wrote: > >>Not having PtrAuth on non-VHE KVM (for whatever reason VHE is not > >>enabled on a v8.3 system) has always

[PATCH v2 14/17] KVM: arm64: Disintegrate SPSR array

2020-06-15 Thread Marc Zyngier
As we're about to move SPSR_EL1 into the VNCR page, we need to disassociate it from the rest of the 32bit cruft. Let's break the array into individual fields. Reviewed-by: James Morse Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_emulate.h | 4 ++--

[PATCH v2 11/17] KVM: arm64: Make struct kvm_regs userspace-only

2020-06-15 Thread Marc Zyngier
struct kvm_regs is used by userspace to indicate which register gets accessed by the {GET,SET}_ONE_REG API. But as we're about to refactor the layout of the in-kernel register structures, we need the kernel to move away from it. Let's make kvm_regs userspace only, and let the kernel map it to its

[PATCH v2 12/17] KVM: arm64: Move ELR_EL1 to the system register array

2020-06-15 Thread Marc Zyngier
As ELR-EL1 is a VNCR-capable register with ARMv8.4-NV, let's move it to the sys_regs array and repaint the accessors. While we're at it, let's kill the now useless accessors used only on the fault injection path. Reviewed-by: James Morse Signed-off-by: Marc Zyngier ---

[PATCH v2 17/17] KVM: arm64: timers: Move timer registers to the sys_regs file

2020-06-15 Thread Marc Zyngier
Move the timer gsisters to the sysreg file. This will further help when they are directly changed by a nesting hypervisor in the VNCR page. This requires moving the initialisation of the timer struct so that some of the helpers (such as arch_timer_ctx_index) can work correctly at an early stage.

[PATCH v2 15/17] KVM: arm64: Move SPSR_EL1 to the system register array

2020-06-15 Thread Marc Zyngier
SPSR_EL1 being a VNCR-capable register with ARMv8.4-NV, move it to the sysregs array and update the accessors. Reviewed-by: James Morse Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_emulate.h | 4 ++-- arch/arm64/include/asm/kvm_host.h| 2 +- arch/arm64/kvm/guest.c

[PATCH v2 10/17] KVM: arm64: debug: Use ctxt_sys_reg() instead of raw sys_regs access

2020-06-15 Thread Marc Zyngier
Now that we have a wrapper for the sysreg accesses, let's use that consistently. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/debug-sr.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kvm/hyp/debug-sr.c b/arch/arm64/kvm/hyp/debug-sr.c index

[PATCH v2 16/17] KVM: arm64: timers: Rename kvm_timer_sync_hwstate to kvm_timer_sync_user

2020-06-15 Thread Marc Zyngier
kvm_timer_sync_hwstate() has nothing to do with the timer HW state, but more to do with the state of a userspace interrupt controller. Change the suffix from _hwstate to_user, in keeping with the rest of the code. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/arch_timer.c | 2 +-

[PATCH v2 13/17] KVM: arm64: Move SP_EL1 to the system register array

2020-06-15 Thread Marc Zyngier
SP_EL1 being a VNCR-capable register with ARMv8.4-NV, move it to the system register array and update the accessors. Reviewed-by: James Morse Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 3 +-- arch/arm64/kvm/guest.c| 2 +- arch/arm64/kvm/hyp/sysreg-sr.c|

[PATCH v2 00/17] KVM: arm64: Preliminary NV patches

2020-06-15 Thread Marc Zyngier
Hi all, In order not to repeat the 90+ patch series that resulted in a deafening silence last time, I've extracted a smaller set of patches that form the required dependencies that allow the rest of the 65 NV patches to be added on top. Yes, it is that bad. The one real feature here is support

[PATCH v2 02/17] arm64: Detect the ARMv8.4 TTL feature

2020-06-15 Thread Marc Zyngier
In order to reduce the cost of TLB invalidation, the ARMv8.4 TTL feature allows TLBs to be issued with a level allowing for quicker invalidation. Let's detect the feature for now. Further patches will implement its actual usage. Reviewed-by : Suzuki K Polose Signed-off-by: Marc Zyngier ---

[PATCH v2 04/17] arm64: Add level-hinted TLB invalidation helper

2020-06-15 Thread Marc Zyngier
Add a level-hinted TLB invalidation helper that only gets used if ARMv8.4-TTL gets detected. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/stage2_pgtable.h | 9 + arch/arm64/include/asm/tlbflush.h | 45 + 2 files changed, 54 insertions(+) diff --git

[PATCH v2 03/17] arm64: Document SW reserved PTE/PMD bits in Stage-2 descriptors

2020-06-15 Thread Marc Zyngier
Advertise bits [58:55] as reserved for SW in the S2 descriptors. Reviewed-by: Andrew Scull Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/pgtable-hwdef.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/include/asm/pgtable-hwdef.h

[PATCH v2 07/17] KVM: arm64: hyp: Use ctxt_sys_reg/__vcpu_sys_reg instead of raw sys_regs access

2020-06-15 Thread Marc Zyngier
Switch the hypervisor code to using ctxt_sys_reg/__vcpu_sys_reg instead of raw sys_regs accesses. No intended functionnal change. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/kvm/hyp/debug-sr.c | 4 +- arch/arm64/kvm/hyp/switch.c | 11 ++-

[PATCH v2 06/17] KVM: arm64: Introduce accessor for ctxt->sys_reg

2020-06-15 Thread Marc Zyngier
In order to allow the disintegration of the per-vcpu sysreg array, let's introduce a new helper (ctxt_sys_reg()) that returns the in-memory copy of a system register, picked from a given context. __vcpu_sys_reg() is rewritten to use this helper. Signed-off-by: Marc Zyngier ---

[PATCH v2 08/17] KVM: arm64: sve: Use __vcpu_sys_reg() instead of raw sys_regs access

2020-06-15 Thread Marc Zyngier
Now that we have a wrapper for the sysreg accesses, let's use that consistently. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/fpsimd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index e329a36b2bee..e503caff14d1

[PATCH v2 01/17] KVM: arm64: Factor out stage 2 page table data from struct kvm

2020-06-15 Thread Marc Zyngier
From: Christoffer Dall As we are about to reuse our stage 2 page table manipulation code for shadow stage 2 page tables in the context of nested virtualization, we are going to manage multiple stage 2 page tables for a single VM. This requires some pretty invasive changes to our data

[PATCH v2 09/17] KVM: arm64: pauth: Use ctxt_sys_reg() instead of raw sys_regs access

2020-06-15 Thread Marc Zyngier
Now that we have a wrapper for the sysreg accesses, let's use that consistently. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/switch.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c

[PATCH v2 05/17] KVM: arm64: Use TTL hint in when invalidating stage-2 translations

2020-06-15 Thread Marc Zyngier
Since we often have a precise idea of the level we're dealing with when invalidating TLBs, we can provide it to as a hint to our invalidation helper. Reviewed-by: James Morse Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_asm.h | 3 ++- arch/arm64/kvm/hyp/tlb.c | 5 +++--

Re: [PATCH 0/4] KVM/arm64: Enable PtrAuth on non-VHE KVM

2020-06-15 Thread Marc Zyngier
Hi Dave, On 2020-06-15 13:59, Dave Martin wrote: On Mon, Jun 15, 2020 at 09:19:50AM +0100, Marc Zyngier wrote: Not having PtrAuth on non-VHE KVM (for whatever reason VHE is not enabled on a v8.3 system) has always looked like an oddity. This trivial series remedies it, and allows a non-VHE KVM

Re: [PATCH 3/4] KVM: arm64: Allow PtrAuth to be enabled from userspace on non-VHE systems

2020-06-15 Thread Andrew Scull
On Mon, Jun 15, 2020 at 09:19:53AM +0100, Marc Zyngier wrote: > Now that the scene is set for enabling PtrAuth on non-VHE, drop > the restrictions preventing userspace from enabling it. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/reset.c | 21 ++--- > 1 file changed,

Re: [PATCH 0/4] KVM/arm64: Enable PtrAuth on non-VHE KVM

2020-06-15 Thread Dave Martin
On Mon, Jun 15, 2020 at 09:19:50AM +0100, Marc Zyngier wrote: > Not having PtrAuth on non-VHE KVM (for whatever reason VHE is not > enabled on a v8.3 system) has always looked like an oddity. This > trivial series remedies it, and allows a non-VHE KVM to offer PtrAuth > to its guests. How likely

Re: [PATCH 2/4] KVM: arm64: Allow ARM64_PTR_AUTH when ARM64_VHE=n

2020-06-15 Thread Andrew Scull
On Mon, Jun 15, 2020 at 09:19:52AM +0100, Marc Zyngier wrote: > We currently prevent PtrAuth from even being built if KVM is selected, > but VHE isn't. It is a bit of a pointless restriction, since we also > check this at run time (rejecting the enabling of PtrAuth for the > vcpu if we're not

Re: [PATCH 1/4] KVM: arm64: Enable Pointer Authentication at EL2 if available

2020-06-15 Thread Andrew Scull
On Mon, Jun 15, 2020 at 09:19:51AM +0100, Marc Zyngier wrote: > While initializing EL2, switch Pointer Authentication if detected ^ nit: on? > from EL1. We use the EL1-provided keys though. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/hyp-init.S | 11

Re: [PATCH 1/4] KVM: arm64: Enable Pointer Authentication at EL2 if available

2020-06-15 Thread Marc Zyngier
On 2020-06-15 11:03, Mark Rutland wrote: On Mon, Jun 15, 2020 at 09:19:51AM +0100, Marc Zyngier wrote: While initializing EL2, switch Pointer Authentication if detected from EL1. We use the EL1-provided keys though. Perhaps "enable address authentication", to avoid confusion with

Re: [PATCH 1/4] KVM: arm64: Enable Pointer Authentication at EL2 if available

2020-06-15 Thread Marc Zyngier
Hi Andrew, On 2020-06-15 09:48, Andrew Scull wrote: On Mon, Jun 15, 2020 at 09:19:51AM +0100, Marc Zyngier wrote: While initializing EL2, switch Pointer Authentication if detected ^ nit: on? Yes. from EL1. We use the EL1-provided keys though.

Re: [PATCH 4/4] KVM: arm64: Check HCR_EL2 instead of shadow copy to swap PtrAuth registers

2020-06-15 Thread Mark Rutland
On Mon, Jun 15, 2020 at 09:19:54AM +0100, Marc Zyngier wrote: > When save/restoring PtrAuth registers between host and guest, it is > pretty useless to fetch the in-memory state, while we have the right > state in the HCR_EL2 system register. Use that instead. > > Signed-off-by: Marc Zyngier It

Re: [PATCH 3/4] KVM: arm64: Allow PtrAuth to be enabled from userspace on non-VHE systems

2020-06-15 Thread Mark Rutland
On Mon, Jun 15, 2020 at 09:19:53AM +0100, Marc Zyngier wrote: > Now that the scene is set for enabling PtrAuth on non-VHE, drop > the restrictions preventing userspace from enabling it. > > Signed-off-by: Marc Zyngier Other than dropping the `has_vhe()` check this appears to be functionally

Re: [PATCH 2/4] KVM: arm64: Allow ARM64_PTR_AUTH when ARM64_VHE=n

2020-06-15 Thread Mark Rutland
On Mon, Jun 15, 2020 at 09:19:52AM +0100, Marc Zyngier wrote: > We currently prevent PtrAuth from even being built if KVM is selected, > but VHE isn't. It is a bit of a pointless restriction, since we also > check this at run time (rejecting the enabling of PtrAuth for the > vcpu if we're not

Re: [PATCH 1/4] KVM: arm64: Enable Pointer Authentication at EL2 if available

2020-06-15 Thread Mark Rutland
On Mon, Jun 15, 2020 at 09:19:51AM +0100, Marc Zyngier wrote: > While initializing EL2, switch Pointer Authentication if detected > from EL1. We use the EL1-provided keys though. Perhaps "enable address authentication", to avoid confusion with context-switch, and since generic authentication

[PATCH 4/4] KVM: arm64: Check HCR_EL2 instead of shadow copy to swap PtrAuth registers

2020-06-15 Thread Marc Zyngier
When save/restoring PtrAuth registers between host and guest, it is pretty useless to fetch the in-memory state, while we have the right state in the HCR_EL2 system register. Use that instead. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_ptrauth.h | 4 ++-- 1 file changed, 2

[PATCH 1/4] KVM: arm64: Enable Pointer Authentication at EL2 if available

2020-06-15 Thread Marc Zyngier
While initializing EL2, switch Pointer Authentication if detected from EL1. We use the EL1-provided keys though. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp-init.S | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S index

[PATCH 0/4] KVM/arm64: Enable PtrAuth on non-VHE KVM

2020-06-15 Thread Marc Zyngier
Not having PtrAuth on non-VHE KVM (for whatever reason VHE is not enabled on a v8.3 system) has always looked like an oddity. This trivial series remedies it, and allows a non-VHE KVM to offer PtrAuth to its guests. In the tradition of not having separate security between host-EL1 and EL2, EL2

[PATCH 2/4] KVM: arm64: Allow ARM64_PTR_AUTH when ARM64_VHE=n

2020-06-15 Thread Marc Zyngier
We currently prevent PtrAuth from even being built if KVM is selected, but VHE isn't. It is a bit of a pointless restriction, since we also check this at run time (rejecting the enabling of PtrAuth for the vcpu if we're not running with VHE). Just drop this apparently useless restriction.

[PATCH 3/4] KVM: arm64: Allow PtrAuth to be enabled from userspace on non-VHE systems

2020-06-15 Thread Marc Zyngier
Now that the scene is set for enabling PtrAuth on non-VHE, drop the restrictions preventing userspace from enabling it. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/reset.c | 21 ++--- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/reset.c