Re: [PATCH v2 08/21] arm64: KVM: VHE: Introduce unified system register accessors

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:42PM +, Marc Zyngier wrote: > VHE brings its own bag of new system registers, or rather system > register accessors, as it define new ways to access both guest > and host system registers. For example, from the host: > > - The host TCR_EL2 register is accessed

Re: [PATCH v2 07/21] arm64: KVM: VHE: Patch out kern_hyp_va

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:41PM +, Marc Zyngier wrote: > The kern_hyp_va macro is pretty meaninless with VHE, as there is > only one mapping - the kernel one. > > In order to keep the code readable and efficient, use runtime > patching to replace the 'and' instruction used to compute the

Re: [PATCH v2 06/21] arm64: KVM: VHE: Patch out use of HVC

2016-02-01 Thread Marc Zyngier
On 01/02/16 13:16, Christoffer Dall wrote: > On Mon, Jan 25, 2016 at 03:53:40PM +, Marc Zyngier wrote: >> With VHE, the host never issues an HVC instruction to get into the >> KVM code, as we can simply branch there. >> >> Use runtime code patching to simplify things a bit. >> >>

Re: [PATCH v2 09/21] arm64: KVM: VHE: Differenciate host/guest sysreg save/restore

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:43PM +, Marc Zyngier wrote: > With ARMv8, host and guest share the same system register file, > making the save/restore procedure completely symetrical. > With VHE, host and guest now have different requirements, as they > use different sysregs. > > In order to

Re: [PATCH v2 01/21] arm/arm64: Add new is_kernel_in_hyp_mode predicate

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:35PM +, Marc Zyngier wrote: > With ARMv8.1 VHE extension, it will be possible to run the kernel > at EL2 (aka HYP mode). In order for the kernel to easily find out > where it is running, add a new predicate that returns whether or > not the kernel is in HYP mode.

Re: [PATCH v2 13/21] arm64: KVM: VHE: Make __fpsimd_enabled VHE aware

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:47PM +, Marc Zyngier wrote: > As non-VHE and VHE have different ways to express the trapping of > FPSIMD registers to EL2, make __fpsimd_enabled a patchable predicate > and provide a VHE implementation. > > Signed-off-by: Marc Zyngier > ---

Re: [PATCH v2 07/21] arm64: KVM: VHE: Patch out kern_hyp_va

2016-02-01 Thread Marc Zyngier
On 01/02/16 13:20, Christoffer Dall wrote: > On Mon, Jan 25, 2016 at 03:53:41PM +, Marc Zyngier wrote: >> The kern_hyp_va macro is pretty meaninless with VHE, as there is >> only one mapping - the kernel one. >> >> In order to keep the code readable and efficient, use runtime >> patching to

Re: [PATCH v2 12/21] arm64: KVM: VHE: Enable minimal sysreg save/restore

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:46PM +, Marc Zyngier wrote: > We're now in a position where we can introduce VHE's minimal > save/restore, which is limited to the handful of shared sysregs. > > Add the required alternative function calls that result in a > "do nothing" call on VHE, and the

Re: [PATCH v2 06/21] arm64: KVM: VHE: Patch out use of HVC

2016-02-01 Thread Marc Zyngier
On 01/02/16 17:08, Ard Biesheuvel wrote: > On 1 February 2016 at 17:20, Marc Zyngier wrote: >> On 01/02/16 15:36, Catalin Marinas wrote: >>> On Mon, Feb 01, 2016 at 01:34:16PM +, Marc Zyngier wrote: On 01/02/16 13:16, Christoffer Dall wrote: > On Mon, Jan 25,

Re: [PATCH v2 08/21] arm64: KVM: VHE: Introduce unified system register accessors

2016-02-01 Thread Marc Zyngier
On 01/02/16 13:47, Christoffer Dall wrote: > On Mon, Jan 25, 2016 at 03:53:42PM +, Marc Zyngier wrote: >> VHE brings its own bag of new system registers, or rather system >> register accessors, as it define new ways to access both guest >> and host system registers. For example, from the host:

Re: [PATCH v2 14/21] arm64: KVM: VHE: Implement VHE activate/deactivate_traps

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:48PM +, Marc Zyngier wrote: > Running the kernel in HYP mode requires the HCR_E2H bit to be set > at all times, and the HCR_TGE bit to be set when running as a host > (and cleared when running as a guest). At the same time, the vector > must be set to the current

