@@ -405,10 +405,14 @@ SYM_CODE_START(startup_64)
405
405
lretq
406
406
407
407
.Lon_kernel_cs:
408
+ /*
409
+ * RSI holds a pointer to a boot_params structure provided by the
410
+ * loader, and this needs to be preserved across C function calls. So
411
+ * move it into a callee saved register.
412
+ */
413
+ movq %rsi , %r15
408
414
409
- pushq %rsi
410
415
call load_stage1_idt
411
- popq %rsi
412
416
413
417
#ifdef CONFIG_AMD_MEM_ENCRYPT
414
418
/*
@@ -419,12 +423,10 @@ SYM_CODE_START(startup_64)
419
423
* CPUID instructions being issued, so go ahead and do that now via
420
424
* sev_enable(), which will also handle the rest of the SEV-related
421
425
* detection/setup to ensure that has been done in advance of any dependent
422
- * code.
426
+ * code. Pass the boot_params pointer as the first argument.
423
427
*/
424
- pushq %rsi
425
- movq %rsi , %rdi /* real mode address */
428
+ movq %r15 , %rdi
426
429
call sev_enable
427
- popq %rsi
428
430
#endif
429
431
430
432
/*
@@ -437,13 +439,10 @@ SYM_CODE_START(startup_64)
437
439
* - Non zero RDX means trampoline needs to enable 5-level
438
440
* paging.
439
441
*
440
- * RSI holds real mode data and needs to be preserved across
441
- * this function call.
442
+ * Pass the boot_params pointer as the first argument.
442
443
*/
443
- pushq %rsi
444
- movq %rsi , %rdi /* real mode address */
444
+ movq %r15 , %rdi
445
445
call paging_prepare
446
- popq %rsi
447
446
448
447
/* Save the trampoline address in RCX */
449
448
movq %rax , %rcx
@@ -456,9 +455,9 @@ SYM_CODE_START(startup_64)
456
455
* because the architecture does not guarantee that GPRs will retain
457
456
* their full 64-bit values across a 32-bit mode switch.
458
457
*/
458
+ pushq %r15
459
459
pushq %rbp
460
460
pushq %rbx
461
- pushq %rsi
462
461
463
462
/*
464
463
* Push the 64-bit address of trampoline_return() onto the new stack.
@@ -475,9 +474,9 @@ SYM_CODE_START(startup_64)
475
474
lretq
476
475
trampoline_return:
477
476
/* Restore live 64-bit registers */
478
- popq %rsi
479
477
popq %rbx
480
478
popq %rbp
479
+ popq %r15
481
480
482
481
/* Restore the stack, the 32-bit trampoline uses its own stack */
483
482
leaq rva(boot_stack_end)(%rbx ), %rsp
@@ -487,14 +486,9 @@ trampoline_return:
487
486
*
488
487
* RDI is address of the page table to use instead of page table
489
488
* in trampoline memory (if required).
490
- *
491
- * RSI holds real mode data and needs to be preserved across
492
- * this function call.
493
489
*/
494
- pushq %rsi
495
490
leaq rva(top_pgtable)(%rbx ), %rdi
496
491
call cleanup_trampoline
497
- popq %rsi
498
492
499
493
/* Zero EFLAGS */
500
494
pushq $0
@@ -504,15 +498,13 @@ trampoline_return:
504
498
* Copy the compressed kernel to the end of our buffer
505
499
* where decompression in place becomes safe.
506
500
*/
507
- pushq %rsi
508
501
leaq (_bss-8 )(%rip ), %rsi
509
502
leaq rva(_bss-8 )(%rbx ), %rdi
510
503
movl $(_bss - startup_32), %ecx
511
504
shrl $3 , %ecx
512
505
std
513
506
rep movsq
514
507
cld
515
- popq %rsi
516
508
517
509
/*
518
510
* The GDT may get overwritten either during the copy we just did or
@@ -544,30 +536,28 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
544
536
shrq $3 , %rcx
545
537
rep stosq
546
538
547
- pushq %rsi
548
539
call load_stage2_idt
549
540
550
541
/* Pass boot_params to initialize_identity_maps() */
551
- movq ( %rsp ) , %rdi
542
+ movq %r15 , %rdi
552
543
call initialize_identity_maps
553
- popq %rsi
554
544
555
545
/*
556
546
* Do the extraction, and jump to the new kernel..
557
547
*/
558
- pushq %rsi /* Save the real mode argument */
559
- movq %rsi , %rdi /* real mode address */
548
+ /* pass struct boot_params pointer */
549
+ movq %r15 , %rdi
560
550
leaq boot_heap(%rip ), %rsi /* malloc area for uncompression */
561
551
leaq input_data(%rip ), %rdx /* input_data */
562
552
movl input_len(%rip ), %ecx /* input_len */
563
553
movq %rbp , %r8 /* output target address */
564
554
movl output_len(%rip ), %r9d /* decompressed length, end of relocs */
565
555
call extract_kernel /* returns kernel entry point in %rax */
566
- popq %rsi
567
556
568
557
/*
569
558
* Jump to the decompressed kernel.
570
559
*/
560
+ movq %r15 , %rsi
571
561
jmp *%rax
572
562
SYM_FUNC_END(.Lrelocated)
573
563
0 commit comments