18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright IBM Corp. 2005
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com>
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _S390_KEXEC_H
108c2ecf20Sopenharmony_ci#define _S390_KEXEC_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/module.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <asm/processor.h>
158c2ecf20Sopenharmony_ci#include <asm/page.h>
168c2ecf20Sopenharmony_ci#include <asm/setup.h>
178c2ecf20Sopenharmony_ci/*
188c2ecf20Sopenharmony_ci * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
198c2ecf20Sopenharmony_ci * I.e. Maximum page that is mapped directly into kernel memory,
208c2ecf20Sopenharmony_ci * and kmap is not required.
218c2ecf20Sopenharmony_ci */
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* Maximum physical address we can use pages from */
248c2ecf20Sopenharmony_ci#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* Maximum address we can reach in physical address mode */
278c2ecf20Sopenharmony_ci#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* Maximum address we can use for the control pages */
308c2ecf20Sopenharmony_ci/* Not more than 2GB */
318c2ecf20Sopenharmony_ci#define KEXEC_CONTROL_MEMORY_LIMIT (1UL<<31)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/* Allocate control page with GFP_DMA */
348c2ecf20Sopenharmony_ci#define KEXEC_CONTROL_MEMORY_GFP GFP_DMA
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* Maximum address we can use for the crash control pages */
378c2ecf20Sopenharmony_ci#define KEXEC_CRASH_CONTROL_MEMORY_LIMIT (-1UL)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/* Allocate one page for the pdp and the second for the code */
408c2ecf20Sopenharmony_ci#define KEXEC_CONTROL_PAGE_SIZE 4096
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/* Alignment of crashkernel memory */
438c2ecf20Sopenharmony_ci#define KEXEC_CRASH_MEM_ALIGN HPAGE_SIZE
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* The native architecture */
468c2ecf20Sopenharmony_ci#define KEXEC_ARCH KEXEC_ARCH_S390
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/* Allow kexec_file to load a segment to 0 */
498c2ecf20Sopenharmony_ci#define KEXEC_BUF_MEM_UNKNOWN -1
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci/* Provide a dummy definition to avoid build failures. */
528c2ecf20Sopenharmony_cistatic inline void crash_setup_regs(struct pt_regs *newregs,
538c2ecf20Sopenharmony_ci					struct pt_regs *oldregs) { }
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_cistruct kimage;
568c2ecf20Sopenharmony_cistruct s390_load_data {
578c2ecf20Sopenharmony_ci	/* Pointer to the kernel buffer. Used to register cmdline etc.. */
588c2ecf20Sopenharmony_ci	void *kernel_buf;
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	/* Load address of the kernel_buf. */
618c2ecf20Sopenharmony_ci	unsigned long kernel_mem;
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	/* Parmarea in the kernel buffer. */
648c2ecf20Sopenharmony_ci	struct parmarea *parm;
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	/* Total size of loaded segments in memory. Used as an offset. */
678c2ecf20Sopenharmony_ci	size_t memsz;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	struct ipl_report *report;
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ciint s390_verify_sig(const char *kernel, unsigned long kernel_len);
738c2ecf20Sopenharmony_civoid *kexec_file_add_components(struct kimage *image,
748c2ecf20Sopenharmony_ci				int (*add_kernel)(struct kimage *image,
758c2ecf20Sopenharmony_ci						  struct s390_load_data *data));
768c2ecf20Sopenharmony_ciint arch_kexec_do_relocs(int r_type, void *loc, unsigned long val,
778c2ecf20Sopenharmony_ci			 unsigned long addr);
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define ARCH_HAS_KIMAGE_ARCH
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistruct kimage_arch {
828c2ecf20Sopenharmony_ci	void *ipl_buf;
838c2ecf20Sopenharmony_ci};
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ciextern const struct kexec_file_ops s390_kexec_image_ops;
868c2ecf20Sopenharmony_ciextern const struct kexec_file_ops s390_kexec_elf_ops;
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#ifdef CONFIG_KEXEC_FILE
898c2ecf20Sopenharmony_cistruct purgatory_info;
908c2ecf20Sopenharmony_ciint arch_kexec_apply_relocations_add(struct purgatory_info *pi,
918c2ecf20Sopenharmony_ci				     Elf_Shdr *section,
928c2ecf20Sopenharmony_ci				     const Elf_Shdr *relsec,
938c2ecf20Sopenharmony_ci				     const Elf_Shdr *symtab);
948c2ecf20Sopenharmony_ci#define arch_kexec_apply_relocations_add arch_kexec_apply_relocations_add
958c2ecf20Sopenharmony_ci#endif
968c2ecf20Sopenharmony_ci#endif /*_S390_KEXEC_H */
97