linux/arch/powerpc/include/asm/kexec.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#ifndef _ASM_POWERPC_KEXEC_H
   3#define _ASM_POWERPC_KEXEC_H
   4#ifdef __KERNEL__
   5
   6#if defined(CONFIG_FSL_BOOKE) || defined(CONFIG_44x)
   7
   8/*
   9 * On FSL-BookE we setup a 1:1 mapping which covers the first 2GiB of memory
  10 * and therefore we can only deal with memory within this range
  11 */
  12#define KEXEC_SOURCE_MEMORY_LIMIT       (2 * 1024 * 1024 * 1024UL - 1)
  13#define KEXEC_DESTINATION_MEMORY_LIMIT  (2 * 1024 * 1024 * 1024UL - 1)
  14#define KEXEC_CONTROL_MEMORY_LIMIT      (2 * 1024 * 1024 * 1024UL - 1)
  15
  16#else
  17
  18/*
  19 * Maximum page that is mapped directly into kernel memory.
  20 * XXX: Since we copy virt we can use any page we allocate
  21 */
  22#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
  23
  24/*
  25 * Maximum address we can reach in physical address mode.
  26 * XXX: I want to allow initrd in highmem. Otherwise set to rmo on LPAR.
  27 */
  28#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
  29
  30/* Maximum address we can use for the control code buffer */
  31#ifdef __powerpc64__
  32#define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
  33#else
  34/* TASK_SIZE, probably left over from use_mm ?? */
  35#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
  36#endif
  37#endif
  38
  39#define KEXEC_CONTROL_PAGE_SIZE 4096
  40
  41/* The native architecture */
  42#ifdef __powerpc64__
  43#define KEXEC_ARCH KEXEC_ARCH_PPC64
  44#else
  45#define KEXEC_ARCH KEXEC_ARCH_PPC
  46#endif
  47
  48#define KEXEC_STATE_NONE 0
  49#define KEXEC_STATE_IRQS_OFF 1
  50#define KEXEC_STATE_REAL_MODE 2
  51
  52#ifndef __ASSEMBLY__
  53#include <asm/reg.h>
  54
  55typedef void (*crash_shutdown_t)(void);
  56
  57#ifdef CONFIG_KEXEC_CORE
  58
  59/*
  60 * This function is responsible for capturing register states if coming
  61 * via panic or invoking dump using sysrq-trigger.
  62 */
  63static inline void crash_setup_regs(struct pt_regs *newregs,
  64                                        struct pt_regs *oldregs)
  65{
  66        if (oldregs)
  67                memcpy(newregs, oldregs, sizeof(*newregs));
  68        else
  69                ppc_save_regs(newregs);
  70}
  71
  72extern void kexec_smp_wait(void);       /* get and clear naca physid, wait for
  73                                          master to copy new code to 0 */
  74extern int crashing_cpu;
  75extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *));
  76extern void crash_ipi_callback(struct pt_regs *);
  77extern int crash_wake_offline;
  78
  79struct kimage;
  80struct pt_regs;
  81extern void default_machine_kexec(struct kimage *image);
  82extern int default_machine_kexec_prepare(struct kimage *image);
  83extern void default_machine_crash_shutdown(struct pt_regs *regs);
  84extern int crash_shutdown_register(crash_shutdown_t handler);
  85extern int crash_shutdown_unregister(crash_shutdown_t handler);
  86
  87extern void crash_kexec_secondary(struct pt_regs *regs);
  88extern int overlaps_crashkernel(unsigned long start, unsigned long size);
  89extern void reserve_crashkernel(void);
  90extern void machine_kexec_mask_interrupts(void);
  91
  92static inline bool kdump_in_progress(void)
  93{
  94        return crashing_cpu >= 0;
  95}
  96
  97#ifdef CONFIG_KEXEC_FILE
  98extern const struct kexec_file_ops kexec_elf64_ops;
  99
 100#define ARCH_HAS_KIMAGE_ARCH
 101
 102struct kimage_arch {
 103        struct crash_mem *exclude_ranges;
 104
 105        unsigned long backup_start;
 106        void *backup_buf;
 107
 108        unsigned long elfcorehdr_addr;
 109        unsigned long elf_headers_sz;
 110        void *elf_headers;
 111
 112#ifdef CONFIG_IMA_KEXEC
 113        phys_addr_t ima_buffer_addr;
 114        size_t ima_buffer_size;
 115#endif
 116};
 117
 118char *setup_kdump_cmdline(struct kimage *image, char *cmdline,
 119                          unsigned long cmdline_len);
 120int setup_purgatory(struct kimage *image, const void *slave_code,
 121                    const void *fdt, unsigned long kernel_load_addr,
 122                    unsigned long fdt_load_addr);
 123int setup_new_fdt(const struct kimage *image, void *fdt,
 124                  unsigned long initrd_load_addr, unsigned long initrd_len,
 125                  const char *cmdline);
 126int delete_fdt_mem_rsv(void *fdt, unsigned long start, unsigned long size);
 127
 128#ifdef CONFIG_PPC64
 129struct kexec_buf;
 130
 131int load_crashdump_segments_ppc64(struct kimage *image,
 132                                  struct kexec_buf *kbuf);
 133int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,
 134                          const void *fdt, unsigned long kernel_load_addr,
 135                          unsigned long fdt_load_addr);
 136int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
 137                        unsigned long initrd_load_addr,
 138                        unsigned long initrd_len, const char *cmdline);
 139#endif /* CONFIG_PPC64 */
 140
 141#endif /* CONFIG_KEXEC_FILE */
 142
 143#else /* !CONFIG_KEXEC_CORE */
 144static inline void crash_kexec_secondary(struct pt_regs *regs) { }
 145
 146static inline int overlaps_crashkernel(unsigned long start, unsigned long size)
 147{
 148        return 0;
 149}
 150
 151static inline void reserve_crashkernel(void) { ; }
 152
 153static inline int crash_shutdown_register(crash_shutdown_t handler)
 154{
 155        return 0;
 156}
 157
 158static inline int crash_shutdown_unregister(crash_shutdown_t handler)
 159{
 160        return 0;
 161}
 162
 163static inline bool kdump_in_progress(void)
 164{
 165        return false;
 166}
 167
 168static inline void crash_ipi_callback(struct pt_regs *regs) { }
 169
 170static inline void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
 171{
 172}
 173
 174#endif /* CONFIG_KEXEC_CORE */
 175#endif /* ! __ASSEMBLY__ */
 176#endif /* __KERNEL__ */
 177#endif /* _ASM_POWERPC_KEXEC_H */
 178