TianoCore EDK2 master
|
#include <CpuHotPlugData.h>
#include <IndustryStandard/Q35MchIch9.h>
#include <IndustryStandard/QemuCpuHotplug.h>
#include <Library/BaseLib.h>
#include <Library/CpuLib.h>
#include <Library/DebugLib.h>
#include <Library/MmServicesTableLib.h>
#include <Library/PcdLib.h>
#include <Library/SafeIntLib.h>
#include <Pcd/CpuHotEjectData.h>
#include <Protocol/MmCpuIo.h>
#include <Protocol/SmmCpuService.h>
#include <Register/Intel/ArchitecturalMsr.h>
#include <Uefi/UefiBaseType.h>
#include "ApicId.h"
#include "QemuCpuhp.h"
#include "Smbase.h"
Go to the source code of this file.
Functions | |
STATIC EFI_STATUS | ProcessHotAddedCpus (IN APIC_ID *PluggedApicIds, IN UINT32 PluggedCount) |
STATIC BOOLEAN | CheckIfBsp (VOID) |
VOID EFIAPI | EjectCpu (IN UINTN ProcessorNum) |
STATIC EFI_STATUS | UnplugCpus (IN APIC_ID *ToUnplugApicIds, IN UINT32 *ToUnplugSelectors, IN UINT32 ToUnplugCount) |
STATIC EFI_STATUS EFIAPI | CpuHotplugMmi (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL) |
EFI_STATUS EFIAPI | CpuHotplugEntry (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) |
Variables | |
STATIC EFI_MM_CPU_IO_PROTOCOL * | mMmCpuIo |
STATIC EFI_SMM_CPU_SERVICE_PROTOCOL * | mMmCpuService |
STATIC CPU_HOT_PLUG_DATA * | mCpuHotPlugData |
STATIC CPU_HOT_EJECT_DATA * | mCpuHotEjectData |
STATIC APIC_ID * | mPluggedApicIds |
STATIC APIC_ID * | mToUnplugApicIds |
STATIC UINT32 * | mToUnplugSelectors |
STATIC UINT32 | mPostSmmPenAddress |
STATIC EFI_HANDLE | mDispatchHandle |
Root SMI handler for VCPU hotplug SMIs.
Copyright (c) 2020, Red Hat, Inc.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file CpuHotplug.c.
STATIC BOOLEAN CheckIfBsp | ( | VOID | ) |
EjectCpu needs to know the BSP at SMI exit at a point when some of the EFI_SMM_CPU_SERVICE_PROTOCOL state has been torn down. Reuse the logic from OvmfPkg::PlatformSmmBspElection() to do that.
TRUE | If the CPU executing this function is the BSP. |
FALSE | If the CPU executing this function is an AP. |
Definition at line 238 of file CpuHotplug.c.
EFI_STATUS EFIAPI CpuHotplugEntry | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
Definition at line 709 of file CpuHotplug.c.
STATIC EFI_STATUS EFIAPI CpuHotplugMmi | ( | IN EFI_HANDLE | DispatchHandle, |
IN CONST VOID *Context | OPTIONAL, | ||
IN OUT VOID *CommBuffer | OPTIONAL, | ||
IN OUT UINTN *CommBufferSize | OPTIONAL | ||
) |
CPU Hotplug MMI handler function.
This is a root MMI handler.
[in] | DispatchHandle | The unique handle assigned to this handler by EFI_MM_SYSTEM_TABLE.MmiHandlerRegister(). |
[in] | Context | Context passed in by EFI_MM_SYSTEM_TABLE.MmiManage(). Due to CpuHotplugMmi() being a root MMI handler, Context is ASSERT()ed to be NULL. |
[in,out] | CommBuffer | Ignored, due to CpuHotplugMmi() being a root MMI handler. |
[in,out] | CommBufferSize | Ignored, due to CpuHotplugMmi() being a root MMI handler. |
EFI_SUCCESS | The MMI was handled and the MMI source was quiesced. When returned by a non-root MMI handler, EFI_SUCCESS terminates the processing of MMI handlers in EFI_MM_SYSTEM_TABLE.MmiManage(). For a root MMI handler (i.e., for the present function too), EFI_SUCCESS behaves identically to EFI_WARN_INTERRUPT_SOURCE_QUIESCED, as further root MMI handlers are going to be called by EFI_MM_SYSTEM_TABLE.MmiManage() anyway. |
EFI_WARN_INTERRUPT_SOURCE_QUIESCED | The MMI source has been quiesced, but other handlers should still be called. |
EFI_WARN_INTERRUPT_SOURCE_PENDING | The MMI source is still pending, and other handlers should still be called. |
EFI_INTERRUPT_PENDING | The MMI source could not be quiesced. |
Definition at line 605 of file CpuHotplug.c.
CPU Hot-eject handler, called from SmmCpuFeaturesRendezvousExit() on each CPU at exit from SMM.
If, the executing CPU is neither the BSP, nor being ejected, nothing to be done. If, the executing CPU is being ejected, wait in a halted loop until ejected. If, the executing CPU is the BSP, set QEMU CPU status to eject for CPUs being ejected.
[in] | ProcessorNum | ProcessorNum denotes the CPU exiting SMM, and will be used as an index into CPU_HOT_EJECT_DATA->QemuSelectorMap. It is identical to the processor handle number in EFI_SMM_CPU_SERVICE_PROTOCOL. |
Definition at line 269 of file CpuHotplug.c.
STATIC EFI_STATUS ProcessHotAddedCpus | ( | IN APIC_ID * | PluggedApicIds, |
IN UINT32 | PluggedCount | ||
) |
Process CPUs that have been hot-added, per QemuCpuhpCollectApicIds().
For each such CPU, relocate the SMBASE, and report the CPU to PiSmmCpuDxeSmm via EFI_SMM_CPU_SERVICE_PROTOCOL. If the supposedly hot-added CPU is already known, skip it silently.
[in] | PluggedApicIds | The APIC IDs of the CPUs that have been hot-plugged. |
[in] | PluggedCount | The number of filled-in APIC IDs in PluggedApicIds. |
EFI_SUCCESS | CPUs corresponding to all the APIC IDs are populated. |
EFI_OUT_OF_RESOURCES | Out of APIC ID space in "mCpuHotPlugData". |
Definition at line 95 of file CpuHotplug.c.
STATIC EFI_STATUS UnplugCpus | ( | IN APIC_ID * | ToUnplugApicIds, |
IN UINT32 * | ToUnplugSelectors, | ||
IN UINT32 | ToUnplugCount | ||
) |
Process to be hot-unplugged CPUs, per QemuCpuhpCollectApicIds().
For each such CPU, report the CPU to PiSmmCpuDxeSmm via EFI_SMM_CPU_SERVICE_PROTOCOL and stash the QEMU Cpu Selectors for later ejection. If the to be hot-unplugged CPU is unknown, skip it silently.
Additonally, if we do stash any Cpu Selectors, also install a CPU eject handler which would handle the ejection.
[in] | ToUnplugApicIds | The APIC IDs of the CPUs that are about to be hot-unplugged. |
[in] | ToUnplugSelectors | The QEMU Selectors of the CPUs that are about to be hot-unplugged. |
[in] | ToUnplugCount | The number of filled-in APIC IDs in ToUnplugApicIds. |
EFI_ALREADY_STARTED | For the ProcessorNum that EFI_SMM_CPU_SERVICE_PROTOCOL had assigned to one of the APIC IDs in ToUnplugApicIds, mCpuHotEjectData->QemuSelectorMap already has the QemuSelector value stashed. (This should never happen.) |
EFI_SUCCESS | Known APIC IDs have been removed from SMM data structures. |
Definition at line 413 of file CpuHotplug.c.
STATIC CPU_HOT_EJECT_DATA* mCpuHotEjectData |
Definition at line 43 of file CpuHotplug.c.
STATIC CPU_HOT_PLUG_DATA* mCpuHotPlugData |
Definition at line 42 of file CpuHotplug.c.
STATIC EFI_HANDLE mDispatchHandle |
Definition at line 70 of file CpuHotplug.c.
STATIC EFI_MM_CPU_IO_PROTOCOL* mMmCpuIo |
Definition at line 31 of file CpuHotplug.c.
STATIC EFI_SMM_CPU_SERVICE_PROTOCOL* mMmCpuService |
Definition at line 36 of file CpuHotplug.c.
STATIC APIC_ID* mPluggedApicIds |
Definition at line 59 of file CpuHotplug.c.
STATIC UINT32 mPostSmmPenAddress |
Definition at line 66 of file CpuHotplug.c.
STATIC APIC_ID* mToUnplugApicIds |
Definition at line 60 of file CpuHotplug.c.
STATIC UINT32* mToUnplugSelectors |
Definition at line 61 of file CpuHotplug.c.