Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_POWERPC_KEXEC_H
0003 #define _ASM_POWERPC_KEXEC_H
0004 #ifdef __KERNEL__
0005 
0006 #if defined(CONFIG_FSL_BOOKE) || defined(CONFIG_44x)
0007 
0008 /*
0009  * On FSL-BookE we setup a 1:1 mapping which covers the first 2GiB of memory
0010  * and therefore we can only deal with memory within this range
0011  */
0012 #define KEXEC_SOURCE_MEMORY_LIMIT   (2 * 1024 * 1024 * 1024UL - 1)
0013 #define KEXEC_DESTINATION_MEMORY_LIMIT  (2 * 1024 * 1024 * 1024UL - 1)
0014 #define KEXEC_CONTROL_MEMORY_LIMIT  (2 * 1024 * 1024 * 1024UL - 1)
0015 
0016 #else
0017 
0018 /*
0019  * Maximum page that is mapped directly into kernel memory.
0020  * XXX: Since we copy virt we can use any page we allocate
0021  */
0022 #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
0023 
0024 /*
0025  * Maximum address we can reach in physical address mode.
0026  * XXX: I want to allow initrd in highmem. Otherwise set to rmo on LPAR.
0027  */
0028 #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
0029 
0030 /* Maximum address we can use for the control code buffer */
0031 #ifdef __powerpc64__
0032 #define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
0033 #else
0034 /* TASK_SIZE, probably left over from use_mm ?? */
0035 #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
0036 #endif
0037 #endif
0038 
0039 #define KEXEC_CONTROL_PAGE_SIZE 4096
0040 
0041 /* The native architecture */
0042 #ifdef __powerpc64__
0043 #define KEXEC_ARCH KEXEC_ARCH_PPC64
0044 #else
0045 #define KEXEC_ARCH KEXEC_ARCH_PPC
0046 #endif
0047 
0048 #define KEXEC_STATE_NONE 0
0049 #define KEXEC_STATE_IRQS_OFF 1
0050 #define KEXEC_STATE_REAL_MODE 2
0051 
0052 #ifndef __ASSEMBLY__
0053 #include <asm/reg.h>
0054 
0055 typedef void (*crash_shutdown_t)(void);
0056 
0057 #ifdef CONFIG_KEXEC_CORE
0058 
0059 /*
0060  * This function is responsible for capturing register states if coming
0061  * via panic or invoking dump using sysrq-trigger.
0062  */
0063 static inline void crash_setup_regs(struct pt_regs *newregs,
0064                     struct pt_regs *oldregs)
0065 {
0066     if (oldregs)
0067         memcpy(newregs, oldregs, sizeof(*newregs));
0068     else
0069         ppc_save_regs(newregs);
0070 }
0071 
0072 extern void kexec_smp_wait(void);   /* get and clear naca physid, wait for
0073                       master to copy new code to 0 */
0074 extern int crashing_cpu;
0075 extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *));
0076 extern void crash_ipi_callback(struct pt_regs *);
0077 extern int crash_wake_offline;
0078 
0079 struct kimage;
0080 struct pt_regs;
0081 extern void default_machine_kexec(struct kimage *image);
0082 extern void default_machine_crash_shutdown(struct pt_regs *regs);
0083 extern int crash_shutdown_register(crash_shutdown_t handler);
0084 extern int crash_shutdown_unregister(crash_shutdown_t handler);
0085 
0086 extern void crash_kexec_prepare(void);
0087 extern void crash_kexec_secondary(struct pt_regs *regs);
0088 int __init overlaps_crashkernel(unsigned long start, unsigned long size);
0089 extern void reserve_crashkernel(void);
0090 extern void machine_kexec_mask_interrupts(void);
0091 
0092 static inline bool kdump_in_progress(void)
0093 {
0094     return crashing_cpu >= 0;
0095 }
0096 
0097 void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_code_buffer,
0098              unsigned long start_address) __noreturn;
0099 
0100 void kexec_copy_flush(struct kimage *image);
0101 
0102 #if defined(CONFIG_CRASH_DUMP) && defined(CONFIG_PPC_RTAS)
0103 void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
0104 #define crash_free_reserved_phys_range crash_free_reserved_phys_range
0105 #endif
0106 
0107 #ifdef CONFIG_KEXEC_FILE
0108 extern const struct kexec_file_ops kexec_elf64_ops;
0109 
0110 #define ARCH_HAS_KIMAGE_ARCH
0111 
0112 struct kimage_arch {
0113     struct crash_mem *exclude_ranges;
0114 
0115     unsigned long backup_start;
0116     void *backup_buf;
0117     void *fdt;
0118 };
0119 
0120 char *setup_kdump_cmdline(struct kimage *image, char *cmdline,
0121               unsigned long cmdline_len);
0122 int setup_purgatory(struct kimage *image, const void *slave_code,
0123             const void *fdt, unsigned long kernel_load_addr,
0124             unsigned long fdt_load_addr);
0125 
0126 #ifdef CONFIG_PPC64
0127 struct kexec_buf;
0128 
0129 int arch_kexec_kernel_image_probe(struct kimage *image, void *buf, unsigned long buf_len);
0130 #define arch_kexec_kernel_image_probe arch_kexec_kernel_image_probe
0131 
0132 int arch_kimage_file_post_load_cleanup(struct kimage *image);
0133 #define arch_kimage_file_post_load_cleanup arch_kimage_file_post_load_cleanup
0134 
0135 int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf);
0136 #define arch_kexec_locate_mem_hole arch_kexec_locate_mem_hole
0137 
0138 int load_crashdump_segments_ppc64(struct kimage *image,
0139                   struct kexec_buf *kbuf);
0140 int setup_purgatory_ppc64(struct kimage *image, const void *slave_code,
0141               const void *fdt, unsigned long kernel_load_addr,
0142               unsigned long fdt_load_addr);
0143 unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image);
0144 int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
0145             unsigned long initrd_load_addr,
0146             unsigned long initrd_len, const char *cmdline);
0147 #endif /* CONFIG_PPC64 */
0148 
0149 #endif /* CONFIG_KEXEC_FILE */
0150 
0151 #else /* !CONFIG_KEXEC_CORE */
0152 static inline void crash_kexec_secondary(struct pt_regs *regs) { }
0153 
0154 static inline int overlaps_crashkernel(unsigned long start, unsigned long size)
0155 {
0156     return 0;
0157 }
0158 
0159 static inline void reserve_crashkernel(void) { ; }
0160 
0161 static inline int crash_shutdown_register(crash_shutdown_t handler)
0162 {
0163     return 0;
0164 }
0165 
0166 static inline int crash_shutdown_unregister(crash_shutdown_t handler)
0167 {
0168     return 0;
0169 }
0170 
0171 static inline bool kdump_in_progress(void)
0172 {
0173     return false;
0174 }
0175 
0176 static inline void crash_ipi_callback(struct pt_regs *regs) { }
0177 
0178 static inline void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
0179 {
0180 }
0181 
0182 #endif /* CONFIG_KEXEC_CORE */
0183 
0184 #ifdef CONFIG_PPC_BOOK3S_64
0185 #include <asm/book3s/64/kexec.h>
0186 #endif
0187 
0188 #ifndef reset_sprs
0189 #define reset_sprs reset_sprs
0190 static inline void reset_sprs(void)
0191 {
0192 }
0193 #endif
0194 
0195 #endif /* ! __ASSEMBLY__ */
0196 #endif /* __KERNEL__ */
0197 #endif /* _ASM_POWERPC_KEXEC_H */