From 053e878bfb5c9d5eca779789b62891add30b14ba Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sun, 5 Dec 2021 14:54:17 -0800 Subject: UefiCpuPkg: Apply uncrustify changes REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the UefiCpuPkg package Cc: Andrew Fish Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Michael Kubacki Reviewed-by: Ray Ni --- .../X64/ArchExceptionHandler.c | 131 +++++++++++---------- .../CpuExceptionHandlerLib/X64/ArchInterruptDefs.h | 32 ++--- 2 files changed, 86 insertions(+), 77 deletions(-) (limited to 'UefiCpuPkg/Library/CpuExceptionHandlerLib/X64') diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c index d3da16e4df..cd7dccd481 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchExceptionHandler.c @@ -17,8 +17,8 @@ **/ VOID ArchUpdateIdtEntry ( - OUT IA32_IDT_GATE_DESCRIPTOR *IdtEntry, - IN UINTN InterruptHandler + OUT IA32_IDT_GATE_DESCRIPTOR *IdtEntry, + IN UINTN InterruptHandler ) { IdtEntry->Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler; @@ -35,11 +35,11 @@ ArchUpdateIdtEntry ( **/ UINTN ArchGetIdtHandler ( - IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry + IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry ) { - return IdtEntry->Bits.OffsetLow + (((UINTN) IdtEntry->Bits.OffsetHigh) << 16) + - (((UINTN) IdtEntry->Bits.OffsetUpper) << 32); + return IdtEntry->Bits.OffsetLow + (((UINTN)IdtEntry->Bits.OffsetHigh) << 16) + + (((UINTN)IdtEntry->Bits.OffsetUpper) << 32); } /** @@ -51,13 +51,13 @@ ArchGetIdtHandler ( **/ VOID ArchSaveExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData ) { - IA32_EFLAGS32 Eflags; - RESERVED_VECTORS_DATA *ReservedVectors; + IA32_EFLAGS32 Eflags; + RESERVED_VECTORS_DATA *ReservedVectors; ReservedVectors = ExceptionHandlerData->ReservedVectors; // @@ -74,13 +74,13 @@ ArchSaveExceptionContext ( // // Clear IF flag to avoid old IDT handler enable interrupt by IRET // - Eflags.UintN = SystemContext.SystemContextX64->Rflags; - Eflags.Bits.IF = 0; + Eflags.UintN = SystemContext.SystemContextX64->Rflags; + Eflags.Bits.IF = 0; SystemContext.SystemContextX64->Rflags = Eflags.UintN; // // Modify the EIP in stack, then old IDT handler will return to HookAfterStubBegin. // - SystemContext.SystemContextX64->Rip = (UINTN) ReservedVectors[ExceptionType].HookAfterStubHeaderCode; + SystemContext.SystemContextX64->Rip = (UINTN)ReservedVectors[ExceptionType].HookAfterStubHeaderCode; } /** @@ -92,14 +92,14 @@ ArchSaveExceptionContext ( **/ VOID ArchRestoreExceptionContext ( - IN UINTN ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext, - IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData + IN UINTN ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext, + IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData ) { - RESERVED_VECTORS_DATA *ReservedVectors; + RESERVED_VECTORS_DATA *ReservedVectors; - ReservedVectors = ExceptionHandlerData->ReservedVectors; + ReservedVectors = ExceptionHandlerData->ReservedVectors; SystemContext.SystemContextX64->Ss = ReservedVectors[ExceptionType].OldSs; SystemContext.SystemContextX64->Rsp = ReservedVectors[ExceptionType].OldSp; SystemContext.SystemContextX64->Rflags = ReservedVectors[ExceptionType].OldFlags; @@ -121,31 +121,32 @@ ArchRestoreExceptionContext ( **/ EFI_STATUS ArchSetupExceptionStack ( - IN CPU_EXCEPTION_INIT_DATA *StackSwitchData + IN CPU_EXCEPTION_INIT_DATA *StackSwitchData ) { - IA32_DESCRIPTOR Gdtr; - IA32_DESCRIPTOR Idtr; - IA32_IDT_GATE_DESCRIPTOR *IdtTable; - IA32_TSS_DESCRIPTOR *TssDesc; - IA32_TASK_STATE_SEGMENT *Tss; - UINTN StackTop; - UINTN Index; - UINTN Vector; - UINTN TssBase; - UINTN GdtSize; - - if (StackSwitchData == NULL || - StackSwitchData->Ia32.Revision != CPU_EXCEPTION_INIT_DATA_REV || - StackSwitchData->X64.KnownGoodStackTop == 0 || - StackSwitchData->X64.KnownGoodStackSize == 0 || - StackSwitchData->X64.StackSwitchExceptions == NULL || - StackSwitchData->X64.StackSwitchExceptionNumber == 0 || - StackSwitchData->X64.StackSwitchExceptionNumber > CPU_EXCEPTION_NUM || - StackSwitchData->X64.GdtTable == NULL || - StackSwitchData->X64.IdtTable == NULL || - StackSwitchData->X64.ExceptionTssDesc == NULL || - StackSwitchData->X64.ExceptionTss == NULL) { + IA32_DESCRIPTOR Gdtr; + IA32_DESCRIPTOR Idtr; + IA32_IDT_GATE_DESCRIPTOR *IdtTable; + IA32_TSS_DESCRIPTOR *TssDesc; + IA32_TASK_STATE_SEGMENT *Tss; + UINTN StackTop; + UINTN Index; + UINTN Vector; + UINTN TssBase; + UINTN GdtSize; + + if ((StackSwitchData == NULL) || + (StackSwitchData->Ia32.Revision != CPU_EXCEPTION_INIT_DATA_REV) || + (StackSwitchData->X64.KnownGoodStackTop == 0) || + (StackSwitchData->X64.KnownGoodStackSize == 0) || + (StackSwitchData->X64.StackSwitchExceptions == NULL) || + (StackSwitchData->X64.StackSwitchExceptionNumber == 0) || + (StackSwitchData->X64.StackSwitchExceptionNumber > CPU_EXCEPTION_NUM) || + (StackSwitchData->X64.GdtTable == NULL) || + (StackSwitchData->X64.IdtTable == NULL) || + (StackSwitchData->X64.ExceptionTssDesc == NULL) || + (StackSwitchData->X64.ExceptionTss == NULL)) + { return EFI_INVALID_PARAMETER; } @@ -163,7 +164,8 @@ ArchSetupExceptionStack ( } if (((UINTN)StackSwitchData->X64.ExceptionTssDesc + StackSwitchData->X64.ExceptionTssDescSize) > - ((UINTN)(StackSwitchData->X64.GdtTable) + StackSwitchData->X64.GdtTableSize)) { + ((UINTN)(StackSwitchData->X64.GdtTable) + StackSwitchData->X64.GdtTableSize)) + { return EFI_INVALID_PARAMETER; } @@ -173,6 +175,7 @@ ArchSetupExceptionStack ( if (StackSwitchData->X64.ExceptionTssDescSize < sizeof (IA32_TSS_DESCRIPTOR)) { return EFI_INVALID_PARAMETER; } + if (StackSwitchData->X64.ExceptionTssSize < sizeof (IA32_TASK_STATE_SEGMENT)) { return EFI_INVALID_PARAMETER; } @@ -196,13 +199,14 @@ ArchSetupExceptionStack ( (UINTN)(StackSwitchData->X64.GdtTable); if ((UINTN)StackSwitchData->X64.GdtTable != Gdtr.Base) { CopyMem (StackSwitchData->X64.GdtTable, (VOID *)Gdtr.Base, Gdtr.Limit + 1); - Gdtr.Base = (UINTN)StackSwitchData->X64.GdtTable; + Gdtr.Base = (UINTN)StackSwitchData->X64.GdtTable; Gdtr.Limit = (UINT16)GdtSize - 1; } if ((UINTN)StackSwitchData->X64.IdtTable != Idtr.Base) { Idtr.Base = (UINTN)StackSwitchData->X64.IdtTable; } + if (StackSwitchData->X64.IdtTableSize > 0) { Idtr.Limit = (UINT16)(StackSwitchData->X64.IdtTableSize - 1); } @@ -213,16 +217,16 @@ ArchSetupExceptionStack ( // TssBase = (UINTN)Tss; - TssDesc->Uint128.Uint64 = 0; - TssDesc->Uint128.Uint64_1= 0; - TssDesc->Bits.LimitLow = sizeof(IA32_TASK_STATE_SEGMENT) - 1; - TssDesc->Bits.BaseLow = (UINT16)TssBase; - TssDesc->Bits.BaseMidl = (UINT8)(TssBase >> 16); - TssDesc->Bits.Type = IA32_GDT_TYPE_TSS; - TssDesc->Bits.P = 1; - TssDesc->Bits.LimitHigh = 0; - TssDesc->Bits.BaseMidh = (UINT8)(TssBase >> 24); - TssDesc->Bits.BaseHigh = (UINT32)(TssBase >> 32); + TssDesc->Uint128.Uint64 = 0; + TssDesc->Uint128.Uint64_1 = 0; + TssDesc->Bits.LimitLow = sizeof (IA32_TASK_STATE_SEGMENT) - 1; + TssDesc->Bits.BaseLow = (UINT16)TssBase; + TssDesc->Bits.BaseMidl = (UINT8)(TssBase >> 16); + TssDesc->Bits.Type = IA32_GDT_TYPE_TSS; + TssDesc->Bits.P = 1; + TssDesc->Bits.LimitHigh = 0; + TssDesc->Bits.BaseMidh = (UINT8)(TssBase >> 24); + TssDesc->Bits.BaseHigh = (UINT32)(TssBase >> 32); // // Fixup exception task descriptor and task-state segment @@ -236,16 +240,18 @@ ArchSetupExceptionStack ( // Fixup IST // Tss->IST[Index] = StackTop; - StackTop -= StackSwitchData->X64.KnownGoodStackSize; + StackTop -= StackSwitchData->X64.KnownGoodStackSize; // // Set the IST field to enable corresponding IST // Vector = StackSwitchData->X64.StackSwitchExceptions[Index]; - if (Vector >= CPU_EXCEPTION_NUM || - Vector >= (Idtr.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR)) { + if ((Vector >= CPU_EXCEPTION_NUM) || + (Vector >= (Idtr.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR))) + { continue; } + IdtTable[Vector].Bits.Reserved_0 = (UINT8)(Index + 1); } @@ -276,8 +282,8 @@ ArchSetupExceptionStack ( VOID EFIAPI DumpCpuContext ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext ) { InternalPrintMessage ( @@ -304,8 +310,10 @@ DumpCpuContext ( (SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_SGX) != 0 ); } + InternalPrintMessage ("\n"); } + InternalPrintMessage ( "RIP - %016lx, CS - %016lx, RFLAGS - %016lx\n", SystemContext.SystemContextX64->Rip, @@ -406,8 +414,8 @@ DumpCpuContext ( **/ VOID DumpImageAndCpuContent ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EFI_SYSTEM_CONTEXT SystemContext + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext ) { DumpCpuContext (ExceptionType, SystemContext); @@ -415,7 +423,8 @@ DumpImageAndCpuContent ( // Dump module image base and module entry point by RIP // if ((ExceptionType == EXCEPT_IA32_PAGE_FAULT) && - ((SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0)) { + ((SystemContext.SystemContextX64->ExceptionData & IA32_PF_EC_ID) != 0)) + { // // The RIP in SystemContext could not be used // if it is page fault with I/D set. diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h index c3a07862ea..008670cb0d 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ArchInterruptDefs.h @@ -10,9 +10,9 @@ #define _ARCH_CPU_INTERRUPT_DEFS_H_ typedef struct { - EFI_SYSTEM_CONTEXT_X64 SystemContext; - BOOLEAN ExceptionDataFlag; - UINTN OldIdtHandler; + EFI_SYSTEM_CONTEXT_X64 SystemContext; + BOOLEAN ExceptionDataFlag; + UINTN OldIdtHandler; } EXCEPTION_HANDLER_CONTEXT; // @@ -24,20 +24,20 @@ typedef struct { } CPU_STATUS_CODE_TEMPLATE; typedef struct { - SPIN_LOCK SpinLock; - UINT32 ApicId; - UINT32 Attribute; - UINTN ExceptonHandler; - UINTN OldSs; - UINTN OldSp; - UINTN OldFlags; - UINTN OldCs; - UINTN OldIp; - UINTN ExceptionData; - UINT8 HookAfterStubHeaderCode[HOOKAFTER_STUB_SIZE]; + SPIN_LOCK SpinLock; + UINT32 ApicId; + UINT32 Attribute; + UINTN ExceptonHandler; + UINTN OldSs; + UINTN OldSp; + UINTN OldFlags; + UINTN OldCs; + UINTN OldIp; + UINTN ExceptionData; + UINT8 HookAfterStubHeaderCode[HOOKAFTER_STUB_SIZE]; } RESERVED_VECTORS_DATA; -#define CPU_TSS_DESC_SIZE sizeof (IA32_TSS_DESCRIPTOR) -#define CPU_TSS_SIZE sizeof (IA32_TASK_STATE_SEGMENT) +#define CPU_TSS_DESC_SIZE sizeof (IA32_TSS_DESCRIPTOR) +#define CPU_TSS_SIZE sizeof (IA32_TASK_STATE_SEGMENT) #endif -- cgit v1.2.3