Re: A question about decompressing kernel on boot

2018-02-25 Thread ????
Hi Hao Lee,
Really appreciate your help.
:-)
Regards,
Larry






-- Original --
From:  "haolee.swjtu"<haolee.sw...@gmail.com>;
Date:  Mon, Feb 26, 2018 00:17 AM
To:  ""<losemyhea...@foxmail.com>;
Cc:  "kernelnewbies"<kernelnewbies@kernelnewbies.org>; 
Subject:  Re: A question about decompressing kernel on boot




 
leaq(_bss-8)(%rip), %rsi
 
leaq(_bss-8)(%rbx), %rdi
 
movq$_bss /* - $startup_32 */, %rcx
 
shrq$3, %rcx
 
std
 
rep movsq
 
cld
 
 
 
The movsq instruction copys 8 bytes each time and for the first time it will 
copy [_bss-8, _bss) to the new location. If we don't minus 8, the data in 
[_bss, _bss+8) will also be copied on the first execution of movsq. Obviously, 
we don't want to copy the bss section.
 

 Regards,
 Hao Lee___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: A question about decompressing kernel on boot

2018-02-25 Thread haolee.swjtu

	leaq	(_bss-8)(%rip), %rsi

	leaq	(_bss-8)(%rbx), %rdi

	movq	$_bss /* - $startup_32 */, %rcx

	shrq	$3, %rcx

	std

	rep	movsq

	cld


The movsq instruction copys 8 bytes each time and for the first time it will copy [_bss-8, _bss) to the new location. If we don't minus 8, the data in [_bss, _bss+8) will also be copied on the first execution of movsq. Obviously, we don't want to copy the bss section.

Regards,
Hao Lee___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


A question about decompressing kernel on boot

2018-02-25 Thread ????
Hi list,



In the source code arch/x86/boot/compressed/head_64.S, it described
how compressed kernel is copied from the origin place to another pointed by rbx 
register.


But I'm confused about the copying code, why it needs to minus 8 from _bss when 
calculating
_bss original and new addresses.


This is the source code.
/*
 * Copy the compressed kernel to the end of our buffer
 * where decompression in place becomes safe.
 */
pushq   %rsi
leaq(_bss-8)(%rip), %rsi
leaq(_bss-8)(%rbx), %rdi
movq$_bss /* - $startup_32 */, %rcx
shrq$3, %rcx
std
rep movsq
cld
popq%rsi


Thanks,
Larry___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies