/
entry.S
143 lines (119 loc) · 2.14 KB
/
entry.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* Jailhouse, a Linux-based partitioning hypervisor
*
* Copyright (c) Siemens AG, 2013
*
* Authors:
* Jan Kiszka <jan.kiszka@siemens.com>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*/
#include <asm/processor.h>
#include <asm/asm-defines.h>
/* Entry point for Linux loader module on JAILHOUSE_ENABLE */
.text
.globl arch_entry
arch_entry:
cli
push %rbp
push %rbx
push %r12
push %r13
push %r14
push %r15
/* Locate the per_cpu region for the given CPU ID */
mov %rdi,%rsi
imul $PERCPU_SIZE_ASM,%rsi,%rsi
lea __page_pool(%rip),%rax
add %rax,%rsi
/* Save the Linux stack pointer inside the per_cpu region */
mov %rsp,PERCPU_LINUX_SP(%rsi)
/* Set the Jailhouse stack pointer */
lea PERCPU_STACK_END-8(%rsi),%rsp
push %rsi
/*
* Call the architecture-independent entry(cpuid, struct per_cpu*)
* function.
*/
call entry
pop %rsi
mov PERCPU_LINUX_SP(%rsi),%rsp
pop %r15
pop %r14
pop %r13
pop %r12
pop %rbx
pop %rbp
ret
/* Exception/interrupt entry points */
.macro common_exception_entry vector
.cfi_startproc
.cfi_def_cfa_offset 16
pushq $\vector
.cfi_adjust_cfa_offset 8
mov %rsp,%rdi
call x86_exception_handler
1: jmp 1b
.cfi_endproc
.endm
.macro no_error_entry vector
.balign 16
pushq $(EXCEPTION_NO_ERROR)
common_exception_entry \vector
.endm
.macro error_entry vector
.balign 16
common_exception_entry \vector
.endm
.global exception_entries
.balign 16
exception_entries:
no_error_entry 0
no_error_entry 1
vector=3
.rept 5
no_error_entry vector
vector=vector+1
.endr
error_entry 8
no_error_entry 9
vector=10
.rept 5
error_entry vector
vector=vector+1
.endr
no_error_entry 16
error_entry 17
no_error_entry 18
no_error_entry 19
.macro interrupt_entry func
push %rax
push %rcx
push %rdx
push %rsi
push %rdi
push %r8
push %r9
push %r10
push %r11
call \func
pop %r11
pop %r10
pop %r9
pop %r8
pop %rdi
pop %rsi
pop %rdx
pop %rcx
pop %rax
iretq
.endm
.global nmi_entry
.balign 16
nmi_entry:
interrupt_entry vcpu_nmi_handler
.global irq_entry
.balign 16
irq_entry:
interrupt_entry apic_irq_handler