OvmfPkg: Add SecPeiCcProbeLib

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

SecPeiCcProbeLib is designed to probe the Confidential Computing guest
type in SEC/PEI phase. The CC guest type was set by each CC guest at
the beginning of boot up and saved in PcdOvmfWorkArea.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Min M Xu 2022-07-07 10:47:31 +08:00 committed by mergify[bot]
parent c05a218a97
commit c4bc1a9498
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,31 @@
/** @file
CcProbeLib is used to probe the Confidential computing guest type.
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Library/CcProbeLib.h>
#include <WorkArea.h>
/**
Probe the ConfidentialComputing Guest type. See defition of
CC_GUEST_TYPE in <ConfidentialComputingGuestAttr.h>.
@return The guest type
**/
UINT8
EFIAPI
CcProbe (
VOID
)
{
OVMF_WORK_AREA *WorkArea;
WorkArea = (OVMF_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase);
return WorkArea != NULL ? WorkArea->Header.GuestType : CcGuestTypeNonEncrypted;
}

View File

@ -0,0 +1,25 @@
## @file
# CcProbeLib is used to probe Confidential Computing guest type.
#
# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = SecPeiCcProbeLib
FILE_GUID = 78eb7f2a-a42a-4b01-b160-5a05a0a52bac
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = CcProbeLib|SEC PEIM PEI_CORE
[Sources]
SecPeiCcProbeLib.c
[Packages]
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase