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)
committerAlex Shi <alex.shi@linaro.org>
Wed, 9 Nov 2016 14:15:47 +0000 (22:15 +0800)
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>
(cherry picked from commit 910917bb7db070cc67557a6b3c8fcceaa5c398a7)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
arch/arm/kvm/arm.c

index d7bef2144760c3f02fd5ba0efb3fafe68dd7b79c..449e312f1892344a673854547eb978b089c68a93 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");
@@ -1065,6 +1066,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
         */