Skip to content

Commit

Permalink
[prefix] Use %cs as implicit parameter to uninstall()
Browse files Browse the repository at this point in the history
romprefix.S currently calls uninstall() with an invalid value in %ax.
Consequently, base memory is not freed after a ROM boot attempt (or
after entering iPXE during POST).

The uninstall() function is physically present in .text16, and so can
use %cs to determine the .text16 segment address.  The .data16 segment
address is not required, since uninstall() is called only by code
paths which set up .data16 to immediately follow .text16.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 8, 2013
1 parent c7694ac commit 0d4a760
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/arch/i386/prefix/libprefix.S
Expand Up @@ -545,8 +545,7 @@ alloc_basemem:
* Free space allocated with alloc_basemem.
*
* Parameters:
* %ax : .text16 segment address
* %bx : .data16 segment address
* none (.text16 segment address is implicit in %cs)
* Returns:
* %ax : 0 if successfully freed
* Corrupts:
Expand All @@ -559,28 +558,30 @@ alloc_basemem:
free_basemem:
/* Preserve registers */
pushw %fs
pushw %ax

/* Check FBMS counter */
pushw %ax
movw %cs, %ax
shrw $6, %ax
pushw $0x40
popw %fs
cmpw %ax, %fs:0x13
popw %ax
jne 1f

/* Check hooked interrupt count */
cmpw $0, %cs:hooked_bios_interrupts
jne 1f

/* OK to free memory */
movw %cs, %ax
addw $_text16_memsz_pgh, %ax
addw $_data16_memsz_pgh, %ax
shrw $6, %ax
movw %ax, %fs:0x13
xorw %ax, %ax

1: /* Restore registers and return */
popw %ax
popw %fs
ret
.size free_basemem, . - free_basemem
Expand Down Expand Up @@ -872,8 +873,7 @@ close_payload:
* Uninstall all text and data segments.
*
* Parameters:
* %ax : .text16 segment address
* %bx : .data16 segment address
* none (.text16 segment address is implicit in %cs)
* Returns:
* none
* Corrupts:
Expand Down

0 comments on commit 0d4a760

Please sign in to comment.