diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2015-03-10 22:07:00 +0300 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2015-04-30 12:15:15 +0300 |
commit | e83df6dec91f5e7d83bf1722d50c9642b09c2307 (patch) | |
tree | e5d039f70b0fb63e6dcaf9e05502e1aea9f3a380 /arch/arm64/include | |
parent | d54c7a6d9f014e83e8e99fcc241f83537ffa4618 (diff) | |
download | linux-e83df6dec91f5e7d83bf1722d50c9642b09c2307.tar.xz |
arm64: KVM: Do not use pgd_index to index stage-2 pgd
commit 04b8dc85bf4a64517e3cf20e409eeaa503b15cc1 upstream.
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: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'arch/arm64/include')
-rw-r--r-- | arch/arm64/include/asm/kvm_mmu.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 6e127e7ca687..0c661b823576 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -106,6 +106,8 @@ static inline void kvm_set_s2pte_writable(pte_t *pte) #define kvm_pud_addr_end(addr, end) pud_addr_end(addr, end) #define kvm_pmd_addr_end(addr, end) pmd_addr_end(addr, end) +#define kvm_pgd_index(addr) (((addr) >> PGDIR_SHIFT) & (PTRS_PER_S2_PGD - 1)) + static inline bool kvm_page_empty(void *ptr) { struct page *ptr_page = virt_to_page(ptr); |