2019-05-19 16:51:31 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-02-09 20:47:17 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 Linaro Limited.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef VIRT_H
|
|
|
|
#define VIRT_H
|
|
|
|
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flag indicating that the kernel was not entered in the same mode on every
|
|
|
|
* CPU. The zImage loader stashes this value in an SPSR, so we need an
|
2012-12-02 21:44:36 +04:00
|
|
|
* architecturally defined flag bit here.
|
2012-02-09 20:47:17 +04:00
|
|
|
*/
|
2012-12-02 21:44:36 +04:00
|
|
|
#define BOOT_CPU_MODE_MISMATCH PSR_N_BIT
|
2012-02-09 20:47:17 +04:00
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
2013-07-18 20:20:33 +04:00
|
|
|
#include <asm/cacheflush.h>
|
2012-02-09 20:47:17 +04:00
|
|
|
|
|
|
|
#ifdef CONFIG_ARM_VIRT_EXT
|
|
|
|
/*
|
|
|
|
* __boot_cpu_mode records what mode the primary CPU was booted in.
|
|
|
|
* A correctly-implemented bootloader must start all CPUs in the same mode:
|
|
|
|
* if it fails to do this, the flag BOOT_CPU_MODE_MISMATCH is set to indicate
|
|
|
|
* that some CPU(s) were booted in a different mode.
|
|
|
|
*
|
|
|
|
* This allows the kernel to flag an error when the secondaries have come up.
|
|
|
|
*/
|
|
|
|
extern int __boot_cpu_mode;
|
|
|
|
|
2013-07-18 20:20:33 +04:00
|
|
|
static inline void sync_boot_mode(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* As secondaries write to __boot_cpu_mode with caches disabled, we
|
|
|
|
* must flush the corresponding cache entries to ensure the visibility
|
|
|
|
* of their writes.
|
|
|
|
*/
|
|
|
|
sync_cache_r(&__boot_cpu_mode);
|
|
|
|
}
|
|
|
|
|
2012-02-09 20:47:17 +04:00
|
|
|
#else
|
|
|
|
#define __boot_cpu_mode (SVC_MODE)
|
2013-07-18 20:20:33 +04:00
|
|
|
#define sync_boot_mode()
|
2012-02-09 20:47:17 +04:00
|
|
|
#endif
|
|
|
|
|
2012-02-17 20:54:28 +04:00
|
|
|
#ifndef ZIMAGE
|
|
|
|
void hyp_mode_check(void);
|
|
|
|
|
|
|
|
/* Reports the availability of HYP mode */
|
|
|
|
static inline bool is_hyp_mode_available(void)
|
|
|
|
{
|
|
|
|
return ((__boot_cpu_mode & MODE_MASK) == HYP_MODE &&
|
|
|
|
!(__boot_cpu_mode & BOOT_CPU_MODE_MISMATCH));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the bootloader has booted CPUs in different modes */
|
|
|
|
static inline bool is_hyp_mode_mismatched(void)
|
|
|
|
{
|
|
|
|
return !!(__boot_cpu_mode & BOOT_CPU_MODE_MISMATCH);
|
|
|
|
}
|
2016-01-02 16:57:18 +03:00
|
|
|
|
2014-06-09 22:47:09 +04:00
|
|
|
static inline bool is_kernel_in_hyp_mode(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-17 20:54:28 +04:00
|
|
|
#endif
|
|
|
|
|
2017-04-03 21:37:47 +03:00
|
|
|
#else
|
|
|
|
|
|
|
|
/* Only assembly code should need those */
|
|
|
|
|
2017-04-03 21:38:03 +03:00
|
|
|
#define HVC_SET_VECTORS 0
|
|
|
|
#define HVC_SOFT_RESTART 1
|
2017-04-03 21:37:47 +03:00
|
|
|
|
2012-02-09 20:47:17 +04:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
2017-04-03 21:37:51 +03:00
|
|
|
#define HVC_STUB_ERR 0xbadca11
|
|
|
|
|
2012-02-09 20:47:17 +04:00
|
|
|
#endif /* ! VIRT_H */
|