arm64: KVM: Map the kernel RO section into HYP
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 27 Oct 2015 12:18:48 +0000 (12:18 +0000)
committerMarc Zyngier <marc.zyngier@arm.com>
Mon, 14 Dec 2015 11:30:43 +0000 (11:30 +0000)
In order to run C code in HYP, we must make sure that the kernel's
RO section is mapped into HYP (otherwise things break badly).

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
arch/arm/kvm/arm.c

index 8a79a572948729be3c0d15867cc6f534914c9b2f..6e35d1d7893ed31c86bfe9ee62f7b9266055a921 100644 (file)
@@ -44,6 +44,7 @@
 #include <asm/kvm_emulate.h>
 #include <asm/kvm_coproc.h>
 #include <asm/kvm_psci.h>
+#include <asm/sections.h>
 
 #ifdef REQUIRES_VIRT
 __asm__(".arch_extension       virt");
@@ -1068,6 +1069,12 @@ static int init_hyp_mode(void)
                goto out_free_mappings;
        }
 
+       err = create_hyp_mappings(__start_rodata, __end_rodata);
+       if (err) {
+               kvm_err("Cannot map rodata section\n");
+               goto out_free_mappings;
+       }
+
        /*
         * Map the Hyp stack pages
         */