From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web11.25550.1650166254108272855 for ; Sat, 16 Apr 2022 20:30:55 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([101.224.116.119]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Sun, 17 Apr 2022 11:30:49 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 101.224.116.119 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Min Xu'" , Cc: "'Michael D Kinney'" , "'Zhiguang Liu'" , "'James Bottomley'" , "'Jiewen Yao'" , "'Gerd Hoffmann'" , "'Brijesh Singh'" , "'Erdem Aktas'" , "'Tom Lendacky'" References: In-Reply-To: Subject: =?UTF-8?B?5Zue5aSNOiBbUEFUQ0ggVjMgMC83XSBJbnRyb2R1Y2UgQ2NQcm9iZSBpbiBNZGVQa2c=?= Date: Sun, 17 Apr 2022 11:30:50 +0800 Message-ID: <000301d8520b$895497d0$9bfdc770$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQL84R9h5C2XRnq97OWJ+xyn1RGxhKqqVKNw Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Min: The change in MdePkg is good to me. Reviewed-by: Liming Gao Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Min Xu > =B7=A2=CB=CD=CA=B1=BC=E4: 2022=C4=EA4=D4=C217=C8=D5 11:01 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Min Xu ; Michael D Kinney > ; Liming Gao ; > Zhiguang Liu ; James Bottomley > ; Jiewen Yao ; Gerd Hoffmann > ; Brijesh Singh ; Erdem = Aktas > ; Tom Lendacky > =D6=F7=CC=E2: [PATCH V3 0/7] Introduce CcProbe in MdePkg >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3902 >=20 > Bad IO performance in SEC phase is observed after TDX features was > introduced. (after commit b6b2de884864 - "MdePkg: Support mmio for > Tdx guest in BaseIoLibIntrinsic"). >=20 > 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. >=20 > CcProbe is introduced in this patch-set. It is called in > BaseIoLibIntrinsicSev instead of IsTdxGuest. There are 2 versions of > the CcProbeLib. Null instance of CcProbe always returns > CCGuestTypeNonEncrypted. Its OvmfPkg version checks the Ovmf work area > and returns the CC guest type. >=20 > In this patch-set another issue is fixed with CcProbe as well. If the > working guest is SEV and in the beginning of SecMain.c TdIsEnabled() > was called. At this point, exception handling is not established and > a CPUID instruction will generate a #VC and cause the booting SEV = guest > to crash. Patch #7 is to fix this broken. >=20 > Code is at: https://github.com/mxu9/edk2/tree/cc_probe.v3 >=20 > v3 changes: > - Fix the broken issue in SEV guest at SecMain.c. Please refer to > Patch #7. >=20 > v2 changes: > - Rename TdProbe to CcProbe to make the lib work for Confidential > Computing guests. > - Rename the GUEST_TYPE to CC_GUEST_TYPE and move it from > WorkArea.h@OvmfPkg to ConfidentialComputingGuestAttr.h@MdePkg. > This is because CcProbeLib is designed to return the CC Guest > type and the lib is located at MdePkg. > - Rename the CC_GUEST_TYPE's fields name to Camel style. See the > commit message in patch #1. >=20 > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Cc: James Bottomley > Cc: Jiewen Yao > Cc: Gerd Hoffmann > Cc: Brijesh Singh > Cc: Erdem Aktas > Cc: Tom Lendacky > Signed-off-by: Min Xu >=20 > Min Xu (7): > MdePkg: Add CC_GUEST_TYPE in ConfidentialComputingGuestAttr.h > OvmfPkg: Replace GUEST_TYPE with CC_GUEST_TYPE > MdePkg: Add CcProbeLib > OvmfPkg: Add CcProbeLib > OvmfPkg: Add CcProbeLib in *.dsc > MdePkg: Probe Cc guest in BaseIoLibIntrinsicSev > OvmfPkg: Call CcProbe in SecMain.c instead of TsIsEnabled >=20 > .../Include/ConfidentialComputingGuestAttr.h | 11 ++++++- > MdePkg/Include/Library/CcProbeLib.h | 26 > ++++++++++++++++ > .../BaseIoLibIntrinsicSev.inf | 1 + > .../BaseIoLibIntrinsic/IoLibInternalTdx.c | 13 ++------ > .../Library/CcProbeLibNull/CcProbeLibNull.c | 26 ++++++++++++++++ > .../Library/CcProbeLibNull/CcProbeLibNull.inf | 21 +++++++++++++ > MdePkg/MdePkg.dec | 5 +++ > MdePkg/MdePkg.dsc | 1 + > OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + > OvmfPkg/Bhyve/BhyveX64.dsc | 1 + > OvmfPkg/CloudHv/CloudHvX64.dsc | 1 + > OvmfPkg/Include/WorkArea.h | 9 +----- > OvmfPkg/IntelTdx/IntelTdxX64.dsc | 1 + > OvmfPkg/IntelTdx/Sec/SecMain.c | 6 ++-- > OvmfPkg/IntelTdx/Sec/SecMain.inf | 1 + > .../PeiMemEncryptSevLibInternal.c | 2 +- > .../SecMemEncryptSevLibInternal.c | 2 +- > OvmfPkg/Library/CcProbeLib/CcProbeLib.c | 31 > +++++++++++++++++++ > OvmfPkg/Library/CcProbeLib/CcProbeLib.inf | 25 +++++++++++++++ > OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c | 2 +- > OvmfPkg/Microvm/MicrovmX64.dsc | 1 + > OvmfPkg/OvmfPkgIa32.dsc | 1 + > OvmfPkg/OvmfPkgIa32X64.dsc | 1 + > OvmfPkg/OvmfPkgX64.dsc | 1 + > OvmfPkg/OvmfXen.dsc | 1 + > OvmfPkg/Sec/AmdSev.c | 2 +- > OvmfPkg/Sec/SecMain.c | 5 +-- > OvmfPkg/Sec/SecMain.inf | 1 + > 28 files changed, 170 insertions(+), 29 deletions(-) > create mode 100644 MdePkg/Include/Library/CcProbeLib.h > create mode 100644 MdePkg/Library/CcProbeLibNull/CcProbeLibNull.c > create mode 100644 MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf > create mode 100644 OvmfPkg/Library/CcProbeLib/CcProbeLib.c > create mode 100644 OvmfPkg/Library/CcProbeLib/CcProbeLib.inf >=20 > -- > 2.29.2.windows.2