Files
system76-edk2/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
Min Xu 7012cb73c4 MdePkg: Probe Cc guest in BaseIoLibIntrinsicSev
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3902

Bad IO performance in SEC phase is observed after TDX features was
introduced. (after commit b6b2de8848 - "MdePkg: Support mmio for
Tdx guest in BaseIoLibIntrinsic").

This is because IsTdxGuest() will be called in each MMIO operation.
It is trying to cache the result of the probe in the efi data segment.
However, that doesn't work in SEC, because the data segment is read only
(so the write seems to succeed but a read will always return the
original value), leading to us calling TdIsEnabled() check for every
mmio we do, which is causing the slowdown because it's very expensive.

This patch is to call CcProbe instead of TdIsEnabled in IsTdxGuest.
Null instance of CcProbe always returns CCGuestTypeNonEncrypted. Its
OvmfPkg version returns the guest type in Ovmf work area.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
2022-04-19 01:26:08 +00:00

62 lines
1.4 KiB
INI

## @file
# Instance of I/O Library using compiler intrinsics.
#
# I/O Library that uses compiler intrinsics to perform IN and OUT instructions
# for IA-32 and x64.
#
# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BaseIoLibIntrinsicSev
MODULE_UNI_FILE = BaseIoLibIntrinsic.uni
FILE_GUID = 93742f95-6e71-4581-b600-8e1da443f95a
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = IoLib
#
# VALID_ARCHITECTURES = IA32 X64
#
[Sources]
IoLibMmioBuffer.c
BaseIoLibIntrinsicInternal.h
IoHighLevel.c
IoLibTdx.h
IoLibSev.h
[Sources.IA32]
IoLibGcc.c | GCC
IoLibMsc.c | MSFT
IoLib.c
IoLibInternalTdxNull.c
Ia32/IoFifoSev.nasm
[Sources.X64]
IoLibGcc.c | GCC
IoLibMsc.c | MSFT
IoLib.c
IoLibInternalTdx.c
IoLibFifo.c
X64/IoFifoSev.nasm
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
DebugLib
BaseLib
RegisterFilterLib
CcProbeLib
[LibraryClasses.X64]
TdxLib