From 66b9a5191da57f54c409f3ba4ad8566e73fc790f Mon Sep 17 00:00:00 2001 From: Aiden Park Date: Wed, 4 Dec 2019 22:30:03 -0800 Subject: [PATCH] Preserve ebx register in AsmEnableAvx() System reset occurs after returning from AsmEnableAvx() in Stage1A.c because ebx register is used for cpuid, but not restored. - Save/Restore ebx register - Move AsmEnableAvx () after init idt and serialport Signed-off-by: Aiden Park --- .../Library/ExtraBaseLib/Ia32/CpuSupport.nasm | 2 ++ BootloaderCorePkg/Stage1A/Stage1A.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/BootloaderCommonPkg/Library/ExtraBaseLib/Ia32/CpuSupport.nasm b/BootloaderCommonPkg/Library/ExtraBaseLib/Ia32/CpuSupport.nasm index 74caf43a..f492de73 100644 --- a/BootloaderCommonPkg/Library/ExtraBaseLib/Ia32/CpuSupport.nasm +++ b/BootloaderCommonPkg/Library/ExtraBaseLib/Ia32/CpuSupport.nasm @@ -57,6 +57,7 @@ FlushExit: ;------------------------------------------------------------------------------ global ASM_PFX(AsmEnableAvx) ASM_PFX(AsmEnableAvx): + push ebx ; ; Check if AVX is supported ; @@ -79,4 +80,5 @@ ASM_PFX(AsmEnableAvx): xsetbv NoAvxSupport: + pop ebx ret diff --git a/BootloaderCorePkg/Stage1A/Stage1A.c b/BootloaderCorePkg/Stage1A/Stage1A.c index c1362f7b..b9229569 100644 --- a/BootloaderCorePkg/Stage1A/Stage1A.c +++ b/BootloaderCorePkg/Stage1A/Stage1A.c @@ -243,6 +243,9 @@ SecStartup2 ( BoardInit (PostTempRamInit); AddMeasurePoint (0x1040); + // Enable more CPU featurs + AsmEnableAvx (); + if (DebugCodeEnabled()) { DEBUG ((DEBUG_INFO, "\n============= %a STAGE1A =============\n",mBootloaderName)); } else { @@ -315,9 +318,6 @@ SecStartup ( TimeStamp = ReadTimeStamp (); Stage1aAsmHob = (STAGE1A_ASM_HOB *)Params; - // Enable more CPU featurs - AsmEnableAvx (); - // Init global data LdrGlobal = &LdrGlobalData; ZeroMem (LdrGlobal, sizeof (LOADER_GLOBAL_DATA));