]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
driver: ioremap the hypervisor firmware to any kernel address
authorAntonios Motakis <antonios.motakis@huawei.com>
Fri, 17 Jun 2016 12:37:29 +0000 (14:37 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Sun, 26 Jun 2016 07:16:27 +0000 (09:16 +0200)
At the moment the Linux driver maps the Jailhouse binary to
JAILHOUSE_BASE. The underlying assumption is that Linux may map the
firmware (in the Linux kernel space), to the same virtual address it
has been built to run from.

This assumption is unworkable on ARMv8 processors running in AArch64
mode. Kernel memory is allocated in a high address region, that is
not addressable from EL2, where the hypervisor will run from.

This patch removes the assumption, by introducing the
JAILHOUSE_BORROW_ROOT_PT define, which signals the behavior of the
current architectures.

We also turn the entry point in the header, into an offset from the
Jailhouse load address, so we can enter the image regardless of
where it  will be mapped.

Signed-off-by: Antonios Motakis <antonios.motakis@huawei.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
driver/main.c
hypervisor/arch/arm/include/asm/jailhouse_hypercall.h
hypervisor/arch/x86/include/asm/jailhouse_hypercall.h
hypervisor/setup.c

index 39ab7946cff56f13efce6ff7721a99c43a510924..ec184af32072b84a9280ea304cb79c0f7f3c6c2d 100644 (file)
@@ -139,11 +139,14 @@ static void enter_hypervisor(void *info)
 {
        struct jailhouse_header *header = info;
        unsigned int cpu = smp_processor_id();
+       int (*entry)(unsigned int);
        int err;
 
+       entry = header->entry + (unsigned long) hypervisor_mem;
+
        if (cpu < header->max_cpus)
                /* either returns 0 or the same error code across all CPUs */
-               err = header->entry(cpu);
+               err = entry(cpu);
        else
                err = -EINVAL;
 
@@ -178,6 +181,7 @@ static int jailhouse_cmd_enable(struct jailhouse_system __user *arg)
        struct jailhouse_system *config;
        struct jailhouse_memory *hv_mem = &config_header.hypervisor_memory;
        struct jailhouse_header *header;
+       unsigned long remap_addr = 0;
        void __iomem *console = NULL;
        unsigned long config_size;
        const char *fw_name;
@@ -235,7 +239,10 @@ static int jailhouse_cmd_enable(struct jailhouse_system __user *arg)
            config_size >= hv_mem->size - hv_core_and_percpu_size)
                goto error_release_fw;
 
-       hypervisor_mem = jailhouse_ioremap(hv_mem->phys_start, JAILHOUSE_BASE,
+#ifdef JAILHOUSE_BORROW_ROOT_PT
+       remap_addr = JAILHOUSE_BASE;
+#endif
+       hypervisor_mem = jailhouse_ioremap(hv_mem->phys_start, remap_addr,
                                           hv_mem->size);
        if (!hypervisor_mem) {
                pr_err("jailhouse: Unable to map RAM reserved for hypervisor "
@@ -258,6 +265,7 @@ static int jailhouse_cmd_enable(struct jailhouse_system __user *arg)
        }
 
        if (config->debug_console.flags & JAILHOUSE_MEM_IO) {
+#ifdef JAILHOUSE_BORROW_ROOT_PT
                console = ioremap(config->debug_console.phys_start,
                                  config->debug_console.size);
                if (!console) {
@@ -270,6 +278,10 @@ static int jailhouse_cmd_enable(struct jailhouse_system __user *arg)
                /* The hypervisor has no notion of address spaces, so we need
                 * to enforce conversion. */
                header->debug_console_base = (void * __force)console;
+#else
+               header->debug_console_base =
+                       (void * __force) config->debug_console.phys_start;
+#endif
        }
 
        err = jailhouse_cell_prepare_root(&config->root_cell);
index 480f487ed56d6f541fa8617bc0273e942dffedef..45e7a3d9ceaecc1d454bc6c1108381adf4ba6b3e 100644 (file)
@@ -37,6 +37,7 @@
  */
 
 #define JAILHOUSE_BASE                 0xf0000000
+#define JAILHOUSE_BORROW_ROOT_PT       1
 
 #define JAILHOUSE_CALL_INS             ".arch_extension virt\n\t" \
                                        "hvc #0x4a48"
index fe5f5d5bfbc8e474e4a25ec8c00b6d57cb6146da..90b8cb72a823f0c1ec33748094c61da0c0095a7e 100644 (file)
@@ -36,7 +36,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define JAILHOUSE_BASE         __MAKE_UL(0xfffffffff0000000)
+#define JAILHOUSE_BASE                 __MAKE_UL(0xfffffffff0000000)
+#define JAILHOUSE_BORROW_ROOT_PT       1
 
 /*
  * As this is never called on a CPU without VM extensions,
index 98b6d85991c5f669dc571f3d8083404e228cf7a1..4fb61a7de44d5b7a1dc9354759684cdc5b5127f8 100644 (file)
@@ -210,5 +210,5 @@ hypervisor_header = {
        .signature = JAILHOUSE_SIGNATURE,
        .core_size = (unsigned long)__page_pool - JAILHOUSE_BASE,
        .percpu_size = sizeof(struct per_cpu),
-       .entry = arch_entry,
+       .entry = arch_entry - JAILHOUSE_BASE,
 };