From 786ae7688414d58a14ef68b023af4b040f37323e Mon Sep 17 00:00:00 2001 From: Hongbin1 Zhang Date: Mon, 3 Mar 2025 13:06:26 +0800 Subject: [PATCH] IntelFsp2WrapperPkg: Bootloader need to recover fs and gs When enter FSP, bootloader need to save fs and gs, when back to bootloader, bootloader need to restore fs and gs, so it could avoid bootloader access wrong data segment when usging fs and gs. Signed-off-by: Hongbin1 Zhang Cc: Chasel Chiu Cc: Nate DeSimone Cc: Duggapu Chinni B Cc: Star Zeng Cc: Ted Kuo Cc: Ashraf Ali S Cc: Ray Ni --- .../Library/BaseFspWrapperApiLib/X64/Thunk64To32.nasm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/X64/Thunk64To32.nasm b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/X64/Thunk64To32.nasm index db8e62ebc5..a65bb103b1 100644 --- a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/X64/Thunk64To32.nasm +++ b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/X64/Thunk64To32.nasm @@ -110,9 +110,11 @@ ASM_PFX(AsmExecute32BitCode): retf Compatible: - ; reload DS/ES/SS to make sure they are correct referred to current GDT + ; reload DS/ES/FS/GS/SS to make sure they are correct referred to current GDT mov ds, ax mov es, ax + mov fs, ax + mov gs, ax mov ss, ax ; @@ -208,11 +210,13 @@ ReloadCS: retf .0: ; - ; Reload original DS/ES/SS + ; Reload original DS/ES/FS/GS/SS ; pop rcx mov ds, rcx mov es, rcx + mov fs, rcx + mov gs, rcx mov ss, rcx ;