mirror of
				https://gitlab.com/qemu-project/edk2.git
				synced 2025-10-30 07:56:39 +08:00 
			
		
		
		
	UefiCpuPkg: Always Initialize Separate AP Exception Stacks
Today, CpuMpPei and CpuDxe only initialize separate exception stacks for the APs when PcdCpuStackGuard is enabled so that if a stack overflow occurs, hitting the guard page, the exception can be handler with a separate stack. However, this operation also creates a separate GDT for each AP. This is a safer option than all APs sharing the BSP's GDT because there are issues with concurrent access to the structures contained within. Furthermore, even when a stack guard page is not present, stack overflows can still occur and corrupt the stack; if an exception is taken here, it is still valuable to have a separate exception stack for sanity. This commit updates CpuMpPei and CpuDxe to always create separate exception stacks for the APs (and therefore separate GDTs). Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
This commit is contained in:
		 Oliver Smith-Denny
					Oliver Smith-Denny
				
			
				
					committed by
					
						![mergify[bot]](/assets/img/avatar_default.png) mergify[bot]
						mergify[bot]
					
				
			
			
				
	
			
			
			![mergify[bot]](/assets/img/avatar_default.png) mergify[bot]
						mergify[bot]
					
				
			
						parent
						
							f64b4065b7
						
					
				
				
					commit
					e67f405713
				
			| @ -89,7 +89,6 @@ | ||||
|  | ||||
| [Pcd] | ||||
|   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask    ## CONSUMES | ||||
|   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard                       ## CONSUMES | ||||
|   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask               ## CONSUMES | ||||
|   gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask    ## CONSUMES | ||||
|   gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask                    ## CONSUMES | ||||
|  | ||||
| @ -761,11 +761,9 @@ InitializeMpExceptionHandlers ( | ||||
|   } | ||||
|  | ||||
|   // | ||||
|   // Setup stack switch for Stack Guard feature. | ||||
|   // Setup stack switch for Stack Guard feature and separate AP GDTs. | ||||
|   // | ||||
|   if (PcdGetBool (PcdCpuStackGuard)) { | ||||
|     InitializeMpExceptionStackSwitchHandlers (); | ||||
|   } | ||||
|   InitializeMpExceptionStackSwitchHandlers (); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  | ||||
| @ -68,7 +68,8 @@ InitializeExceptionStackSwitchHandlers ( | ||||
| } | ||||
|  | ||||
| /** | ||||
|   Initializes MP exceptions handlers for the sake of stack switch requirement. | ||||
|   Initializes MP exceptions handlers for the sake of stack switch requirement and giving the APs | ||||
|   their own GDTs. | ||||
|  | ||||
|   This function will allocate required resources required to setup stack switch | ||||
|   and pass them through SwitchStackData to each logic processor. | ||||
| @ -86,10 +87,6 @@ InitializeMpExceptionStackSwitchHandlers ( | ||||
|   EFI_STATUS                      Status; | ||||
|   UINT8                           *Buffer; | ||||
|  | ||||
|   if (!PcdGetBool (PcdCpuStackGuard)) { | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   Status = MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL); | ||||
|   ASSERT_EFI_ERROR (Status); | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user