diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2016-06-30 13:40:50 -0400 |
---|---|---|
committer | Christoffer Dall <christoffer.dall@linaro.org> | 2016-07-03 17:41:27 -0400 |
commit | eac378a9ceb7196b776a965d915e02995fb8ba55 (patch) | |
tree | 207965331a3cb620ebcd081ac61b1580a2a7cf90 /arch | |
parent | f7bec68d2faed8180d7172cdbd69d99e3cad1387 (diff) |
arm/arm64: KVM: Check that IDMAP doesn't intersect with VA range
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 potentially occur on a 32bit system with
the kernel loaded high enough in memory so that in conflicts with
the kernel VA.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/kvm/mmu.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 0b36dd52af62..8a0aa37605c5 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c | |||
@@ -1709,6 +1709,21 @@ int kvm_mmu_init(void) | |||
1709 | */ | 1709 | */ |
1710 | BUG_ON((hyp_idmap_start ^ (hyp_idmap_end - 1)) & PAGE_MASK); | 1710 | BUG_ON((hyp_idmap_start ^ (hyp_idmap_end - 1)) & PAGE_MASK); |
1711 | 1711 | ||
1712 | kvm_info("IDMAP page: %lx\n", hyp_idmap_start); | ||
1713 | kvm_info("HYP VA range: %lx:%lx\n", | ||
1714 | KERN_TO_HYP(PAGE_OFFSET), KERN_TO_HYP(~0UL)); | ||
1715 | |||
1716 | if (hyp_idmap_start >= KERN_TO_HYP(PAGE_OFFSET) && | ||
1717 | hyp_idmap_start < KERN_TO_HYP(~0UL)) { | ||
1718 | /* | ||
1719 | * The idmap page is intersecting with the VA space, | ||
1720 | * it is not safe to continue further. | ||
1721 | */ | ||
1722 | kvm_err("IDMAP intersecting with HYP VA, unable to continue\n"); | ||
1723 | err = -EINVAL; | ||
1724 | goto out; | ||
1725 | } | ||
1726 | |||
1712 | hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, hyp_pgd_order); | 1727 | hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, hyp_pgd_order); |
1713 | if (!hyp_pgd) { | 1728 | if (!hyp_pgd) { |
1714 | kvm_err("Hyp mode PGD not allocated\n"); | 1729 | kvm_err("Hyp mode PGD not allocated\n"); |