From: "Chiu, Chasel" <chasel.chiu@intel.com>
To: devel@edk2.groups.io
Cc: Chasel Chiu <chasel.chiu@intel.com>,
Nate DeSimone <nathaniel.l.desimone@intel.com>,
Star Zeng <star.zeng@intel.com>, Ray Ni <ray.ni@intel.com>
Subject: [PATCH v2] IntelFsp2Pkg: LoadMicrocodeDefault() causing unnecessary delay.
Date: Wed, 29 Mar 2023 08:43:52 -0700 [thread overview]
Message-ID: <20230329154352.1092-1-chasel.chiu@intel.com> (raw)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4391
FSP should support the scenario that CPU microcode already loaded
before calling LoadMicrocodeDefault(), in this case it should return
directly without spending more time.
Also the LoadMicrocodeDefault() should only attempt to load one version
of the microcode for current CPU and return.
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm | 18 ++++++++++++++----
IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm | 16 ++++++++++++----
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
index 2cff8b3643..b902d017ee 100644
--- a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
@@ -245,6 +245,19 @@ ASM_PFX(LoadMicrocodeDefault):
cmp esp, 0
jz ParamError
+ ;
+ ; If microcode already loaded before this function, exit this function with SUCCESS.
+ ;
+ mov eax, 1
+ cpuid
+ mov ecx, MSR_IA32_BIOS_SIGN_ID
+ rdmsr ; Get current microcode signature
+ xor eax, eax
+ test edx, edx
+ jnz Exit2
+
+
+
; skip loading Microcode if the MicrocodeCodeSize is zero
; and report error if size is less than 2k
; first check UPD header revision
@@ -450,7 +463,7 @@ LoadCheck:
; Verify this microcode update is not already loaded
cmp dword [esi + MicrocodeHdr.MicrocodeHdrRevision], edx
- je Continue
+ je Done ; if already one version microcode loaded, go to done
LoadMicrocode:
; EAX contains the linear address of the start of the Update Data
@@ -465,9 +478,6 @@ LoadMicrocode:
mov eax, 1
cpuid
-Continue:
- jmp NextMicrocode
-
Done:
mov eax, 1
cpuid
diff --git a/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm b/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm
index b32fa32a89..2a23c33c9b 100644
--- a/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm
+++ b/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm
@@ -141,6 +141,17 @@ ASM_PFX(LoadMicrocodeDefault):
jz ParamError
mov rsp, rcx
+ ;
+ ; If microcode already loaded before this function, exit this function with SUCCESS.
+ ;
+ mov eax, 1
+ cpuid
+ mov ecx, MSR_IA32_BIOS_SIGN_ID
+ rdmsr ; Get current microcode signature
+ xor rax, rax
+ test edx, edx
+ jnz Exit2
+
; skip loading Microcode if the MicrocodeCodeSize is zero
; and report error if size is less than 2k
; first check UPD header revision
@@ -291,7 +302,7 @@ LoadCheck:
; Verify this microcode update is not already loaded
cmp dword [esi + MicrocodeHdr.MicrocodeHdrRevision], edx
- je Continue
+ je Done ; if already one version microcode loaded, go to done
LoadMicrocode:
; EAX contains the linear address of the start of the Update Data
@@ -306,9 +317,6 @@ LoadMicrocode:
mov eax, 1
cpuid
-Continue:
- jmp NextMicrocode
-
Done:
mov eax, 1
cpuid
--
2.35.0.windows.1
next reply other threads:[~2023-03-29 15:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-29 15:43 Chiu, Chasel [this message]
2023-03-30 3:21 ` [edk2-devel] [PATCH v2] IntelFsp2Pkg: LoadMicrocodeDefault() causing unnecessary delay Kuo, Ted
2023-03-30 5:30 ` Ni, Ray
2023-03-30 15:29 ` Chiu, Chasel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230329154352.1092-1-chasel.chiu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox