From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id EFA80AC127C for ; Thu, 1 Aug 2024 14:55:46 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=0u8ZOe/IXNLSJQfeas1+IlbDIX7c2/ck0KBeGT3eVxg=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:User-Agent:To:Cc:References:From:Subject:In-Reply-To:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1722524146; v=1; b=pB7C1O0vM1QcKhxnGQEqBlmPhc3KV8FEg1zFgmEx9L6548QXCsnCMZna0XgVMhC++63CtaJw z0TDOHYDC5pJ5LJQUkij7IVViRK04GXMKAksTxKFl5M9r+BbDy+zDAMn2LFKpguVujoAxDKNfsp 0zsqICfiu5KFtsJQBz+BJXXR4D5VIhtCV1daCoytqAa/l0miXJoH1YuHxq87nZfLSErytgZWu0D f8MBjXtf9J+sj5zbbvNhUR80UU0/uMD+sTCx2EguPq+sTzgQDYleG0VnHswZKtdJPES1KG/Xbd8 09otCdpER7b+osMFVUu5rioqPG0Si6mb0hbLNcMIBRa9Q== X-Received: by 127.0.0.2 with SMTP id Dl93YY7687511xyS8vKMJnjt; Thu, 01 Aug 2024 07:55:45 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.41]) by mx.groups.io with SMTP id smtpd.web11.70311.1722524144335874239 for ; Thu, 01 Aug 2024 07:55:44 -0700 X-Received: from DM4PR12MB5070.namprd12.prod.outlook.com (2603:10b6:5:389::22) by SJ1PR12MB6172.namprd12.prod.outlook.com (2603:10b6:a03:459::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.28; Thu, 1 Aug 2024 14:55:41 +0000 X-Received: from DM4PR12MB5070.namprd12.prod.outlook.com ([fe80::20a9:919e:fd6b:5a6e]) by DM4PR12MB5070.namprd12.prod.outlook.com ([fe80::20a9:919e:fd6b:5a6e%5]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024 14:55:40 +0000 Message-ID: <2b3fdab6-7345-2edf-b588-479ce3b5b115@amd.com> Date: Thu, 1 Aug 2024 09:55:39 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 To: devel@edk2.groups.io, east.moutain.yang@gmail.com Cc: yuanhao.xie@intel.com, brijesh.singh@amd.com, min.m.xu@intel.com, michael.kubacki@microsoft.com References: <20240731102234.63342-1-east.moutain.yang@gmail.com> From: "Lendacky, Thomas via groups.io" Subject: Re: [edk2-devel] [PATCH v1] UefiCpuPkg/Library/MpInitLib: fix SEV-ES AP bootinng failure In-Reply-To: <20240731102234.63342-1-east.moutain.yang@gmail.com> X-ClientProxiedBy: SN7PR04CA0112.namprd04.prod.outlook.com (2603:10b6:806:122::27) To DM4PR12MB5070.namprd12.prod.outlook.com (2603:10b6:5:389::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR12MB5070:EE_|SJ1PR12MB6172:EE_ X-MS-Office365-Filtering-Correlation-Id: dc5ab225-d728-4ce2-eaf4-08dcb23a02e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?utf-8?B?SUx2OXJqTEU5eW5xTjdUVklGSHUwdTNkeWxTU3p3TmlkSEVpYzhTY2UyVFhJ?= =?utf-8?B?V0ExajA5VWgvOEpTTVVKWk1aTmJPaFRWMFhsU21US09sVTZWeEVJV0NSTjJs?= =?utf-8?B?SUFKMnd5bytuRkJ6TzF1Y3lXdE8zK1VlTGZZOGhHaVVhd3lm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MTQ4bmpVanFHaXBSd0pi?= =?utf-8?B?bHB6ZXZKdzJMOGxuR0F0QVRMVE9tRTU3OEZoTlZYelB6QkxjUG5uTTNvWVJ5?= =?utf-8?B?MVIyTU9ubkI3T2FJaEQ0UmVRRHMyeEc2R01hcU5Menh3MEZVRHNrNm10alUr?= =?utf-8?B?ZDQvc3JLSU9jc1ZtcVZTWDFXVjFQT2U0a3lMb2tWTGZMZlV5MDc4bEF2VDN2?= =?utf-8?B?TEQrUGtWY1QvUXdYUFMxclU1UDFCNXE0QU1MN1d2Qi9SN09TYkFwdmhaaE53?= =?utf-8?Q?FHpS3RJOrKidQYY4AxKwB/OPf?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc5ab225-d728-4ce2-eaf4-08dcb23a02e5 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5070.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 14:55:40.7862 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vHGSrDZsONCaWJBKXFGDURVxdxAC19gwJJJDnFrSS4IWBvNKINcZkhLkJcBlNM2ORTIpW/e+9KZlqEWbY2dhkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6172 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Thu, 01 Aug 2024 07:55:44 -0700 Resent-From: thomas.lendacky@amd.com Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ffc5yas4VHg5xhoUGeO1tdGXx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=pB7C1O0v; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io On 7/31/24 05:22, Wencheng Yang via groups.io wrote: > According to SEV-ES Guest-Hypervisor Communication Block Standardization > section 4.3 SMP Booting, the subsequent reset requires the AP enters > Reset Hold state either by AP Reset Hold NAE event or > AP Reset Hold Request MSR Protocol. >=20 > If the AP is not in AP Reset Hold state, it may miss subsequent > INIT-SIPI, as the INIT-SIPI process depends on GHCB page in kernel, > which is only mapped in VMGEXIT interception. >=20 > To ensure all APs are in AP Reset Hold state, we add a var in > AP specific data structure, set the var before the AP going to > AP Reset Hold state. Subsequent INIT-SIPI should check the var of each > AP before issuing INIT-SIPI signal. Were you actually seeing an issue here? The moving of InterlockedDecrement() was for the same reason as this patch. I assume this was discovered when the CpuMpData->InitFlag wasn't set to ApInitConfig, which skips the InterlockedDecrement()? What if the InterlockedIncrement() was delayed like InterlockedDecrement(), would that also fix the issue? If so, that would remove the changes to, and related to, the CPU_AP_DATA struct. If not, then using this method can remove the changes around the InterlockedDecrement() in the ApWakeupFunction() and SevEsPlaceApHlt() and just rely on the EnteredHlt flag/ I just saw this and haven't had a chance to test it, yet. I'm very busy at the moment but will try to get to it very soon. >=20 > Cc: Yuanhao Xie > Cc: Brijesh Singh > Cc: Min Xu > Cc: Michael Kubacki >=20 > Signed-off-by: Wencheng Yang > --- > UefiCpuPkg/Library/MpInitLib/AmdSev.c | 11 ++++++- > UefiCpuPkg/Library/MpInitLib/MpHandOff.h | 1 + > UefiCpuPkg/Library/MpInitLib/MpLib.c | 39 ++++++++++++++++++++++-- > UefiCpuPkg/Library/MpInitLib/MpLib.h | 4 ++- > UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 2 ++ > 5 files changed, 52 insertions(+), 5 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/AmdSev.c b/UefiCpuPkg/Library/M= pInitLib/AmdSev.c > index d34f9513e0..e5d5ecb181 100644 > --- a/UefiCpuPkg/Library/MpInitLib/AmdSev.c > +++ b/UefiCpuPkg/Library/MpInitLib/AmdSev.c > @@ -194,16 +194,19 @@ SetSevEsJumpTable ( > **/ > VOID > SevEsPlaceApHlt ( > - CPU_MP_DATA *CpuMpData > + CPU_MP_DATA *CpuMpData, > + UINT32 ProcessorNumber The alignment is off here (and in other places below). You'll need to run this through uncrustify so that it doesn't fail CI. > ) > { > MSR_SEV_ES_GHCB_REGISTER Msr; > GHCB *Ghcb; > UINT64 Status; > BOOLEAN DoDecrement; > + BOOLEAN EnterHltLoop; Maybe a better name is EnteredHlt. > BOOLEAN InterruptState; > =20 > DoDecrement =3D (BOOLEAN)(CpuMpData->InitFlag =3D=3D ApInitConfig); > + EnterHltLoop =3D FALSE; > =20 > while (TRUE) { > Msr.GhcbPhysicalAddress =3D AsmReadMsr64 (MSR_SEV_ES_GHCB); > @@ -221,7 +224,13 @@ SevEsPlaceApHlt ( > InterlockedDecrement ((UINT32 *)&CpuMpData->MpCpuExchangeInfo->Num= ApsExecuting); > } > =20 > + if (!EnterHltLoop) { > + EnterHltLoop =3D TRUE; > + CpuMpData->CpuData[ProcessorNumber].SevEsApEnterHltLoopAfterWakeup= =3D 1; > + } > + > Status =3D CcExitVmgExit (Ghcb, SVM_EXIT_AP_RESET_HOLD, 0, 0); > + Remove the added blank line. > if ((Status =3D=3D 0) && (Ghcb->SaveArea.SwExitInfo2 !=3D 0)) { > CcExitVmgDone (Ghcb, InterruptState); > break; > diff --git a/UefiCpuPkg/Library/MpInitLib/MpHandOff.h b/UefiCpuPkg/Librar= y/MpInitLib/MpHandOff.h > index ae93b7e3d7..50e290f5b3 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpHandOff.h > +++ b/UefiCpuPkg/Library/MpInitLib/MpHandOff.h > @@ -37,6 +37,7 @@ extern EFI_GUID mMpHandOffConfigGuid; > typedef struct { > UINT32 ApicId; > UINT32 Health; > + UINT32 SevEsApEnterHltLoopAfterWakeup; SevEsEnteredHlt should be enough, right? > UINT64 StartupSignalAddress; > UINT64 StartupProcedureAddress; > } PROCESSOR_HAND_OFF; > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/Mp= InitLib/MpLib.c > index 1951922912..59f0d87f9d 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -660,13 +660,14 @@ InitializeApData ( > **/ > VOID > PlaceAPInHltLoop ( > - IN CPU_MP_DATA *CpuMpData > + IN CPU_MP_DATA *CpuMpData, > + IN UINTN ProcessorNumber > ) > { > while (TRUE) { > DisableInterrupts (); > if (CpuMpData->UseSevEsAPMethod) { > - SevEsPlaceApHlt (CpuMpData); > + SevEsPlaceApHlt (CpuMpData, ProcessorNumber); > } else { > CpuSleep (); > } > @@ -762,6 +763,9 @@ ApWakeupFunction ( > while (TRUE) { > if (CpuMpData->InitFlag =3D=3D ApInitConfig) { > ProcessorNumber =3D ApIndex; > + if (CpuMpData->UseSevEsAPMethod) { > + CpuMpData->CpuData[ProcessorNumber].SevEsApEnterHltLoopAfterWake= up =3D 0; > + } > // > // This is first time AP wakeup, get BIST information from AP stac= k > // > @@ -782,6 +786,9 @@ ApWakeupFunction ( > // Execute AP function if AP is ready > // > GetProcessorNumber (CpuMpData, &ProcessorNumber); > + if (CpuMpData->UseSevEsAPMethod) { > + CpuMpData->CpuData[ProcessorNumber].SevEsApEnterHltLoopAfterWake= up =3D 0; > + } > // > // Clear AP start-up signal when AP waken up > // > @@ -903,7 +910,7 @@ ApWakeupFunction ( > // Place AP is specified loop mode > // > if (CpuMpData->ApLoopMode =3D=3D ApInHltLoop) { > - PlaceAPInHltLoop (CpuMpData); > + PlaceAPInHltLoop (CpuMpData, ProcessorNumber); > // > // Never run here > // > @@ -993,6 +1000,20 @@ GetApResetVectorSize ( > *SizeAbove1Mb =3D AddressMap->RendezvousFunnelSize - AddressMap->Mod= eTransitionOffset; > } > } > +/** > + Wait for SEV-ES AP enter in HLT-LOOP.^M > + > + @param[in] SevEsApInHltLoop Pointer to SevEsApInHltLoop^M > +**/ > +VOID > +WaitSevEsApEnterHltLoopAfterWakeup ( > + IN volatile UINT32 *SevEsApEnterHltLoop > + ) > +{ > + while (*(UINT32*)SevEsApEnterHltLoop =3D=3D 0) { > + CpuPause (); > + } > +} > =20 > /** > This function will fill the exchange info structure. > @@ -1324,6 +1345,17 @@ WakeUpAP ( > // > SendStartupIpiAllExcludingSelf ((UINT32)ExchangeInfo->BufferSt= art); > } else { > + // > + // Subsequent INIT-SIPI-SIPI > + // > + if (CpuMpData->SevEsIsEnabled && (CpuMpData->InitFlag !=3D ApI= nitConfig)) { > + for (Index =3D 0; Index < CpuMpData->CpuCount; Index++) { > + CpuData =3D &CpuMpData->CpuData[Index]; > + if (Index !=3D CpuMpData->BspNumber) { > + WaitSevEsApEnterHltLoopAfterWakeup(&CpuData->SevEsApEnte= rHltLoopAfterWakeup); > + } > + } > + } > SendInitSipiSipiAllExcludingSelf ((UINT32)ExchangeInfo->Buffer= Start); > } > } > @@ -2270,6 +2302,7 @@ MpInitLibInitialize ( > InitializeSpinLock (&CpuMpData->CpuData[Index].ApLock); > CpuMpData->CpuData[Index].CpuHealthy =3D (MpHandOff->Info[HobInd= ex].Health =3D=3D 0) ? TRUE : FALSE; > CpuMpData->CpuData[Index].ApFunction =3D 0; > + CpuMpData->CpuData[Index].SevEsApEnterHltLoopAfterWakeup =3D MpH= andOff->Info[HobIndex].SevEsApEnterHltLoopAfterWakeup; > CpuInfoInHob[Index].InitialApicId =3D MpHandOff->Info[HobInde= x].ApicId; > CpuInfoInHob[Index].ApTopOfStack =3D CpuMpData->Buffer + (In= dex + 1) * CpuMpData->CpuApStackSize; > CpuInfoInHob[Index].ApicId =3D MpHandOff->Info[HobInde= x].ApicId; > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/Mp= InitLib/MpLib.h > index 88b31fecca..c33a7bf658 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h > @@ -146,6 +146,7 @@ typedef enum { > typedef struct { > SPIN_LOCK ApLock; > volatile UINT32 *StartupApSignal; > + volatile UINT32 SevEsApEnterHltLoopAfterWakeup; Similar to above, SevEsEnteredHlt. Thanks, Tom > volatile UINTN ApFunction; > volatile UINTN ApFunctionArgument; > BOOLEAN CpuHealthy; > @@ -862,7 +863,8 @@ SetSevEsJumpTable ( > **/ > VOID > SevEsPlaceApHlt ( > - CPU_MP_DATA *CpuMpData > + CPU_MP_DATA *CpuMpData, > + UINT32 ProcessorNumber > ); > =20 > /** > diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library= /MpInitLib/PeiMpLib.c > index 16a858d542..b393ce00be 100644 > --- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c > @@ -164,6 +164,8 @@ SaveCpuMpData ( > if (CpuMpData->ApLoopMode !=3D ApInHltLoop) { > MpHandOff->Info[Index-HobBase].StartupSignalAddress =3D (UINT64= )(UINTN)CpuMpData->CpuData[Index].StartupApSignal; > MpHandOff->Info[Index-HobBase].StartupProcedureAddress =3D (UINT64= )(UINTN)&CpuMpData->CpuData[Index].ApFunction; > + } else { > + MpHandOff->Info[Index-HobBase].SevEsApEnterHltLoopAfterWakeup =3D = CpuMpData->CpuData[Index].SevEsApEnterHltLoopAfterWakeup; > } > } > =20 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120179): https://edk2.groups.io/g/devel/message/120179 Mute This Topic: https://groups.io/mt/107630732/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-