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 7F8B0D808CC for ; Wed, 22 Nov 2023 17:11:13 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=LEIwqlXcKfH+mh1kW+hcLp2qvBhLOzIvdSPK9G4fy8w=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: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=1700673071; v=1; b=WMexnMszy/yN9aCjZ5eWQol1d2R+4Xj2iia7Tfo/mAyewrjPzXHJ7p7nqNJFBbZvtNdKuu01 uAjKwCb+kwQd51F1uVrkdW0fOfFDqsA+D5/G4Q3tKMGjZeY1sDIe43Uwnme7SKFMQl8G4fhLs9X tCYmk0oyxLn6sAUYI05HT/F0= X-Received: by 127.0.0.2 with SMTP id 2CmoYY7687511xCixY8tcZoo; Wed, 22 Nov 2023 09:11:11 -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.web10.25300.1700673071156140282 for ; Wed, 22 Nov 2023 09:11:11 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-48-uM4BOmfQNTGEHel-Ze3ZZg-1; Wed, 22 Nov 2023 12:11:05 -0500 X-MC-Unique: uM4BOmfQNTGEHel-Ze3ZZg-1 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 83F3C8007B3; Wed, 22 Nov 2023 17:11:04 +0000 (UTC) X-Received: from [10.39.193.187] (unknown [10.39.193.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B2322026D4C; Wed, 22 Nov 2023 17:11:03 +0000 (UTC) Message-ID: <04cf1f85-69b7-d9f5-7047-3644ca7307d0@redhat.com> Date: Wed, 22 Nov 2023 18:11:02 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [Patch V2 2/3] UefiCpuPkg/MpInitLib: Detect microcode and store MTRR when CpuCount > 1 From: "Laszlo Ersek" 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-3-yuanhao.xie@intel.com> <9f2bf026-e473-dcab-c5a0-085810ff34aa@redhat.com> In-Reply-To: <9f2bf026-e473-dcab-c5a0-085810ff34aa@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 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: yKDU9n1BZNZuswp92qauKBc5x7686176AA= 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=WMexnMsz; 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/22/23 18:06, Laszlo Ersek wrote: > On 11/22/23 18:03, Laszlo Ersek wrote: >> On 11/21/23 08:39, Yuanhao Xie wrote: >>> Detect and apply Microcode on BSP, store BSP's MTRR setting only when >>> CpuCount > 1. >>> >>> The purpose of this patch is to enhance the review process. >>> The separation in this patch is aimed at facilitating a more >>> straightforward review, with the ultimate goal of eliminating the >>> microcode loading functionality for the second time Mp initialization >>> >>> 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 | 18 +++++++++--------- >>> 1 file changed, 9 insertions(+), 9 deletions(-) >>> >>> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/= MpInitLib/MpLib.c >>> index e8ffb99874..bb5d4188f0 100644 >>> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c >>> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c >>> @@ -2236,19 +2236,19 @@ MpInitLibInitialize ( >>> ShadowMicrocodeUpdatePatch (CpuMpData); >>> } >>> =20 >>> - // >>> - // Detect and apply Microcode on BSP >>> - // >>> - MicrocodeDetect (CpuMpData, CpuMpData->BspNumber); >>> - // >>> - // Store BSP's MTRR setting >>> - // >>> - MtrrGetAllMtrrs (&CpuMpData->MtrrTable); >>> - >>> // >>> // Wakeup APs to do some AP initialize sync (Microcode & MTRR) >>> // >>> if (CpuMpData->CpuCount > 1) { >>> + // >>> + // Detect and apply Microcode on BSP >>> + // >>> + MicrocodeDetect (CpuMpData, CpuMpData->BspNumber); >>> + // >>> + // Store BSP's MTRR setting >>> + // >>> + MtrrGetAllMtrrs (&CpuMpData->MtrrTable); >>> + >>> if (MpHandOff !=3D NULL) { >>> // >>> // Only needs to use this flag for DXE phase to update the wake = up >> >> I can't very well gauge the effect that this patch has on >> MicrocodeDetect(). MicrocodeDetect() is a function that is not obvious >> to me. However, microcode detection is disabled on OVMF, both via HOB >> and via PCD (zero region size). So, I have nothing against *restricting* >> microcode detection "further". >> >> Regarding MtrrTable: it seems that this field is only consumed in >> ApMtrrSync() and ApInitializeSync(). I suppose those functions never run >> when CpuMpData->CpuCount is 1. [*] > Thus restricting MtrrGetAllMtrrs() should >> be fine as well. >=20 > sorry, small mistake: when writing this, I was already looking at the > final state of the tree. Right after this patch is applied, only > ApInitializeSync() exists! >=20 > But that fact only makes my argument stronger -- so my R-b for this > patch stands. My assumption at [*] is correct, in fact; ApInitializeSync() is only called from the context updated in patch#1! And after patch#3, which introduces ApMtrrSync(), the same applies to ApMtrrSync() too. So all is fine. Thanks Laszlo >=20 >> >> Reviewed-by: Laszlo Ersek >> >=20 > Thanks > Laszlo -=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 (#111620): https://edk2.groups.io/g/devel/message/111620 Mute This Topic: https://groups.io/mt/102724547/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-