[edk2-devel] [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Check for memory below 4G
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4009 Check if there is usable memory below 4 GiB before testing for allocation without the EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE attribute. Cc: G Edhaya Chandran Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Cc: Sunny Wang Signed-off-by: Dimitrije Pavlov --- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c | 142 +++- 1 file changed, 140 insertions(+), 2 deletions(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c index 89adcba91e70..fafbf62f77c6 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c @@ -4118,7 +4118,69 @@ AllocateBuffer_Func ( UINTNAttributesNum; EFI_PCI_ROOT_BRIDGE_IO_DEVICE*RBDev; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo; + EFI_MEMORY_DESCRIPTOR*MemoryMap; + EFI_MEMORY_DESCRIPTOR*Entry; + UINTNMemoryMapSize; + UINTNMapKey; + UINTNDescriptorSize; + UINT32 DescriptorVersion; + UINTNIterator; + BOOLEAN UsableMemoryBelow4G; + // + // Obtain the memory map size + // + MemoryMapSize = 0; + Status = gBS->GetMemoryMap ( + &MemoryMapSize, + NULL, + &MapKey, + &DescriptorSize, + &DescriptorVersion + ); + ASSERT (Status == EFI_BUFFER_TOO_SMALL); + // + // Allocating a buffer for the memory map will change + // the memory map, so we increase the size here just in case + // + MemoryMapSize += EFI_PAGE_SIZE; + Status = gBS->AllocatePool ( + EfiLoaderData, + MemoryMapSize, + (VOID **)&MemoryMap + ); + if (EFI_ERROR (Status)) { +return Status; + } + // + // Get the actual memory map + // + Status = gBS->GetMemoryMap ( + &MemoryMapSize, + MemoryMap, + &MapKey, + &DescriptorSize, + &DescriptorVersion + ); + if (EFI_ERROR (Status)) { +gBS->FreePool (MemoryMap); + } + + // + // Check each entry in the memory map for free memory below 4 GiB and set + // UsableMemoryBelow4G accordingly + // + UsableMemoryBelow4G = FALSE; + for (Iterator = 0; Iterator < MemoryMapSize; Iterator += DescriptorSize) { +Entry = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + Iterator); +if ( Entry->PhysicalStart < (EFI_PHYSICAL_ADDRESS)SIZE_4GB + && ( Entry->Type == EfiConventionalMemory || Entry->Type == EfiPersistentMemory)) +{ + UsableMemoryBelow4G = TRUE; + break; +} + } + gBS->FreePool (MemoryMap); AllocateType = 0; @@ -4188,7 +4250,14 @@ AllocateBuffer_Func ( for (MemoryTypeNum = 0; MemoryTypeNum < 2; MemoryTypeNum++) { for (AttributesNum = 0; AttributesNum < 8; AttributesNum++) { - + // + // If there is no usable memory below 4 GiB, skip 32-bit allocations + // + if ( !UsableMemoryBelow4G +&& !(Attributes[AttributesNum] & EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE)) + { +continue; + } Status = RootBridgeIo->AllocateBuffer ( RootBridgeIo, AllocateType, @@ -4298,7 +4367,69 @@ FreeBuffer_Func ( UINTNAttributesNum; EFI_PCI_ROOT_BRIDGE_IO_DEVICE*RBDev; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo; + EFI_MEMORY_DESCRIPTOR*MemoryMap; + EFI_MEMORY_DESCRIPTOR*Entry; + UINTNMemoryMapSize; + UINTNMapKey; + UINTNDescriptorSize; + UINT32 DescriptorVersion; + UINTNIterator; + BOOLEAN UsableMemoryBelow4G; + // + // Obtain the memory map size + // + MemoryMapSize = 0; + Status = gBS->GetMemoryMap ( + &MemoryMapSize, + NULL, + &MapKey, + &DescriptorSize, + &D
[edk2-devel] [PATCH v1 1/1] OvmfPkg/PlatformDxe: Handle all requests in ExtractConfig and RouteConfig
Per the UEFI specification, if the Request argument in EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig() is NULL or does not contain any request elements, the implementation should return all of the settings being abstracted for the particular ConfigHdr reference. The current implementation returns EFI_INVALID_PARAMETER if Request is NULL or does not contain any request elements. Instead, construct a new ConfigRequest to handle these cases per the specification. In addition, per the UEFI specification, if the Configuration argument in EFI_HII_CONFIG_ACCESS_PROTOCOL.RouteConfig() has a ConfigHdr that specifies a non-existing target, the implementation should return EFI_NOT_FOUND. The current implementation returns EFI_INVALID_PARAMETER if Configuration has a non-existing target in ConfigHdr. Instead, perform a check and return EFI_NOT_FOUND in this case. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov --- OvmfPkg/PlatformDxe/PlatformConfig.h | 2 + OvmfPkg/PlatformDxe/Platform.c | 115 +++- OvmfPkg/PlatformDxe/PlatformConfig.c | 2 +- 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/PlatformDxe/PlatformConfig.h b/OvmfPkg/PlatformDxe/PlatformConfig.h index 902c9b2ce043..5d9b457b1b4b 100644 --- a/OvmfPkg/PlatformDxe/PlatformConfig.h +++ b/OvmfPkg/PlatformDxe/PlatformConfig.h @@ -50,4 +50,6 @@ PlatformConfigLoad ( #define PLATFORM_CONFIG_F_GRAPHICS_RESOLUTION BIT0 #define PLATFORM_CONFIG_F_DOWNGRADEBIT63 +extern CHAR16 mVariableName[]; + #endif // _PLATFORM_CONFIG_H_ diff --git a/OvmfPkg/PlatformDxe/Platform.c b/OvmfPkg/PlatformDxe/Platform.c index a6d459f3dfd7..0e32c6e76037 100644 --- a/OvmfPkg/PlatformDxe/Platform.c +++ b/OvmfPkg/PlatformDxe/Platform.c @@ -108,6 +108,11 @@ STATIC EFI_EVENT mGopEvent; // STATIC VOID *mGopTracker; +// +// The driver image handle, used to obtain the device path for . +// +STATIC EFI_HANDLE mImageHandle; + // // Cache the resolutions we get from the GOP. // @@ -229,6 +234,10 @@ ExtractConfig ( { MAIN_FORM_STATE MainFormState; EFI_STATUS Status; + EFI_STRING ConfigRequestHdr; + EFI_STRING ConfigRequest; + UINTNSize; + BOOLEAN AllocatedRequest; DEBUG ((DEBUG_VERBOSE, "%a: Request=\"%s\"\n", __FUNCTION__, Request)); @@ -236,18 +245,73 @@ ExtractConfig ( return EFI_INVALID_PARAMETER; } + ConfigRequestHdr = NULL; + ConfigRequest= NULL; + Size = 0; + AllocatedRequest = FALSE; + + // + // Check if matches the GUID and name + // + *Progress = Request; + if ((Request != NULL) && + !HiiIsConfigHdrMatch ( + Request, + &gOvmfPlatformConfigGuid, + mVariableName + ) + ) + { +return EFI_NOT_FOUND; + } + Status = PlatformConfigToFormState (&MainFormState); if (EFI_ERROR (Status)) { -*Progress = Request; return Status; } + if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { +// +// Request has no , so construct full request string. +// Allocate and fill a buffer large enough to hold +// followed by "&OFFSET=0&WIDTH=" followed by a +// null terminator. +// +ConfigRequestHdr = HiiConstructConfigHdr ( + &gOvmfPlatformConfigGuid, + mVariableName, + mImageHandle + ); +if (ConfigRequestHdr == NULL) { + return EFI_OUT_OF_RESOURCES; +} + +Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); +ConfigRequest= AllocateZeroPool (Size); +AllocatedRequest = TRUE; +if (ConfigRequest == NULL) { + FreePool (ConfigRequestHdr); + return EFI_OUT_OF_RESOURCES; +} + +UnicodeSPrint ( + ConfigRequest, + Size, + L"%s&OFFSET=0&WIDTH=%016LX", + ConfigRequestHdr, + sizeof MainFormState + ); +FreePool (ConfigRequestHdr); + } else { +ConfigRequest = Request; + } + // // Answer the textual request keying off the binary form state. // Status = gHiiConfigRouting->BlockToConfig ( gHiiConfigRouting, -Request, +ConfigRequest, (VOID *)&MainFormState, sizeof MainFormState, Results, @@ -265,6 +329,33 @@ ExtractConfig ( DEBUG ((DEBUG_VERBOSE, "%a: Results=\"%s\"\n", __FUNCTION__, *Results)); } + // + // If we used a newly allocated ConfigRequest, update Progress to point to + // original Request instead of ConfigRequest. + // + if (Request == NULL) { +*Progress = NULL; + } else if (StrStr (Req
[edk2-devel] [PATCH v1 1/1] OvmfPkg/VirtioNetDxe: Check ChildHandle argument in GetControllerName
Per the UEFI specification, a device driver implementation should return EFI_UNSUPPORTED if the ChildHandle argument in EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName() is not NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov --- OvmfPkg/VirtioNetDxe/ComponentName.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/OvmfPkg/VirtioNetDxe/ComponentName.c b/OvmfPkg/VirtioNetDxe/ComponentName.c index e340ca2f8fe4..718096630f6f 100644 --- a/OvmfPkg/VirtioNetDxe/ComponentName.c +++ b/OvmfPkg/VirtioNetDxe/ComponentName.c @@ -129,6 +129,13 @@ VirtioNetGetControllerName ( return EFI_INVALID_PARAMETER; } + // + // This is a device driver, so ChildHandle must be NULL. + // + if (ChildHandle != NULL) { +return EFI_UNSUPPORTED; + } + // // confirm that the device is managed by this driver, using the VirtIo // Protocol -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92518): https://edk2.groups.io/g/devel/message/92518 Mute This Topic: https://groups.io/mt/93082232/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 2/3] OvmfPkg/VirtioGpuDxe: Check QueryMode arguments
The current implementation does not check if Info or SizeInfo pointers are NULL. This causes the SCT test suite to crash. Add a check to return EFI_INVALID_PARAMETER if any of these pointers are NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov Reviewed-by: Sunny Wang --- OvmfPkg/VirtioGpuDxe/Gop.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c index 401db47672ec..16e92830d411 100644 --- a/OvmfPkg/VirtioGpuDxe/Gop.c +++ b/OvmfPkg/VirtioGpuDxe/Gop.c @@ -308,7 +308,10 @@ GopQueryMode ( { EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo; - if (ModeNumber >= This->Mode->MaxMode) { + if ((Info == NULL) || + (SizeOfInfo == NULL) || + (ModeNumber >= This->Mode->MaxMode)) + { return EFI_INVALID_PARAMETER; } -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92483): https://edk2.groups.io/g/devel/message/92483 Mute This Topic: https://groups.io/mt/93067594/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 0/3] OvmfPkg: Check arguments for validity
Some functions across OVMF don't check pointer arguments for validity, which causes null pointer dereferences and crashes in the SCT test suite. This series adds checks to return EFI_INVALID_PARAMETER if a pointer argument is NULL. v3: - Fix coding standard issues to pass CI checks [Ard] v2: https://edk2.groups.io/g/devel/message/92443 Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Reviewed-by: Sunny Wang Dimitrije Pavlov (3): OvmfPkg/PlatformDxe: Check ExtractConfig and RouteConfig arguments OvmfPkg/VirtioGpuDxe: Check QueryMode arguments OvmfPkg/VirtioFsDxe: Check GetDriverName arguments OvmfPkg/PlatformDxe/Platform.c | 8 OvmfPkg/VirtioFsDxe/DriverBinding.c | 4 OvmfPkg/VirtioGpuDxe/Gop.c | 5 - 3 files changed, 16 insertions(+), 1 deletion(-) -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92484): https://edk2.groups.io/g/devel/message/92484 Mute This Topic: https://groups.io/mt/93067595/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 1/3] OvmfPkg/PlatformDxe: Check ExtractConfig and RouteConfig arguments
The current implementation does not check if Progress or Results pointers in ExtractConfig are NULL, or if Progress pointer in RouteConfig is NULL. This causes the SCT test suite to crash. Add a check to return EFI_INVALID_PARAMETER if any of these pointers are NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov Reviewed-by: Sunny Wang --- OvmfPkg/PlatformDxe/Platform.c | 8 1 file changed, 8 insertions(+) diff --git a/OvmfPkg/PlatformDxe/Platform.c b/OvmfPkg/PlatformDxe/Platform.c index 4bf22712c78f..a6d459f3dfd7 100644 --- a/OvmfPkg/PlatformDxe/Platform.c +++ b/OvmfPkg/PlatformDxe/Platform.c @@ -232,6 +232,10 @@ ExtractConfig ( DEBUG ((DEBUG_VERBOSE, "%a: Request=\"%s\"\n", __FUNCTION__, Request)); + if ((Progress == NULL) || (Results == NULL)) { +return EFI_INVALID_PARAMETER; + } + Status = PlatformConfigToFormState (&MainFormState); if (EFI_ERROR (Status)) { *Progress = Request; @@ -340,6 +344,10 @@ RouteConfig ( Configuration )); + if (Progress == NULL) { +return EFI_INVALID_PARAMETER; + } + // // the "read" step in RMW // -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92486): https://edk2.groups.io/g/devel/message/92486 Mute This Topic: https://groups.io/mt/93067597/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v3 3/3] OvmfPkg/VirtioFsDxe: Check GetDriverName arguments
The current implementation does not check if Language or DriverName are NULL. This causes the SCT test suite to crash. Add a check to return EFI_INVALID_PARAMETER if any of these pointers are NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov Reviewed-by: Sunny Wang --- OvmfPkg/VirtioFsDxe/DriverBinding.c | 4 1 file changed, 4 insertions(+) diff --git a/OvmfPkg/VirtioFsDxe/DriverBinding.c b/OvmfPkg/VirtioFsDxe/DriverBinding.c index 86eb9cf0ba51..69d2bb777089 100644 --- a/OvmfPkg/VirtioFsDxe/DriverBinding.c +++ b/OvmfPkg/VirtioFsDxe/DriverBinding.c @@ -218,6 +218,10 @@ VirtioFsGetDriverName ( OUT CHAR16**DriverName ) { + if ((Language == NULL) || (DriverName == NULL)) { +return EFI_INVALID_PARAMETER; + } + if (AsciiStrCmp (Language, "en") != 0) { return EFI_UNSUPPORTED; } -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92485): https://edk2.groups.io/g/devel/message/92485 Mute This Topic: https://groups.io/mt/93067596/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v2 3/3] OvmfPkg/VirtioFsDxe: Check GetDriverName arguments
The current implementation does not check if Language or DriverName are NULL. This causes the SCT test suite to crash. Add a check to return EFI_INVALID_PARAMETER if any of these pointers are NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov --- OvmfPkg/VirtioFsDxe/DriverBinding.c | 4 1 file changed, 4 insertions(+) diff --git a/OvmfPkg/VirtioFsDxe/DriverBinding.c b/OvmfPkg/VirtioFsDxe/DriverBinding.c index 86eb9cf0ba51..3d80ff0f91f5 100644 --- a/OvmfPkg/VirtioFsDxe/DriverBinding.c +++ b/OvmfPkg/VirtioFsDxe/DriverBinding.c @@ -218,6 +218,10 @@ VirtioFsGetDriverName ( OUT CHAR16**DriverName ) { + if (Language == NULL || DriverName == NULL) { +return EFI_INVALID_PARAMETER; + } + if (AsciiStrCmp (Language, "en") != 0) { return EFI_UNSUPPORTED; } -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92441): https://edk2.groups.io/g/devel/message/92441 Mute This Topic: https://groups.io/mt/93040548/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v2 0/3] OvmfPkg: Check arguments for validity
Some functions across OVMF don't check pointer arguments for validity, which causes null pointer dereferences and crashes in the SCT test suite. This series adds checks to return EFI_INVALID_PARAMETER if a pointer argument is NULL. v2: - Add Liming Gao to Cc [Ard] - Turn individual patches into a series [Ard] - Fix issue with corrupted patches [Ard] Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Dimitrije Pavlov (3): OvmfPkg/PlatformDxe: Check ExtractConfig and RouteConfig arguments OvmfPkg/VirtioGpuDxe: Check QueryMode arguments OvmfPkg/VirtioFsDxe: Check GetDriverName arguments OvmfPkg/PlatformDxe/Platform.c | 8 OvmfPkg/VirtioFsDxe/DriverBinding.c | 4 OvmfPkg/VirtioGpuDxe/Gop.c | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92443): https://edk2.groups.io/g/devel/message/92443 Mute This Topic: https://groups.io/mt/93040550/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v2 1/3] OvmfPkg/PlatformDxe: Check ExtractConfig and RouteConfig arguments
The current implementation does not check if Progress or Results pointers in ExtractConfig are NULL, or if Progress pointer in RouteConfig is NULL. This causes the SCT test suite to crash. Add a check to return EFI_INVALID_PARAMETER if any of these pointers are NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov --- OvmfPkg/PlatformDxe/Platform.c | 8 1 file changed, 8 insertions(+) diff --git a/OvmfPkg/PlatformDxe/Platform.c b/OvmfPkg/PlatformDxe/Platform.c index 4bf22712c78f..d7be2ab65efa 100644 --- a/OvmfPkg/PlatformDxe/Platform.c +++ b/OvmfPkg/PlatformDxe/Platform.c @@ -232,6 +232,10 @@ ExtractConfig ( DEBUG ((DEBUG_VERBOSE, "%a: Request=\"%s\"\n", __FUNCTION__, Request)); + if (Progress == NULL || Results == NULL) { +return EFI_INVALID_PARAMETER; + } + Status = PlatformConfigToFormState (&MainFormState); if (EFI_ERROR (Status)) { *Progress = Request; @@ -340,6 +344,10 @@ RouteConfig ( Configuration )); + if (Progress == NULL) { +return EFI_INVALID_PARAMETER; + } + // // the "read" step in RMW // -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92442): https://edk2.groups.io/g/devel/message/92442 Mute This Topic: https://groups.io/mt/93040549/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v2 2/3] OvmfPkg/VirtioGpuDxe: Check QueryMode arguments
The current implementation does not check if Info or SizeInfo pointers are NULL. This causes the SCT test suite to crash. Add a check to return EFI_INVALID_PARAMETER if any of these pointers are NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Liming Gao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov --- OvmfPkg/VirtioGpuDxe/Gop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c index 401db47672ec..bb68b1cdc2bc 100644 --- a/OvmfPkg/VirtioGpuDxe/Gop.c +++ b/OvmfPkg/VirtioGpuDxe/Gop.c @@ -308,7 +308,9 @@ GopQueryMode ( { EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo; - if (ModeNumber >= This->Mode->MaxMode) { + if (Info == NULL || + SizeOfInfo == NULL || + ModeNumber >= This->Mode->MaxMode) { return EFI_INVALID_PARAMETER; } -- 2.37.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92440): https://edk2.groups.io/g/devel/message/92440 Mute This Topic: https://groups.io/mt/93040547/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 1/1] OvmfPkg/PlatformDxe: Check ExtractConfig and RouteConfig arguments
The current implementation does not check if Progress or Results pointers in ExtractConfig are NULL, or if Progress pointer in RouteConfig is NULL. This causes the SCT test suite to crash. Add a check to return EFI_INVALID_PARAMETER if any of these pointers are NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov --- OvmfPkg/PlatformDxe/Platform.c | 8 1 file changed, 8 insertions(+) diff --git a/OvmfPkg/PlatformDxe/Platform.c b/OvmfPkg/PlatformDxe/Platform.c index 4bf22712c78f..d7be2ab65efa 100644 --- a/OvmfPkg/PlatformDxe/Platform.c +++ b/OvmfPkg/PlatformDxe/Platform.c @@ -232,6 +232,10 @@ ExtractConfig ( DEBUG ((DEBUG_VERBOSE, "%a: Request=\"%s\"\n", __FUNCTION__, Request)); + if (Progress == NULL || Results == NULL) { +return EFI_INVALID_PARAMETER; + } + Status = PlatformConfigToFormState (&MainFormState); if (EFI_ERROR (Status)) { *Progress = Request; @@ -340,6 +344,10 @@ RouteConfig ( Configuration )); + if (Progress == NULL) { +return EFI_INVALID_PARAMETER; + } + // // the "read" step in RMW // -- 2.37.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92437): https://edk2.groups.io/g/devel/message/92437 Mute This Topic: https://groups.io/mt/93038203/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 1/1] OvmfPkg/VirtioGpuDxe: Check QueryMode arguments for validity
The current implementation does not check if Info or SizeInfo pointers are NULL. This causes the SCT test suite to crash. Add a check to return EFI_INVALID_PARAMETER if any of these pointers are NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov --- OvmfPkg/VirtioGpuDxe/Gop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c index 401db47672ec..bb68b1cdc2bc 100644 --- a/OvmfPkg/VirtioGpuDxe/Gop.c +++ b/OvmfPkg/VirtioGpuDxe/Gop.c @@ -308,7 +308,9 @@ GopQueryMode ( { EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo; - if (ModeNumber >= This->Mode->MaxMode) { + if (Info == NULL || + SizeOfInfo == NULL || + ModeNumber >= This->Mode->MaxMode) { return EFI_INVALID_PARAMETER; } -- 2.37.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92436): https://edk2.groups.io/g/devel/message/92436 Mute This Topic: https://groups.io/mt/93038176/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v1 1/1] OvmfPkg/VirtioFsDxe: Check GetDriverName arguments
The current implementation does not check if Language or DriverName are NULL. This causes the SCT test suite to crash. Add a check to return EFI_INVALID_PARAMETER if any of these pointers are NULL. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Sunny Wang Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov --- OvmfPkg/VirtioFsDxe/DriverBinding.c | 4 1 file changed, 4 insertions(+) diff --git a/OvmfPkg/VirtioFsDxe/DriverBinding.c b/OvmfPkg/VirtioFsDxe/DriverBinding.c index 86eb9cf0ba51..3d80ff0f91f5 100644 --- a/OvmfPkg/VirtioFsDxe/DriverBinding.c +++ b/OvmfPkg/VirtioFsDxe/DriverBinding.c @@ -218,6 +218,10 @@ VirtioFsGetDriverName ( OUT CHAR16**DriverName ) { + if (Language == NULL || DriverName == NULL) { +return EFI_INVALID_PARAMETER; + } + if (AsciiStrCmp (Language, "en") != 0) { return EFI_UNSUPPORTED; } -- 2.37.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92434): https://edk2.groups.io/g/devel/message/92434 Mute This Topic: https://groups.io/mt/93038111/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [edk2-platforms][PATCH v1 1/1] Platform/Qemu: Fix build break in SbsaQemu
Commit 6eb407947592e084110a124be089bef167af1383 added a new dependency of PlatformPKProtectionLib to SecureBootVariableLib. This causes the build of SbsaQemu to fail. Add the PlatformPKProtectionLib library instance to SbsaQemu.dsc to fix the build. Cc: Ard Biesheuvel Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Signed-off-by: Dimitrije Pavlov --- Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 1 + 1 file changed, 1 insertion(+) diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc index 97014e2fb630..c912424173a6 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc @@ -158,6 +158,7 @@ [LibraryClasses.common] AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf SecureBootVariableProvisionLib|SecurityPkg/Library/SecureBootVariableProvisionLib/SecureBootVariableProvisionLib.inf + PlatformPKProtectionLib|SecurityPkg/Library/PlatformPKProtectionLibVarPolicy/PlatformPKProtectionLibVarPolicy.inf # re-use the UserPhysicalPresent() dummy implementation from the ovmf tree PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92045): https://edk2.groups.io/g/devel/message/92045 Mute This Topic: https://groups.io/mt/92771121/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v2 1/1] OvmfPkg/QemuVideoDxe: Zero out PixelInformation in QueryMode
Ensure that the PixelInformation field of the EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure is zeroed out in EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode() and EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode() when PixelFormat is PixelBlueGreenRedReserved8BitPerColor. According to UEFI 2.9 Section 12.9, PixelInformation field of the EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure is valid only if PixelFormat is PixelBitMask. This means that firmware is not required to fill out the PixelInformation field for other PixelFormat types, which implies that the QemuVideoDxe implementation is technically correct. However, not zeroing out those fields will leak the contents of the memory returned by the memory allocator, so it is better to explicitly set them to zero. In addition, the SCT test suite relies on PixelInformation always having a consistent value, which causes failures. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Cc: Sunny Wang Cc: Jeremy Linton Signed-off-by: Dimitrije Pavlov Acked-by: Gerd Hoffmann --- OvmfPkg/QemuVideoDxe/Gop.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c index 0c4dea7fb6f2..7a9fe208c99c 100644 --- a/OvmfPkg/QemuVideoDxe/Gop.c +++ b/OvmfPkg/QemuVideoDxe/Gop.c @@ -31,7 +31,14 @@ QemuVideoCompleteModeInfo ( Info->PixelInformation.ReservedMask = 0; } else if (ModeData->ColorDepth == 32) { DEBUG ((DEBUG_INFO, "PixelBlueGreenRedReserved8BitPerColor\n")); -Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; +Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; +Info->PixelInformation.RedMask = 0; +Info->PixelInformation.GreenMask= 0; +Info->PixelInformation.BlueMask = 0; +Info->PixelInformation.ReservedMask = 0; + } else { +DEBUG ((DEBUG_ERROR, "%a: Invalid ColorDepth %u", __FUNCTION__, ModeData->ColorDepth)); +ASSERT (FALSE); } Info->PixelsPerScanLine = Info->HorizontalResolution; -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91953): https://edk2.groups.io/g/devel/message/91953 Mute This Topic: https://groups.io/mt/92679973/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [PATCH v2 1/1] OvmfPkg/QemuVideoDxe: Zero out PixelInformation in QueryMode
Ensure that the PixelInformation field of the EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure is zeroed out in EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode() and EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode() when PixelFormat is PixelBlueGreenRedReserved8BitPerColor. According to UEFI 2.9 Section 12.9, PixelInformation field of the EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure is valid only if PixelFormat is PixelBitMask. This means that firmware is not required to fill out the PixelInformation field for other PixelFormat types, which implies that the QemuVideoDxe implementation is technically correct. However, not zeroing out those fields will leak the contents of the memory returned by the memory allocator, so it is better to explicitly set them to zero. In addition, the SCT test suite relies on PixelInformation always having a consistent value, which causes failures. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Cc: Sunny Wang Cc: Jeremy Linton Signed-off-by: Dimitrije Pavlov Acked-by: Gerd Hoffmann --- OvmfPkg/QemuVideoDxe/Gop.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c index 0c4dea7fb6f2..7a9fe208c99c 100644 --- a/OvmfPkg/QemuVideoDxe/Gop.c +++ b/OvmfPkg/QemuVideoDxe/Gop.c @@ -31,7 +31,14 @@ QemuVideoCompleteModeInfo ( Info->PixelInformation.ReservedMask = 0; } else if (ModeData->ColorDepth == 32) { DEBUG ((DEBUG_INFO, "PixelBlueGreenRedReserved8BitPerColor\n")); -Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; +Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; +Info->PixelInformation.RedMask = 0; +Info->PixelInformation.GreenMask= 0; +Info->PixelInformation.BlueMask = 0; +Info->PixelInformation.ReservedMask = 0; + } else { +DEBUG ((DEBUG_ERROR, "%a: Invalid ColorDepth %u", __FUNCTION__, ModeData->ColorDepth)); +ASSERT (FALSE); } Info->PixelsPerScanLine = Info->HorizontalResolution; -- 2.34.1
Re: [edk2-devel] [PATCH v1 1/1] OvmfPkg/QemuVideoDxe: Zero out PixelInformation in QueryMode
Looks like the patch is corrupted for you for some reason. Up the email chain it shows fine. You can see the patch here: https://edk2.groups.io/g/devel/message/90822 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91905): https://edk2.groups.io/g/devel/message/91905 Mute This Topic: https://groups.io/mt/92050521/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [edk2-platforms][PATCH v1 1/1] Silicon/Qemu: Add SMBIOS tables of types 16, 17, and 19
Arm SBBR specification includes the list of required and recommended SMBIOS tables. Tables of types 16 (Physical Memory Array), 17 (Memory Device), and 19 (Memory Array Mapped Address) are required, but are not included in the current SbsaQemu SMBIOS driver. The current SMBIOS driver provides a limited number of tables using ArmPkg. This patch adds SbsaQemu-specific tables of types 16, 17, and 19. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Graeme Gregory Cc: Radoslaw Biernacki Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Cc: Sunny Wang Cc: Jeremy Linton Signed-off-by: Dimitrije Pavlov --- Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 1 + Platform/Qemu/SbsaQemu/SbsaQemu.fdf | 1 + Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.inf | 48 +++ Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.c | 405 4 files changed, 455 insertions(+) diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc index 97014e2fb630..b7050d911708 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc @@ -721,6 +721,7 @@ [Components.common] ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf EmbeddedPkg/Library/FdtLib/FdtLib.inf MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf + Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.inf # # PCI support diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf index c35e3ed44054..9f031c3e6649 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.fdf +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.fdf @@ -242,6 +242,7 @@ [FV.FvMain] INF ArmPkg/Universal/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf INF ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf + INF Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.inf # # PCI support diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.inf new file mode 100644 index ..b5d156f6654e --- /dev/null +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.inf @@ -0,0 +1,48 @@ +#/** @file +# +# Static SMBIOS tables for the SbsaQemu platform. +# +# Copyright (c) 2022, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#**/ + +[Defines] + INF_VERSION= 0x0001001A + BASE_NAME = SbsaQemuSmbiosDxe + FILE_GUID = DDE1ACCB-0555-4CAA-85E7-3CBC8962026E + MODULE_TYPE= DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT= SbsaQemuSmbiosDriverEntryPoint + +[Sources] + SbsaQemuSmbiosDxe.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + ArmPkg/ArmPkg.dec + +[LibraryClasses] + ArmLib + ArmPlatformLib + UefiBootServicesTableLib + MemoryAllocationLib + BaseMemoryLib + BaseLib + UefiLib + UefiDriverEntryPoint + DebugLib + PrintLib + +[Protocols] + gEfiSmbiosProtocolGuid + +[Depex] + gEfiSmbiosProtocolGuid + +[Pcd] + gArmTokenSpaceGuid.PcdSystemMemorySize + gArmTokenSpaceGuid.PcdSystemMemoryBase diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.c new file mode 100644 index ..9ef5168b79f6 --- /dev/null +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuSmbiosDxe/SbsaQemuSmbiosDxe.c @@ -0,0 +1,405 @@ +/** @file + * + * Static SMBIOS tables for the SbsaQemu platform. + * + * Note: Some tables are provided by ArmPkg. The tables that are not provided by + * ArmPkg, but are required by SBBR, are as follows: + *Physical Memory Array (Type 16) + *Memory Device (Type 17) - For each socketed system-memory Device + *Memory Array Mapped Address (Type 19) - One per contiguous block per Physical Memory Array + * + * Copyright (c) 2022, ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + A global variable to store the SMBIOS handle for table Type 16. This variable should + only be modified by calling PhyMemArrayInfoUpdateSmbiosType16. +**/ +STATIC SMBIOS_HANDLE mPhyMemArrayInfoType16Handle = SMBIOS_HANDLE_PI_RESERVED; + +/** + SMBIOS data definition, TYPE16, Physical Memory Array +**/ +SMBIOS_TABLE_TYPE16 mPhyMemArrayInfoType16 = { + { EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, sizeof (SMBIOS_TABLE_TYPE16), 0 }, + MemoryArrayLocationSystemBoard, // Location; (system board) + MemoryArrayUseSystemMemory, // Use; (system memory
[edk2-devel] [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Don't always check PixelInformation
According to UEFI 2.9 Section 12.9, the PixelInformation field of the EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure is valid only if PixelFormat is PixelBitMask. The current implementation always checks the contents of PixelInformation field of the EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure returned by QueryMode, regardless of PixelFormat. Check PixelInformation only if PixelFormat is PixelBitMask. Cc: G Edhaya Chandran Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Cc: Sunny Wang Cc: Jeremy Linton Signed-off-by: Dimitrije Pavlov --- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestConformance.c | 30 ++-- uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestFunction.c | 19 + 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestConformance.c index 13e7227f5845..b2bff9d756b1 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestConformance.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestConformance.c @@ -493,16 +493,28 @@ Returns: ); if (Status != EFI_SUCCESS) { AssertionType = EFI_TEST_ASSERTION_FAILED; - } else { + } else { AssertionType = EFI_TEST_ASSERTION_PASSED; - } - - if (SctCompareMem ( - (void *) info, - (void *) GraphicsOutput->Mode->Info, - sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) - ) != 0) { -AssertionType = EFI_TEST_ASSERTION_FAILED; +if (info != NULL) { + // + // PixelInformation is checked only if PixelFormat is PixelBitMask + // + if ( info->Version != GraphicsOutput->Mode->Info->Version +|| info->HorizontalResolution != GraphicsOutput->Mode->Info->HorizontalResolution +|| info->VerticalResolution != GraphicsOutput->Mode->Info->VerticalResolution +|| info->PixelFormat != GraphicsOutput->Mode->Info->PixelFormat +|| info->PixelsPerScanLine!= GraphicsOutput->Mode->Info->PixelsPerScanLine +|| ( info->PixelFormat == PixelBitMask + && ( info->PixelInformation.RedMask != GraphicsOutput->Mode->Info->PixelInformation.RedMask +|| info->PixelInformation.GreenMask!= GraphicsOutput->Mode->Info->PixelInformation.GreenMask +|| info->PixelInformation.BlueMask != GraphicsOutput->Mode->Info->PixelInformation.BlueMask +|| info->PixelInformation.ReservedMask != GraphicsOutput->Mode->Info->PixelInformation.ReservedMask))) + { +AssertionType = EFI_TEST_ASSERTION_FAILED; + } +} else { + AssertionType = EFI_TEST_ASSERTION_FAILED; +} } if (info != NULL) { diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestFunction.c index da51fbc44596..f31ea8175af8 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestFunction.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/GraphicsOutput/BlackBoxTest/GraphicsOutputBBTestFunction.c @@ -125,11 +125,20 @@ Returns: } else { AssertionType = EFI_TEST_ASSERTION_PASSED; if (Info != NULL) { -if (SctCompareMem ( -(void *) Info, -(void *) GraphicsOutput->Mode->Info, -sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) -) != 0) { +// +// PixelInformation is checked only if PixelFormat is PixelBitMask +// +if ( Info->Version != GraphicsOutput->Mode->Info->Version + || Info->HorizontalResolution != GraphicsOutput->Mode->Info->HorizontalResolution + || Info->VerticalResolution != GraphicsOutput->Mode->Info->VerticalResolution + || Info->PixelFormat != GraphicsOutput->Mode->Info->PixelFormat + || Info->PixelsPerScanLine!= GraphicsOutput->Mode->Info->PixelsPerScanLine + || ( Info->PixelFormat == PixelBitMask +&& ( Info->PixelInformation.RedMask != GraphicsOutput->Mode->Info->PixelInformation.RedMask + || Info->PixelInformation.GreenMask!= GraphicsOutput->Mode->Info->PixelInformation.GreenMask +
[edk2-devel] [PATCH v1 1/1] OvmfPkg/QemuVideoDxe: Zero out PixelInformation in QueryMode
Ensure that the PixelInformation field of the EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure is zeroed out in EFI_GRAPHICS_OUTPUT_PROTOCOL.QueryMode() and EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode() when PixelFormat is PixelBlueGreenRedReserved8BitPerColor. According to UEFI 2.9 Section 12.9, PixelInformation field of the EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure is valid only if PixelFormat is PixelBitMask. This means that firmware is not required to fill out the PixelInformation field for other PixelFormat types, which implies that the QemuVideoDxe implementation is technically correct. However, not zeroing out those fields will leak the contents of the memory returned by the memory allocator, so it is better to explicitly set them to zero. In addition, the SCT test suite relies on PixelInformation always having a consistent value, which causes failures. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Cc: Sunny Wang Cc: Jeremy Linton Signed-off-by: Dimitrije Pavlov --- OvmfPkg/QemuVideoDxe/Gop.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c index 0c4dea7fb6f2..7a9fe208c99c 100644 --- a/OvmfPkg/QemuVideoDxe/Gop.c +++ b/OvmfPkg/QemuVideoDxe/Gop.c @@ -31,7 +31,14 @@ QemuVideoCompleteModeInfo ( Info->PixelInformation.ReservedMask = 0; } else if (ModeData->ColorDepth == 32) { DEBUG ((DEBUG_INFO, "PixelBlueGreenRedReserved8BitPerColor\n")); -Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; +Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; +Info->PixelInformation.RedMask = 0; +Info->PixelInformation.GreenMask= 0; +Info->PixelInformation.BlueMask = 0; +Info->PixelInformation.ReservedMask = 0; + } else { +DEBUG ((DEBUG_ERROR, "%a: Invalid ColorDepth %u", __FUNCTION__, ModeData->ColorDepth)); +ASSERT (FALSE); } Info->PixelsPerScanLine = Info->HorizontalResolution; -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90822): https://edk2.groups.io/g/devel/message/90822 Mute This Topic: https://groups.io/mt/92050521/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] [edk2-platforms][PATCH v1 1/1] Silicon/Qemu: Provide _STA ACPI method
SBBR requires platforms to provide the _STA ACPI method for each defined device. This patch implements a stub method that always indicates devices are present and functional. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Graeme Gregory Cc: Radoslaw Biernacki Cc: Jeff Booher-Kaeding Cc: Samer El-Haj-Mahmoud Cc: Sunny Wang Cc: Jeremy Linton Signed-off-by: Dimitrije Pavlov --- Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl | 38 +++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl b/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl index 1bf9fbb99e75..3357916571fe 100644 --- a/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl +++ b/Silicon/Qemu/SbsaQemu/AcpiTables/Dsdt.asl @@ -16,6 +16,9 @@ Name (_PRS, ResourceTemplate() { \ Interrupt (ResourceProducer, Level, ActiveHigh, Exclusive) { Irq } \ }) \ +Method (_STA) { \ + Return (0xF) \ +} \ Method (_CRS, 0) { Return (_PRS) } \ Method (_SRS, 1) { } \ Method (_DIS) { } \ @@ -40,6 +43,9 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 0x1000) Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 33 } }) + Method (_STA) { +Return (0xF) + } } // AHCI Host Controller @@ -57,13 +63,18 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", FixedPcdGet32 (PcdPlatformAhciSize)) Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 42 } }) + Method (_STA) { +Return (0xF) + } } // USB EHCI Host Controller Device (USB0) { Name (_HID, "LNRO0D20") Name (_CID, "PNP0D20") - +Method (_STA) { + Return (0xF) +} Method (_CRS, 0x0, Serialized) { Name (RBUF, ResourceTemplate() { Memory32Fixed (ReadWrite, @@ -77,6 +88,9 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", // Root Hub Device (RHUB) { Name (_ADR, 0x) // Address of Root Hub should be 0 as per ACPI 5.0 spec +Method (_STA) { + Return (0xF) +} // Ports connected to Root Hub Device (HUB1) { @@ -87,6 +101,9 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 0x, // Reserved 0 must be zero 0x // Reserved 1 must be zero }) +Method (_STA) { + Return (0xF) +} Device (PRT1) { Name (_ADR, 0x0001) @@ -102,6 +119,9 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }) +Method (_STA) { + Return (0xF) +} } // USB0_RHUB_HUB1_PRT1 Device (PRT2) { Name (_ADR, 0x0002) @@ -117,6 +137,9 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }) +Method (_STA) { + Return (0xF) +} } // USB0_RHUB_HUB1_PRT2 Device (PRT3) { @@ -133,6 +156,9 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }) +Method (_STA) { + Return (0xF) +} } // USB0_RHUB_HUB1_PRT3 Device (PRT4) { @@ -149,6 +175,9 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 0x31, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }) +Method (_STA) { + Return (0xF) +} } // USB0_RHUB_HUB1_PRT4 } // USB0_RHUB_HUB1 } // USB0_RHUB @@ -164,6 +193,10 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", Name (_UID, "PCI0") Name (_CCA, One)// Initially mark the PCI coherent (for JunoR1) + Method (_