]> git.ipfire.org Git - people/arne_f/kernel.git/commit
arm64: KVM: Do not use pgd_index to index stage-2 pgd
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 10 Mar 2015 19:07:00 +0000 (19:07 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jul 2015 17:38:00 +0000 (10:38 -0700)
commitec86d15103a9b73c5f1decd2ea7bc12efecaa3c0
treea0269f200913c592dc1a249cd33fe02b360b78cd
parent3ef8d0f1fbf99155d6167d279b38c4bd8ed6c73f
arm64: KVM: Do not use pgd_index to index stage-2 pgd

commit 04b8dc85bf4a64517e3cf20e409eeaa503b15cc1 upstream.

[Since we don't backport commit c647355 (KVM: arm: Add initial dirty page
locking support) for linux-3.14.y, there is no stage2_wp_range in
arch/arm/kvm/mmu.c. So ignore the change in stage2_wp_range introduced
by this patch.]

The kernel's pgd_index macro is designed to index a normal, page
sized array. KVM is a bit diffferent, as we can use concatenated
pages to have a bigger address space (for example 40bit IPA with
4kB pages gives us an 8kB PGD.

In the above case, the use of pgd_index will always return an index
inside the first 4kB, which makes a guest that has memory above
0x8000000000 rather unhappy, as it spins forever in a page fault,
whist the host happilly corrupts the lower pgd.

The obvious fix is to get our own kvm_pgd_index that does the right
thing(tm).

Tested on X-Gene with a hacked kvmtool that put memory at a stupidly
high address.

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm/include/asm/kvm_mmu.h
arch/arm/kvm/mmu.c
arch/arm64/include/asm/kvm_mmu.h