xref: /openbmc/linux/arch/s390/include/asm/kexec.h (revision 85250a24)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright IBM Corp. 2005
4  *
5  * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com>
6  *
7  */
8 
9 #ifndef _S390_KEXEC_H
10 #define _S390_KEXEC_H
11 
12 #include <linux/module.h>
13 
14 #include <asm/processor.h>
15 #include <asm/page.h>
16 #include <asm/setup.h>
17 /*
18  * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
19  * I.e. Maximum page that is mapped directly into kernel memory,
20  * and kmap is not required.
21  */
22 
23 /* Maximum physical address we can use pages from */
24 #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
25 
26 /* Maximum address we can reach in physical address mode */
27 #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
28 
29 /* Maximum address we can use for the control pages */
30 /* Not more than 2GB */
31 #define KEXEC_CONTROL_MEMORY_LIMIT (1UL<<31)
32 
33 /* Allocate control page with GFP_DMA */
34 #define KEXEC_CONTROL_MEMORY_GFP (GFP_DMA | __GFP_NORETRY)
35 
36 /* Maximum address we can use for the crash control pages */
37 #define KEXEC_CRASH_CONTROL_MEMORY_LIMIT (-1UL)
38 
39 /* Allocate one page for the pdp and the second for the code */
40 #define KEXEC_CONTROL_PAGE_SIZE 4096
41 
42 /* Alignment of crashkernel memory */
43 #define KEXEC_CRASH_MEM_ALIGN HPAGE_SIZE
44 
45 /* The native architecture */
46 #define KEXEC_ARCH KEXEC_ARCH_S390
47 
48 /* Allow kexec_file to load a segment to 0 */
49 #define KEXEC_BUF_MEM_UNKNOWN -1
50 
51 /* Provide a dummy definition to avoid build failures. */
52 static inline void crash_setup_regs(struct pt_regs *newregs,
53 					struct pt_regs *oldregs) { }
54 
55 struct kimage;
56 struct s390_load_data {
57 	/* Pointer to the kernel buffer. Used to register cmdline etc.. */
58 	void *kernel_buf;
59 
60 	/* Load address of the kernel_buf. */
61 	unsigned long kernel_mem;
62 
63 	/* Parmarea in the kernel buffer. */
64 	struct parmarea *parm;
65 
66 	/* Total size of loaded segments in memory. Used as an offset. */
67 	size_t memsz;
68 
69 	struct ipl_report *report;
70 };
71 
72 int s390_verify_sig(const char *kernel, unsigned long kernel_len);
73 void *kexec_file_add_components(struct kimage *image,
74 				int (*add_kernel)(struct kimage *image,
75 						  struct s390_load_data *data));
76 int arch_kexec_do_relocs(int r_type, void *loc, unsigned long val,
77 			 unsigned long addr);
78 
79 #define ARCH_HAS_KIMAGE_ARCH
80 
81 struct kimage_arch {
82 	void *ipl_buf;
83 };
84 
85 extern const struct kexec_file_ops s390_kexec_image_ops;
86 extern const struct kexec_file_ops s390_kexec_elf_ops;
87 
88 #ifdef CONFIG_CRASH_DUMP
89 void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
90 #define crash_free_reserved_phys_range crash_free_reserved_phys_range
91 
92 void arch_kexec_protect_crashkres(void);
93 #define arch_kexec_protect_crashkres arch_kexec_protect_crashkres
94 
95 void arch_kexec_unprotect_crashkres(void);
96 #define arch_kexec_unprotect_crashkres arch_kexec_unprotect_crashkres
97 #endif
98 
99 #ifdef CONFIG_KEXEC_FILE
100 struct purgatory_info;
101 int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
102 				     Elf_Shdr *section,
103 				     const Elf_Shdr *relsec,
104 				     const Elf_Shdr *symtab);
105 #define arch_kexec_apply_relocations_add arch_kexec_apply_relocations_add
106 
107 int arch_kimage_file_post_load_cleanup(struct kimage *image);
108 #define arch_kimage_file_post_load_cleanup arch_kimage_file_post_load_cleanup
109 #endif
110 #endif /*_S390_KEXEC_H */
111