Commit-ID: de6baf44716051a3652d482e86115f44d513d5cf Gitweb: http://git.kernel.org/tip/de6baf44716051a3652d482e86115f44d513d5cf Author: H. Peter Anvin <hpa@xxxxxxxxx> AuthorDate: Tue, 5 May 2009 14:16:37 -0700 Committer: H. Peter Anvin <hpa@xxxxxxxxx> CommitDate: Thu, 7 May 2009 13:38:45 -0700 x86, boot: use rep movsq to move kernel on 64 bits rep movsq is the architecturally preferred way to move a block of data. It isn't the fastest way on all existing CPUs, but it it likely to be in the future, and perhaps more importantly, we should encourage the architecturally right thing to do. This means saving and restoring %rsi around the copy code, which is easily done by setting up the stack early. However, we should not copy .bss (which we are about to zero anyway); we should only copy up to the *beginning* of .bss (just as on 32 bits.) This also makes the code quite a bit more similar between 32 and 64 bits. [ Impact: trivial optimization ] Signed-off-by: H. Peter Anvin <hpa@xxxxxxxxx> --- arch/x86/boot/compressed/head_64.S | 41 ++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 18 deletions(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 2678fdf..8bc8ed8 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -220,18 +220,30 @@ ENTRY(startup_64) #endif leaq z_extract_offset(%rbp), %rbx -/* Copy the compressed kernel to the end of our buffer +/* + * Set up the stack + */ + leaq boot_stack_end(%rbx), %rsp + +/* + * Zero EFLAGS after setting rsp + */ + pushq $0 + popfq + +/* + * Copy the compressed kernel to the end of our buffer * where decompression in place becomes safe. */ - leaq _end_before_pgt(%rip), %r8 - leaq _end_before_pgt(%rbx), %r9 - movq $_end_before_pgt /* - $startup_32 */, %rcx -1: subq $8, %r8 - subq $8, %r9 - movq 0(%r8), %rax - movq %rax, 0(%r9) - subq $8, %rcx - jnz 1b + pushq %rsi /* Kernel structure pointer */ + leaq (_bss-8)(%rip), %rsi + leaq (_bss-8)(%rbx), %rdi + movq $_bss /* - $startup_32 */, %rcx + shrq $3, %rcx + std + rep movsq + cld + popq %rsi /* * Jump to the relocated address. @@ -243,7 +255,7 @@ ENTRY(startup_64) relocated: /* - * Clear BSS + * Clear BSS (stack is empty at this point) */ xorl %eax, %eax leaq _edata(%rip), %rdi @@ -253,13 +265,6 @@ relocated: cld rep stosq - /* Setup the stack */ - leaq boot_stack_end(%rip), %rsp - - /* zero EFLAGS after setting rsp */ - pushq $0 - popfq - /* * Do the decompression, and jump to the new kernel.. */ -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
![]() |