* [PATCH] IntelFsp2Pkg: LoadMicrocodeDefault() causing unnecessary delay.
@ 2023-03-28 18:12 Chiu, Chasel
0 siblings, 0 replies; only message in thread
From: Chiu, Chasel @ 2023-03-28 18:12 UTC (permalink / raw)
To: devel; +Cc: Chasel Chiu, Nate DeSimone, Star Zeng, Ray Ni
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 | 17 +++++++++++++++--
IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm | 15 +++++++++++++--
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
index 2cff8b3643..606bf0b08b 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
@@ -464,7 +477,7 @@ LoadMicrocode:
wrmsr
mov eax, 1
cpuid
-
+ jmp Done ; if already one version microcode loaded, go to done
Continue:
jmp NextMicrocode
diff --git a/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm b/IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm
index b32fa32a89..d9407b6fdb 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
@@ -305,7 +316,7 @@ LoadMicrocode:
wrmsr
mov eax, 1
cpuid
-
+ jmp Done ; if already one version microcode loaded, go to done
Continue:
jmp NextMicrocode
--
2.35.0.windows.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-28 18:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-28 18:12 [PATCH] IntelFsp2Pkg: LoadMicrocodeDefault() causing unnecessary delay Chiu, Chasel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox