]>
Commit | Line | Data |
---|---|---|
f35a9205 MZ |
1 | /* |
2 | * Copyright (C) 2012 ARM Ltd. | |
3 | * Author: Marc Zyngier <marc.zyngier@arm.com> | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License version 2 as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | ||
18 | #ifndef __ASM__VIRT_H | |
19 | #define __ASM__VIRT_H | |
20 | ||
828e9834 ML |
21 | #define BOOT_CPU_MODE_EL1 (0xe11) |
22 | #define BOOT_CPU_MODE_EL2 (0xe12) | |
f35a9205 MZ |
23 | |
24 | #ifndef __ASSEMBLY__ | |
25 | ||
82deae0f MZ |
26 | #include <asm/ptrace.h> |
27 | ||
f35a9205 MZ |
28 | /* |
29 | * __boot_cpu_mode records what mode CPUs were booted in. | |
30 | * A correctly-implemented bootloader must start all CPUs in the same mode: | |
31 | * In this case, both 32bit halves of __boot_cpu_mode will contain the | |
32 | * same value (either 0 if booted in EL1, BOOT_CPU_MODE_EL2 if booted in EL2). | |
33 | * | |
34 | * Should the bootloader fail to do this, the two values will be different. | |
35 | * This allows the kernel to flag an error when the secondaries have come up. | |
36 | */ | |
37 | extern u32 __boot_cpu_mode[2]; | |
38 | ||
712c6ff4 MZ |
39 | void __hyp_set_vectors(phys_addr_t phys_vector_base); |
40 | phys_addr_t __hyp_get_vectors(void); | |
41 | ||
f35a9205 MZ |
42 | /* Reports the availability of HYP mode */ |
43 | static inline bool is_hyp_mode_available(void) | |
44 | { | |
45 | return (__boot_cpu_mode[0] == BOOT_CPU_MODE_EL2 && | |
46 | __boot_cpu_mode[1] == BOOT_CPU_MODE_EL2); | |
47 | } | |
48 | ||
49 | /* Check if the bootloader has booted CPUs in different modes */ | |
50 | static inline bool is_hyp_mode_mismatched(void) | |
51 | { | |
52 | return __boot_cpu_mode[0] != __boot_cpu_mode[1]; | |
53 | } | |
54 | ||
82deae0f MZ |
55 | static inline bool is_kernel_in_hyp_mode(void) |
56 | { | |
57 | u64 el; | |
58 | ||
59 | asm("mrs %0, CurrentEL" : "=r" (el)); | |
60 | return el == CurrentEL_EL2; | |
61 | } | |
62 | ||
ac1ad20f SP |
63 | #ifdef CONFIG_ARM64_VHE |
64 | extern void verify_cpu_run_el(void); | |
65 | #else | |
66 | static inline void verify_cpu_run_el(void) {} | |
67 | #endif | |
68 | ||
45451914 MZ |
69 | /* The section containing the hypervisor text */ |
70 | extern char __hyp_text_start[]; | |
71 | extern char __hyp_text_end[]; | |
72 | ||
f35a9205 MZ |
73 | #endif /* __ASSEMBLY__ */ |
74 | ||
75 | #endif /* ! __ASM__VIRT_H */ |