1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include <linux/linkage.h>
19
20#include <asm/assembler.h>
21#include <asm/kvm_arm.h>
22#include <asm/kvm_mmu.h>
23
24 .text
25 .pushsection .hyp.idmap.text, "ax"
26
27 .align 11
28
29ENTRY(__kvm_hyp_init)
30 ventry __invalid
31 ventry __invalid
32 ventry __invalid
33 ventry __invalid
34
35 ventry __invalid
36 ventry __invalid
37 ventry __invalid
38 ventry __invalid
39
40 ventry __do_hyp_init
41 ventry __invalid
42 ventry __invalid
43 ventry __invalid
44
45 ventry __invalid
46 ventry __invalid
47 ventry __invalid
48 ventry __invalid
49
50__invalid:
51 b .
52
53
54
55
56
57
58
59__do_hyp_init:
60
61 msr ttbr0_el2, x0
62
63 mrs x4, tcr_el1
64 ldr x5, =TCR_EL2_MASK
65 and x4, x4, x5
66 ldr x5, =TCR_EL2_FLAGS
67 orr x4, x4, x5
68 msr tcr_el2, x4
69
70 ldr x4, =VTCR_EL2_FLAGS
71 msr vtcr_el2, x4
72
73 mrs x4, mair_el1
74 msr mair_el2, x4
75 isb
76
77 mrs x4, sctlr_el2
78 and x4, x4,
79 ldr x5, =SCTLR_EL2_FLAGS
80 orr x4, x4, x5
81 msr sctlr_el2, x4
82 isb
83
84
85 ldr x4, =TRAMPOLINE_VA
86 adr x5, target
87 bfi x4, x5,
88 br x4
89
90target:
91 msr ttbr0_el2, x1
92 isb
93
94
95 tlbi alle2
96 dsb sy
97
98
99 kern_hyp_va x2
100 mov sp, x2
101 kern_hyp_va x3
102 msr vbar_el2, x3
103
104
105 eret
106ENDPROC(__kvm_hyp_init)
107
108 .ltorg
109
110 .popsection
111