[PATCH] updated: arm64: KVM: vgic: deal with GIC sub-page alignment

2016-06-30 Thread Itaru Kitayama
This is merely an update to the patch Marc posted in 2014: https://lists.cs.columbia.edu/pipermail/kvmarm/2014-June/010055.html This updated patch is against today's current kvmarm git tree tag, kvm-for-arm-v4.7-rc6. The GIC CPU interface is always 4k aligned. If the host is using 64k pages,

[PATCH v2 07/18] arm64: KVM: Refactor kern_hyp_va to deal with multiple offsets

2016-06-30 Thread Marc Zyngier
As we move towards a selectable HYP VA range, it is obvious that we don't want to test a variable to find out if we need to use the bottom VA range, the top VA range, or use the address as is (for VHE). Instead, we can expand our current helper to generate the right mask or nop with code

[PATCH v2 04/18] arm64: KVM: Kill HYP_PAGE_OFFSET

2016-06-30 Thread Marc Zyngier
HYP_PAGE_OFFSET is not massively useful. And the way we use it in KERN_HYP_VA is inconsistent with the equivalent operation in EL2, where we use a mask instead. Let's replace the uses of HYP_PAGE_OFFSET with HYP_PAGE_OFFSET_MASK, and get rid of the pointless macro. Signed-off-by: Marc Zyngier

[PATCH v2 00/18] arm/arm64: KVM: Merge boot and runtime page tables

2016-06-30 Thread Marc Zyngier
Until now, we've been setting up KVM using two sets of page tables: one for the "boot" where we perform the basic MMU setup, and one for the runtime. Switching between the two was though to be safe, but we've recently realized that it is not: it is not enough to ensure that the VA->PA mapping is

[PATCH v2 14/18] arm: KVM: Simplify HYP init

2016-06-30 Thread Marc Zyngier
Just like for arm64, we can now make the HYP setup a lot simpler, and we can now initialise it in one go (instead of the two phases we currently have). Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_host.h | 15 + arch/arm/kvm/init.S | 49

[PATCH v2 08/18] arm/arm64: KVM: Export __hyp_text_start/end symbols

2016-06-30 Thread Marc Zyngier
Declare the __hyp_text_start/end symbols in asm/virt.h so that they can be reused without having to declare them locally. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/virt.h | 4 arch/arm/kvm/mmu.c| 2 -- arch/arm64/include/asm/virt.h | 4 3

[PATCH v2 17/18] arm/arm64: KVM: Check that IDMAP doesn't intersect with VA range

2016-06-30 Thread Marc Zyngier
This is more of a safety measure than anything else: If we end-up with an idmap page that intersect with the range picked for the the HYP VA space, abort the KVM setup, as it is unsafe to go further. I cannot imagine it happening on 64bit (we have a mechanism to work around it), but could

[PATCH v2 18/18] arm/arm64: Get rid of KERN_TO_HYP

2016-06-30 Thread Marc Zyngier
We have both KERN_TO_HYP and kern_hyp_va, which do the exact same thing. Let's standardize on the latter. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_hyp.h | 2 -- arch/arm/include/asm/kvm_mmu.h | 2 +- arch/arm/kvm/mmu.c | 18

[PATCH v2 03/18] arm/arm64: KVM: Remove hyp_kern_va helper

2016-06-30 Thread Marc Zyngier
hyp_kern_va is now completely unused, so let's remove it entirely. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_hyp.h | 1 - arch/arm64/include/asm/kvm_hyp.h | 12 2 files changed, 13 deletions(-) diff --git a/arch/arm/include/asm/kvm_hyp.h

[PATCH v2 02/18] arm64: KVM: Always reference __hyp_panic_string via its kernel VA

2016-06-30 Thread Marc Zyngier
__hyp_panic_string is passed via the HYP panic code to the panic function, and is being "upgraded" to a kernel address, as it is referenced by the HYP code (in a PC-relative way). This is a bit silly, and we'd be better off obtaining the kernel address and not mess with it at all. This patch

[PATCH v2 09/18] arm64: KVM: Runtime detection of lower HYP offset

2016-06-30 Thread Marc Zyngier
Add the code that enables the switch to the lower HYP VA range. Signed-off-by: Marc Zyngier --- arch/arm64/kernel/cpufeature.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index

[PATCH v2 06/18] arm64: KVM: Define HYP offset masks

2016-06-30 Thread Marc Zyngier
Define the two possible HYP VA regions in terms of VA_BITS, and keep HYP_PAGE_OFFSET_MASK as a temporary compatibility definition. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_mmu.h | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git

[PATCH v2 10/18] arm/arm64: KVM: Always have merged page tables

