From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web08.15823.1650501976118252296 for ; Wed, 20 Apr 2022 17:46:16 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=jH0fEfVL; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650501976; x=1682037976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M9r/PDFUw2FXpNK60/RfriFHqoPxBX14d6AirhHvDM0=; b=jH0fEfVLBuFMaTUYRuDl+q9C7+6RoBKidIusYnNhiJbsLBeYKcyXc5Sm fU8aFGfWb6RNfnY9erxIlMr+7c8Tk9Ma8M+88GYJ8GoDXK/EozVmg6anE tYLbbdlDxq8nlip6HBDLxR6KJmfeVDhra5cwkDNkAnrhrdH+E+4ztMGzP xwr5CskyWfPZvsrqStEtSyUwBmewjY2MRHyYUiiKCGLc/tyYzbNirZg/A xdIII3UdEMCknDVZm1yWkunNpkSm2BXMmzLwxZXIEP1Ec2Y8lY7Q9/7Jm ibjW3ZSW7XKvjL9pAHkrv0mKWp6y2Brz1Fjhgp7LRGO2sojAYLMrdXzIt Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10323"; a="246083480" X-IronPort-AV: E=Sophos;i="5.90,277,1643702400"; d="scan'208";a="246083480" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2022 17:46:15 -0700 X-IronPort-AV: E=Sophos;i="5.90,277,1643702400"; d="scan'208";a="576901308" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.28.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2022 17:46:13 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [PATCH V3 1/1] OvmfPkg/OvmfPkgX64: Adjust load sequence of TdxDxe and AmdSevDxe driver Date: Thu, 21 Apr 2022 08:45:29 +0800 Message-Id: X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3904 TdxDxe driver is introduced for Intel TDX feature. Unfortunately, this driver also breaks boot process in SEV-ES guest. The root cause is in the PciLib which is imported by TdxDxe driver. In a SEV-ES guest the AmdSevDxe driver performs a MemEncryptSevClearMmioPageEncMask() call against the PcdPciExpressBaseAddress range to mark it shared/unencrypted. However, the TdxDxe driver is loaded before the AmdSevDxe driver, and the PciLib in TdxDxe is DxePciLibI440FxQ35 which will access the PcdPciExpressBaseAddress range. Since the range has not been marked shared/unencrypted, the #VC handler terminates the guest for trying to do MMIO to an encrypted region. Adjusting the load sequence of TdxDxe and AmdSevDxe can fix the issue. Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky SEV-Tested-by: Tom Lendacky TDX-Tested-by: Min Xu Reviewed-by: Jiewen Yao Signed-off-by: Min Xu --- OvmfPkg/OvmfPkgX64.fdf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index 71df28705ea8..6e72cdf3453e 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -214,8 +214,13 @@ READ_LOCK_STATUS = TRUE APRIORI DXE { INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf - INF OvmfPkg/TdxDxe/TdxDxe.inf + # AmdSevDxe must be loaded before TdxDxe. Because in SEV guest AmdSevDxe + # driver performs a MemEncryptSevClearMmioPageEncMask() call against the + # PcdPciExpressBaseAddress range to mark it shared/unencrypted. + # Otherwise #VC handler terminates the guest for trying to do MMIO to an + # encrypted region (Since the range has not been marked shared/unencrypted). INF OvmfPkg/AmdSevDxe/AmdSevDxe.inf + INF OvmfPkg/TdxDxe/TdxDxe.inf !if $(SMM_REQUIRE) == FALSE INF OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf !endif -- 2.29.2.windows.2