From e7989ef64fee773a90291325fd46dceda35d400d Mon Sep 17 00:00:00 2001 From: vit9696 Date: Mon, 18 May 2020 18:58:44 +0300 Subject: [PATCH] OcCpuLib: Fix trashing EBX register in AsmReadIntelMicrocodeRevision This register is callee-preserved in MSABI. --- Library/OcCpuLib/IA32/Microcode.nasm | 2 ++ Library/OcCpuLib/X64/Microcode.nasm | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Library/OcCpuLib/IA32/Microcode.nasm b/Library/OcCpuLib/IA32/Microcode.nasm index fe026660..634f95ef 100644 --- a/Library/OcCpuLib/IA32/Microcode.nasm +++ b/Library/OcCpuLib/IA32/Microcode.nasm @@ -34,6 +34,7 @@ ASM_PFX(AsmReadIntelMicrocodeRevision): ; Several Intel CPUs, notably Westmere, require a certain assembly ; sequence to retrieve microcode revision. ; Reference: https://github.com/acidanthera/bugtracker/issues/621. + push ebx mov ecx, MSR_IA32_BIOS_SIGN_ID xor eax, eax xor edx, edx @@ -43,4 +44,5 @@ ASM_PFX(AsmReadIntelMicrocodeRevision): mov ecx, MSR_IA32_BIOS_SIGN_ID rdmsr mov eax, edx + pop ebx ret diff --git a/Library/OcCpuLib/X64/Microcode.nasm b/Library/OcCpuLib/X64/Microcode.nasm index 1051a205..a3f5b489 100644 --- a/Library/OcCpuLib/X64/Microcode.nasm +++ b/Library/OcCpuLib/X64/Microcode.nasm @@ -34,6 +34,7 @@ ASM_PFX(AsmReadIntelMicrocodeRevision): ; Several Intel CPUs, notably Westmere, require a certain assembly ; sequence to retrieve microcode revision. ; Reference: https://github.com/acidanthera/bugtracker/issues/621. + push rbx mov ecx, MSR_IA32_BIOS_SIGN_ID xor eax, eax xor edx, edx @@ -43,4 +44,5 @@ ASM_PFX(AsmReadIntelMicrocodeRevision): mov ecx, MSR_IA32_BIOS_SIGN_ID rdmsr mov eax, edx + pop rbx ret