diff --git a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c index 6a23b4ba79..54943444de 100644 --- a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c +++ b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c @@ -697,9 +697,12 @@ Ring3CalculateCrc32 ( OUT UINT32 *Crc32 ) { - DEBUG ((DEBUG_ERROR, "Ring3: CalculateCrc32 is not supported\n")); - - return EFI_UNSUPPORTED; + return SysCall ( + SysCallCalculateCrc32, + Data, + DataSize, + Crc32 + ); } EFI_STATUS diff --git a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c index 366fb45a77..13abe746b6 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c +++ b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c @@ -650,6 +650,42 @@ CallBootService ( return StatusBS; + case SysCallCalculateCrc32: + // + // Argument 1: VOID *Data + // Argument 2: UINTN DataSize + // Argument 3: UINT32 *Crc32 + // + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)CoreRbp->Argument1, &Attributes); + ASSERT ((Attributes & EFI_MEMORY_USER) != 0); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(CoreRbp->Argument1 + CoreRbp->Argument2 - 1), &Attributes); + ASSERT ((Attributes & EFI_MEMORY_USER) != 0); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)CoreRbp->Argument3, &Attributes); + ASSERT ((Attributes & EFI_MEMORY_USER) != 0); + gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(CoreRbp->Argument3 + sizeof (UINT32 *) - 1), &Attributes); + ASSERT ((Attributes & EFI_MEMORY_USER) != 0); + + Argument4 = (UINTN)AllocatePool (CoreRbp->Argument2); + if ((VOID *)Argument4 == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + DisableSMAP (); + CopyMem ((VOID *)Argument4, (VOID *)CoreRbp->Argument1, CoreRbp->Argument2); + EnableSMAP (); + + Status = gBS->CalculateCrc32 ( + (VOID *)Argument4, + CoreRbp->Argument2, + (UINT32 *)&Argument5 + ); + + DisableSMAP (); + *(UINT32 *)CoreRbp->Argument3 = (UINT32)Argument5; + EnableSMAP (); + + return Status; + case SysCallGetVariable: // // Argument 1: CHAR16 *VariableName diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h index 8f93030aa6..df3cf9ae4a 100644 --- a/MdePkg/Include/Uefi/UefiSpec.h +++ b/MdePkg/Include/Uefi/UefiSpec.h @@ -2028,6 +2028,7 @@ typedef enum { SysCallRaiseTpl, SysCallRestoreTpl, SysCallLocateHandleBuffer, + SysCallCalculateCrc32, // // RuntimeServices //