MdeModulePkg PCI Bus Driver: Add more checks before dispatching an EFI PCI Option ROM image.
* Check if the machine type of the image is supported by the current UEFI system. * Ignore the image if it is an EFI application as required by the UEFI spec. Signed-off-by: rsun3 Reviewed-by: li-elvin git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12465 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
4cb0548d01
commit
a93e23f9ed
@ -669,6 +669,27 @@ ProcessOpRomImage (
|
|||||||
ImageSize = (UINT32) (Pcir->ImageLength * 512);
|
ImageSize = (UINT32) (Pcir->ImageLength * 512);
|
||||||
Indicator = Pcir->Indicator;
|
Indicator = Pcir->Indicator;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Skip the image if it is not an EFI PCI Option ROM image
|
||||||
|
//
|
||||||
|
if (Pcir->CodeType != PCI_CODE_TYPE_EFI_IMAGE) {
|
||||||
|
goto NextImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Skip the EFI PCI Option ROM image if its machine type is not supported
|
||||||
|
//
|
||||||
|
if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (EfiRomHeader->EfiMachineType)) {
|
||||||
|
goto NextImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Ignore the EFI PCI Option ROM image if it is an EFI application
|
||||||
|
//
|
||||||
|
if (EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {
|
||||||
|
goto NextImage;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create Pci Option Rom Image device path header
|
// Create Pci Option Rom Image device path header
|
||||||
//
|
//
|
||||||
@ -686,10 +707,8 @@ ProcessOpRomImage (
|
|||||||
//
|
//
|
||||||
BufferSize = 0;
|
BufferSize = 0;
|
||||||
Buffer = NULL;
|
Buffer = NULL;
|
||||||
Status = EFI_SUCCESS;
|
|
||||||
ImageHandle = NULL;
|
ImageHandle = NULL;
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
Status = gBS->LoadImage (
|
Status = gBS->LoadImage (
|
||||||
FALSE,
|
FALSE,
|
||||||
gPciBusDriverBinding.DriverBindingHandle,
|
gPciBusDriverBinding.DriverBindingHandle,
|
||||||
@ -698,7 +717,6 @@ ProcessOpRomImage (
|
|||||||
BufferSize,
|
BufferSize,
|
||||||
&ImageHandle
|
&ImageHandle
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
FreePool (PciOptionRomImageDevicePath);
|
FreePool (PciOptionRomImageDevicePath);
|
||||||
|
|
||||||
@ -719,6 +737,7 @@ ProcessOpRomImage (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NextImage:
|
||||||
RomBarOffset += ImageSize;
|
RomBarOffset += ImageSize;
|
||||||
|
|
||||||
} while (((Indicator & 0x80) == 0x00) && ((UINTN) (RomBarOffset - (UINT8 *) RomBar) < PciDevice->RomSize));
|
} while (((Indicator & 0x80) == 0x00) && ((UINTN) (RomBarOffset - (UINT8 *) RomBar) < PciDevice->RomSize));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user