From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 59669D8112E for ; Wed, 22 Nov 2023 17:25:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KOKK2pAkVukONkiPxkZOHcQaRM4AxT0QGRRBrKZ0vF0=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1700673898; v=1; b=xHq2eCI0MGwC0ZmXQIw0mOpGCcWlLouXLUNzhJEjj9O53RQ3OvWGyaYuBAwPU3W+zGGEkdhO cXHJvqSr8xE+v8k0OAp2zKrUbC+Ms2ilk56wvSwGFv7YX6wqqGJh+n7p2Dj7B5zKdHcNlgf9WKZ D1USQt951xv62I9NXkPGTDog= X-Received: by 127.0.0.2 with SMTP id lptDYY7687511xBVvx1gyzB8; Wed, 22 Nov 2023 09:24:58 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.25582.1700673898108833805 for ; Wed, 22 Nov 2023 09:24:58 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-1Xh947PcNvOcFaDyKCZWag-1; Wed, 22 Nov 2023 12:24:50 -0500 X-MC-Unique: 1Xh947PcNvOcFaDyKCZWag-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3425E3812581; Wed, 22 Nov 2023 17:24:50 +0000 (UTC) X-Received: from [10.39.193.187] (unknown [10.39.193.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1ED41C060AE; Wed, 22 Nov 2023 17:24:48 +0000 (UTC) Message-ID: Date: Wed, 22 Nov 2023 18:24:47 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [Patch V2 3/3] UefiCpuPkg/MpInitLib: Eliminate redundant microcode loading in DXE. To: devel@edk2.groups.io, yuanhao.xie@intel.com Cc: Ray Ni , Eric Dong , Rahul Kumar , Tom Lendacky References: <20231121073956.2741-1-yuanhao.xie@intel.com> <20231121073956.2741-4-yuanhao.xie@intel.com> From: "Laszlo Ersek" In-Reply-To: <20231121073956.2741-4-yuanhao.xie@intel.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 0V8GQ7sfGXrGtsM1OFejch28x7686176AA= 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=20140610 header.b=xHq2eCI0; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) On 11/21/23 08:39, Yuanhao Xie wrote: > The DXE stage's Microcode loading process has been elimincated by: >=20 > 1. Microcode HOB consumption in MP initialization within the DXE phase. > 2. Restricting MicrocodeDetect to the PEI phase instead of DXE for BSP. > 3. BSP now WakeUpAp only for synchronizing MTRR settings, with > Microcode loading no longer a part of this process. >=20 > Cc: Ray Ni > Cc: Eric Dong > Cc: Rahul Kumar > Cc: Tom Lendacky > Cc: Laszlo Ersek > Signed-off-by: Yuanhao Xie > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 54 ++++++++++++++++++++++++++++++= +++++------------------- > 1 file changed, 35 insertions(+), 19 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/Mp= InitLib/MpLib.c > index bb5d4188f0..0cf3520f9e 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -434,7 +434,27 @@ ApFuncEnableX2Apic ( > } > =20 > /** > - Do sync on APs. > + Sync BSP's MTRR table to AP during waking up APs. > + @param[in, out] Buffer Pointer to private data buffer. > +**/ > +VOID > +EFIAPI > +ApMtrrSync ( > + IN OUT VOID *Buffer > + ) > +{ > + CPU_MP_DATA *CpuMpData; > + > + CpuMpData =3D (CPU_MP_DATA *)Buffer; > + > + // > + // Sync BSP's MTRR table to AP > + // > + MtrrSetAllMtrrs (&CpuMpData->MtrrTable); > +} > + > +/** > + Do sync on APs, includes loading microcode, and sync MTRRs. > =20 > @param[in, out] Buffer Pointer to private data buffer. > **/ > @@ -2224,26 +2244,10 @@ MpInitLibInitialize ( > } > } > =20 > - if (!GetMicrocodePatchInfoFromHob ( > - &CpuMpData->MicrocodePatchAddress, > - &CpuMpData->MicrocodePatchRegionSize > - )) > - { > - // > - // The microcode patch information cache HOB does not exist, which m= eans > - // the microcode patches data has not been loaded into memory yet > - // > - ShadowMicrocodeUpdatePatch (CpuMpData); > - } > - (1) This patch seems great, functionally speaking, but I *think* the above part (the elimination of the GetMicrocodePatchInfoFromHob() call, and the dependent ShadowMicrocodeUpdatePatch() call) should be split to a separate patch -- perhaps before, perhaps after, the rest of this patch, in the series. That's because the GetMicrocodePatchInfoFromHob() and ShadowMicrocodeUpdatePatch() calls are removed *altogether* from the code in this patch; they are not *moved* to any of the branches below. Which makes me think that *even without* restricting the MicrocodeDetect() call below (and calling ApMtrrSync() on the other branch below), the HOB stuff is just generally superfluous. - If that's the case, then please split this part out to a new patch in v3. (Please also don't forget to update the commit message here!) With that, you can add Reviewed-by: Laszlo Ersek to what *remains* from this patch. (I.e. everything except the GetMicrocodePatchInfoFromHob/ShadowMicrocodeUpdatePatch removal.) - If I'm wrong, and the GetMicrocodePatchInfoFromHob / ShadowMicrocodeUpdatePatch removal is an integral part of this patch (if it cannot be separated, semantically), then I don't understand something about this patch. But in that case I'd like you to explain the reason for removing these function calls right in this patch. I might reply with an R-b to that explanation. (Although I'd probably request that the explanation be included in the commit message, in v3.) Thanks! Laszlo > // > - // Wakeup APs to do some AP initialize sync (Microcode & MTRR) > + // Wakeup APs to do some AP initialize sync. > // > if (CpuMpData->CpuCount > 1) { > - // > - // Detect and apply Microcode on BSP > - // > - MicrocodeDetect (CpuMpData, CpuMpData->BspNumber); > // > // Store BSP's MTRR setting > // > @@ -2256,8 +2260,20 @@ MpInitLibInitialize ( > // in DXE. > // > CpuMpData->InitFlag =3D ApInitReconfig; > - WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE); > + // > + // Wakeup APs to sync MTRR settings. > + // For the case the PEI and DXE are in different bit mode. > + // It is necessary to do the MTRRs syncing. > + // > + WakeUpAP (CpuMpData, TRUE, 0, ApMtrrSync, CpuMpData, TRUE); > } else { > + // > + // Detect and apply Microcode on BSP > + // > + MicrocodeDetect (CpuMpData, CpuMpData->BspNumber); > + // > + // Wakeup APs to do some AP initialize sync load microcode and Syn= c MTRRs > + // > WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData, TRUE); > } > =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 (#111621): https://edk2.groups.io/g/devel/message/111621 Mute This Topic: https://groups.io/mt/102724548/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-