Re: [PATCH v2 00/21] arm64: Virtualization Host Extension support

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:34PM +, Marc Zyngier wrote: > ARMv8.1 comes with the "Virtualization Host Extension" (VHE for > short), which enables simpler support of Type-2 hypervisors. > > This extension allows the kernel to directly run at EL2, and > significantly reduces the number of

Re: [PATCH v2 17/21] arm64: KVM: VHE: Add alternative panic handling

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:51PM +, Marc Zyngier wrote: > As the kernel fully runs in HYP when VHE is enabled, we can > directly branch to the kernel's panic() implementation, and > not perform an exception return. > > Add the alternative code to deal with this. > > Signed-off-by: Marc

Re: [PATCH v2 02/21] arm64: Allow the arch timer to use the HYP timer

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:36PM +, Marc Zyngier wrote: > With the ARMv8.1 VHE, the kernel can run in HYP mode, and thus > use the HYP timer instead of the normal guest timer in a mostly > transparent way, except for the interrupt line. > > This patch reworks the arch timer code to allow

Re: [PATCH 00/10] KVM PCIe/MSI passthrough on ARM/ARM64

2016-02-01 Thread Will Deacon
On Fri, Jan 29, 2016 at 10:25:52PM +0100, Eric Auger wrote: > On 01/29/2016 08:33 PM, Alex Williamson wrote: > >>> We know that x86 handles MSI vectors specially, so there is some > >>> hardware that helps the situation. It's not just that x86 has a fixed > >>> range for MSI, it's how it manages

Re: [PATCH v2 15/21] arm64: KVM: VHE: Use unified sysreg accessors for timer

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:49PM +, Marc Zyngier wrote: > Switch the timer code to the unified sysreg accessors. > > Signed-off-by: Marc Zyngier Reviewed-by: Christoffer Dall > --- > arch/arm64/kvm/hyp/timer-sr.c | 10 +- > 1

Re: [PATCH v2 16/21] arm64: KVM: VHE: Add fpsimd enabling on guest access

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:50PM +, Marc Zyngier wrote: > Despite the fact that a VHE enabled kernel runs at EL2, it uses > CPACR_EL1 to trap FPSIMD access. Add the required alternative > code to re-enable guest FPSIMD access when it has trapped to > EL2. > > Signed-off-by: Marc Zyngier

Re: [PATCH v2 18/21] arm64: KVM: Introduce hyp_alternate_value helper

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:52PM +, Marc Zyngier wrote: > We already have hyp_alternate_select() to define a function pointer > that gets changed by a kernel feature or workaround. > > It would be useful to have a similar feature that resolves in a > direct value, without requiring a

Re: [PATCH v2 05/21] arm64: KVM: VHE: Turn VTCR_EL2 setup into a reusable macro

2016-02-01 Thread Marc Zyngier
On 01/02/16 13:13, Christoffer Dall wrote: > On Mon, Jan 25, 2016 at 03:53:39PM +, Marc Zyngier wrote: >> On a VHE-capable system, there is no point in setting VTCR_EL2 >> at KVM init time. We can perfectly set it up when the kernel >> boots, removing the need for a more complicated

Re: [PATCH v2 20/21] arm64: VHE: Add support for running Linux in EL2 mode

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:54PM +, Marc Zyngier wrote: > With ARMv8.1 VHE, the architecture is able to (almost) transparently > run the kernel at EL2, despite being written for EL1. > > This patch takes care of the "almost" part, mostly preventing the kernel > from dropping from EL2 to

Re: [PATCH v2 21/21] arm64: Panic when VHE and non VHE CPUs coexist

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:55PM +, Marc Zyngier wrote: > Having both VHE and non-VHE capable CPUs in the same system > is likely to be a recipe for disaster. > > If the boot CPU has VHE, but a secondary is not, we won't be > able to downgrade and run the kernel at EL1. Add CPU hotplug > to

Re: [PATCH v2 02/21] arm64: Allow the arch timer to use the HYP timer

2016-02-01 Thread Christoffer Dall
On Mon, Feb 01, 2016 at 01:42:34PM +, Marc Zyngier wrote: > On 01/02/16 12:29, Christoffer Dall wrote: > > On Mon, Jan 25, 2016 at 03:53:36PM +, Marc Zyngier wrote: > >> With the ARMv8.1 VHE, the kernel can run in HYP mode, and thus > >> use the HYP timer instead of the normal guest timer

Re: [PATCH v2 06/21] arm64: KVM: VHE: Patch out use of HVC

