From: Antonios Motakis <[email protected]> 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 <[email protected]> --- driver/main.c | 16 ++++++++++++++-- hypervisor/arch/arm/include/asm/jailhouse_hypercall.h | 1 + hypervisor/arch/x86/include/asm/jailhouse_hypercall.h | 3 ++- hypervisor/setup.c | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/driver/main.c b/driver/main.c index 39ab794..ec184af 100644 --- a/driver/main.c +++ b/driver/main.c @@ -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); diff --git a/hypervisor/arch/arm/include/asm/jailhouse_hypercall.h b/hypervisor/arch/arm/include/asm/jailhouse_hypercall.h index 480f487..45e7a3d 100644 --- a/hypervisor/arch/arm/include/asm/jailhouse_hypercall.h +++ b/hypervisor/arch/arm/include/asm/jailhouse_hypercall.h @@ -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" diff --git a/hypervisor/arch/x86/include/asm/jailhouse_hypercall.h b/hypervisor/arch/x86/include/asm/jailhouse_hypercall.h index fe5f5d5..90b8cb7 100644 --- a/hypervisor/arch/x86/include/asm/jailhouse_hypercall.h +++ b/hypervisor/arch/x86/include/asm/jailhouse_hypercall.h @@ -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, diff --git a/hypervisor/setup.c b/hypervisor/setup.c index 98b6d85..4fb61a7 100644 --- a/hypervisor/setup.c +++ b/hypervisor/setup.c @@ -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, }; -- 2.8.0.rc3 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
