1 Star 0 Fork 17

方保顺/edk2

forked from src-anolis-os/edk2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
0035-anolis-OvmfPkg-BaseMemcryptSevLib-update-page-status.patch 2.49 KB
一键复制 编辑 原始数据 按行查看 历史
jiangxin00 提交于 2023-12-11 14:05 +08:00 . Support Hygon CSV3 feaure and SEV live migration
From 16936ea22fc052576844dfdad6987531aa27a8ec Mon Sep 17 00:00:00 2001
From: Liu Zixing <liuzixing@hygon.cn>
Date: Sat, 26 Feb 2022 14:39:06 +0800
Subject: [PATCH 35/46] anolis: OvmfPkg/BaseMemcryptSevLib: update page status
to Secure Processor for CSV
For CSV VM, when encrypting/decrypting a shared/private memory region,
guest needs to
- set/clear the c-bit in guest page table
- the Secure Processor should be updated accordingly
The BaseMemcryptSevLib has done the first step.
Calling the secure call library for second step.
Signed-off-by: Xin Jiang <jiangxin@hygon.cn>
Change-Id: Icab502ee201d887d6056bcb0116b2e5a1b9eb6b9
---
.../BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf | 1 +
.../BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf b/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
index f2e162d..dc32929 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
@@ -49,6 +49,7 @@
DebugLib
MemoryAllocationLib
PcdLib
+ CsvLib
[FeaturePcd]
gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
index c696745..6726010 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
@@ -18,6 +18,8 @@
#include "VirtualMemory.h"
+#include <Library/CsvLib.h>
+
STATIC BOOLEAN mAddressEncMaskChecked = FALSE;
STATIC UINT64 mAddressEncMask;
STATIC PAGE_TABLE_POOL *mPageTablePool = NULL;
@@ -585,6 +587,11 @@ SetMemoryEncDec (
UINT64 AddressEncMask;
BOOLEAN IsWpEnabled;
RETURN_STATUS Status;
+ PHYSICAL_ADDRESS PageAddress;
+ UINTN PageNum;
+
+ PageAddress = PhysicalAddress;
+ PageNum = EFI_SIZE_TO_PAGES (Length);
//
// Set PageMapLevel4Entry to suppress incorrect compiler/analyzer warnings.
@@ -816,6 +823,13 @@ Done:
EnableReadOnlyPageWriteProtect ();
}
+ if (CsvIsEnabled () && Status == EFI_SUCCESS) {
+ if (Mode == ClearCBit)
+ CsvUpdateMemory (PageAddress, PageNum, TRUE);
+ else
+ CsvUpdateMemory (PageAddress, PageNum, FALSE);
+ }
+
return Status;
}
--
2.17.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fang_baoshun/edk2.git
git@gitee.com:fang_baoshun/edk2.git
fang_baoshun
edk2
edk2
a8

搜索帮助