2016-02-01 Thread Christoffer Dall
On Mon, Feb 01, 2016 at 01:34:16PM +, Marc Zyngier wrote: > On 01/02/16 13:16, Christoffer Dall wrote: > > On Mon, Jan 25, 2016 at 03:53:40PM +, Marc Zyngier wrote: > >> With VHE, the host never issues an HVC instruction to get into the > >> KVM code, as we can simply branch there. > >> >

Re: [PATCH v2 05/21] arm64: KVM: VHE: Turn VTCR_EL2 setup into a reusable macro

2016-02-01 Thread Christoffer Dall
On Mon, Feb 01, 2016 at 02:21:57PM +, Marc Zyngier wrote: > On 01/02/16 13:13, Christoffer Dall wrote: > > On Mon, Jan 25, 2016 at 03:53:39PM +, Marc Zyngier wrote: > >> On a VHE-capable system, there is no point in setting VTCR_EL2 > >> at KVM init time. We can perfectly set it up when

Re: [PATCH v2 07/21] arm64: KVM: VHE: Patch out kern_hyp_va

2016-02-01 Thread Christoffer Dall
On Mon, Feb 01, 2016 at 01:38:57PM +, Marc Zyngier wrote: > On 01/02/16 13:20, Christoffer Dall wrote: > > On Mon, Jan 25, 2016 at 03:53:41PM +, Marc Zyngier wrote: > >> The kern_hyp_va macro is pretty meaninless with VHE, as there is > >> only one mapping - the kernel one. > >> > >> In

Re: [PATCH v2 08/21] arm64: KVM: VHE: Introduce unified system register accessors

2016-02-01 Thread Christoffer Dall
On Mon, Feb 01, 2016 at 02:04:39PM +, Marc Zyngier wrote: > On 01/02/16 13:47, Christoffer Dall wrote: > > On Mon, Jan 25, 2016 at 03:53:42PM +, Marc Zyngier wrote: > >> VHE brings its own bag of new system registers, or rather system > >> register accessors, as it define new ways to

Re: [PATCH v2 19/21] arm64: KVM: Move most of the fault decoding to C

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:53PM +, Marc Zyngier wrote: > The fault decoding process (including computing the IPA in the case > of a permission fault) would be much better done in C code, as we > have a reasonable infrastructure to deal with the VHE/non-VHE > differences. > > Let's move the

Re: [PATCH v2 11/21] arm64: KVM: VHE: Use unified system register accessors

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:45PM +, Marc Zyngier wrote: > Use the recently introduced unified system register accessors for > those sysregs that behave differently depending on VHE being in > use or not. > > Signed-off-by: Marc Zyngier Reviewed-by: Christoffer Dall

Re: [PATCH v2 03/21] arm64: Add ARM64_HAS_VIRT_HOST_EXTN feature

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:37PM +, Marc Zyngier wrote: > Add a new ARM64_HAS_VIRT_HOST_EXTN features to indicate that the > CPU has the ARMv8.1 VHE capability. > > This will be used to trigger kernel patching in KVM. > > Signed-off-by: Marc Zyngier > --- >

Re: [PATCH v2 04/21] arm64: KVM: Skip HYP setup when already running in HYP

2016-02-01 Thread Christoffer Dall
On Mon, Jan 25, 2016 at 03:53:38PM +, Marc Zyngier wrote: > With the kernel running at EL2, there is no point trying to > configure page tables for HYP, as the kernel is already mapped. > > Take this opportunity to refactor the whole init a bit, allowing > the various parts of the hypervisor

Re: [PATCH v2 06/21] arm64: KVM: VHE: Patch out use of HVC

2016-02-01 Thread Marc Zyngier
On 01/02/16 15:36, Catalin Marinas wrote: > On Mon, Feb 01, 2016 at 01:34:16PM +, Marc Zyngier wrote: >> On 01/02/16 13:16, Christoffer Dall wrote: >>> On Mon, Jan 25, 2016 at 03:53:40PM +, Marc Zyngier wrote: diff --git a/arch/arm64/kvm/hyp/hyp-entry.S

Re: [PATCH v2 06/21] arm64: KVM: VHE: Patch out use of HVC

2016-02-01 Thread Ard Biesheuvel
On 1 February 2016 at 17:20, Marc Zyngier wrote: > On 01/02/16 15:36, Catalin Marinas wrote: >> On Mon, Feb 01, 2016 at 01:34:16PM +, Marc Zyngier wrote: >>> On 01/02/16 13:16, Christoffer Dall wrote: On Mon, Jan 25, 2016 at 03:53:40PM +, Marc Zyngier wrote: