2 * Jailhouse, a Linux-based partitioning hypervisor
4 * Copyright (c) ARM Limited, 2014
7 * Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
13 #ifndef _JAILHOUSE_ASM_SETUP_MMU_H
14 #define _JAILHOUSE_ASM_SETUP_MMU_H
17 #include <asm/percpu.h>
21 /* Procedures used to translate addresses during the MMU setup process */
22 typedef void* (*phys2virt_t)(unsigned long);
23 typedef unsigned long (*virt2phys_t)(volatile const void *);
25 static void __attribute__((naked)) __attribute__((noinline))
26 cpu_switch_el2(unsigned long phys_bootstrap, virt2phys_t virt2phys)
30 * The linux hyp stub allows to install the vectors with a
31 * single hvc. The vector base address is in r0
37 * Now that the bootstrap vectors are installed, call setup_el2
38 * with the translated physical values of lr and sp as
53 * The call to virt2phys may clobber all temp registers. This
54 * list ensures that the compiler uses a decent register for
57 : "cc", "memory", "r0", "r1", "r2", "r3");
60 static inline void __attribute__((always_inline))
61 cpu_switch_phys2virt(phys2virt_t phys2virt)
63 /* phys2virt is allowed to touch the stack */
69 /* Translate phys_sp */
72 /* Jump back to virtual addresses */
77 : "cc", "r0", "r1", "r2", "r3", "lr", "sp");
80 #endif /* !__ASSEMBLY__ */
81 #endif /* _JAILHOUSE_ASM_SETUP_MMU_H */