public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH V3 0/2] Re-design CcProbeLib
@ 2022-08-25 14:24 Min Xu
  2022-08-25 14:24 ` [PATCH V3 1/2] OvmfPkg: Add SecPeiCcProbeLib Min Xu
  2022-08-25 14:24 ` [PATCH V3 2/2] OvmfPkg: Update CcProbeLib to DxeCcProbeLib Min Xu
  0 siblings, 2 replies; 6+ messages in thread
From: Min Xu @ 2022-08-25 14:24 UTC (permalink / raw)
  To: devel
  Cc: Min Xu, Gerd Hoffmann, Erdem Aktas, James Bottomley, Jiewen Yao,
	Tom Lendacky, Yuan Yu

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3974

CcProbeLib once was designed to probe the Confidential Computing guest
type by checking the PcdOvmfWorkArea. But this memory is allocated with
either EfiACPIMemoryNVS or EfiBootServicesData. It cannot be accessed
after ExitBootService. Please see the detailed analysis in BZ#3974.

To fix this issue, CcProbeLib is re-designed as 2 implementation:
 - SecPeiCcProbeLib
 - DxeCcProbeLib

In SecPeiCcProbeLib we check the CC guest type by reading the
PcdOvmfWorkArea. Because it is used in SEC / PEI and we don't worry about
the issues in BZ#3974.

In DxeCcProbeLib we cache the GuestType in Ovmf work area in first-call.
After that the Guest type is returned with the cached value. So that we
don't need to worry about the access to Ovmf work area after
ExitBootService.

The reason why we probe CC guest type in 2 different ways is the global
varialbe. Global variable cannot be used in SEC/PEI and CcProbe is called
very frequently.

Code: https://github.com/mxu9/edk2/tree/CcProbeLib.BZ3974.v3

v3 changes:
 - Re-design CcProbeLib to 2 implementation: SecPeiCcProbeLib and
   DxeCcProbeLib. The difference between the 2 implementation is the
   cache of the CcGuestType.

v2 changes:
 - Reserve Ovmf work-area as RT_DATA. See
   https://edk2.groups.io/g/devel/message/92599

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Yuan Yu <yuanyu@google.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>

Min M Xu (2):
  OvmfPkg: Add SecPeiCcProbeLib
  OvmfPkg: Update CcProbeLib to DxeCcProbeLib

 OvmfPkg/IntelTdx/IntelTdxX64.dsc              |  3 +-
 OvmfPkg/Library/CcProbeLib/DxeCcProbeLib.c    | 38 +++++++++++++++++++
 .../{CcProbeLib.inf => DxeCcProbeLib.inf}     |  6 +--
 .../{CcProbeLib.c => SecPeiCcProbeLib.c}      |  0
 .../Library/CcProbeLib/SecPeiCcProbeLib.inf   | 25 ++++++++++++
 OvmfPkg/OvmfPkgX64.dsc                        |  5 ++-
 6 files changed, 72 insertions(+), 5 deletions(-)
 create mode 100644 OvmfPkg/Library/CcProbeLib/DxeCcProbeLib.c
 rename OvmfPkg/Library/CcProbeLib/{CcProbeLib.inf => DxeCcProbeLib.inf} (70%)
 rename OvmfPkg/Library/CcProbeLib/{CcProbeLib.c => SecPeiCcProbeLib.c} (100%)
 create mode 100644 OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf

-- 
2.29.2.windows.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-26  9:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-25 14:24 [PATCH V3 0/2] Re-design CcProbeLib Min Xu
2022-08-25 14:24 ` [PATCH V3 1/2] OvmfPkg: Add SecPeiCcProbeLib Min Xu
2022-08-25 14:24 ` [PATCH V3 2/2] OvmfPkg: Update CcProbeLib to DxeCcProbeLib Min Xu
2022-08-26  5:23   ` Gerd Hoffmann
2022-08-26  8:21     ` [edk2-devel] " Min Xu
2022-08-26  9:11       ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox