summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/CpuHotplugSmm/Smbase.c
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/CpuHotplugSmm/Smbase.c')
-rw-r--r--OvmfPkg/CpuHotplugSmm/Smbase.c93
1 files changed, 60 insertions, 33 deletions
diff --git a/OvmfPkg/CpuHotplugSmm/Smbase.c b/OvmfPkg/CpuHotplugSmm/Smbase.c
index d8f45c4313..5d50605893 100644
--- a/OvmfPkg/CpuHotplugSmm/Smbase.c
+++ b/OvmfPkg/CpuHotplugSmm/Smbase.c
@@ -18,10 +18,10 @@
#include "Smbase.h"
-extern CONST UINT8 mPostSmmPen[];
-extern CONST UINT16 mPostSmmPenSize;
-extern CONST UINT8 mFirstSmiHandler[];
-extern CONST UINT16 mFirstSmiHandlerSize;
+extern CONST UINT8 mPostSmmPen[];
+extern CONST UINT16 mPostSmmPenSize;
+extern CONST UINT8 mFirstSmiHandler[];
+extern CONST UINT16 mFirstSmiHandlerSize;
/**
Allocate a non-SMRAM reserved memory page for the Post-SMM Pen for hot-added
@@ -46,12 +46,12 @@ extern CONST UINT16 mFirstSmiHandlerSize;
**/
EFI_STATUS
SmbaseAllocatePostSmmPen (
- OUT UINT32 *PenAddress,
- IN CONST EFI_BOOT_SERVICES *BootServices
+ OUT UINT32 *PenAddress,
+ IN CONST EFI_BOOT_SERVICES *BootServices
)
{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS Address;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Address;
//
// The pen code must fit in one page, and the last byte must remain free for
@@ -59,14 +59,23 @@ SmbaseAllocatePostSmmPen (
//
if (mPostSmmPenSize >= EFI_PAGE_SIZE) {
Status = EFI_BAD_BUFFER_SIZE;
- DEBUG ((DEBUG_ERROR, "%a: mPostSmmPenSize=%u: %r\n", __FUNCTION__,
- mPostSmmPenSize, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: mPostSmmPenSize=%u: %r\n",
+ __FUNCTION__,
+ mPostSmmPenSize,
+ Status
+ ));
return Status;
}
Address = BASE_1MB - 1;
- Status = BootServices->AllocatePages (AllocateMaxAddress,
- EfiReservedMemoryType, 1, &Address);
+ Status = BootServices->AllocatePages (
+ AllocateMaxAddress,
+ EfiReservedMemoryType,
+ 1,
+ &Address
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: AllocatePages(): %r\n", __FUNCTION__, Status));
return Status;
@@ -90,7 +99,7 @@ SmbaseAllocatePostSmmPen (
**/
VOID
SmbaseReinstallPostSmmPen (
- IN UINT32 PenAddress
+ IN UINT32 PenAddress
)
{
CopyMem ((VOID *)(UINTN)PenAddress, mPostSmmPen, mPostSmmPenSize);
@@ -110,8 +119,8 @@ SmbaseReinstallPostSmmPen (
**/
VOID
SmbaseReleasePostSmmPen (
- IN UINT32 PenAddress,
- IN CONST EFI_BOOT_SERVICES *BootServices
+ IN UINT32 PenAddress,
+ IN CONST EFI_BOOT_SERVICES *BootServices
)
{
BootServices->FreePages (PenAddress, 1);
@@ -133,12 +142,15 @@ SmbaseInstallFirstSmiHandler (
VOID
)
{
- FIRST_SMI_HANDLER_CONTEXT *Context;
+ FIRST_SMI_HANDLER_CONTEXT *Context;
- CopyMem ((VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET),
- mFirstSmiHandler, mFirstSmiHandlerSize);
+ CopyMem (
+ (VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET),
+ mFirstSmiHandler,
+ mFirstSmiHandlerSize
+ );
- Context = (VOID *)(UINTN)SMM_DEFAULT_SMBASE;
+ Context = (VOID *)(UINTN)SMM_DEFAULT_SMBASE;
Context->ApicIdGate = MAX_UINT64;
}
@@ -184,25 +196,31 @@ SmbaseInstallFirstSmiHandler (
**/
EFI_STATUS
SmbaseRelocate (
- IN APIC_ID ApicId,
- IN UINTN Smbase,
- IN UINT32 PenAddress
+ IN APIC_ID ApicId,
+ IN UINTN Smbase,
+ IN UINT32 PenAddress
)
{
- EFI_STATUS Status;
- volatile UINT8 *SmmVacated;
- volatile FIRST_SMI_HANDLER_CONTEXT *Context;
- UINT64 ExchangeResult;
+ EFI_STATUS Status;
+ volatile UINT8 *SmmVacated;
+ volatile FIRST_SMI_HANDLER_CONTEXT *Context;
+ UINT64 ExchangeResult;
if (Smbase > MAX_UINT32) {
Status = EFI_INVALID_PARAMETER;
- DEBUG ((DEBUG_ERROR, "%a: ApicId=" FMT_APIC_ID " Smbase=0x%Lx: %r\n",
- __FUNCTION__, ApicId, (UINT64)Smbase, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ApicId=" FMT_APIC_ID " Smbase=0x%Lx: %r\n",
+ __FUNCTION__,
+ ApicId,
+ (UINT64)Smbase,
+ Status
+ ));
return Status;
}
SmmVacated = (UINT8 *)(UINTN)PenAddress + (EFI_PAGE_SIZE - 1);
- Context = (VOID *)(UINTN)SMM_DEFAULT_SMBASE;
+ Context = (VOID *)(UINTN)SMM_DEFAULT_SMBASE;
//
// Clear AboutToLeaveSmm, so we notice when the hot-added CPU is just about
@@ -261,12 +279,21 @@ SmbaseRelocate (
//
// Un-gate SMBASE relocation for the hot-added CPU whose APIC ID is ApicId.
//
- ExchangeResult = InterlockedCompareExchange64 (&Context->ApicIdGate,
- MAX_UINT64, ApicId);
+ ExchangeResult = InterlockedCompareExchange64 (
+ &Context->ApicIdGate,
+ MAX_UINT64,
+ ApicId
+ );
if (ExchangeResult != MAX_UINT64) {
Status = EFI_PROTOCOL_ERROR;
- DEBUG ((DEBUG_ERROR, "%a: ApicId=" FMT_APIC_ID " ApicIdGate=0x%Lx: %r\n",
- __FUNCTION__, ApicId, ExchangeResult, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ApicId=" FMT_APIC_ID " ApicIdGate=0x%Lx: %r\n",
+ __FUNCTION__,
+ ApicId,
+ ExchangeResult,
+ Status
+ ));
return Status;
}