From 9337cf8c99c503d7c13e901ea605e460fb836393 Mon Sep 17 00:00:00 2001 From: jljusten Date: Wed, 7 Oct 2009 16:01:06 +0000 Subject: [PATCH] OVMF SEC: Modify to search sections of FFS file for PE32 image. Previously the code would expect that the PE32 image was in the first section of the FFS file. This might not be the case if the PE32 section is forced to be aligned. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9331 6f19259b-4bc3-4df7-8a09-765794883524 --- OvmfPkg/ResetVector/Bin/ResetVector.ia32.raw | Bin 852 -> 884 bytes OvmfPkg/ResetVector/Bin/ResetVector.x64.raw | Bin 28676 -> 28676 bytes .../Ia32/SearchForSecAndPeiEntries.asm | 29 ++++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/ResetVector/Bin/ResetVector.ia32.raw b/OvmfPkg/ResetVector/Bin/ResetVector.ia32.raw index e68e75d19e407e18cf7ca6b29d34fa59465d67fc..76286b9fa3c49e96543042703f424cc2004062d4 100644 GIT binary patch delta 211 zcmcb@_JwVNEThImxrOR;85tN1Z+G77yx;jEtvl9$@kUYROJ)WJ28W`=)&nK6tn5H` zQP{+1+PcgB{{R2-Jdg_%7wCAz tvJI1&P}~1Ben#=M9m+sg@hcrjdu2Vjg(+(C6DCKNy?$53-tT;o)*WlWc%vxoB{Ks9gF{hV>w%IeR(2q} zD0t#CZH;4p|Nnn^2FL}9i+3J-DF9^dx(yQC4iRMPJl=WY^`gl(j4K5qAwn(<719Ew zcC0d!C74{;o`Mv&Oip4l6KeRM#?L68wnG_c6Ti}dv{$B+S20B~O_(r=*_Gw)pO@m3 HJ(;xu%M(N% diff --git a/OvmfPkg/ResetVector/Bin/ResetVector.x64.raw b/OvmfPkg/ResetVector/Bin/ResetVector.x64.raw index 94bb3e269eedd2e6920d30cd11c0f6d84615727c..adf44b10286bc4ec4ab35ffbd2d325889a19096c 100644 GIT binary patch delta 257 zcmZp9z}WJDaf3+CWS1OC#O9_g;^qAR|Npms zn|wZ3Ve;(UcHVY?8l_b0Nq8i$5Xau%wWGcqt3-tN5DdB5{TT6e4gqTtEjaO9_g;`O4* zKDjFeA|XO94HeP?rFN_`lQr^Ol%9eVxBLSVAAr&xJN^R!kip=gc+5lbxQF6VkIB7x z#zI>E)A$+1({?BWox!hkAnnz?$(QncxIKWXC)hI>0IA6)`3pH$gAB^}^K$p(d--Yr D(tc&7 diff --git a/OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm b/OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm index b4f734fb76..9bb0cd1fa6 100644 --- a/OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm +++ b/OvmfPkg/ResetVector/Ia32/SearchForSecAndPeiEntries.asm @@ -144,6 +144,7 @@ peiCoreEntryPointWasFound: ; ; Input: ; EAX - Start of FFS file +; ECX - End of FFS file ; ; Output: ; EAX - Entry point of PE32 (or 0 if not found) @@ -154,11 +155,33 @@ peiCoreEntryPointWasFound: GetEntryPointOfFfsFileReturnEdx: test eax, eax jz getEntryPointOfFfsFileErrorReturn + add eax, 0x18 ; EAX = Start of section - cmp byte [eax + 0x1b], EFI_SECTION_PE32 - jne getEntryPointOfFfsFileErrorReturn +getEntryPointOfFfsFileLoopForSections: + cmp eax, ecx + jae getEntryPointOfFfsFileErrorReturn - add eax, 0x1c ; EAX = Start of PE32 image + cmp byte [eax + 3], EFI_SECTION_PE32 + je getEntryPointOfFfsFileFoundPe32Section + + ; + ; The section type was not PE32, so move to next section + ; + mov ebx, dword [eax] + and ebx, 0x00ffffff + add eax, ebx + jc getEntryPointOfFfsFileErrorReturn + + ; + ; Ensure that FFS section is 32-bit aligned + ; + add eax, 3 + jc getEntryPointOfFfsFileErrorReturn + and al, 0xfc + jmp getEntryPointOfFfsFileLoopForSections + +getEntryPointOfFfsFileFoundPe32Section: + add eax, 4 ; EAX = Start of PE32 image mov ebx, eax cmp word [eax], 'MZ'