@@ -405,10 +405,14 @@ SYM_CODE_START(startup_64)
405405 lretq
406406
407407.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
408414
409- pushq %rsi
410415 call load_stage1_idt
411- popq %rsi
412416
413417#ifdef CONFIG_AMD_MEM_ENCRYPT
414418 /*
@@ -419,12 +423,10 @@ SYM_CODE_START(startup_64)
419423 * CPUID instructions being issued, so go ahead and do that now via
420424 * sev_enable(), which will also handle the rest of the SEV-related
421425 * 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.
423427 */
424- pushq %rsi
425- movq %rsi , %rdi /* real mode address */
428+ movq %r15 , %rdi
426429 call sev_enable
427- popq %rsi
428430#endif
429431
430432 /*
@@ -437,13 +439,10 @@ SYM_CODE_START(startup_64)
437439 * - Non zero RDX means trampoline needs to enable 5-level
438440 * paging.
439441 *
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.
442443 */
443- pushq %rsi
444- movq %rsi , %rdi /* real mode address */
444+ movq %r15 , %rdi
445445 call paging_prepare
446- popq %rsi
447446
448447 /* Save the trampoline address in RCX */
449448 movq %rax , %rcx
@@ -456,9 +455,9 @@ SYM_CODE_START(startup_64)
456455 * because the architecture does not guarantee that GPRs will retain
457456 * their full 64-bit values across a 32-bit mode switch.
458457 */
458+ pushq %r15
459459 pushq %rbp
460460 pushq %rbx
461- pushq %rsi
462461
463462 /*
464463 * Push the 64-bit address of trampoline_return() onto the new stack.
@@ -475,9 +474,9 @@ SYM_CODE_START(startup_64)
475474 lretq
476475trampoline_return:
477476 /* Restore live 64-bit registers */
478- popq %rsi
479477 popq %rbx
480478 popq %rbp
479+ popq %r15
481480
482481 /* Restore the stack, the 32-bit trampoline uses its own stack */
483482 leaq rva(boot_stack_end)(%rbx ), %rsp
@@ -487,14 +486,9 @@ trampoline_return:
487486 *
488487 * RDI is address of the page table to use instead of page table
489488 * in trampoline memory (if required).
490- *
491- * RSI holds real mode data and needs to be preserved across
492- * this function call.
493489 */
494- pushq %rsi
495490 leaq rva(top_pgtable)(%rbx ), %rdi
496491 call cleanup_trampoline
497- popq %rsi
498492
499493 /* Zero EFLAGS */
500494 pushq $0
@@ -504,15 +498,13 @@ trampoline_return:
504498 * Copy the compressed kernel to the end of our buffer
505499 * where decompression in place becomes safe.
506500 */
507- pushq %rsi
508501 leaq (_bss-8 )(%rip ), %rsi
509502 leaq rva(_bss-8 )(%rbx ), %rdi
510503 movl $(_bss - startup_32), %ecx
511504 shrl $3 , %ecx
512505 std
513506 rep movsq
514507 cld
515- popq %rsi
516508
517509 /*
518510 * The GDT may get overwritten either during the copy we just did or
@@ -544,30 +536,28 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
544536 shrq $3 , %rcx
545537 rep stosq
546538
547- pushq %rsi
548539 call load_stage2_idt
549540
550541 /* Pass boot_params to initialize_identity_maps() */
551- movq ( %rsp ) , %rdi
542+ movq %r15 , %rdi
552543 call initialize_identity_maps
553- popq %rsi
554544
555545/*
556546 * Do the extraction, and jump to the new kernel..
557547 */
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
560550 leaq boot_heap(%rip ), %rsi /* malloc area for uncompression */
561551 leaq input_data(%rip ), %rdx /* input_data */
562552 movl input_len(%rip ), %ecx /* input_len */
563553 movq %rbp , %r8 /* output target address */
564554 movl output_len(%rip ), %r9d /* decompressed length, end of relocs */
565555 call extract_kernel /* returns kernel entry point in %rax */
566- popq %rsi
567556
568557/*
569558 * Jump to the decompressed kernel.
570559 */
560+ movq %r15 , %rsi
571561 jmp *%rax
572562SYM_FUNC_END(.Lrelocated)
573563
0 commit comments