]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Fix potential issue when IDT table is at above 4G
authorLiu, Zhiguang <Zhiguang.Liu@intel.com>
Thu, 25 Aug 2022 02:55:04 +0000 (10:55 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 31 Aug 2022 04:23:55 +0000 (04:23 +0000)
Currently, when waking up AP, IDT table of AP will be set in 16 bit code,
and assume the IDT table base is 32 bit. However, the IDT table is created
by BSP. Issue will happen if the BSP allocates memory above 4G for BSP's
IDT table. Moreover, even the IDT table location is below 4G, the handler
function inside the IDT table is 64 bit, and it won't take effect until
CPU transfers to 64 bit long mode. There is no benefit to set IDT table in
such an early phase.
To avoid such issue, this patch moves the LIDT instruction into 64 bit
code.

Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm

index 1daaa72b1e58eb5ce435eb29e67c969d9a710a5d..cd95b03da8455594f52f8a1de4a3ea08ef100b88 100644 (file)
@@ -64,9 +64,6 @@ BITS 16
     mov        si, MP_CPU_EXCHANGE_INFO_FIELD (GdtrProfile)\r
 o32 lgdt       [cs:si]\r
 \r
-    mov        si, MP_CPU_EXCHANGE_INFO_FIELD (IdtrProfile)\r
-o32 lidt       [cs:si]\r
-\r
     ;\r
     ; Switch to protected mode\r
     ;\r
@@ -154,6 +151,11 @@ BITS 64
 \r
 LongModeStart:\r
     mov        esi, ebx\r
+\r
+    ; Set IDT table at the start of 64 bit code\r
+    lea        edi, [esi + MP_CPU_EXCHANGE_INFO_FIELD (IdtrProfile)]\r
+    lidt       [edi]\r
+\r
     lea        edi, [esi + MP_CPU_EXCHANGE_INFO_FIELD (InitFlag)]\r
     cmp        qword [edi], 1       ; ApInitConfig\r
     jnz        GetApicId\r