#\r
ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf\r
EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf\r
- ArmVirtPkg/HighMemDxe/HighMemDxe.inf\r
+ OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf\r
OvmfPkg/VirtioBlkDxe/VirtioBlk.inf\r
OvmfPkg/VirtioScsiDxe/VirtioScsi.inf\r
OvmfPkg/VirtioNetDxe/VirtioNet.inf\r
INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
INF ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf\r
INF EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf\r
- INF ArmVirtPkg/HighMemDxe/HighMemDxe.inf\r
+ INF OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf\r
\r
#\r
# PI DXE Drivers producing Architectural Protocols (EFI Services)\r
ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf\r
ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf\r
EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf\r
- ArmVirtPkg/HighMemDxe/HighMemDxe.inf\r
+ OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf\r
OvmfPkg/VirtioBlkDxe/VirtioBlk.inf\r
OvmfPkg/VirtioScsiDxe/VirtioScsi.inf\r
OvmfPkg/VirtioNetDxe/VirtioNet.inf\r
INF ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf\r
INF EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf\r
INF ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf\r
- INF ArmVirtPkg/HighMemDxe/HighMemDxe.inf\r
+ INF OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf\r
\r
#\r
# PI DXE Drivers producing Architectural Protocols (EFI Services)\r
#\r
ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf\r
EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf\r
- ArmVirtPkg/HighMemDxe/HighMemDxe.inf\r
+ OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf\r
OvmfPkg/VirtioBlkDxe/VirtioBlk.inf\r
OvmfPkg/VirtioScsiDxe/VirtioScsi.inf\r
OvmfPkg/VirtioNetDxe/VirtioNet.inf\r
INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
INF ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf\r
INF EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf\r
- INF ArmVirtPkg/HighMemDxe/HighMemDxe.inf\r
+ INF OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf\r
\r
#\r
# PI DXE Drivers producing Architectural Protocols (EFI Services)\r
#\r
ArmVirtPkg/VirtioFdtDxe/VirtioFdtDxe.inf\r
EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.inf\r
- ArmVirtPkg/HighMemDxe/HighMemDxe.inf\r
+ OvmfPkg/Fdt/HighMemDxe/HighMemDxe.inf\r
OvmfPkg/VirtioBlkDxe/VirtioBlk.inf\r
OvmfPkg/VirtioScsiDxe/VirtioScsi.inf\r
OvmfPkg/VirtioNetDxe/VirtioNet.inf\r
+++ /dev/null
-/** @file\r
-* High memory node enumeration DXE driver for ARM Virtual Machines\r
-*\r
-* Copyright (c) 2015-2016, Linaro Ltd. All rights reserved.\r
-*\r
-* SPDX-License-Identifier: BSD-2-Clause-Patent\r
-*\r
-**/\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-#include <Protocol/Cpu.h>\r
-#include <Protocol/FdtClient.h>\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeHighMemDxe (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- FDT_CLIENT_PROTOCOL *FdtClient;\r
- EFI_CPU_ARCH_PROTOCOL *Cpu;\r
- EFI_STATUS Status, FindNodeStatus;\r
- INT32 Node;\r
- CONST UINT32 *Reg;\r
- UINT32 RegSize;\r
- UINTN AddressCells, SizeCells;\r
- UINT64 CurBase;\r
- UINT64 CurSize;\r
- UINT64 Attributes;\r
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;\r
-\r
- Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,\r
- (VOID **)&FdtClient);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL,\r
- (VOID **)&Cpu);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Check for memory node and add the memory spaces except the lowest one\r
- //\r
- for (FindNodeStatus = FdtClient->FindMemoryNodeReg (FdtClient, &Node,\r
- (CONST VOID **) &Reg, &AddressCells,\r
- &SizeCells, &RegSize);\r
- !EFI_ERROR (FindNodeStatus);\r
- FindNodeStatus = FdtClient->FindNextMemoryNodeReg (FdtClient, Node,\r
- &Node, (CONST VOID **) &Reg, &AddressCells,\r
- &SizeCells, &RegSize)) {\r
- ASSERT (AddressCells <= 2);\r
- ASSERT (SizeCells <= 2);\r
-\r
- while (RegSize > 0) {\r
- CurBase = SwapBytes32 (*Reg++);\r
- if (AddressCells > 1) {\r
- CurBase = (CurBase << 32) | SwapBytes32 (*Reg++);\r
- }\r
- CurSize = SwapBytes32 (*Reg++);\r
- if (SizeCells > 1) {\r
- CurSize = (CurSize << 32) | SwapBytes32 (*Reg++);\r
- }\r
- RegSize -= (AddressCells + SizeCells) * sizeof (UINT32);\r
-\r
- Status = gDS->GetMemorySpaceDescriptor (CurBase, &GcdDescriptor);\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_WARN,\r
- "%a: Region 0x%lx - 0x%lx not found in the GCD memory space map\n",\r
- __FUNCTION__, CurBase, CurBase + CurSize - 1));\r
- continue;\r
- }\r
- if (GcdDescriptor.GcdMemoryType == EfiGcdMemoryTypeNonExistent) {\r
- Status = gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, CurBase,\r
- CurSize, EFI_MEMORY_WB);\r
-\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR,\r
- "%a: Failed to add System RAM @ 0x%lx - 0x%lx (%r)\n",\r
- __FUNCTION__, CurBase, CurBase + CurSize - 1, Status));\r
- continue;\r
- }\r
-\r
- Status = gDS->SetMemorySpaceAttributes (CurBase, CurSize,\r
- EFI_MEMORY_WB);\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_WARN,\r
- "%a: gDS->SetMemorySpaceAttributes() failed on region 0x%lx - 0x%lx (%r)\n",\r
- __FUNCTION__, CurBase, CurBase + CurSize - 1, Status));\r
- }\r
-\r
- //\r
- // Due to the ambiguous nature of the RO/XP GCD memory space attributes,\r
- // it is impossible to add a memory space with the XP attribute in a way\r
- // that does not result in the XP attribute being set on *all* UEFI\r
- // memory map entries that are carved from it, including code regions\r
- // that require executable permissions.\r
- //\r
- // So instead, we never set the RO/XP attributes in the GCD memory space\r
- // capabilities or attribute fields, and apply any protections directly\r
- // on the page table mappings by going through the cpu arch protocol.\r
- //\r
- Attributes = EFI_MEMORY_WB;\r
- if ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) &\r
- (1U << (UINT32)EfiConventionalMemory)) != 0) {\r
- Attributes |= EFI_MEMORY_XP;\r
- }\r
-\r
- Status = Cpu->SetMemoryAttributes (Cpu, CurBase, CurSize, Attributes);\r
-\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR,\r
- "%a: Failed to set System RAM @ 0x%lx - 0x%lx attribute (%r)\n",\r
- __FUNCTION__, CurBase, CurBase + CurSize - 1, Status));\r
- } else {\r
- DEBUG ((EFI_D_INFO, "%a: Add System RAM @ 0x%lx - 0x%lx\n",\r
- __FUNCTION__, CurBase, CurBase + CurSize - 1));\r
- }\r
- }\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
+++ /dev/null
-## @file\r
-# High memory node enumeration DXE driver for ARM Virtual Machines\r
-#\r
-# Copyright (c) 2015-2016, Linaro Ltd. All rights reserved.\r
-#\r
-# SPDX-License-Identifier: BSD-2-Clause-Patent\r
-#\r
-##\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = HighMemDxe\r
- FILE_GUID = 63EA1463-FBFA-428A-B97F-E222755852D7\r
- MODULE_TYPE = DXE_DRIVER\r
- VERSION_STRING = 1.0\r
-\r
- ENTRY_POINT = InitializeHighMemDxe\r
-\r
-[Sources]\r
- HighMemDxe.c\r
-\r
-[Packages]\r
- EmbeddedPkg/EmbeddedPkg.dec\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- ArmPkg/ArmPkg.dec\r
- ArmVirtPkg/ArmVirtPkg.dec\r
-\r
-[LibraryClasses]\r
- BaseLib\r
- DebugLib\r
- DxeServicesTableLib\r
- PcdLib\r
- UefiBootServicesTableLib\r
- UefiDriverEntryPoint\r
-\r
-[Protocols]\r
- gEfiCpuArchProtocolGuid ## CONSUMES\r
- gFdtClientProtocolGuid ## CONSUMES\r
-\r
-[Pcd]\r
- gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy\r
-\r
-[Depex]\r
- gEfiCpuArchProtocolGuid AND gFdtClientProtocolGuid\r
--- /dev/null
+/** @file\r
+* High memory node enumeration DXE driver for ARM Virtual Machines\r
+*\r
+* Copyright (c) 2015-2016, Linaro Ltd. All rights reserved.\r
+*\r
+* SPDX-License-Identifier: BSD-2-Clause-Patent\r
+*\r
+**/\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#include <Protocol/Cpu.h>\r
+#include <Protocol/FdtClient.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeHighMemDxe (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ FDT_CLIENT_PROTOCOL *FdtClient;\r
+ EFI_CPU_ARCH_PROTOCOL *Cpu;\r
+ EFI_STATUS Status, FindNodeStatus;\r
+ INT32 Node;\r
+ CONST UINT32 *Reg;\r
+ UINT32 RegSize;\r
+ UINTN AddressCells, SizeCells;\r
+ UINT64 CurBase;\r
+ UINT64 CurSize;\r
+ UINT64 Attributes;\r
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;\r
+\r
+ Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,\r
+ (VOID **)&FdtClient);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL,\r
+ (VOID **)&Cpu);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Check for memory node and add the memory spaces except the lowest one\r
+ //\r
+ for (FindNodeStatus = FdtClient->FindMemoryNodeReg (FdtClient, &Node,\r
+ (CONST VOID **) &Reg, &AddressCells,\r
+ &SizeCells, &RegSize);\r
+ !EFI_ERROR (FindNodeStatus);\r
+ FindNodeStatus = FdtClient->FindNextMemoryNodeReg (FdtClient, Node,\r
+ &Node, (CONST VOID **) &Reg, &AddressCells,\r
+ &SizeCells, &RegSize)) {\r
+ ASSERT (AddressCells <= 2);\r
+ ASSERT (SizeCells <= 2);\r
+\r
+ while (RegSize > 0) {\r
+ CurBase = SwapBytes32 (*Reg++);\r
+ if (AddressCells > 1) {\r
+ CurBase = (CurBase << 32) | SwapBytes32 (*Reg++);\r
+ }\r
+ CurSize = SwapBytes32 (*Reg++);\r
+ if (SizeCells > 1) {\r
+ CurSize = (CurSize << 32) | SwapBytes32 (*Reg++);\r
+ }\r
+ RegSize -= (AddressCells + SizeCells) * sizeof (UINT32);\r
+\r
+ Status = gDS->GetMemorySpaceDescriptor (CurBase, &GcdDescriptor);\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((DEBUG_WARN,\r
+ "%a: Region 0x%lx - 0x%lx not found in the GCD memory space map\n",\r
+ __FUNCTION__, CurBase, CurBase + CurSize - 1));\r
+ continue;\r
+ }\r
+ if (GcdDescriptor.GcdMemoryType == EfiGcdMemoryTypeNonExistent) {\r
+ Status = gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, CurBase,\r
+ CurSize, EFI_MEMORY_WB);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR,\r
+ "%a: Failed to add System RAM @ 0x%lx - 0x%lx (%r)\n",\r
+ __FUNCTION__, CurBase, CurBase + CurSize - 1, Status));\r
+ continue;\r
+ }\r
+\r
+ Status = gDS->SetMemorySpaceAttributes (CurBase, CurSize,\r
+ EFI_MEMORY_WB);\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((DEBUG_WARN,\r
+ "%a: gDS->SetMemorySpaceAttributes() failed on region 0x%lx - 0x%lx (%r)\n",\r
+ __FUNCTION__, CurBase, CurBase + CurSize - 1, Status));\r
+ }\r
+\r
+ //\r
+ // Due to the ambiguous nature of the RO/XP GCD memory space attributes,\r
+ // it is impossible to add a memory space with the XP attribute in a way\r
+ // that does not result in the XP attribute being set on *all* UEFI\r
+ // memory map entries that are carved from it, including code regions\r
+ // that require executable permissions.\r
+ //\r
+ // So instead, we never set the RO/XP attributes in the GCD memory space\r
+ // capabilities or attribute fields, and apply any protections directly\r
+ // on the page table mappings by going through the cpu arch protocol.\r
+ //\r
+ Attributes = EFI_MEMORY_WB;\r
+ if ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) &\r
+ (1U << (UINT32)EfiConventionalMemory)) != 0) {\r
+ Attributes |= EFI_MEMORY_XP;\r
+ }\r
+\r
+ Status = Cpu->SetMemoryAttributes (Cpu, CurBase, CurSize, Attributes);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((EFI_D_ERROR,\r
+ "%a: Failed to set System RAM @ 0x%lx - 0x%lx attribute (%r)\n",\r
+ __FUNCTION__, CurBase, CurBase + CurSize - 1, Status));\r
+ } else {\r
+ DEBUG ((EFI_D_INFO, "%a: Add System RAM @ 0x%lx - 0x%lx\n",\r
+ __FUNCTION__, CurBase, CurBase + CurSize - 1));\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+## @file\r
+# High memory node enumeration DXE driver for ARM Virtual Machines\r
+#\r
+# Copyright (c) 2015-2016, Linaro Ltd. All rights reserved.\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = HighMemDxe\r
+ FILE_GUID = 63EA1463-FBFA-428A-B97F-E222755852D7\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+\r
+ ENTRY_POINT = InitializeHighMemDxe\r
+\r
+[Sources]\r
+ HighMemDxe.c\r
+\r
+[Packages]\r
+ EmbeddedPkg/EmbeddedPkg.dec\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ DebugLib\r
+ DxeServicesTableLib\r
+ PcdLib\r
+ UefiBootServicesTableLib\r
+ UefiDriverEntryPoint\r
+\r
+[Protocols]\r
+ gEfiCpuArchProtocolGuid ## CONSUMES\r
+ gFdtClientProtocolGuid ## CONSUMES\r
+\r
+[Pcd]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy\r
+\r
+[Depex]\r
+ gEfiCpuArchProtocolGuid AND gFdtClientProtocolGuid\r