@@ -51,7 +51,9 @@ SYM_CODE_START_NOALIGN(startup_64)
51
51
* for us. These identity mapped page tables map all of the
52
52
* kernel pages and possibly all of memory.
53
53
*
54
- * %rsi holds a physical pointer to real_mode_data.
54
+ * %RSI holds the physical address of the boot_params structure
55
+ * provided by the bootloader. Preserve it in %R15 so C function calls
56
+ * will not clobber it.
55
57
*
56
58
* We come here either directly from a 64bit bootloader, or from
57
59
* arch/x86/boot/compressed/head_64.S.
@@ -62,6 +64,7 @@ SYM_CODE_START_NOALIGN(startup_64)
62
64
* compiled to run at we first fixup the physical addresses in our page
63
65
* tables and then reload them.
64
66
*/
67
+ mov %rsi , %r15
65
68
66
69
/* Set up the stack for verify_cpu() */
67
70
leaq (__end_init_task - PTREGS_SIZE)(%rip ), %rsp
@@ -75,9 +78,7 @@ SYM_CODE_START_NOALIGN(startup_64)
75
78
shrq $32 , %rdx
76
79
wrmsr
77
80
78
- pushq %rsi
79
81
call startup_64_setup_env
80
- popq %rsi
81
82
82
83
/* Now switch to __KERNEL_CS so IRET works reliably */
83
84
pushq $__KERNEL_CS
@@ -93,12 +94,10 @@ SYM_CODE_START_NOALIGN(startup_64)
93
94
* Activate SEV/SME memory encryption if supported/enabled. This needs to
94
95
* be done now, since this also includes setup of the SEV-SNP CPUID table,
95
96
* which needs to be done before any CPUID instructions are executed in
96
- * subsequent code.
97
+ * subsequent code. Pass the boot_params pointer as the first argument.
97
98
*/
98
- movq %rsi , %rdi
99
- pushq %rsi
99
+ movq %r15 , %rdi
100
100
call sme_enable
101
- popq %rsi
102
101
#endif
103
102
104
103
/* Sanitize CPU configuration */
@@ -111,9 +110,8 @@ SYM_CODE_START_NOALIGN(startup_64)
111
110
* programmed into CR3.
112
111
*/
113
112
leaq _text(%rip ), %rdi
114
- pushq %rsi
113
+ movq %r15 , %rsi
115
114
call __startup_64
116
- popq %rsi
117
115
118
116
/* Form the CR3 value being sure to include the CR3 modifier */
119
117
addq $(early_top_pgt - __START_KERNEL_map), %rax
@@ -127,8 +125,6 @@ SYM_CODE_START(secondary_startup_64)
127
125
* At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 0,
128
126
* and someone has loaded a mapped page table.
129
127
*
130
- * %rsi holds a physical pointer to real_mode_data.
131
- *
132
128
* We come here either from startup_64 (using physical addresses)
133
129
* or from trampoline.S (using virtual addresses).
134
130
*
@@ -153,6 +149,9 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
153
149
UNWIND_HINT_END_OF_STACK
154
150
ANNOTATE_NOENDBR
155
151
152
+ /* Clear %R15 which holds the boot_params pointer on the boot CPU */
153
+ xorq %r15 , %r15
154
+
156
155
/*
157
156
* Retrieve the modifier (SME encryption mask if SME is active) to be
158
157
* added to the initial pgdir entry that will be programmed into CR3.
@@ -199,13 +198,9 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
199
198
* hypervisor could lie about the C-bit position to perform a ROP
200
199
* attack on the guest by writing to the unencrypted stack and wait for
201
200
* the next RET instruction.
202
- * %rsi carries pointer to realmode data and is callee-clobbered. Save
203
- * and restore it.
204
201
*/
205
- pushq %rsi
206
202
movq %rax , %rdi
207
203
call sev_verify_cbit
208
- popq %rsi
209
204
210
205
/*
211
206
* Switch to new page-table
@@ -365,9 +360,7 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
365
360
wrmsr
366
361
367
362
/* Setup and Load IDT */
368
- pushq %rsi
369
363
call early_setup_idt
370
- popq %rsi
371
364
372
365
/* Check if nx is implemented */
373
366
movl $0x80000001 , %eax
@@ -403,9 +396,8 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
403
396
pushq $0
404
397
popfq
405
398
406
- /* rsi is pointer to real mode structure with interesting info.
407
- pass it to C */
408
- movq %rsi , %rdi
399
+ /* Pass the boot_params pointer as first argument */
400
+ movq %r15 , %rdi
409
401
410
402
.Ljump_to_C_code:
411
403
/*
0 commit comments