| .. | .. |
|---|
| 125 | 125 | unsigned long cmdline_len); |
|---|
| 126 | 126 | typedef int (kexec_cleanup_t)(void *loader_data); |
|---|
| 127 | 127 | |
|---|
| 128 | | -#ifdef CONFIG_KEXEC_VERIFY_SIG |
|---|
| 128 | +#ifdef CONFIG_KEXEC_SIG |
|---|
| 129 | 129 | typedef int (kexec_verify_sig_t)(const char *kernel_buf, |
|---|
| 130 | 130 | unsigned long kernel_len); |
|---|
| 131 | 131 | #endif |
|---|
| .. | .. |
|---|
| 134 | 134 | kexec_probe_t *probe; |
|---|
| 135 | 135 | kexec_load_t *load; |
|---|
| 136 | 136 | kexec_cleanup_t *cleanup; |
|---|
| 137 | | -#ifdef CONFIG_KEXEC_VERIFY_SIG |
|---|
| 137 | +#ifdef CONFIG_KEXEC_SIG |
|---|
| 138 | 138 | kexec_verify_sig_t *verify_sig; |
|---|
| 139 | 139 | #endif |
|---|
| 140 | 140 | }; |
|---|
| .. | .. |
|---|
| 143 | 143 | |
|---|
| 144 | 144 | int kexec_image_probe_default(struct kimage *image, void *buf, |
|---|
| 145 | 145 | unsigned long buf_len); |
|---|
| 146 | +int kexec_image_post_load_cleanup_default(struct kimage *image); |
|---|
| 147 | + |
|---|
| 148 | +/* |
|---|
| 149 | + * If kexec_buf.mem is set to this value, kexec_locate_mem_hole() |
|---|
| 150 | + * will try to allocate free memory. Arch may overwrite it. |
|---|
| 151 | + */ |
|---|
| 152 | +#ifndef KEXEC_BUF_MEM_UNKNOWN |
|---|
| 153 | +#define KEXEC_BUF_MEM_UNKNOWN 0 |
|---|
| 154 | +#endif |
|---|
| 146 | 155 | |
|---|
| 147 | 156 | /** |
|---|
| 148 | 157 | * struct kexec_buf - parameters for finding a place for a buffer in memory |
|---|
| .. | .. |
|---|
| 174 | 183 | bool get_value); |
|---|
| 175 | 184 | void *kexec_purgatory_get_symbol_addr(struct kimage *image, const char *name); |
|---|
| 176 | 185 | |
|---|
| 177 | | -int __weak arch_kexec_apply_relocations_add(struct purgatory_info *pi, |
|---|
| 178 | | - Elf_Shdr *section, |
|---|
| 179 | | - const Elf_Shdr *relsec, |
|---|
| 180 | | - const Elf_Shdr *symtab); |
|---|
| 181 | | -int __weak arch_kexec_apply_relocations(struct purgatory_info *pi, |
|---|
| 182 | | - Elf_Shdr *section, |
|---|
| 183 | | - const Elf_Shdr *relsec, |
|---|
| 184 | | - const Elf_Shdr *symtab); |
|---|
| 186 | +/* Architectures may override the below functions */ |
|---|
| 187 | +int arch_kexec_kernel_image_probe(struct kimage *image, void *buf, |
|---|
| 188 | + unsigned long buf_len); |
|---|
| 189 | +void *arch_kexec_kernel_image_load(struct kimage *image); |
|---|
| 190 | +int arch_kimage_file_post_load_cleanup(struct kimage *image); |
|---|
| 191 | +#ifdef CONFIG_KEXEC_SIG |
|---|
| 192 | +int arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, |
|---|
| 193 | + unsigned long buf_len); |
|---|
| 194 | +#endif |
|---|
| 195 | +int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf); |
|---|
| 185 | 196 | |
|---|
| 186 | | -int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, |
|---|
| 187 | | - int (*func)(struct resource *, void *)); |
|---|
| 188 | 197 | extern int kexec_add_buffer(struct kexec_buf *kbuf); |
|---|
| 189 | 198 | int kexec_locate_mem_hole(struct kexec_buf *kbuf); |
|---|
| 190 | 199 | |
|---|
| .. | .. |
|---|
| 198 | 207 | struct crash_mem { |
|---|
| 199 | 208 | unsigned int max_nr_ranges; |
|---|
| 200 | 209 | unsigned int nr_ranges; |
|---|
| 201 | | - struct crash_mem_range ranges[0]; |
|---|
| 210 | + struct crash_mem_range ranges[]; |
|---|
| 202 | 211 | }; |
|---|
| 203 | 212 | |
|---|
| 204 | 213 | extern int crash_exclude_mem_range(struct crash_mem *mem, |
|---|
| .. | .. |
|---|
| 206 | 215 | unsigned long long mend); |
|---|
| 207 | 216 | extern int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map, |
|---|
| 208 | 217 | void **addr, unsigned long *sz); |
|---|
| 218 | + |
|---|
| 219 | +#ifndef arch_kexec_apply_relocations_add |
|---|
| 220 | +/* |
|---|
| 221 | + * arch_kexec_apply_relocations_add - apply relocations of type RELA |
|---|
| 222 | + * @pi: Purgatory to be relocated. |
|---|
| 223 | + * @section: Section relocations applying to. |
|---|
| 224 | + * @relsec: Section containing RELAs. |
|---|
| 225 | + * @symtab: Corresponding symtab. |
|---|
| 226 | + * |
|---|
| 227 | + * Return: 0 on success, negative errno on error. |
|---|
| 228 | + */ |
|---|
| 229 | +static inline int |
|---|
| 230 | +arch_kexec_apply_relocations_add(struct purgatory_info *pi, Elf_Shdr *section, |
|---|
| 231 | + const Elf_Shdr *relsec, const Elf_Shdr *symtab) |
|---|
| 232 | +{ |
|---|
| 233 | + pr_err("RELA relocation unsupported.\n"); |
|---|
| 234 | + return -ENOEXEC; |
|---|
| 235 | +} |
|---|
| 236 | +#endif |
|---|
| 237 | + |
|---|
| 238 | +#ifndef arch_kexec_apply_relocations |
|---|
| 239 | +/* |
|---|
| 240 | + * arch_kexec_apply_relocations - apply relocations of type REL |
|---|
| 241 | + * @pi: Purgatory to be relocated. |
|---|
| 242 | + * @section: Section relocations applying to. |
|---|
| 243 | + * @relsec: Section containing RELs. |
|---|
| 244 | + * @symtab: Corresponding symtab. |
|---|
| 245 | + * |
|---|
| 246 | + * Return: 0 on success, negative errno on error. |
|---|
| 247 | + */ |
|---|
| 248 | +static inline int |
|---|
| 249 | +arch_kexec_apply_relocations(struct purgatory_info *pi, Elf_Shdr *section, |
|---|
| 250 | + const Elf_Shdr *relsec, const Elf_Shdr *symtab) |
|---|
| 251 | +{ |
|---|
| 252 | + pr_err("REL relocation unsupported.\n"); |
|---|
| 253 | + return -ENOEXEC; |
|---|
| 254 | +} |
|---|
| 255 | +#endif |
|---|
| 209 | 256 | #endif /* CONFIG_KEXEC_FILE */ |
|---|
| 210 | 257 | |
|---|
| 258 | +#ifdef CONFIG_KEXEC_ELF |
|---|
| 259 | +struct kexec_elf_info { |
|---|
| 260 | + /* |
|---|
| 261 | + * Where the ELF binary contents are kept. |
|---|
| 262 | + * Memory managed by the user of the struct. |
|---|
| 263 | + */ |
|---|
| 264 | + const char *buffer; |
|---|
| 265 | + |
|---|
| 266 | + const struct elfhdr *ehdr; |
|---|
| 267 | + const struct elf_phdr *proghdrs; |
|---|
| 268 | +}; |
|---|
| 269 | + |
|---|
| 270 | +int kexec_build_elf_info(const char *buf, size_t len, struct elfhdr *ehdr, |
|---|
| 271 | + struct kexec_elf_info *elf_info); |
|---|
| 272 | + |
|---|
| 273 | +int kexec_elf_load(struct kimage *image, struct elfhdr *ehdr, |
|---|
| 274 | + struct kexec_elf_info *elf_info, |
|---|
| 275 | + struct kexec_buf *kbuf, |
|---|
| 276 | + unsigned long *lowest_load_addr); |
|---|
| 277 | + |
|---|
| 278 | +void kexec_free_elf_info(struct kexec_elf_info *elf_info); |
|---|
| 279 | +int kexec_elf_probe(const char *buf, unsigned long len); |
|---|
| 280 | +#endif |
|---|
| 211 | 281 | struct kimage { |
|---|
| 212 | 282 | kimage_entry_t head; |
|---|
| 213 | 283 | kimage_entry_t *entry; |
|---|
| .. | .. |
|---|
| 310 | 380 | extern bool kexec_in_progress; |
|---|
| 311 | 381 | |
|---|
| 312 | 382 | int crash_shrink_memory(unsigned long new_size); |
|---|
| 313 | | -size_t crash_get_memory_size(void); |
|---|
| 314 | 383 | void crash_free_reserved_phys_range(unsigned long begin, unsigned long end); |
|---|
| 384 | +ssize_t crash_get_memory_size(void); |
|---|
| 315 | 385 | |
|---|
| 316 | 386 | void arch_kexec_protect_crashkres(void); |
|---|
| 317 | 387 | void arch_kexec_unprotect_crashkres(void); |
|---|
| .. | .. |
|---|
| 372 | 442 | #define kexec_in_progress false |
|---|
| 373 | 443 | #endif /* CONFIG_KEXEC_CORE */ |
|---|
| 374 | 444 | |
|---|
| 445 | +#ifdef CONFIG_KEXEC_SIG |
|---|
| 446 | +void set_kexec_sig_enforced(void); |
|---|
| 447 | +#else |
|---|
| 448 | +static inline void set_kexec_sig_enforced(void) {} |
|---|
| 449 | +#endif |
|---|
| 450 | + |
|---|
| 375 | 451 | #endif /* !defined(__ASSEBMLY__) */ |
|---|
| 376 | 452 | |
|---|
| 377 | 453 | #endif /* LINUX_KEXEC_H */ |
|---|