Skip to content

Commit

Permalink
arm: Move cpu_switch_el2 into calling module
Browse files Browse the repository at this point in the history
Uninlined functions should not be defined in headers. No functional
changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
jan-kiszka committed Jul 14, 2015
1 parent 1588b43 commit 99370e0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
35 changes: 0 additions & 35 deletions hypervisor/arch/arm/include/asm/setup_mmu.h
Expand Up @@ -22,41 +22,6 @@
typedef void* (*phys2virt_t)(unsigned long);
typedef unsigned long (*virt2phys_t)(volatile const void *);

static void __attribute__((naked)) __attribute__((noinline))
cpu_switch_el2(unsigned long phys_bootstrap, virt2phys_t virt2phys)
{
asm volatile(
/*
* The linux hyp stub allows to install the vectors with a
* single hvc. The vector base address is in r0
* (phys_bootstrap).
*/
"hvc #0\n\t"

/*
* Now that the bootstrap vectors are installed, call setup_el2
* with the translated physical values of lr and sp as
* arguments.
*/
"mov r0, sp\n\t"
"push {lr}\n\t"
"blx %0\n\t"
"pop {lr}\n\t"
"push {r0}\n\t"
"mov r0, lr\n\t"
"blx %0\n\t"
"pop {r1}\n\t"
"hvc #0\n\t"
:
: "r" (virt2phys)
/*
* The call to virt2phys may clobber all temp registers. This
* list ensures that the compiler uses a decent register for
* hvirt2phys.
*/
: "cc", "memory", "r0", "r1", "r2", "r3");
}

static inline void __attribute__((always_inline))
cpu_switch_phys2virt(phys2virt_t phys2virt)
{
Expand Down
35 changes: 35 additions & 0 deletions hypervisor/arch/arm/mmu_hyp.c
Expand Up @@ -90,6 +90,41 @@ static void destroy_id_maps(void)
}
}

static void __attribute__((naked)) __attribute__((noinline))
cpu_switch_el2(unsigned long phys_bootstrap, virt2phys_t virt2phys)
{
asm volatile(
/*
* The linux hyp stub allows to install the vectors with a
* single hvc. The vector base address is in r0
* (phys_bootstrap).
*/
"hvc #0\n\t"

/*
* Now that the bootstrap vectors are installed, call setup_el2
* with the translated physical values of lr and sp as
* arguments.
*/
"mov r0, sp\n\t"
"push {lr}\n\t"
"blx %0\n\t"
"pop {lr}\n\t"
"push {r0}\n\t"
"mov r0, lr\n\t"
"blx %0\n\t"
"pop {r1}\n\t"
"hvc #0\n\t"
:
: "r" (virt2phys)
/*
* The call to virt2phys may clobber all temp registers. This
* list ensures that the compiler uses a decent register for
* hvirt2phys.
*/
: "cc", "memory", "r0", "r1", "r2", "r3");
}

/*
* This code is put in the id-mapped `.trampoline' section, allowing to enable
* and disable the MMU in a readable and portable fashion.
Expand Down

0 comments on commit 99370e0

Please sign in to comment.