代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/edk2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 922d2aa15213ea16782d36d84cc39c9d99e295e5 Mon Sep 17 00:00:00 2001
From: Liu Zixing <liuzixing@hygon.cn>
Date: Fri, 25 Feb 2022 16:12:38 +0800
Subject: [PATCH 05/11] OvmfPkg/PlatformPei: Initialize CSV VM's memory
For CSV VM, the Secure Processor builds a temporary nested
page table to help the guest to run into the PEI phase.
In PEI phase, CSV VM detects the start address and size of the
guest physical memory.
The CSV VM sends the memory information to the Secure Processor
to build the permanent nested page table.
Signed-off-by: Xin Jiang <jiangxin@hygon.cn>
---
OvmfPkg/Include/Library/PlatformInitLib.h | 5 ++
OvmfPkg/Library/PlatformInitLib/MemDetect.c | 2 +-
OvmfPkg/PlatformPei/Csv.c | 82 +++++++++++++++++++++
OvmfPkg/PlatformPei/Platform.c | 2 +
OvmfPkg/PlatformPei/Platform.h | 10 +++
OvmfPkg/PlatformPei/PlatformPei.inf | 4 +
6 files changed, 104 insertions(+), 1 deletion(-)
create mode 100644 OvmfPkg/PlatformPei/Csv.c
diff --git a/OvmfPkg/Include/Library/PlatformInitLib.h b/OvmfPkg/Include/Library/PlatformInitLib.h
index 57b18b9..6c28c7f 100644
--- a/OvmfPkg/Include/Library/PlatformInitLib.h
+++ b/OvmfPkg/Include/Library/PlatformInitLib.h
@@ -151,6 +151,11 @@ PlatformGetSystemMemorySizeBelow4gb (
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
);
+UINT64
+EFIAPI
+PlatformGetSystemMemorySizeAbove4gb (
+ );
+
/**
Initialize the PhysMemAddressWidth field in PlatformInfoHob based on guest RAM size.
**/
diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
index 662e7e8..3c9f01c 100644
--- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
+++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
@@ -402,8 +402,8 @@ PlatformGetSystemMemorySizeBelow4gb (
PlatformInfoHob->LowMemory = (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);
}
-STATIC
UINT64
+EFIAPI
PlatformGetSystemMemorySizeAbove4gb (
)
{
diff --git a/OvmfPkg/PlatformPei/Csv.c b/OvmfPkg/PlatformPei/Csv.c
new file mode 100644
index 0000000..5ab8331
--- /dev/null
+++ b/OvmfPkg/PlatformPei/Csv.c
@@ -0,0 +1,82 @@
+/** @file
+
+ CSV initialization in PEI
+
+ Copyright (c) 2022, HYGON. All rights reserved.<BR>
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Uefi/UefiBaseType.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/HobLib.h>
+#include <Library/CsvLib.h>
+#include <Library/MemEncryptSevLib.h>
+#include <Library/PlatformInitLib.h>
+
+#include "Platform.h"
+
+VOID
+CsvInitializeMemInfo (
+ IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
+ )
+{
+ UINT64 LowerMemorySize;
+ UINT64 UpperMemorySize;
+
+ if (!CsvIsEnabled ()) {
+ return ;
+ }
+
+ LowerMemorySize = PlatformInfoHob->LowMemory;
+ UpperMemorySize = PlatformGetSystemMemorySizeAbove4gb ();
+
+ CsvUpdateMapLowerMemory (
+ 0,
+ LowerMemorySize >> EFI_PAGE_SHIFT
+ );
+
+ if (UpperMemorySize > 0) {
+ CsvUpdateMapUpperMemory (
+ BASE_4GB,
+ UpperMemorySize >> EFI_PAGE_SHIFT
+ );
+ }
+
+ BuildMemoryAllocationHob (
+ (EFI_PHYSICAL_ADDRESS)(UINTN) FixedPcdGet32 (PcdCsvDefaultSecureCallBase),
+ (UINT64)(UINTN) FixedPcdGet32 (PcdCsvDefaultSecureCallSize),
+ EfiReservedMemoryType
+ );
+}
+
+VOID
+CsvInitializeGhcb (
+ VOID
+ )
+{
+ RETURN_STATUS EncryptStatus;
+
+ if (!CsvIsEnabled ()) {
+ return ;
+ }
+
+ //
+ // Encrypt the SecGhcb as it's not a Ghcb any more
+ //
+ EncryptStatus = MemEncryptSevSetPageEncMask(
+ 0,
+ PcdGet32 (PcdOvmfSecGhcbBase),
+ 1
+ );
+ ASSERT_RETURN_ERROR (EncryptStatus);
+}
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index f5dc41c..34d764e 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -345,6 +345,7 @@ InitializePlatform (
PlatformQemuUc32BaseInitialization (PlatformInfoHob);
InitializeRamRegions (PlatformInfoHob);
+ CsvInitializeMemInfo (PlatformInfoHob);
if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) {
if (!PlatformInfoHob->SmmSmramRequire) {
@@ -364,6 +365,7 @@ InitializePlatform (
} else {
MiscInitialization (PlatformInfoHob);
}
+ CsvInitializeGhcb();
IntelTdxInitialize ();
InstallFeatureControlCallback (PlatformInfoHob);
diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 1cf4484..1893f3f 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -106,4 +106,14 @@ SevInitializeRam (
VOID
);
+VOID
+CsvInitializeMemInfo (
+ IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
+ );
+
+VOID
+CsvInitializeGhcb (
+ VOID
+ );
+
#endif // _PLATFORM_PEI_H_INCLUDED_
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
index 3934aee..45d1688 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -32,6 +32,7 @@
Platform.c
Platform.h
IntelTdx.c
+ Csv.c
[Packages]
EmbeddedPkg/EmbeddedPkg.dec
@@ -65,6 +66,7 @@
PcdLib
CcExitLib
PlatformInitLib
+ CsvLib
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
@@ -131,6 +133,8 @@
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize
+ gUefiOvmfPkgTokenSpaceGuid.PcdCsvDefaultSecureCallBase
+ gUefiOvmfPkgTokenSpaceGuid.PcdCsvDefaultSecureCallSize
[FeaturePcd]
gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable
--
2.25.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。