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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Purgatory setup code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright IBM Corp. 2018
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <asm/asm-offsets.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <asm/sigp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) /* The purgatory is the code running between two kernels. It's main purpose
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * is to verify that the next kernel was not corrupted after load and to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * start it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * If the next kernel is a crash kernel there are some peculiarities to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * consider:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * First the purgatory is called twice. Once only to verify the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * sha digest. So if the crash kernel got corrupted the old kernel can try
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * to trigger a stand-alone dumper. And once to actually load the crash kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * Second the purgatory also has to swap the crash memory region with its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * destination at address 0. As the purgatory is part of crash memory this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * requires some finesse. The tactic here is that the purgatory first copies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * itself to the end of the destination and then swaps the rest of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * memory running from there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define bufsz purgatory_end-stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) .macro MEMCPY dst,src,len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	lgr	%r0,\dst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	lgr	%r1,\len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	lgr	%r2,\src
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	lgr	%r3,\len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 20:	mvcle	%r0,%r2,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	jo	20b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) .macro MEMSWAP dst,src,buf,len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 10:	cghi	\len,bufsz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	jh	11f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	lgr	%r4,\len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	j	12f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 11:	lghi	%r4,bufsz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 12:	MEMCPY	\buf,\dst,%r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	MEMCPY	\dst,\src,%r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	MEMCPY	\src,\buf,%r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	agr	\dst,%r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	agr	\src,%r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	sgr	\len,%r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	cghi	\len,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	jh	10b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) .macro START_NEXT_KERNEL base subcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	lg	%r4,kernel_entry-\base(%r13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	lg	%r5,load_psw_mask-\base(%r13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	ogr	%r4,%r5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	stg	%r4,0(%r0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	xgr	%r0,%r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	lghi	%r1,\subcode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	diag	%r0,%r1,0x308
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) .text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) .align PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) ENTRY(purgatory_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	/* The purgatory might be called after a diag308 so better set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	 * architecture and addressing mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	lhi	%r1,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	sigp	%r1,%r0,SIGP_SET_ARCHITECTURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	sam64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	larl	%r5,gprregs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	stmg	%r6,%r15,0(%r5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	basr	%r13,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) .base_crash:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	/* Setup stack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	larl	%r15,purgatory_end-STACK_FRAME_OVERHEAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	/* If the next kernel is KEXEC_TYPE_CRASH the purgatory is called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 * directly with a flag passed in %r2 whether the purgatory shall do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	 * checksum verification only (%r2 = 0 -> verification only).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	 * Check now and preserve over C function call by storing in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	 * %r10 whith
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	 *	1 -> checksum verification only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	 *	0 -> load new kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	lghi	%r10,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	lg	%r11,kernel_type-.base_crash(%r13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	cghi	%r11,1		/* KEXEC_TYPE_CRASH */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	jne	.do_checksum_verification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	cghi	%r2,0		/* checksum verification only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	jne	.do_checksum_verification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	lghi	%r10,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .do_checksum_verification:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	brasl	%r14,verify_sha256_digest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	cghi	%r10,1		/* checksum verification only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	je	.return_old_kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	cghi	%r2,0		/* checksum match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	jne	.disabled_wait
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	/* If the next kernel is a crash kernel the purgatory has to swap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	 * the mem regions first.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	cghi	%r11,1 /* KEXEC_TYPE_CRASH */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	je	.start_crash_kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	/* start normal kernel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	START_NEXT_KERNEL .base_crash 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) .return_old_kernel:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	lmg	%r6,%r15,gprregs-.base_crash(%r13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	br	%r14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) .disabled_wait:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	lpswe	disabled_wait_psw-.base_crash(%r13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) .start_crash_kernel:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	/* Location of purgatory_start in crash memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	lgr	%r8,%r13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	aghi	%r8,-(.base_crash-purgatory_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	/* Destination for this code i.e. end of memory to be swapped. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	lg	%r9,crash_size-.base_crash(%r13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	aghi	%r9,-(purgatory_end-purgatory_start)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	/* Destination in crash memory, i.e. same as r9 but in crash memory. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	lg	%r10,crash_start-.base_crash(%r13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	agr	%r10,%r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	/* Buffer location (in crash memory) and size. As the purgatory is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	 * behind the point of no return it can re-use the stack as buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	lghi	%r11,bufsz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	larl	%r12,stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	MEMCPY	%r12,%r9,%r11	/* dst	-> (crash) buf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	MEMCPY	%r9,%r8,%r11	/* self -> dst */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	/* Jump to new location. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	lgr	%r7,%r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	aghi	%r7,.jump_to_dst-purgatory_start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	br	%r7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) .jump_to_dst:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	basr	%r13,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) .base_dst:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	/* clear buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	MEMCPY	%r12,%r10,%r11	/* (crash) buf -> (crash) dst */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	/* Load new buffer location after jump */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	larl	%r7,stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	aghi	%r10,stack-purgatory_start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	MEMCPY	%r10,%r7,%r11	/* (new) buf -> (crash) buf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	/* Now the code is set up to run from its designated location. Start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	 * swapping the rest of crash memory now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	 * The registers will be used as follow:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	 *	%r0-%r4	reserved for macros defined above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	 *	%r5-%r6 tmp registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	 *	%r7	pointer to current struct sha region
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	 *	%r8	index to iterate over all sha regions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	 *	%r9	pointer in crash memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	 *	%r10	pointer in old kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	 *	%r11	total size (still) to be moved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	 *	%r12	pointer to buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	lgr	%r12,%r7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	lgr	%r11,%r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	lghi	%r10,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	lg	%r9,crash_start-.base_dst(%r13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	lghi	%r8,16	/* KEXEC_SEGMENTS_MAX */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	larl	%r7,purgatory_sha_regions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	j .loop_first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	/* Loop over all purgatory_sha_regions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) .loop_next:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	aghi	%r8,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	cghi	%r8,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	je	.loop_out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	aghi	%r7,__KEXEC_SHA_REGION_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) .loop_first:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	lg	%r5,__KEXEC_SHA_REGION_START(%r7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	cghi	%r5,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	je	.loop_next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	/* Copy [end last sha region, start current sha region) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	/* Note: kexec_sha_region->start points in crash memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	sgr	%r5,%r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	MEMCPY	%r9,%r10,%r5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	agr	%r9,%r5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	agr	%r10,%r5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	sgr	%r11,%r5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	/* Swap sha region */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	lg	%r6,__KEXEC_SHA_REGION_LEN(%r7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	MEMSWAP	%r9,%r10,%r12,%r6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	sg	%r11,__KEXEC_SHA_REGION_LEN(%r7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	j	.loop_next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) .loop_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	/* Copy rest of crash memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	MEMCPY	%r9,%r10,%r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	/* start crash kernel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	START_NEXT_KERNEL .base_dst 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) load_psw_mask:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	.long	0x00080000,0x80000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	.align	8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) disabled_wait_psw:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	.quad	0x0002000180000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	.quad	0x0000000000000000 + .do_checksum_verification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) gprregs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	.rept	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	.quad	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	.endr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) /* Macro to define a global variable with name and size (in bytes) to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)  * shared with C code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  * Add the .size and .type attribute to satisfy checks on the Elf_Sym during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)  * purgatory load.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) .macro GLOBAL_VARIABLE name,size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) \name:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	.global \name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	.size	\name,\size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	.type	\name,object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	.skip	\size,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) GLOBAL_VARIABLE purgatory_sha256_digest,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) GLOBAL_VARIABLE purgatory_sha_regions,16*__KEXEC_SHA_REGION_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) GLOBAL_VARIABLE kernel_entry,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) GLOBAL_VARIABLE kernel_type,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) GLOBAL_VARIABLE crash_start,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) GLOBAL_VARIABLE crash_size,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	.align	PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) stack:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	/* The buffer to move this code must be as big as the code. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	.skip	stack-purgatory_start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	.align	PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) purgatory_end: