mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 02:05:31 +07:00
f9076ecfb1
Commit 68234df4ea
("arm64: kill flush_cache_all()") removed the global
arm64 routines cpu_reset() and cpu_soft_restart() needed by the arm64
kexec and kdump support. Add back a simplified version of
cpu_soft_restart() with some changes needed for kexec in the new files
cpu_reset.S, and cpu_reset.h.
When a CPU is reset it needs to be put into the exception level it had when
it entered the kernel. Update cpu_soft_restart() to accept an argument
which signals if the reset address should be entered at EL1 or EL2, and
add a new hypercall HVC_SOFT_RESTART which is used for the EL2 switch.
Signed-off-by: Geoff Levand <geoff@infradead.org>
Reviewed-by: James Morse <james.morse@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
97 lines
2.7 KiB
C
97 lines
2.7 KiB
C
/*
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
* Author: Marc Zyngier <marc.zyngier@arm.com>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef __ASM__VIRT_H
|
|
#define __ASM__VIRT_H
|
|
|
|
/*
|
|
* The arm64 hcall implementation uses x0 to specify the hcall type. A value
|
|
* less than 0xfff indicates a special hcall, such as get/set vector.
|
|
* Any other value is used as a pointer to the function to call.
|
|
*/
|
|
|
|
/* HVC_GET_VECTORS - Return the value of the vbar_el2 register. */
|
|
#define HVC_GET_VECTORS 0
|
|
|
|
/*
|
|
* HVC_SET_VECTORS - Set the value of the vbar_el2 register.
|
|
*
|
|
* @x1: Physical address of the new vector table.
|
|
*/
|
|
#define HVC_SET_VECTORS 1
|
|
|
|
/*
|
|
* HVC_SOFT_RESTART - CPU soft reset, used by the cpu_soft_restart routine.
|
|
*/
|
|
#define HVC_SOFT_RESTART 2
|
|
|
|
#define BOOT_CPU_MODE_EL1 (0xe11)
|
|
#define BOOT_CPU_MODE_EL2 (0xe12)
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
/*
|
|
* __boot_cpu_mode records what mode CPUs were booted in.
|
|
* A correctly-implemented bootloader must start all CPUs in the same mode:
|
|
* In this case, both 32bit halves of __boot_cpu_mode will contain the
|
|
* same value (either 0 if booted in EL1, BOOT_CPU_MODE_EL2 if booted in EL2).
|
|
*
|
|
* Should the bootloader fail to do this, the two values will be different.
|
|
* This allows the kernel to flag an error when the secondaries have come up.
|
|
*/
|
|
extern u32 __boot_cpu_mode[2];
|
|
|
|
void __hyp_set_vectors(phys_addr_t phys_vector_base);
|
|
phys_addr_t __hyp_get_vectors(void);
|
|
|
|
/* Reports the availability of HYP mode */
|
|
static inline bool is_hyp_mode_available(void)
|
|
{
|
|
return (__boot_cpu_mode[0] == BOOT_CPU_MODE_EL2 &&
|
|
__boot_cpu_mode[1] == BOOT_CPU_MODE_EL2);
|
|
}
|
|
|
|
/* Check if the bootloader has booted CPUs in different modes */
|
|
static inline bool is_hyp_mode_mismatched(void)
|
|
{
|
|
return __boot_cpu_mode[0] != __boot_cpu_mode[1];
|
|
}
|
|
|
|
static inline bool is_kernel_in_hyp_mode(void)
|
|
{
|
|
u64 el;
|
|
|
|
asm("mrs %0, CurrentEL" : "=r" (el));
|
|
return el == CurrentEL_EL2;
|
|
}
|
|
|
|
#ifdef CONFIG_ARM64_VHE
|
|
extern void verify_cpu_run_el(void);
|
|
#else
|
|
static inline void verify_cpu_run_el(void) {}
|
|
#endif
|
|
|
|
/* The section containing the hypervisor text */
|
|
extern char __hyp_text_start[];
|
|
extern char __hyp_text_end[];
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* ! __ASM__VIRT_H */
|