]> git.proxmox.com Git - mirror_edk2.git/commit - UefiCpuPkg/Library/MpInitLib/MpLib.c
UefiCpuPkg/MpInitLib: Set X2ApicEnable flag from BSP
authorRay Ni <ray.ni@intel.com>
Wed, 23 Oct 2019 06:23:38 +0000 (14:23 +0800)
committerRay Ni <ray.ni@intel.com>
Tue, 5 Nov 2019 02:03:43 +0000 (10:03 +0800)
commit54d1e76f4e17255080f083b155cee8c6678d8175
tree75e981f0c8764ee4d18045f21c2a08abba50cf84
parent8d3f428109623096cb8845779cdf9dc44949b8e9
UefiCpuPkg/MpInitLib: Set X2ApicEnable flag from BSP

Today's logic sets X2ApicEnable flag in each AP's initialization
path when InitFlag == ApInitConfig.
Since all CPUs update the same global data, a spin-lock is used
to avoid modifications from multiple CPUs happen at the same time.
The spin-lock causes two problems:
1. Potential performance downgrade.
2. Undefined behavior when improper timer lib is used.
   For example we saw certain platforms used AcpiTimerLib from
   PcAtChipsetPkg and that library depends on retrieving PeiServices
   from idtr. But in fact AP's (idtr - 4) doesn't point to
   PeiServices.

The patch simplifies the code to let BSP set the X2ApicEnable flag so
the spin-lock acquisition from AP is not needed any more.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
UefiCpuPkg/Library/MpInitLib/MpLib.c