]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core/driver: Switch hypervisor to fixed virtual address layout
authorJan Kiszka <jan.kiszka@siemens.com>
Thu, 30 Jan 2014 11:16:55 +0000 (12:16 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Tue, 4 Feb 2014 17:05:15 +0000 (18:05 +0100)
Now that the driver always puts us at the same virtual address, we can
compile this into the hypervisor as well. On x86, we switch to the code
model "kernel", i.e. all virtual addresses have the higher 32 bits set.
This allows to drop -fpic and -fpie, the global offset table. And the
entry field in the header is now absolute.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/Makefile
hypervisor/arch/arm/include/asm/jailhouse_hypercall.h
hypervisor/arch/x86/apic.c
hypervisor/arch/x86/entry.S
hypervisor/arch/x86/include/asm/jailhouse_hypercall.h
hypervisor/hypervisor.lds.S
hypervisor/include/jailhouse/entry.h
hypervisor/include/jailhouse/header.h
hypervisor/setup.c
main.c

index 2b369308be361d334552e646b2987c9fc62a2122..97f30de9d4e38cd14b1a1dee362a93d65cf4bc08 100644 (file)
 LINUXINCLUDE := -I$(src)/arch/$(SRCARCH)/include -I$(src)/include
 KBUILD_CFLAGS := -g -Os -Wall -Wstrict-prototypes -Wtype-limits \
                 -Wmissing-declarations -Wmissing-prototypes \
-                -fno-strict-aliasing -fpic -fpie -fno-common \
+                -fno-strict-aliasing -fno-pic -fno-common \
                 -fno-stack-protector
+
+ifeq ($(SRCARCH),x86)
+KBUILD_CFLAGS += -mcmodel=kernel
+endif
+
 ifneq ($(wildcard $(src)/include/jailhouse/config.h),)
 KBUILD_CFLAGS += -include $(src)/include/jailhouse/config.h
 endif
index 2a24b98f3d3583803c171f1831ba01613e5d3137..f216604b5e49b4298eb66da5ff71d3228b38372d 100644 (file)
@@ -10,6 +10,8 @@
  * the COPYING file in the top-level directory.
  */
 
+#define JAILHOUSE_BASE                 0xf0000000
+
 #define JAILHOUSE_CALL_INS             ".arch_extension virt\n\t" \
                                        "hvc #0x4a48"
 #define JAILHOUSE_CALL_NUM_RESULT      "r0"
@@ -22,6 +24,8 @@
 #define __asmeq(x, y)  ".ifnc " x "," y " ; .err ; .endif\n\t"
 #endif
 
+#ifndef __ASSEMBLY__
+
 static inline __u32 jailhouse_call0(__u32 num)
 {
        register __u32 num_result asm(JAILHOUSE_CALL_NUM_RESULT) = num;
@@ -134,3 +138,5 @@ jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region,
        asm volatile("dmb ishst" : : : "memory");
        comm_region->reply_from_cell = reply;
 }
+
+#endif /* !__ASSEMBLY__ */
index 9c2a9c8168496308d982863cb3a3b1770f60a080..67a54dd6e68a5278c08b73fe374aa9ac6b789e80 100644 (file)
@@ -120,7 +120,6 @@ int apic_init(void)
        int err;
 
        if (apicbase & APIC_BASE_EXTD) {
-               /* set programmatically to enable address fixup */
                apic_ops.read = read_x2apic;
                apic_ops.read_id = read_x2apic_id;
                apic_ops.write = write_x2apic;
index bca462c9064946513a347afd4d3d0b66b503378a..7c86535c7d4f00ac405546aee4bec99b69e27e58 100644 (file)
@@ -53,25 +53,6 @@ arch_entry:
        ret
 
 
-/* Fix up Global Offset Table with absolute hypervisor address */
-       .globl got_init
-got_init:
-       lea __got_start(%rip),%rdx
-       lea __got_end(%rip),%rcx
-       lea hypervisor_header(%rip),%rax
-
-got_loop:
-       cmp %rdx,%rcx
-       je got_done
-
-       add %rax,(%rdx)
-       add $8,%rdx
-       jmp got_loop
-
-got_done:
-       ret
-
-
 /* Exception/interrupt entry points */
 .macro common_exception_entry vector
        pushq $\vector
index 298d5df8507d6ae38cbf2f55e7c4ee1f6f94ef33..5e148c81c49d8e669383677cb2a9821e868e22b3 100644 (file)
@@ -14,6 +14,8 @@
 #error 64-bit kernel required!
 #endif
 
+#define JAILHOUSE_BASE         0xfffffffff0000000
+
 #define JAILHOUSE_CALL_INS     "vmcall"
 #define JAILHOUSE_CALL_RESULT  "=a" (result)
 #define JAILHOUSE_CALL_NUM     "a" (num)
@@ -22,6 +24,8 @@
 #define JAILHOUSE_CALL_ARG3    "d" (arg3)
 #define JAILHOUSE_CALL_ARG4    "c" (arg4)
 
+#ifndef __ASSEMBLY__
+
 static inline __u32 jailhouse_call0(__u32 num)
 {
        __u32 result;
@@ -100,3 +104,5 @@ jailhouse_send_reply_from_cell(struct jailhouse_comm_region *comm_region,
        asm volatile("mfence" : : : "memory");
        comm_region->reply_from_cell = reply;
 }
+
+#endif /* !__ASSEMBLY__ */
index 53c46072469e22fa33aa6f10067eeea7554a32e3..bd4681d9e0dbfa6211cbf806aec7d64b3edf5ff3 100644 (file)
  */
 
 #include <asm/paging.h>
+#include <asm/jailhouse_hypercall.h>
 
 SECTIONS
 {
-       . = 0;
+       . = JAILHOUSE_BASE;
        .header         : { *(.header) }
 
        . = ALIGN(16);
@@ -27,12 +28,6 @@ SECTIONS
        . = ALIGN(16);
        .data           : { *(.data) }
 
-       .got            : {
-               __got_start = .;
-               *(.got*)
-               __got_end = .;
-       }
-
        . = ALIGN(16);
        .bss            : { *(.bss) }
        __hv_core_end = .;
index 0c8f3654862f2aa8a24a5e43352a906518277c8c..252c35a7d2af02b27291e40c565c556303c62df0 100644 (file)
@@ -33,8 +33,7 @@
 extern struct jailhouse_header hypervisor_header;
 extern void *config_memory;
 
-int arch_entry(int cpu_id);
-void got_init(void);
+int arch_entry(unsigned int cpu_id);
 void vm_exit(void);
 
 int entry(struct per_cpu *cpu_data);
index debc6539a15a4b4959e08c6036790c9d58360821..782737ce6eac3eafca39c4484658cee9ffb3141b 100644 (file)
@@ -17,7 +17,7 @@ struct jailhouse_header {
        char signature[8];
        unsigned long core_size;
        unsigned long percpu_size;
-       unsigned long entry;
+       int (*entry)(unsigned int);
 
        /* filled by loader */
        unsigned long size;
@@ -25,5 +25,3 @@ struct jailhouse_header {
        unsigned int possible_cpus;
        unsigned int online_cpus;
 };
-
-typedef int (*entry_func)(unsigned int);
index 9de67255d500de6fbdc9cb2ae0a026a24f77cef8..65261a27e5ba7940a1d58b02c44026032a142eec 100644 (file)
@@ -52,9 +52,6 @@ static void init_early(unsigned int cpu_id)
 
        master_cpu_id = cpu_id;
 
-       /* must be first, printk/arch_dbg_write uses the GOT */
-       got_init();
-
        arch_dbg_write_init();
 
        printk("\nInitializing Jailhouse hypervisor on CPU %d\n", cpu_id);
@@ -197,7 +194,7 @@ int entry(struct per_cpu *cpu_data)
 struct jailhouse_header __attribute__((section(".header")))
 hypervisor_header = {
        .signature = JAILHOUSE_SIGNATURE,
-       .core_size = (unsigned long)__hv_core_end,
+       .core_size = (unsigned long)__hv_core_end - JAILHOUSE_BASE,
        .percpu_size = sizeof(struct per_cpu),
-       .entry = (unsigned long)arch_entry,
+       .entry = arch_entry,
 };
diff --git a/main.c b/main.c
index 76b4857bb1358a8a37379edf1953715ddaa3c720..20f2d6177f07c6cbc4711246820afdce4dffaa76 100644 (file)
--- a/main.c
+++ b/main.c
@@ -59,14 +59,6 @@ cell_cpumask_next(int n, const struct jailhouse_cell_desc *config)
             (cpu) = cell_cpumask_next((cpu), (config)),        \
             (cpu) < (config)->cpu_set_size * 8;)
 
-#ifdef CONFIG_X86
-#define JAILHOUSE_BASE         0xfffffffff0000000
-#elif defined(CONFIG_ARM)
-#define JAILHOUSE_BASE         0xe0000000
-#else
-#error Unsupported architecture
-#endif
-
 static void *jailhouse_ioremap(phys_addr_t phys, unsigned long virt,
                               unsigned long size)
 {
@@ -95,13 +87,10 @@ static void *jailhouse_ioremap(phys_addr_t phys, unsigned long virt,
 static void enter_hypervisor(void *info)
 {
        struct jailhouse_header *header = info;
-       entry_func entry;
        int err;
 
-       entry = (entry_func)(hypervisor_mem + header->entry);
-
        /* either returns 0 or the same error code across all CPUs */
-       err = entry(smp_processor_id());
+       err = header->entry(smp_processor_id());
        if (err)
                error_code = err;