2016-06-30 Thread Marc Zyngier
We're in a position where we can now always have "merged" page tables, where both the runtime mapping and the idmap coexist. This results in some code being removed, but there is more to come. Signed-off-by: Marc Zyngier --- arch/arm/kvm/mmu.c | 74

[PATCH v2 12/18] arm/arm64: KVM: Drop boot_pgd

2016-06-30 Thread Marc Zyngier
Since we now only have one set of page tables, the concept of boot_pgd is useless and can be removed. We still keep it as an element of the "extended idmap" thing. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_host.h | 8 +++-

[PATCH v2 13/18] arm/arm64: KVM: Kill free_boot_hyp_pgd

2016-06-30 Thread Marc Zyngier
There is no way to free the boot PGD, because it doesn't exist anymore as a standalone entity. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_mmu.h | 1 - arch/arm/kvm/arm.c | 4 arch/arm/kvm/mmu.c | 30

[PATCH v2 01/18] arm64: KVM: Merged page tables documentation

2016-06-30 Thread Marc Zyngier
Since dealing with VA ranges tends to hurt my brain badly, let's start with a bit of documentation that will hopefully help understanding what comes next... Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_mmu.h | 40 +--- 1

[PATCH v2 11/18] arm64: KVM: Simplify HYP init/teardown

2016-06-30 Thread Marc Zyngier
Now that we only have the "merged page tables" case to deal with, there is a bunch of things we can simplify in the HYP code (both at init and teardown time). Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 12 ++-- arch/arm64/kvm/hyp-init.S

[PATCH v2 16/18] arm/arm64: KVM: Prune unused #defines

2016-06-30 Thread Marc Zyngier
We can now remove a number of dead #defines, thanks to the trampoline code being gone. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_mmu.h | 9 - arch/arm64/include/asm/kvm_mmu.h | 10 -- 2 files changed, 19 deletions(-) diff --git

[PATCH v2 15/18] arm: KVM: Allow hyp teardown

