]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/arm/entry.S
arm: restore kernel on setup failure
[jailhouse.git] / hypervisor / arch / arm / entry.S
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2013
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #include <asm/head.h>
14 #include <asm/percpu.h>
15
16 /* Entry point for Linux loader module on JAILHOUSE_ENABLE */
17         .text
18         .globl arch_entry
19 arch_entry:
20         /* r0: cpuid */
21         push    {r0 - r12}
22
23         ldr     r1, =__page_pool
24         mov     r4, #1
25         lsl     r4, #PERCPU_SIZE_SHIFT
26         /*
27          * percpu data = pool + cpuid * shift
28          * TODO: handle aff1 and aff2
29          */
30         mla     r1, r4, r0, r1
31         add     r4, r1, #PERCPU_LINUX_SP
32
33         /*
34          * Save SP, LR, CPSR
35          * r4 is used so that they can be easily retrieved on failure.
36          */
37         str     sp, [r4], #4
38         str     lr, [r4], #4
39         mrs     r3, cpsr
40         str     r3, [r4]
41
42         mov     sp, r1
43         add     sp, #PERCPU_STACK_END
44         /*
45          * Keep some space for a struct registers, in case setup fails and needs
46          * to return to the driver through the arch_shutdown_self path.
47          */
48         sub     sp, #((NUM_USR_REGS + 1) * 4)
49         /* Call entry(cpuid, struct per_cpu*) */
50         bl      entry
51
52         /*
53          * entry only returns here when there is an error before setting up EL2
54          */
55         ldr     r3, [r4], #-4
56         msr     spsr, r3
57         ldr     lr, [r4], #-4
58         ldr     sp, [r4]
59
60         /* Keep the return value in r0 */
61         pop     {r1}
62         pop     {r1 - r12}
63         subs    pc, lr, #0
64
65         .globl bootstrap_vectors
66         .align 5
67 bootstrap_vectors:
68         b       .
69         b       .
70         b       .
71         b       .
72         b       .
73         b       setup_el2
74         b       .
75         b       .
76
77 setup_el2:
78         /*
79          * Load the physical values of lr and sp, and continue execution at EL2.
80          */
81         mov     lr, r0
82         mov     sp, r1
83
84         bx      lr