mirror of
https://github.com/ipxe/ipxe
synced 2026-02-14 02:31:26 +03:00
[prefix] Pad .text16 and .data16 segment sizes at build time
Commit c64747d ("[librm] Speed up real-to-protected mode transition
under KVM") rounded down the .text16 segment address calculated in
alloc_basemem() to a multiple of 64 bytes in order to speed up mode
transitions under KVM.
This creates a potential discrepancy between alloc_basemem() and
free_basemem(), meaning that free_basemem() may free less memory than
was allocated by alloc_basemem().
Fix by padding the calculated sizes of both .text16 and .data16 to a
multiple of 64 bytes at build time.
Debugged-by: Yossef Efraim <yossefe@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -558,14 +558,11 @@ alloc_basemem:
|
|||||||
shlw $6, %ax
|
shlw $6, %ax
|
||||||
|
|
||||||
/* Calculate .data16 segment address */
|
/* Calculate .data16 segment address */
|
||||||
subw $_data16_memsz_pgh, %ax
|
subw $_data16_memsz_ppgh, %ax
|
||||||
pushw %ax
|
pushw %ax
|
||||||
|
|
||||||
/* Calculate .text16 segment address. Round down to ensure
|
/* Calculate .text16 segment address */
|
||||||
* low bits are zero, to speed up mode transitions under KVM.
|
subw $_text16_memsz_ppgh, %ax
|
||||||
*/
|
|
||||||
subw $_text16_memsz_pgh, %ax
|
|
||||||
andb $~0x03, %al
|
|
||||||
pushw %ax
|
pushw %ax
|
||||||
|
|
||||||
/* Update FBMS */
|
/* Update FBMS */
|
||||||
@@ -616,8 +613,8 @@ free_basemem:
|
|||||||
|
|
||||||
/* OK to free memory */
|
/* OK to free memory */
|
||||||
movw %cs, %ax
|
movw %cs, %ax
|
||||||
addw $_text16_memsz_pgh, %ax
|
addw $_text16_memsz_ppgh, %ax
|
||||||
addw $_data16_memsz_pgh, %ax
|
addw $_data16_memsz_ppgh, %ax
|
||||||
shrw $6, %ax
|
shrw $6, %ax
|
||||||
movw %ax, %fs:0x13
|
movw %ax, %fs:0x13
|
||||||
xorw %ax, %ax
|
xorw %ax, %ax
|
||||||
|
|||||||
@@ -247,8 +247,8 @@ SECTIONS {
|
|||||||
* Values calculated to save code from doing it
|
* Values calculated to save code from doing it
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
_text16_memsz_pgh = ( ( _text16_memsz + 15 ) / 16 );
|
_text16_memsz_ppgh = ( ( ( _text16_memsz + 63 ) / 64 ) * 4 );
|
||||||
_data16_memsz_pgh = ( ( _data16_memsz + 15 ) / 16 );
|
_data16_memsz_ppgh = ( ( ( _data16_memsz + 63 ) / 64 ) * 4 );
|
||||||
_textdata_memsz_pgh = ( ( _textdata_memsz + 15 ) / 16 );
|
_textdata_memsz_pgh = ( ( _textdata_memsz + 15 ) / 16 );
|
||||||
_textdata_memsz_kb = ( ( _textdata_memsz + 1023 ) / 1024 );
|
_textdata_memsz_kb = ( ( _textdata_memsz + 1023 ) / 1024 );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user