diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 2881475b80..9865d2b374 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -233,6 +233,7 @@ ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf CpuArchLib|ArmPkg/Library/CpuArchLib/CpuArchLib.inf + MemoryPoolLib|MdeModulePkg/Library/MemoryPoolLib/MemoryPoolLib.inf [LibraryClasses.common.DXE_DRIVER] SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index 0b3cbfbadd..dbaf476b91 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -465,6 +465,10 @@ MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf FatPkg/EnhancedFatDxe/Fat.inf + MdeModulePkg/Core/Dxe/DxeRing3/DxeRing3.inf { + + MemoryPoolLib|MdeModulePkg/Library/MemoryPoolLib/MemoryPoolLib.inf + } MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc index 9ed1c73715..e0ec532f12 100644 --- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc @@ -38,6 +38,10 @@ READ_STATUS = TRUE READ_LOCK_CAP = TRUE READ_LOCK_STATUS = TRUE +APRIORI DXE { + INF MdeModulePkg/Core/Dxe/DxeRing3/DxeRing3.inf +} + INF MdeModulePkg/Core/Dxe/DxeMain.inf INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf INF OvmfPkg/Fdt/VirtioFdtDxe/VirtioFdtDxe.inf @@ -82,6 +86,7 @@ READ_LOCK_STATUS = TRUE INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf INF FatPkg/EnhancedFatDxe/Fat.inf + INF MdeModulePkg/Core/Dxe/DxeRing3/DxeRing3.inf INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf INF OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf index 8d76d9082a..8f64b8af0c 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -22,7 +22,7 @@ # # The following information is for reference only and not required by the build tools. # -# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only) +# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only) ARM AARCH64 # [Sources] @@ -78,11 +78,20 @@ SysCall/X64/InitializeMsr.c SysCall/X64/CoreBootServices.nasm +[Sources.ARM] + SysCall/ARM/InitializeMsr.c + SysCall/ARM/CoreBootServices.S + +[Sources.AARCH64] + SysCall/AARCH64/InitializeMsr.c + SysCall/AARCH64/CoreBootServices.S + [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec UefiCpuPkg/UefiCpuPkg.dec OvmfPkg/OvmfPkg.dec + ArmPkg/ArmPkg.dec [LibraryClasses] BaseMemoryLib diff --git a/MdeModulePkg/Core/Dxe/DxeRing3/AARCH64/SysCall.S b/MdeModulePkg/Core/Dxe/DxeRing3/AARCH64/SysCall.S new file mode 100644 index 0000000000..2a22be0c0a --- /dev/null +++ b/MdeModulePkg/Core/Dxe/DxeRing3/AARCH64/SysCall.S @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2024, Mikhail Krichanov. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +//------------------------------------------------------------------------------ + +#include + +//------------------------------------------------------------------------------ +// EFI_STATUS +// EFIAPI +// SysCall ( +// IN UINT8 Type, +// ... +// ); +//------------------------------------------------------------------------------ +ASM_FUNC(SysCall) + + ret + +//------------------------------------------------------------------------------ +// VOID +// EFIAPI +// Ring3EntryPoint ( +// IN RING3_CALL_DATA *Data +// ); +// +// (rcx) RIP of Ring3EntryPoint saved for SYSRET in CallRing3(). +// (rdx) Data +//------------------------------------------------------------------------------ +ASM_FUNC(Ring3EntryPoint) + + ret diff --git a/MdeModulePkg/Core/Dxe/DxeRing3/ARM/SysCall.S b/MdeModulePkg/Core/Dxe/DxeRing3/ARM/SysCall.S new file mode 100644 index 0000000000..dd9d6d8721 --- /dev/null +++ b/MdeModulePkg/Core/Dxe/DxeRing3/ARM/SysCall.S @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2024, Mikhail Krichanov. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +//------------------------------------------------------------------------------ + +#include + +//------------------------------------------------------------------------------ +// EFI_STATUS +// EFIAPI +// SysCall ( +// IN UINT8 Type, +// ... +// ); +//------------------------------------------------------------------------------ +ASM_FUNC(SysCall) + + bx LR + +//------------------------------------------------------------------------------ +// VOID +// EFIAPI +// Ring3EntryPoint ( +// IN RING3_CALL_DATA *Data +// ); +// +// (rcx) RIP of Ring3EntryPoint saved for SYSRET in CallRing3(). +// (rdx) Data +//------------------------------------------------------------------------------ +ASM_FUNC(Ring3EntryPoint) + + bx LR diff --git a/MdeModulePkg/Core/Dxe/DxeRing3/DxeRing3.inf b/MdeModulePkg/Core/Dxe/DxeRing3/DxeRing3.inf index 4c36e5a97e..ca5e9a0f5b 100644 --- a/MdeModulePkg/Core/Dxe/DxeRing3/DxeRing3.inf +++ b/MdeModulePkg/Core/Dxe/DxeRing3/DxeRing3.inf @@ -18,7 +18,7 @@ # # The following information is for reference only and not required by the build tools. # -# VALID_ARCHITECTURES = IA32 X64 +# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 # [Sources] @@ -34,9 +34,16 @@ [Sources.X64] X64/SysCall.nasm +[Sources.ARM] + ARM/SysCall.S + +[Sources.AARCH64] + AARCH64/SysCall.S + [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + ArmPkg/ArmPkg.dec [LibraryClasses] BaseLib diff --git a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S new file mode 100644 index 0000000000..1d26d79473 --- /dev/null +++ b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/CoreBootServices.S @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) 2024, Mikhail Krichanov. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +// +//------------------------------------------------------------------------------ + +#include + +//------------------------------------------------------------------------------ +// VOID +// EFIAPI +// DisableSMAP ( +// VOID +// ); +//------------------------------------------------------------------------------ +ASM_FUNC(DisableSMAP) + ret + +//------------------------------------------------------------------------------ +// VOID +// EFIAPI +// EnableSMAP ( +// VOID +// ); +//------------------------------------------------------------------------------ +ASM_FUNC(EnableSMAP) + ret + +//------------------------------------------------------------------------------ +// EFI_STATUS +// EFIAPI +// CallInstallMultipleProtocolInterfaces ( +// IN EFI_HANDLE *Handle, +// IN VOID **ArgList, +// IN UINT32 ArgListSize, +// IN VOID *Function +// ); +//------------------------------------------------------------------------------ +ASM_FUNC(CallInstallMultipleProtocolInterfaces) + ret + +//------------------------------------------------------------------------------ +// EFI_STATUS +// EFIAPI +// CoreBootServices ( +// IN UINT8 Type, +// ... +// ); +// +// (rcx) RIP of the next instruction saved by SYSCALL in SysCall(). +// (rdx) Argument 1 of the called function. +// (r8) Argument 2 of the called function. +// (r9) Argument 3 of the called function. +// (r10) Type. +// (r11) RFLAGS saved by SYSCALL in SysCall(). +// +// (On User Stack) Argument 4, 5, ... +//------------------------------------------------------------------------------ +ASM_FUNC(CoreBootServices) + ret + +//------------------------------------------------------------------------------ +// EFI_STATUS +// EFIAPI +// CallRing3 ( +// IN RING3_CALL_DATA *Data +// ); +// +// (rcx) Data +//------------------------------------------------------------------------------ +ASM_FUNC(CallRing3) + ret diff --git a/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c new file mode 100644 index 0000000000..bc844910fd --- /dev/null +++ b/MdeModulePkg/Core/Dxe/SysCall/AARCH64/InitializeMsr.c @@ -0,0 +1,17 @@ +/** @file + + Copyright (c) 2024, Mikhail Krichanov. All rights reserved. + SPDX-License-Identifier: BSD-3-Clause + +**/ + +#include "DxeMain.h" + +VOID +EFIAPI +InitializeMsr ( + VOID + ) +{ + +} diff --git a/MdeModulePkg/Core/Dxe/SysCall/ARM/CoreBootServices.S b/MdeModulePkg/Core/Dxe/SysCall/ARM/CoreBootServices.S new file mode 100644 index 0000000000..406a7f66cf --- /dev/null +++ b/MdeModulePkg/Core/Dxe/SysCall/ARM/CoreBootServices.S @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) 2024, Mikhail Krichanov. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause +// +//------------------------------------------------------------------------------ + +#include + +//------------------------------------------------------------------------------ +// VOID +// EFIAPI +// DisableSMAP ( +// VOID +// ); +//------------------------------------------------------------------------------ +ASM_FUNC(DisableSMAP) + bx LR + +//------------------------------------------------------------------------------ +// VOID +// EFIAPI +// EnableSMAP ( +// VOID +// ); +//------------------------------------------------------------------------------ +ASM_FUNC(EnableSMAP) + bx LR + +//------------------------------------------------------------------------------ +// EFI_STATUS +// EFIAPI +// CallInstallMultipleProtocolInterfaces ( +// IN EFI_HANDLE *Handle, +// IN VOID **ArgList, +// IN UINT32 ArgListSize, +// IN VOID *Function +// ); +//------------------------------------------------------------------------------ +ASM_FUNC(CallInstallMultipleProtocolInterfaces) + bx LR + +//------------------------------------------------------------------------------ +// EFI_STATUS +// EFIAPI +// CoreBootServices ( +// IN UINT8 Type, +// ... +// ); +// +// (rcx) RIP of the next instruction saved by SYSCALL in SysCall(). +// (rdx) Argument 1 of the called function. +// (r8) Argument 2 of the called function. +// (r9) Argument 3 of the called function. +// (r10) Type. +// (r11) RFLAGS saved by SYSCALL in SysCall(). +// +// (On User Stack) Argument 4, 5, ... +//------------------------------------------------------------------------------ +ASM_FUNC(CoreBootServices) + bx LR + +//------------------------------------------------------------------------------ +// EFI_STATUS +// EFIAPI +// CallRing3 ( +// IN RING3_CALL_DATA *Data +// ); +// +// (rcx) Data +//------------------------------------------------------------------------------ +ASM_FUNC(CallRing3) + bx LR diff --git a/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c b/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c new file mode 100644 index 0000000000..bc844910fd --- /dev/null +++ b/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c @@ -0,0 +1,17 @@ +/** @file + + Copyright (c) 2024, Mikhail Krichanov. All rights reserved. + SPDX-License-Identifier: BSD-3-Clause + +**/ + +#include "DxeMain.h" + +VOID +EFIAPI +InitializeMsr ( + VOID + ) +{ + +} diff --git a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c index a7acb4ceb8..95f98b3ef8 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c +++ b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c @@ -329,9 +329,7 @@ CoreFileSetPosition ( File->Ring3File, Position ); -#endif - -#if defined (MDE_CPU_IA32) +#elif defined (MDE_CPU_IA32) // // UINT64 Position is passed as 2 double words on stack. // @@ -341,6 +339,13 @@ CoreFileSetPosition ( File->Ring3File, Position ); +#else + return GoToRing3 ( + 2, + (VOID *)mRing3FileProtocol.SetPosition, + File->Ring3File, + Position + ); #endif } @@ -607,9 +612,7 @@ CoreFileOpen ( OpenMode, Attributes ); -#endif - -#if defined (MDE_CPU_IA32) +#elif defined (MDE_CPU_IA32) // // UINT64 OpenMode and Attributes are each passed as 2 double words on stack. // @@ -622,6 +625,16 @@ CoreFileOpen ( OpenMode, Attributes ); +#else + Status = GoToRing3 ( + 5, + (VOID *)mRing3FileProtocol.Open, + File->Ring3File, + Ring3NewHandle, + Ring3FileName, + OpenMode, + Attributes + ); #endif if (EFI_ERROR (Status)) { *NewHandle = NULL;