TianoCore EDK2 master
|
Go to the source code of this file.
Functions | |
EFI_STATUS | SmbaseAllocatePostSmmPen (OUT UINT32 *PenAddress, IN CONST EFI_BOOT_SERVICES *BootServices) |
VOID | SmbaseReinstallPostSmmPen (IN UINT32 PenAddress) |
VOID | SmbaseReleasePostSmmPen (IN UINT32 PenAddress, IN CONST EFI_BOOT_SERVICES *BootServices) |
VOID | SmbaseInstallFirstSmiHandler (VOID) |
EFI_STATUS | SmbaseRelocate (IN APIC_ID ApicId, IN UINTN Smbase, IN UINT32 PenAddress) |
SMBASE relocation for hot-plugged CPUs.
Copyright (c) 2020, Red Hat, Inc.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Smbase.h.
EFI_STATUS SmbaseAllocatePostSmmPen | ( | OUT UINT32 * | PenAddress, |
IN CONST EFI_BOOT_SERVICES * | BootServices | ||
) |
Allocate a non-SMRAM reserved memory page for the Post-SMM Pen for hot-added CPUs.
This function may only be called from the entry point function of the driver.
[out] | PenAddress | The address of the allocated (normal RAM) reserved page. |
[in] | BootServices | Pointer to the UEFI boot services table. Used for allocating the normal RAM (not SMRAM) reserved page. |
EFI_SUCCESS | Allocation successful. |
EFI_BAD_BUFFER_SIZE | The Post-SMM Pen template is not smaller than EFI_PAGE_SIZE. |
VOID SmbaseInstallFirstSmiHandler | ( | VOID | ) |
Place the handler routine for the first SMIs of hot-added CPUs at (SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET).
Note that this effects an "SMRAM to SMRAM" copy.
Additionally, shut the APIC ID gate in FIRST_SMI_HANDLER_CONTEXT.
This function may only be called from the entry point function of the driver, and only after PcdQ35SmramAtDefaultSmbase has been determined to be TRUE.
VOID SmbaseReinstallPostSmmPen | ( | IN UINT32 | PenAddress | ) |
Copy the Post-SMM Pen template code into the reserved page allocated with SmbaseAllocatePostSmmPen().
Note that this effects an "SMRAM to normal RAM" copy.
The SMM Monarch is supposed to call this function from the root MMI handler.
[in] | PenAddress | The allocation address returned by SmbaseAllocatePostSmmPen(). |
VOID SmbaseReleasePostSmmPen | ( | IN UINT32 | PenAddress, |
IN CONST EFI_BOOT_SERVICES * | BootServices | ||
) |
Release the reserved page allocated with SmbaseAllocatePostSmmPen().
This function may only be called from the entry point function of the driver, on the error path.
[in] | PenAddress | The allocation address returned by SmbaseAllocatePostSmmPen(). |
[in] | BootServices | Pointer to the UEFI boot services table. Used for releasing the normal RAM (not SMRAM) reserved page. |
EFI_STATUS SmbaseRelocate | ( | IN APIC_ID | ApicId, |
IN UINTN | Smbase, | ||
IN UINT32 | PenAddress | ||
) |
Relocate the SMBASE on a hot-added CPU. Then pen the hot-added CPU in the normal RAM reserved memory page, set up earlier with SmbaseAllocatePostSmmPen() and SmbaseReinstallPostSmmPen().
The SMM Monarch is supposed to call this function from the root MMI handler.
The SMM Monarch is responsible for calling SmbaseInstallFirstSmiHandler(), SmbaseAllocatePostSmmPen(), and SmbaseReinstallPostSmmPen() before calling this function.
If the OS maliciously boots the hot-added CPU ahead of letting the ACPI CPU hotplug event handler broadcast the CPU hotplug MMI, then the hot-added CPU returns to the OS rather than to the pen, upon RSM. In that case, this function will hang forever (unless the OS happens to signal back through the last byte of the pen page).
[in] | ApicId | The APIC ID of the hot-added CPU whose SMBASE should be relocated. |
[in] | Smbase | The new SMBASE address. The root MMI handler is responsible for passing in a free ("unoccupied") SMBASE address that was pre-configured by PiSmmCpuDxeSmm in CPU_HOT_PLUG_DATA. |
[in] | PenAddress | The address of the Post-SMM Pen for hot-added CPUs, as returned by SmbaseAllocatePostSmmPen(), and installed by SmbaseReinstallPostSmmPen(). |
EFI_SUCCESS | The SMBASE of the hot-added CPU with APIC ID ApicId has been relocated to Smbase. The hot-added CPU has reported back about leaving SMM. |
EFI_PROTOCOL_ERROR | Synchronization bug encountered around FIRST_SMI_HANDLER_CONTEXT.ApicIdGate. |
EFI_INVALID_PARAMETER | Smbase does not fit in 32 bits. No relocation has been attempted. |