audk/MdePkg
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
..
Include MdePkg: Add CcProbeLibNull 2022-04-19 01:26:08 +00:00
Library MdePkg: Probe Cc guest in BaseIoLibIntrinsicSev 2022-04-19 01:26:08 +00:00
Test MdePkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
MdeLibs.dsc.inc MdePkg: Add MdeLibs.dsc.inc file to MdePkg 2021-03-30 12:48:30 +00:00
MdePkg.ci.yaml MdePkg: Update YAML to ignore specific ECC files/errors 2021-11-30 14:19:07 +00:00
MdePkg.dec MdePkg: Add CcProbeLibNull 2022-04-19 01:26:08 +00:00
MdePkg.dsc MdePkg: Add CcProbeLibNull 2022-04-19 01:26:08 +00:00
MdePkg.uni MdePkg: Add PcdSpeculationBarrierType 2019-04-30 16:39:09 -07:00
MdePkgExtra.uni MdePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:13 -07:00