From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.5722.1651887402613426917 for ; Fri, 06 May 2022 18:36:53 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=LtBXefNa; spf=pass (domain: intel.com, ip: 192.55.52.120, 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=1651887413; x=1683423413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qLzDKQMy+n0MmYTZ+xuxzEOvVCWritzXBpWND0S3cZc=; b=LtBXefNaLyZhq47imAfPYGZiGwaH1x03210QGjRz+ZzpY3rxVQz4IAbC /AF3ykbLtgIknJZ0Oq3AQyilWiTGA1MQg+5eFoWBtudl24f6+KK/piOXr MsXn/1YwDHxhCL6uX2OCailli//wfiPMz9CPIt/0GnuNGL3FGA68CnEwF 65DdEly9TNzjK54ONxl6qnjhq3PQDjFrh0ZoDSrS7WGrq25KXNWVGhK17 eO4gkGijA+beCagiPzfdSnJDXHJDtP0MeL8I/pHCMAOomK0Qlc9GD4dWQ 5sO6XmIq+EPibkz9XwhCwa4gIRVi5ff596jFkyGVDqhddWk5BIfl9FZHe Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10339"; a="267463951" X-IronPort-AV: E=Sophos;i="5.91,205,1647327600"; d="scan'208";a="267463951" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 18:36:52 -0700 X-IronPort-AV: E=Sophos;i="5.91,205,1647327600"; d="scan'208";a="538143056" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.172.52]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 18:36:50 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Eric Dong , Ray Ni , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann Subject: [PATCH V2 4/6] OvmfPkg/Sec: Install MpInitLibDepLib PPIs in SecMain.c Date: Sat, 7 May 2022 09:36:21 +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 From: Min M Xu BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3918 Td guest should use MpInitLibUp, other guest use the MpInitLib. So in SecMain.c different PPI is installed according to the working guest type. Cc: Eric Dong Cc: Ray Ni Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/Sec/SecMain.c | 34 ++++++++++++++++++++++++++++++++-- OvmfPkg/Sec/SecMain.inf | 2 ++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 89371361cd05..1167d22a68cc 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include "AmdSev.h" @@ -61,12 +62,30 @@ EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mTemporaryRamSupportPpi = { TemporaryRamMigration }; -EFI_PEI_PPI_DESCRIPTOR mPrivateDispatchTable[] = { +EFI_PEI_PPI_DESCRIPTOR mPrivateDispatchTableMp[] = { + { + (EFI_PEI_PPI_DESCRIPTOR_PPI), + &gEfiTemporaryRamSupportPpiGuid, + &mTemporaryRamSupportPpi + }, { (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiMpInitLibMpDepPpiGuid, + NULL + }, +}; + +EFI_PEI_PPI_DESCRIPTOR mPrivateDispatchTableUp[] = { + { + (EFI_PEI_PPI_DESCRIPTOR_PPI), &gEfiTemporaryRamSupportPpiGuid, &mTemporaryRamSupportPpi }, + { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiMpInitLibUpDepPpiGuid, + NULL + }, }; // @@ -936,6 +955,7 @@ SecStartupPhase2 ( EFI_SEC_PEI_HAND_OFF *SecCoreData; EFI_FIRMWARE_VOLUME_HEADER *BootFv; EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint; + EFI_PEI_PPI_DESCRIPTOR *EfiPeiPpiDescriptor; SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Context; @@ -948,10 +968,20 @@ SecStartupPhase2 ( SecCoreData->BootFirmwareVolumeBase = BootFv; SecCoreData->BootFirmwareVolumeSize = (UINTN)BootFv->FvLength; + // + // Td guest is required to use the MpInitLibUp (unique-processor version). + // Other guests use the MpInitLib (multi-processor version). + // + if (CcProbe () == CcGuestTypeIntelTdx) { + EfiPeiPpiDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)&mPrivateDispatchTableUp; + } else { + EfiPeiPpiDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)&mPrivateDispatchTableMp; + } + // // Transfer the control to the PEI core // - (*PeiCoreEntryPoint)(SecCoreData, (EFI_PEI_PPI_DESCRIPTOR *)&mPrivateDispatchTable); + (*PeiCoreEntryPoint)(SecCoreData, EfiPeiPpiDescriptor); // // If we get here then the PEI Core returned, which is not recoverable. diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf index 1557b5f4a84e..561a840f29c5 100644 --- a/OvmfPkg/Sec/SecMain.inf +++ b/OvmfPkg/Sec/SecMain.inf @@ -59,6 +59,8 @@ [Ppis] gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED + gEfiPeiMpInitLibMpDepPpiGuid + gEfiPeiMpInitLibUpDepPpiGuid [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase -- 2.29.2.windows.2