2019-06-04 16:11:33 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2016-06-24 01:54:48 +08:00
|
|
|
/*
|
|
|
|
* kexec for arm64
|
|
|
|
*
|
|
|
|
* Copyright (C) Linaro.
|
|
|
|
* Copyright (C) Huawei Futurewei Technologies.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ARM64_KEXEC_H
|
|
|
|
#define _ARM64_KEXEC_H
|
|
|
|
|
|
|
|
/* Maximum physical address we can use pages from */
|
|
|
|
|
|
|
|
#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
|
|
|
|
|
|
|
|
/* Maximum address we can reach in physical address mode */
|
|
|
|
|
|
|
|
#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
|
|
|
|
|
|
|
|
/* Maximum address we can use for the control code buffer */
|
|
|
|
|
|
|
|
#define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
|
|
|
|
|
|
|
|
#define KEXEC_CONTROL_PAGE_SIZE 4096
|
|
|
|
|
|
|
|
#define KEXEC_ARCH KEXEC_ARCH_AARCH64
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
|
|
|
/**
|
|
|
|
* crash_setup_regs() - save registers for the panic kernel
|
|
|
|
*
|
|
|
|
* @newregs: registers are saved here
|
|
|
|
* @oldregs: registers to be saved (may be %NULL)
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void crash_setup_regs(struct pt_regs *newregs,
|
|
|
|
struct pt_regs *oldregs)
|
|
|
|
{
|
2017-04-03 10:24:36 +08:00
|
|
|
if (oldregs) {
|
|
|
|
memcpy(newregs, oldregs, sizeof(*newregs));
|
|
|
|
} else {
|
|
|
|
u64 tmp1, tmp2;
|
|
|
|
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"stp x0, x1, [%2, #16 * 0]\n"
|
|
|
|
"stp x2, x3, [%2, #16 * 1]\n"
|
|
|
|
"stp x4, x5, [%2, #16 * 2]\n"
|
|
|
|
"stp x6, x7, [%2, #16 * 3]\n"
|
|
|
|
"stp x8, x9, [%2, #16 * 4]\n"
|
|
|
|
"stp x10, x11, [%2, #16 * 5]\n"
|
|
|
|
"stp x12, x13, [%2, #16 * 6]\n"
|
|
|
|
"stp x14, x15, [%2, #16 * 7]\n"
|
|
|
|
"stp x16, x17, [%2, #16 * 8]\n"
|
|
|
|
"stp x18, x19, [%2, #16 * 9]\n"
|
|
|
|
"stp x20, x21, [%2, #16 * 10]\n"
|
|
|
|
"stp x22, x23, [%2, #16 * 11]\n"
|
|
|
|
"stp x24, x25, [%2, #16 * 12]\n"
|
|
|
|
"stp x26, x27, [%2, #16 * 13]\n"
|
|
|
|
"stp x28, x29, [%2, #16 * 14]\n"
|
|
|
|
"mov %0, sp\n"
|
|
|
|
"stp x30, %0, [%2, #16 * 15]\n"
|
|
|
|
|
|
|
|
"/* faked current PSTATE */\n"
|
|
|
|
"mrs %0, CurrentEL\n"
|
|
|
|
"mrs %1, SPSEL\n"
|
|
|
|
"orr %0, %0, %1\n"
|
|
|
|
"mrs %1, DAIF\n"
|
|
|
|
"orr %0, %0, %1\n"
|
|
|
|
"mrs %1, NZCV\n"
|
|
|
|
"orr %0, %0, %1\n"
|
|
|
|
/* pc */
|
|
|
|
"adr %1, 1f\n"
|
|
|
|
"1:\n"
|
|
|
|
"stp %1, %0, [%2, #16 * 16]\n"
|
|
|
|
: "=&r" (tmp1), "=&r" (tmp2)
|
|
|
|
: "r" (newregs)
|
|
|
|
: "memory"
|
|
|
|
);
|
|
|
|
}
|
2016-06-24 01:54:48 +08:00
|
|
|
}
|
|
|
|
|
2017-04-03 10:24:35 +08:00
|
|
|
#if defined(CONFIG_KEXEC_CORE) && defined(CONFIG_HIBERNATION)
|
|
|
|
extern bool crash_is_nosave(unsigned long pfn);
|
|
|
|
extern void crash_prepare_suspend(void);
|
|
|
|
extern void crash_post_resume(void);
|
|
|
|
#else
|
|
|
|
static inline bool crash_is_nosave(unsigned long pfn) {return false; }
|
|
|
|
static inline void crash_prepare_suspend(void) {}
|
|
|
|
static inline void crash_post_resume(void) {}
|
|
|
|
#endif
|
|
|
|
|
2021-09-30 22:31:12 +08:00
|
|
|
#if defined(CONFIG_KEXEC_CORE)
|
|
|
|
void cpu_soft_restart(unsigned long el2_switch, unsigned long entry,
|
|
|
|
unsigned long arg0, unsigned long arg1,
|
|
|
|
unsigned long arg2);
|
|
|
|
#endif
|
|
|
|
|
2018-11-15 13:52:49 +08:00
|
|
|
#define ARCH_HAS_KIMAGE_ARCH
|
|
|
|
|
|
|
|
struct kimage_arch {
|
|
|
|
void *dtb;
|
2021-01-26 03:19:06 +08:00
|
|
|
phys_addr_t dtb_mem;
|
arm64: kexec: move relocation function setup
Currently, kernel relocation function is configured in machine_kexec()
at the time of kexec reboot by using control_code_page.
This operation, however, is more logical to be done during kexec_load,
and thus remove from reboot time. Move, setup of this function to
newly added machine_kexec_post_load().
Because once MMU is enabled, kexec control page will contain more than
relocation kernel, but also vector table, add pointer to the actual
function within this page arch.kern_reloc. Currently, it equals to the
beginning of page, we will add offsets later, when vector table is
added.
Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: James Morse <james.morse@arm.com>
Link: https://lore.kernel.org/r/20210125191923.1060122-10-pasha.tatashin@soleen.com
Signed-off-by: Will Deacon <will@kernel.org>
2021-01-26 03:19:14 +08:00
|
|
|
phys_addr_t kern_reloc;
|
2021-09-30 22:31:06 +08:00
|
|
|
phys_addr_t el2_vectors;
|
2021-09-30 22:31:10 +08:00
|
|
|
phys_addr_t ttbr0;
|
2021-09-30 22:31:09 +08:00
|
|
|
phys_addr_t ttbr1;
|
|
|
|
phys_addr_t zero_page;
|
2021-09-30 22:31:10 +08:00
|
|
|
unsigned long phys_offset;
|
|
|
|
unsigned long t0sz;
|
2018-11-15 13:52:49 +08:00
|
|
|
};
|
|
|
|
|
2021-01-26 03:19:06 +08:00
|
|
|
#ifdef CONFIG_KEXEC_FILE
|
2018-11-15 13:52:50 +08:00
|
|
|
extern const struct kexec_file_ops kexec_image_ops;
|
|
|
|
|
2018-11-15 13:52:49 +08:00
|
|
|
struct kimage;
|
|
|
|
|
|
|
|
extern int arch_kimage_file_post_load_cleanup(struct kimage *image);
|
|
|
|
extern int load_other_segments(struct kimage *image,
|
|
|
|
unsigned long kernel_load_addr, unsigned long kernel_size,
|
|
|
|
char *initrd, unsigned long initrd_len,
|
|
|
|
char *cmdline);
|
|
|
|
#endif
|
|
|
|
|
2016-06-24 01:54:48 +08:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
|
|
|
|
#endif
|