Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _ASM_X86_KEXEC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _ASM_X86_KEXEC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #ifdef CONFIG_X86_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) # define PA_CONTROL_PAGE	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) # define VA_CONTROL_PAGE	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) # define PA_PGD			2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) # define PA_SWAP_PAGE		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) # define PAGES_NR		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) # define PA_CONTROL_PAGE	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) # define VA_CONTROL_PAGE	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) # define PA_TABLE_PAGE		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) # define PA_SWAP_PAGE		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) # define PAGES_NR		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) # define KEXEC_CONTROL_CODE_MAX_SIZE	2048
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <asm/bootparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) struct kimage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * I.e. Maximum page that is mapped directly into kernel memory,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * and kmap is not required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * So far x86_64 is limited to 40 physical address bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #ifdef CONFIG_X86_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) /* Maximum physical address we can use pages from */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) # define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) /* Maximum address we can reach in physical address mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) # define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) /* Maximum address we can use for the control code buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) # define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) # define KEXEC_CONTROL_PAGE_SIZE	4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /* The native architecture */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) # define KEXEC_ARCH KEXEC_ARCH_386
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) /* We can also handle crash dumps from 64 bit kernel. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) # define vmcore_elf_check_arch_cross(x) ((x)->e_machine == EM_X86_64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /* Maximum physical address we can use pages from */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) # define KEXEC_SOURCE_MEMORY_LIMIT      (MAXMEM-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) /* Maximum address we can reach in physical address mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) # define KEXEC_DESTINATION_MEMORY_LIMIT (MAXMEM-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) /* Maximum address we can use for the control pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) # define KEXEC_CONTROL_MEMORY_LIMIT     (MAXMEM-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* Allocate one page for the pdp and the second for the code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) # define KEXEC_CONTROL_PAGE_SIZE  (4096UL + 4096UL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) /* The native architecture */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) # define KEXEC_ARCH KEXEC_ARCH_X86_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * This function is responsible for capturing register states if coming
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * via panic otherwise just fix up the ss and sp if coming via kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * mode exception.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static inline void crash_setup_regs(struct pt_regs *newregs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 				    struct pt_regs *oldregs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	if (oldregs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		memcpy(newregs, oldregs, sizeof(*newregs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #ifdef CONFIG_X86_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		asm volatile("movl %%ebx,%0" : "=m"(newregs->bx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		asm volatile("movl %%ecx,%0" : "=m"(newregs->cx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		asm volatile("movl %%edx,%0" : "=m"(newregs->dx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		asm volatile("movl %%esi,%0" : "=m"(newregs->si));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		asm volatile("movl %%edi,%0" : "=m"(newregs->di));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		asm volatile("movl %%ebp,%0" : "=m"(newregs->bp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		asm volatile("movl %%eax,%0" : "=m"(newregs->ax));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		asm volatile("movl %%esp,%0" : "=m"(newregs->sp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		asm volatile("movl %%ss, %%eax;" :"=a"(newregs->ss));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		asm volatile("movl %%cs, %%eax;" :"=a"(newregs->cs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		asm volatile("movl %%ds, %%eax;" :"=a"(newregs->ds));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		asm volatile("movl %%es, %%eax;" :"=a"(newregs->es));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		asm volatile("pushfl; popl %0" :"=m"(newregs->flags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		asm volatile("movq %%rbx,%0" : "=m"(newregs->bx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		asm volatile("movq %%rcx,%0" : "=m"(newregs->cx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		asm volatile("movq %%rdx,%0" : "=m"(newregs->dx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		asm volatile("movq %%rsi,%0" : "=m"(newregs->si));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		asm volatile("movq %%rdi,%0" : "=m"(newregs->di));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		asm volatile("movq %%rbp,%0" : "=m"(newregs->bp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		asm volatile("movq %%rax,%0" : "=m"(newregs->ax));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		asm volatile("movq %%rsp,%0" : "=m"(newregs->sp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		asm volatile("movq %%r8,%0" : "=m"(newregs->r8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		asm volatile("movq %%r9,%0" : "=m"(newregs->r9));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		asm volatile("movq %%r10,%0" : "=m"(newregs->r10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		asm volatile("movq %%r11,%0" : "=m"(newregs->r11));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		asm volatile("movq %%r12,%0" : "=m"(newregs->r12));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		asm volatile("movq %%r13,%0" : "=m"(newregs->r13));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		asm volatile("movq %%r14,%0" : "=m"(newregs->r14));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		asm volatile("movq %%r15,%0" : "=m"(newregs->r15));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		asm volatile("movl %%ss, %%eax;" :"=a"(newregs->ss));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		asm volatile("movl %%cs, %%eax;" :"=a"(newregs->cs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		asm volatile("pushfq; popq %0" :"=m"(newregs->flags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		newregs->ip = _THIS_IP_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #ifdef CONFIG_X86_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) asmlinkage unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) relocate_kernel(unsigned long indirection_page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		unsigned long control_page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		unsigned long start_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		unsigned int has_pae,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		unsigned int preserve_context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) relocate_kernel(unsigned long indirection_page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		unsigned long page_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		unsigned long start_address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		unsigned int preserve_context,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		unsigned int sme_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define ARCH_HAS_KIMAGE_ARCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #ifdef CONFIG_X86_32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct kimage_arch {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	pgd_t *pgd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #ifdef CONFIG_X86_PAE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	pmd_t *pmd0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	pmd_t *pmd1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	pte_t *pte0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	pte_t *pte1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct kimage_arch {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	p4d_t *p4d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	pud_t *pud;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	pmd_t *pmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	pte_t *pte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	/* Core ELF header buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	void *elf_headers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	unsigned long elf_headers_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	unsigned long elf_load_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #endif /* CONFIG_X86_32 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #ifdef CONFIG_X86_64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * Number of elements and order of elements in this structure should match
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * with the ones in arch/x86/purgatory/entry64.S. If you make a change here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  * make an appropriate change in purgatory too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct kexec_entry64_regs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	uint64_t rax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	uint64_t rcx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	uint64_t rdx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	uint64_t rbx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	uint64_t rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	uint64_t rbp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	uint64_t rsi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	uint64_t rdi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	uint64_t r8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	uint64_t r9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	uint64_t r10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	uint64_t r11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	uint64_t r12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	uint64_t r13;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	uint64_t r14;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	uint64_t r15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	uint64_t rip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) extern int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 				       gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #define arch_kexec_post_alloc_pages arch_kexec_post_alloc_pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) extern void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #define arch_kexec_pre_free_pages arch_kexec_pre_free_pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) typedef void crash_vmclear_fn(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) extern void kdump_nmi_shootdown_cpus(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #endif /* __ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) #endif /* _ASM_X86_KEXEC_H */