2016-06-30 Thread Marc Zyngier
So far, KVM was getting in the way of kexec on 32bit (and the arm64 kexec hackers couldn't be bothered to fix it on 32bit...). With simpler page tables, tearing KVM down becomes very easy, so let's just do it. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/kvm_asm.h

Re: [PATCH v7 02/17] KVM: arm/arm64: check return value for kvm_register_vgic_device

2016-06-30 Thread Andre Przywara
Hi, On 29/06/16 16:59, Auger Eric wrote: > > > On 28/06/2016 14:32, Andre Przywara wrote: >> kvm_register_device_ops() can return an error, so lets check its return > returned >> value and propagate this up the call chain. >> >> Signed-off-by: Andre Przywara >> --- >>

Re: [PATCH v7 06/17] KVM: arm/arm64: VGIC: add refcounting for IRQs

2016-06-30 Thread Andre Przywara
Hi Eric, thanks for going through the mes^Wpatches! On 29/06/16 16:58, Auger Eric wrote: > Hi Andre, > > On 28/06/2016 14:32, Andre Przywara wrote: >> In the moment our struct vgic_irq's are statically allocated at guest >> creation time. So getting a pointer to an IRQ structure is trivial and

[PULL 0/2] KVM/ARM Fixes for v4.7-rc6

2016-06-30 Thread Christoffer Dall
Hi Paolo and Radim, Please pull two small fixes for KVM/ARM for rc6 or as soon as it can make it: They fix a build issue without CONFIG_ARM_PMU and plugs pid leak on arm/arm64. Thanks, -Christoffer The following changes since commit a0052191624e9bf8a8f9dc41b92ab5f252566c3c: kvm: vmx: check

[PULL 2/2] KVM: arm/arm64: Stop leaking vcpu pid references

2016-06-30 Thread Christoffer Dall
From: James Morse kvm provides kvm_vcpu_uninit(), which amongst other things, releases the last reference to the struct pid of the task that was last running the vcpu. On arm64 built with CONFIG_DEBUG_KMEMLEAK, starting a guest with kvmtool, then killing it with SIGKILL

[PULL 1/2] arm64: KVM: fix build with CONFIG_ARM_PMU disabled

2016-06-30 Thread Christoffer Dall
From: Sudeep Holla When CONFIG_ARM_PMU is disabled, we get the following build error: arch/arm64/kvm/sys_regs.c: In function 'pmu_counter_idx_valid': arch/arm64/kvm/sys_regs.c:564:27: error: 'ARMV8_PMU_CYCLE_IDX' undeclared (first use in this function) if (idx >= val &&

Re: [PATCH 09/15] arm64: KVM: Simplify HYP init/teardown

2016-06-30 Thread Christoffer Dall
On Thu, Jun 30, 2016 at 01:10:33PM +0100, Marc Zyngier wrote: > On 28/06/16 22:31, Christoffer Dall wrote: > > On Tue, Jun 07, 2016 at 11:58:29AM +0100, Marc Zyngier wrote: > >> Now that we only have the "merged page tables" case to deal with, > >> there is a bunch of things we can simplify in the

Re: [PATCH 08/15] arm/arm64: KVM: Always have merged page tables

2016-06-30 Thread Christoffer Dall
On Thu, Jun 30, 2016 at 01:27:05PM +0100, Marc Zyngier wrote: > On 28/06/16 22:43, Christoffer Dall wrote: > > On Tue, Jun 07, 2016 at 11:58:28AM +0100, Marc Zyngier wrote: > >> We're in a position where we can now always have "merged" page > >> tables, where both the runtime mapping and the idmap

Re: [PATCH 15/15] arm/arm64: KVM: Check that IDMAP doesn't intersect with VA range

2016-06-30 Thread Christoffer Dall
On Thu, Jun 30, 2016 at 01:51:00PM +0100, Marc Zyngier wrote: > On 28/06/16 23:01, Christoffer Dall wrote: > > On Tue, Jun 07, 2016 at 11:58:35AM +0100, Marc Zyngier wrote: > >> This is more of a safety measure than anything else: If we end-up > >> with an idmap page that intersect with the range

Re: [PATCH 15/15] arm/arm64: KVM: Check that IDMAP doesn't intersect with VA range

2016-06-30 Thread Marc Zyngier
On 28/06/16 23:01, Christoffer Dall wrote: > On Tue, Jun 07, 2016 at 11:58:35AM +0100, Marc Zyngier wrote: >> This is more of a safety measure than anything else: If we end-up >> with an idmap page that intersect with the range picked for the >> the HYP VA space, abort the KVM setup, as it is

Re: [PATCH 12/15] arm: KVM: Simplify HYP init

2016-06-30 Thread Marc Zyngier
On 28/06/16 22:50, Christoffer Dall wrote: > On Tue, Jun 07, 2016 at 11:58:32AM +0100, Marc Zyngier wrote: >> Just like for arm64, we can now make the HYP setup a lot simpler, >> and we can now initialise it in one go (instead of the two >> phases we currently have). >> >> Signed-off-by: Marc

Re: [PATCH 08/15] arm/arm64: KVM: Always have merged page tables

2016-06-30 Thread Marc Zyngier
On 28/06/16 22:43, Christoffer Dall wrote: > On Tue, Jun 07, 2016 at 11:58:28AM +0100, Marc Zyngier wrote: >> We're in a position where we can now always have "merged" page >> tables, where both the runtime mapping and the idmap coexist. >> >> This results in some code being removed, but there is

Re: [PATCH 09/15] arm64: KVM: Simplify HYP init/teardown

2016-06-30 Thread Marc Zyngier
On 28/06/16 22:31, Christoffer Dall wrote: > On Tue, Jun 07, 2016 at 11:58:29AM +0100, Marc Zyngier wrote: >> Now that we only have the "merged page tables" case to deal with, >> there is a bunch of things we can simplify in the HYP code (both >> at init and teardown time). >> >> Signed-off-by:

Re: [PATCH v7 00/17] KVM: arm64: GICv3 ITS emulation

2016-06-30 Thread Auger Eric
Hi, On 30/06/2016 13:40, Andrew Jones wrote: > On Thu, Jun 30, 2016 at 11:09:30AM +0100, Andre Przywara wrote: >> Hi, >> >> On 29/06/16 05:43, Bharat Bhushan wrote: >>> >>> -Original Message- From: kvmarm-boun...@lists.cs.columbia.edu [mailto:kvmarm-

Re: [PATCH 05/15] arm64: KVM: Refactor kern_hyp_va/hyp_kern_va to deal with multiple offsets

2016-06-30 Thread Marc Zyngier
On 30/06/16 12:10, Ard Biesheuvel wrote: > On 30 June 2016 at 13:02, Marc Zyngier wrote: >> On 30/06/16 11:42, Ard Biesheuvel wrote: >>> On 30 June 2016 at 12:16, Marc Zyngier wrote: On 30/06/16 10:22, Marc Zyngier wrote: > On 28/06/16 13:42,

Re: [PATCH v7 00/17] KVM: arm64: GICv3 ITS emulation

2016-06-30 Thread Andrew Jones
On Thu, Jun 30, 2016 at 11:09:30AM +0100, Andre Przywara wrote: > Hi, > > On 29/06/16 05:43, Bharat Bhushan wrote: > > > > > >> -Original Message- > >> From: kvmarm-boun...@lists.cs.columbia.edu [mailto:kvmarm- > >> boun...@lists.cs.columbia.edu] On Behalf Of Andre Przywara > >> Sent:

Re: [PATCH v7 15/17] KVM: arm64: implement ITS command queue command handlers

2016-06-30 Thread Diana Madalina Craciun
Hi Andre, On 06/28/2016 03:32 PM, Andre Przywara wrote: > The connection between a device, an event ID, the LPI number and the > allocated CPU is stored in in-memory tables in a GICv3, but their > format is not specified by the spec. Instead software uses a command > queue in a ring buffer to let

Re: [PATCH 05/15] arm64: KVM: Refactor kern_hyp_va/hyp_kern_va to deal with multiple offsets

2016-06-30 Thread Ard Biesheuvel
On 30 June 2016 at 13:02, Marc Zyngier wrote: > On 30/06/16 11:42, Ard Biesheuvel wrote: >> On 30 June 2016 at 12:16, Marc Zyngier wrote: >>> On 30/06/16 10:22, Marc Zyngier wrote: On 28/06/16 13:42, Christoffer Dall wrote: > On Tue, Jun 07,

Re: [PATCH 05/15] arm64: KVM: Refactor kern_hyp_va/hyp_kern_va to deal with multiple offsets

2016-06-30 Thread Marc Zyngier
On 30/06/16 11:42, Ard Biesheuvel wrote: > On 30 June 2016 at 12:16, Marc Zyngier wrote: >> On 30/06/16 10:22, Marc Zyngier wrote: >>> On 28/06/16 13:42, Christoffer Dall wrote: On Tue, Jun 07, 2016 at 11:58:25AM +0100, Marc Zyngier wrote: > As we move towards a

Re: [PATCH 05/15] arm64: KVM: Refactor kern_hyp_va/hyp_kern_va to deal with multiple offsets

2016-06-30 Thread Ard Biesheuvel
On 30 June 2016 at 12:16, Marc Zyngier wrote: > On 30/06/16 10:22, Marc Zyngier wrote: >> On 28/06/16 13:42, Christoffer Dall wrote: >>> On Tue, Jun 07, 2016 at 11:58:25AM +0100, Marc Zyngier wrote: As we move towards a selectable HYP VA range, it is obvious that

Re: [PATCH 05/15] arm64: KVM: Refactor kern_hyp_va/hyp_kern_va to deal with multiple offsets

2016-06-30 Thread Christoffer Dall
On Thu, Jun 30, 2016 at 11:16:44AM +0100, Marc Zyngier wrote: > On 30/06/16 10:22, Marc Zyngier wrote: > > On 28/06/16 13:42, Christoffer Dall wrote: > >> On Tue, Jun 07, 2016 at 11:58:25AM +0100, Marc Zyngier wrote: > >>> As we move towards a selectable HYP VA range, it is obvious that > >>> we

Re: [PATCH 05/15] arm64: KVM: Refactor kern_hyp_va/hyp_kern_va to deal with multiple offsets

2016-06-30 Thread Marc Zyngier
On 30/06/16 10:22, Marc Zyngier wrote: > On 28/06/16 13:42, Christoffer Dall wrote: >> On Tue, Jun 07, 2016 at 11:58:25AM +0100, Marc Zyngier wrote: >>> As we move towards a selectable HYP VA range, it is obvious that >>> we don't want to test a variable to find out if we need to use >>> the

Re: [PATCH v7 00/17] KVM: arm64: GICv3 ITS emulation

2016-06-30 Thread Andre Przywara
Hi, On 29/06/16 05:43, Bharat Bhushan wrote: > > >> -Original Message- >> From: kvmarm-boun...@lists.cs.columbia.edu [mailto:kvmarm- >> boun...@lists.cs.columbia.edu] On Behalf Of Andre Przywara >> Sent: Tuesday, June 28, 2016 6:02 PM >> To: Marc Zyngier ;

Re: [PATCH 05/15] arm64: KVM: Refactor kern_hyp_va/hyp_kern_va to deal with multiple offsets

2016-06-30 Thread Marc Zyngier
On 28/06/16 13:42, Christoffer Dall wrote: > On Tue, Jun 07, 2016 at 11:58:25AM +0100, Marc Zyngier wrote: >> As we move towards a selectable HYP VA range, it is obvious that >> we don't want to test a variable to find out if we need to use >> the bottom VA range, the top VA range, or use the