diff options
author | Quentin Perret <qperret@google.com> | 2021-03-19 13:01:43 +0300 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2021-03-19 15:02:18 +0300 |
commit | 1025c8c0c6accfcbdc8f52ca1940160f65cd87d6 (patch) | |
tree | 847ceaf1da72de962a340ab78b963d8cb32e7eb0 /arch/arm64/kvm/hyp/nvhe/setup.c | |
parent | def1aaf9e0bc6987bb4b417aac37226e994a1a74 (diff) | |
download | linux-1025c8c0c6accfcbdc8f52ca1940160f65cd87d6.tar.xz |
KVM: arm64: Wrap the host with a stage 2
When KVM runs in protected nVHE mode, make use of a stage 2 page-table
to give the hypervisor some control over the host memory accesses. The
host stage 2 is created lazily using large block mappings if possible,
and will default to page mappings in absence of a better solution.
>From this point on, memory accesses from the host to protected memory
regions (e.g. not 'owned' by the host) are fatal and lead to hyp_panic().
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210319100146.1149909-36-qperret@google.com
Diffstat (limited to 'arch/arm64/kvm/hyp/nvhe/setup.c')
-rw-r--r-- | arch/arm64/kvm/hyp/nvhe/setup.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c index c1a3e7e0ebbc..7488f53b0aa2 100644 --- a/arch/arm64/kvm/hyp/nvhe/setup.c +++ b/arch/arm64/kvm/hyp/nvhe/setup.c @@ -12,6 +12,7 @@ #include <nvhe/early_alloc.h> #include <nvhe/gfp.h> #include <nvhe/memory.h> +#include <nvhe/mem_protect.h> #include <nvhe/mm.h> #include <nvhe/trap_handler.h> @@ -157,6 +158,10 @@ void __noreturn __pkvm_init_finalise(void) if (ret) goto out; + ret = kvm_host_prepare_stage2(host_s2_mem_pgt_base, host_s2_dev_pgt_base); + if (ret) + goto out; + pkvm_pgtable_mm_ops = (struct kvm_pgtable_mm_ops) { .zalloc_page = hyp_zalloc_hyp_page, .phys_to_virt = hyp_phys_to_virt, |