From 99d5d6b5a9dc9a3653fd60a34149d326d05929b3 Mon Sep 17 00:00:00 2001 From: Mikhail Krichanov Date: Fri, 22 Mar 2024 18:09:42 +0300 Subject: [PATCH] SysCall: Replaced AllocatePool() with CoreAllocatePages(). --- .../Core/Dxe/SysCall/SupportedProtocols.c | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c index 989ff9d4fa..ac908a3005 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c +++ b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c @@ -26,23 +26,28 @@ GoToRing3 ( ... ) { - EFI_STATUS Status; - RING3_CALL_DATA *Input; - VA_LIST Marker; - UINTN Index; + EFI_STATUS Status; + RING3_CALL_DATA *Input; + VA_LIST Marker; + UINTN Index; + EFI_PHYSICAL_ADDRESS Ring3Pages; + UINT32 PagesNumber; - DisableSMAP (); - Status = gBS->AllocatePool ( - EfiRing3MemoryType, - sizeof (RING3_CALL_DATA) + Number * sizeof (UINTN), - (VOID **)&Input - ); + PagesNumber = (UINT32)EFI_SIZE_TO_PAGES (sizeof (RING3_CALL_DATA) + Number * sizeof (UINTN)); + + Status = CoreAllocatePages ( + AllocateAnyPages, + EfiRing3MemoryType, + PagesNumber, + &Ring3Pages + ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate memory for Input data.\n")); - EnableSMAP (); return Status; } + Input = (RING3_CALL_DATA *)(UINTN)Ring3Pages; + + DisableSMAP (); Input->NumberOfArguments = Number; Input->EntryPoint = EntryPoint; @@ -74,6 +79,8 @@ GoToRing3 ( ); } + CoreFreePages (Ring3Pages, PagesNumber); + return Status; }