aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/include/asm/virt.h
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2012-10-26 10:40:05 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2012-12-05 06:26:48 -0500
commitf35a92053b45cf8154db5558ede3ba5245c9dc7e (patch)
treefc4b8d9cfcd538251db7ee8a03286bef302d6ba0 /arch/arm64/include/asm/virt.h
parentdc637f1fdaa6f335271a0341fef3914b80ab929c (diff)
arm64: record boot mode when entering the kernel
To be able to signal the availability of EL2 to other parts of the kernel, record the boot mode. Once booted, two predicates indicate if HYP mode is available, and if not, whether this is due to a boot mode mismatch or not. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/include/asm/virt.h')
-rw-r--r--arch/arm64/include/asm/virt.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
new file mode 100644
index 000000000000..f28547d9edfa
--- /dev/null
+++ b/arch/arm64/include/asm/virt.h
@@ -0,0 +1,51 @@
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
21#define BOOT_CPU_MODE_EL2 (0x0e12b007)
22
23#ifndef __ASSEMBLY__
24
25/*
26 * __boot_cpu_mode records what mode CPUs were booted in.
27 * A correctly-implemented bootloader must start all CPUs in the same mode:
28 * In this case, both 32bit halves of __boot_cpu_mode will contain the
29 * same value (either 0 if booted in EL1, BOOT_CPU_MODE_EL2 if booted in EL2).
30 *
31 * Should the bootloader fail to do this, the two values will be different.
32 * This allows the kernel to flag an error when the secondaries have come up.
33 */
34extern u32 __boot_cpu_mode[2];
35
36/* Reports the availability of HYP mode */
37static inline bool is_hyp_mode_available(void)
38{
39 return (__boot_cpu_mode[0] == BOOT_CPU_MODE_EL2 &&
40 __boot_cpu_mode[1] == BOOT_CPU_MODE_EL2);
41}
42
43/* Check if the bootloader has booted CPUs in different modes */
44static inline bool is_hyp_mode_mismatched(void)
45{
46 return __boot_cpu_mode[0] != __boot_cpu_mode[1];
47}
48
49#endif /* __ASSEMBLY__ */
50
51#endif /* ! __ASM__VIRT_H */