From: Antonios Motakis <[email protected]> Enable the MMU mappings for the hypervisor running in EL2, and add functions to map device regions to the hypervisor address space.
Signed-off-by: Antonios Motakis <[email protected]> --- hypervisor/arch/arm64/include/asm/setup.h | 29 +++++++++++++++++++++++++++++ hypervisor/arch/arm64/setup.c | 25 ++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 hypervisor/arch/arm64/include/asm/setup.h diff --git a/hypervisor/arch/arm64/include/asm/setup.h b/hypervisor/arch/arm64/include/asm/setup.h new file mode 100644 index 0000000..a2d1930 --- /dev/null +++ b/hypervisor/arch/arm64/include/asm/setup.h @@ -0,0 +1,29 @@ +/* + * Jailhouse AArch64 support + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * + * Authors: + * Antonios Motakis <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#ifndef _JAILHOUSE_ASM_SETUP_H +#define _JAILHOUSE_ASM_SETUP_H + +#include <asm/head.h> +#include <asm/percpu.h> + +#ifndef __ASSEMBLY__ + +#include <jailhouse/string.h> + +void enable_mmu_el2(page_table_t ttbr0_el2); + +int arch_map_device(void *paddr, void *vaddr, unsigned long size); +int arch_unmap_device(void *addr, unsigned long size); + +#endif /* !__ASSEMBLY__ */ +#endif /* !_JAILHOUSE_ASM_SETUP_H */ diff --git a/hypervisor/arch/arm64/setup.c b/hypervisor/arch/arm64/setup.c index ca83940..13e6387 100644 --- a/hypervisor/arch/arm64/setup.c +++ b/hypervisor/arch/arm64/setup.c @@ -12,20 +12,25 @@ #include <jailhouse/entry.h> #include <jailhouse/printk.h> +#include <asm/control.h> +#include <asm/setup.h> int arch_init_early(void) { - return trace_error(-EINVAL); + return arch_mmu_cell_init(&root_cell); } int arch_cpu_init(struct per_cpu *cpu_data) { - return trace_error(-EINVAL); + /* switch to the permanent page tables */ + enable_mmu_el2(hv_paging_structs.root_table); + + return arch_mmu_cpu_cell_init(cpu_data); } int arch_init_late(void) { - return trace_error(-EINVAL); + return map_root_memory_regions(); } void __attribute__((noreturn)) arch_cpu_activate_vmm(struct per_cpu *cpu_data) @@ -34,6 +39,20 @@ void __attribute__((noreturn)) arch_cpu_activate_vmm(struct per_cpu *cpu_data) while (1); } +int arch_map_device(void *paddr, void *vaddr, unsigned long size) +{ + return paging_create(&hv_paging_structs, (unsigned long)paddr, size, + (unsigned long)vaddr, + PAGE_DEFAULT_FLAGS | S1_PTE_FLAG_DEVICE, + PAGING_NON_COHERENT); +} + +int arch_unmap_device(void *vaddr, unsigned long size) +{ + return paging_destroy(&hv_paging_structs, (unsigned long)vaddr, size, + PAGING_NON_COHERENT); +} + void arch_cpu_restore(struct per_cpu *cpu_data, int return_code) { trace_error(-EINVAL); -- 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.
