Bladeren bron

[prefix] Use %cs as implicit parameter to uninstall()

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>
tags/v1.20.1
Michael Brown 11 jaren geleden
bovenliggende
commit
0d4a760ffc
1 gewijzigde bestanden met toevoegingen van 6 en 6 verwijderingen
  1. 6
    6
      src/arch/i386/prefix/libprefix.S

+ 6
- 6
src/arch/i386/prefix/libprefix.S Bestand weergeven

@@ -545,8 +545,7 @@ alloc_basemem:
545 545
  * Free space allocated with alloc_basemem.
546 546
  *
547 547
  * Parameters:
548
- *   %ax : .text16 segment address
549
- *   %bx : .data16 segment address
548
+ *   none (.text16 segment address is implicit in %cs)
550 549
  * Returns:
551 550
  *   %ax : 0 if successfully freed
552 551
  * Corrupts:
@@ -559,14 +558,14 @@ alloc_basemem:
559 558
 free_basemem:
560 559
 	/* Preserve registers */
561 560
 	pushw	%fs
561
+	pushw	%ax
562 562
 
563 563
 	/* Check FBMS counter */
564
-	pushw	%ax
564
+	movw	%cs, %ax
565 565
 	shrw	$6, %ax
566 566
 	pushw	$0x40
567 567
 	popw	%fs
568 568
 	cmpw	%ax, %fs:0x13
569
-	popw	%ax
570 569
 	jne	1f
571 570
 
572 571
 	/* Check hooked interrupt count */
@@ -574,6 +573,7 @@ free_basemem:
574 573
 	jne	1f
575 574
 
576 575
 	/* OK to free memory */
576
+	movw	%cs, %ax
577 577
 	addw	$_text16_memsz_pgh, %ax
578 578
 	addw	$_data16_memsz_pgh, %ax
579 579
 	shrw	$6, %ax
@@ -581,6 +581,7 @@ free_basemem:
581 581
 	xorw	%ax, %ax
582 582
 
583 583
 1:	/* Restore registers and return */
584
+	popw	%ax
584 585
 	popw	%fs
585 586
 	ret
586 587
 	.size free_basemem, . - free_basemem
@@ -872,8 +873,7 @@ close_payload:
872 873
  * Uninstall all text and data segments.
873 874
  *
874 875
  * Parameters:
875
- *   %ax  : .text16 segment address
876
- *   %bx  : .data16 segment address
876
+ *   none (.text16 segment address is implicit in %cs)
877 877
  * Returns:
878 878
  *   none
879 879
  * Corrupts:

Laden…
Annuleren
Opslaan