소스 검색

[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>
tags/v1.20.1
Michael Brown 8 년 전
부모
커밋
7ecfe7159f
2개의 변경된 파일7개의 추가작업 그리고 10개의 파일을 삭제
  1. 5
    8
      src/arch/i386/prefix/libprefix.S
  2. 2
    2
      src/arch/i386/scripts/i386.lds

+ 5
- 8
src/arch/i386/prefix/libprefix.S 파일 보기

@@ -558,14 +558,11 @@ alloc_basemem:
558 558
 	shlw	$6, %ax
559 559
 
560 560
 	/* Calculate .data16 segment address */
561
-	subw	$_data16_memsz_pgh, %ax
561
+	subw	$_data16_memsz_ppgh, %ax
562 562
 	pushw	%ax
563 563
 
564
-	/* Calculate .text16 segment address.  Round down to ensure
565
-	 * low bits are zero, to speed up mode transitions under KVM.
566
-	 */
567
-	subw	$_text16_memsz_pgh, %ax
568
-	andb	$~0x03, %al
564
+	/* Calculate .text16 segment address */
565
+	subw	$_text16_memsz_ppgh, %ax
569 566
 	pushw	%ax
570 567
 
571 568
 	/* Update FBMS */
@@ -616,8 +613,8 @@ free_basemem:
616 613
 
617 614
 	/* OK to free memory */
618 615
 	movw	%cs, %ax
619
-	addw	$_text16_memsz_pgh, %ax
620
-	addw	$_data16_memsz_pgh, %ax
616
+	addw	$_text16_memsz_ppgh, %ax
617
+	addw	$_data16_memsz_ppgh, %ax
621 618
 	shrw	$6, %ax
622 619
 	movw	%ax, %fs:0x13
623 620
 	xorw	%ax, %ax

+ 2
- 2
src/arch/i386/scripts/i386.lds 파일 보기

@@ -247,8 +247,8 @@ SECTIONS {
247 247
      * Values calculated to save code from doing it
248 248
      *
249 249
      */
250
-    _text16_memsz_pgh	= ( ( _text16_memsz + 15 ) / 16 );
251
-    _data16_memsz_pgh	= ( ( _data16_memsz + 15 ) / 16 );
250
+    _text16_memsz_ppgh	= ( ( ( _text16_memsz + 63 ) / 64 ) * 4 );
251
+    _data16_memsz_ppgh	= ( ( ( _data16_memsz + 63 ) / 64 ) * 4 );
252 252
     _textdata_memsz_pgh	= ( ( _textdata_memsz + 15 ) / 16 );
253 253
     _textdata_memsz_kb	= ( ( _textdata_memsz + 1023 ) / 1024 );
254 254
 }

Loading…
취소
저장