aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/boot
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-08 19:45:15 -0400
committerH. Peter Anvin <hpa@zytor.com>2009-05-08 20:34:52 -0400
commit36d3793c947f1ef7ba3d24eeeddc1be41adc5ab4 (patch)
treebf5987e4caacb7aab5a78ca683a3179bd8eba717 /arch/x86/boot
parent97541912785369925723b6255438ad9fce2ddf04 (diff)
x86, boot: use appropriate rep string for move and clear
In the pre-decompression code, use the appropriate largest possible rep movs and rep stos to move code and clear bss, respectively. For reverse copy, do note that the initial values are supposed to be the address of the first (highest) copy datum, not one byte beyond the end of the buffer. rep strings are not necessarily the fastest way to perform these operations on all current processors, but are likely to be in the future, and perhaps more importantly, we want to encourage the architecturally right thing to do here. This also fixes a couple of trivial inefficiencies on 64 bits. [ Impact: trivial performance enhancement, increase code similarity ] Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/boot')
-rw-r--r--arch/x86/boot/compressed/head_32.S11
-rw-r--r--arch/x86/boot/compressed/head_64.S26
2 files changed, 19 insertions, 18 deletions
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index d02a4f02be13..6710dc78ac59 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -100,11 +100,12 @@ ENTRY(startup_32)
100 * where decompression in place becomes safe. 100 * where decompression in place becomes safe.
101 */ 101 */
102 pushl %esi 102 pushl %esi
103 leal _bss(%ebp), %esi 103 leal (_bss-4)(%ebp), %esi
104 leal _bss(%ebx), %edi 104 leal (_bss-4)(%ebx), %edi
105 movl $(_bss - startup_32), %ecx 105 movl $(_bss - startup_32), %ecx
106 shrl $2, %ecx
106 std 107 std
107 rep movsb 108 rep movsl
108 cld 109 cld
109 popl %esi 110 popl %esi
110 111
@@ -135,8 +136,8 @@ relocated:
135 leal _bss(%ebx), %edi 136 leal _bss(%ebx), %edi
136 leal _ebss(%ebx), %ecx 137 leal _ebss(%ebx), %ecx
137 subl %edi, %ecx 138 subl %edi, %ecx
138 cld 139 shrl $2, %ecx
139 rep stosb 140 rep stosl
140 141
141/* 142/*
142 * Do the decompression, and jump to the new kernel.. 143 * Do the decompression, and jump to the new kernel..
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index a0b18426069a..723c72dfd7bc 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -260,15 +260,15 @@ ENTRY(startup_64)
260 * Copy the compressed kernel to the end of our buffer 260 * Copy the compressed kernel to the end of our buffer
261 * where decompression in place becomes safe. 261 * where decompression in place becomes safe.
262 */ 262 */
263 leaq _bss(%rip), %r8 263 pushq %rsi
264 leaq _bss(%rbx), %r9 264 leaq (_bss-8)(%rip), %rsi
265 leaq (_bss-8)(%rbx), %rdi
265 movq $_bss /* - $startup_32 */, %rcx 266 movq $_bss /* - $startup_32 */, %rcx
2661: subq $8, %r8 267 shrq $3, %rcx
267 subq $8, %r9 268 std
268 movq 0(%r8), %rax 269 rep movsq
269 movq %rax, 0(%r9) 270 cld
270 subq $8, %rcx 271 popq %rsi
271 jnz 1b
272 272
273/* 273/*
274 * Jump to the relocated address. 274 * Jump to the relocated address.
@@ -282,12 +282,12 @@ relocated:
282/* 282/*
283 * Clear BSS (stack is currently empty) 283 * Clear BSS (stack is currently empty)
284 */ 284 */
285 xorq %rax, %rax 285 xorl %eax, %eax
286 leaq _bss(%rbx), %rdi 286 leaq _bss(%rip), %rdi
287 leaq _ebss(%rbx), %rcx 287 leaq _ebss(%rip), %rcx
288 subq %rdi, %rcx 288 subq %rdi, %rcx
289 cld 289 shrq $3, %rcx
290 rep stosb 290 rep stosq
291 291
292/* 292/*
293 * Do the decompression, and jump to the new kernel.. 293 * Do the decompression, and jump to the new kernel..