mirror of https://github.com/ipxe/ipxe.git
[prefix] Use .bss16 as temporary stack space for calls to install_block
Some decompression algorithms (e.g. LZMA) require large amounts of temporary stack space, which may not be made available by all prefixes. Use .bss16 as a temporary stack for the duration of the calls to install_block (switching back to the external stack before we start making calls into code which might access variables in .bss16), and allow the decompressor to define a global symbol to force a minimum value on the size of .bss16. Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/34/head
parent
b6889eaa1e
commit
3e04f0791e
|
@ -296,11 +296,9 @@ copy_bytes:
|
||||||
* Zero bytes
|
* Zero bytes
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* %ds:esi : source address
|
|
||||||
* %es:edi : destination address
|
* %es:edi : destination address
|
||||||
* %ecx : length
|
* %ecx : length
|
||||||
* Returns:
|
* Returns:
|
||||||
* %ds:esi : next source address
|
|
||||||
* %es:edi : next destination address
|
* %es:edi : next destination address
|
||||||
* Corrupts:
|
* Corrupts:
|
||||||
* None
|
* None
|
||||||
|
@ -678,12 +676,21 @@ install:
|
||||||
.globl install_prealloc
|
.globl install_prealloc
|
||||||
install_prealloc:
|
install_prealloc:
|
||||||
progress "install_prealloc:\n"
|
progress "install_prealloc:\n"
|
||||||
/* Save registers */
|
/* Save registers on external stack */
|
||||||
pushal
|
pushal
|
||||||
pushw %ds
|
pushw %ds
|
||||||
pushw %es
|
pushw %es
|
||||||
cld /* Sanity: clear the direction flag asap */
|
cld /* Sanity: clear the direction flag asap */
|
||||||
|
|
||||||
|
/* Switch to temporary stack in .bss16 */
|
||||||
|
pushw %ss
|
||||||
|
popw %ds
|
||||||
|
movl %esp, %ecx
|
||||||
|
movw %bx, %ss
|
||||||
|
movl $_data16_memsz, %esp
|
||||||
|
pushw %ds
|
||||||
|
pushl %ecx
|
||||||
|
|
||||||
/* Set up %ds for (read-only) access to .prefix */
|
/* Set up %ds for (read-only) access to .prefix */
|
||||||
pushw %cs
|
pushw %cs
|
||||||
popw %ds
|
popw %ds
|
||||||
|
@ -710,6 +717,7 @@ install_prealloc:
|
||||||
popl %esi
|
popl %esi
|
||||||
|
|
||||||
#ifndef KEEP_IT_REAL
|
#ifndef KEEP_IT_REAL
|
||||||
|
|
||||||
/* Access high memory by enabling the A20 gate. (We will
|
/* Access high memory by enabling the A20 gate. (We will
|
||||||
* already have 4GB segment limits as a result of calling
|
* already have 4GB segment limits as a result of calling
|
||||||
* install_block.)
|
* install_block.)
|
||||||
|
@ -778,7 +786,7 @@ payload_death_message:
|
||||||
movzwl %bx, %edi
|
movzwl %bx, %edi
|
||||||
shll $4, %edi
|
shll $4, %edi
|
||||||
movl $_data16_filesz, %ecx
|
movl $_data16_filesz, %ecx
|
||||||
movl $_data16_memsz, %edx
|
movl $_data16_filesz, %edx /* do not zero our temporary stack */
|
||||||
call install_block /* .data16 */
|
call install_block /* .data16 */
|
||||||
|
|
||||||
/* Set up %ds for access to .data16 */
|
/* Set up %ds for access to .data16 */
|
||||||
|
@ -787,11 +795,8 @@ payload_death_message:
|
||||||
/* Restore decompression temporary area physical address */
|
/* Restore decompression temporary area physical address */
|
||||||
popl %edi
|
popl %edi
|
||||||
|
|
||||||
#ifdef KEEP_IT_REAL
|
#ifndef KEEP_IT_REAL
|
||||||
/* Initialise libkir */
|
|
||||||
movw %ax, (init_libkir_vector+2)
|
|
||||||
lcall *init_libkir_vector
|
|
||||||
#else
|
|
||||||
/* Find a suitable decompression temporary area, if none specified */
|
/* Find a suitable decompression temporary area, if none specified */
|
||||||
pushl %eax
|
pushl %eax
|
||||||
testl %edi, %edi
|
testl %edi, %edi
|
||||||
|
@ -823,6 +828,22 @@ payload_death_message:
|
||||||
call install_block
|
call install_block
|
||||||
popl %edi
|
popl %edi
|
||||||
|
|
||||||
|
#endif /* KEEP_IT_REAL */
|
||||||
|
|
||||||
|
/* Switch back to original stack and zero .bss16 */
|
||||||
|
lss %ss:(%esp), %esp
|
||||||
|
pushl %edi
|
||||||
|
pushw %es
|
||||||
|
movw %bx, %es
|
||||||
|
movl $_data16_filesz, %edi
|
||||||
|
movl $_data16_memsz, %ecx
|
||||||
|
subl %edi, %ecx
|
||||||
|
call zero_bytes
|
||||||
|
popw %es
|
||||||
|
popl %edi
|
||||||
|
|
||||||
|
#ifndef KEEP_IT_REAL
|
||||||
|
|
||||||
/* Initialise librm at current location */
|
/* Initialise librm at current location */
|
||||||
progress " init_librm\n"
|
progress " init_librm\n"
|
||||||
movw %ax, (init_librm_vector+2)
|
movw %ax, (init_librm_vector+2)
|
||||||
|
@ -834,7 +855,6 @@ payload_death_message:
|
||||||
incb memmap_post
|
incb memmap_post
|
||||||
decl %ebp
|
decl %ebp
|
||||||
1:
|
1:
|
||||||
|
|
||||||
/* Call relocate() to determine target address for relocation.
|
/* Call relocate() to determine target address for relocation.
|
||||||
* relocate() will return with %esi, %edi and %ecx set up
|
* relocate() will return with %esi, %edi and %ecx set up
|
||||||
* ready for the copy to the new location.
|
* ready for the copy to the new location.
|
||||||
|
@ -857,7 +877,14 @@ payload_death_message:
|
||||||
/* Initialise librm at new location */
|
/* Initialise librm at new location */
|
||||||
progress " init_librm\n"
|
progress " init_librm\n"
|
||||||
lcall *init_librm_vector
|
lcall *init_librm_vector
|
||||||
#endif
|
|
||||||
|
#else /* KEEP_IT_REAL */
|
||||||
|
|
||||||
|
/* Initialise libkir */
|
||||||
|
movw %ax, (init_libkir_vector+2)
|
||||||
|
lcall *init_libkir_vector
|
||||||
|
|
||||||
|
#endif /* KEEP_IT_REAL */
|
||||||
|
|
||||||
/* Close access to payload */
|
/* Close access to payload */
|
||||||
progress " close_payload\n"
|
progress " close_payload\n"
|
||||||
|
|
|
@ -26,6 +26,13 @@ SECTIONS {
|
||||||
|
|
||||||
PROVIDE ( _max_align = 16 );
|
PROVIDE ( _max_align = 16 );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allow decompressor to require a minimum amount of temporary stack
|
||||||
|
* space.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
PROVIDE ( _min_decompress_stack = 0 );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The prefix
|
* The prefix
|
||||||
*
|
*
|
||||||
|
@ -87,6 +94,7 @@ SECTIONS {
|
||||||
*(.bss16.*)
|
*(.bss16.*)
|
||||||
*(.stack16)
|
*(.stack16)
|
||||||
*(.stack16.*)
|
*(.stack16.*)
|
||||||
|
. = MAX ( ., _mdata16 + _min_decompress_stack );
|
||||||
_edata16 = .;
|
_edata16 = .;
|
||||||
}
|
}
|
||||||
_data16_filesz = ABSOLUTE ( _mdata16 ) - ABSOLUTE ( _data16 );
|
_data16_filesz = ABSOLUTE ( _mdata16 ) - ABSOLUTE ( _data16 );
|
||||||
|
|
Loading…
Reference in New Issue