X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=UefiCpuPkg%2FPiSmmCpuDxeSmm%2FPiSmmCpuDxeSmm.h;h=9b119c8412c529a08844025787acaf5bd58e8564;hb=b10d5ddc0385f39d2c2c62843710b7609a4ca169;hp=f2a91655a33b85bdbf3c69b30252d172c877fe98;hpb=21c1719318056691a3e5901c6e28e5ba2b70afe2;p=mirror_edk2.git diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h index f2a91655a3..9b119c8412 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -1,7 +1,7 @@ /** @file Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU. -Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -53,6 +53,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include "CpuService.h" #include "SmmProfile.h" @@ -71,15 +72,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. /// #define IA32_PG_P BIT0 #define IA32_PG_RW BIT1 +#define IA32_PG_U BIT2 #define IA32_PG_WT BIT3 #define IA32_PG_CD BIT4 #define IA32_PG_A BIT5 +#define IA32_PG_D BIT6 #define IA32_PG_PS BIT7 #define IA32_PG_PAT_2M BIT12 #define IA32_PG_PAT_4K IA32_PG_PS #define IA32_PG_PMNT BIT62 #define IA32_PG_NX BIT63 +#define PAGE_ATTRIBUTE_BITS (IA32_PG_RW | IA32_PG_P) +// +// Bits 1, 2, 5, 6 are reserved in the IA32 PAE PDPTE +// X64 PAE PDPTE does not have such restriction +// +#define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P) + // // Size of Task-State Segment defined in IA32 Manual // @@ -139,7 +149,6 @@ extern SMM_CPU_PRIVATE_DATA *gSmmCpuPrivate; extern CPU_HOT_PLUG_DATA mCpuHotPlugData; extern UINTN mMaxNumberOfCpus; extern UINTN mNumberOfCpus; -extern BOOLEAN mRestoreSmmConfigurationInS3; extern EFI_SMM_CPU_PROTOCOL mSmmCpu; /// @@ -285,11 +294,11 @@ SmmRelocationSemaphoreComplete ( /// The type of SMM CPU Information /// typedef struct { - SPIN_LOCK Busy; + SPIN_LOCK *Busy; volatile EFI_AP_PROCEDURE Procedure; volatile VOID *Parameter; - volatile UINT32 Run; - volatile BOOLEAN Present; + volatile UINT32 *Run; + volatile BOOLEAN *Present; } SMM_CPU_DATA_BLOCK; typedef enum { @@ -304,17 +313,19 @@ typedef struct { // so that UC cache-ability can be set together. // SMM_CPU_DATA_BLOCK *CpuData; - volatile UINT32 Counter; + volatile UINT32 *Counter; volatile UINT32 BspIndex; - volatile BOOLEAN InsideSmm; - volatile BOOLEAN AllCpusInSync; + volatile BOOLEAN *InsideSmm; + volatile BOOLEAN *AllCpusInSync; volatile SMM_CPU_SYNC_MODE EffectiveSyncMode; volatile BOOLEAN SwitchBsp; volatile BOOLEAN *CandidateBsp; } SMM_DISPATCHER_MP_SYNC_DATA; +#define MSR_SPIN_LOCK_INIT_NUM 15 + typedef struct { - SPIN_LOCK SpinLock; + SPIN_LOCK *SpinLock; UINT32 MsrIndex; } MP_MSR_LOCK; @@ -344,32 +355,74 @@ typedef struct { UINT64 MtrrBaseMaskPtr; // Offset 0x58 } PROCESSOR_SMM_DESCRIPTOR; + +/// +/// All global semaphores' pointer +/// +typedef struct { + volatile UINT32 *Counter; + volatile BOOLEAN *InsideSmm; + volatile BOOLEAN *AllCpusInSync; + SPIN_LOCK *PFLock; + SPIN_LOCK *CodeAccessCheckLock; + SPIN_LOCK *MemoryMappedLock; +} SMM_CPU_SEMAPHORE_GLOBAL; + +/// +/// All semaphores for each processor +/// +typedef struct { + SPIN_LOCK *Busy; + volatile UINT32 *Run; + volatile BOOLEAN *Present; +} SMM_CPU_SEMAPHORE_CPU; + +/// +/// All MSRs semaphores' pointer and counter +/// +typedef struct { + SPIN_LOCK *Msr; + UINTN AvailableCounter; +} SMM_CPU_SEMAPHORE_MSR; + +/// +/// All semaphores' information +/// +typedef struct { + SMM_CPU_SEMAPHORE_GLOBAL SemaphoreGlobal; + SMM_CPU_SEMAPHORE_CPU SemaphoreCpu; + SMM_CPU_SEMAPHORE_MSR SemaphoreMsr; +} SMM_CPU_SEMAPHORES; + extern IA32_DESCRIPTOR gcSmiGdtr; extern IA32_DESCRIPTOR gcSmiIdtr; extern VOID *gcSmiIdtrPtr; extern CONST PROCESSOR_SMM_DESCRIPTOR gcPsd; extern UINT64 gPhyMask; -extern ACPI_CPU_DATA mAcpiCpuData; extern SMM_DISPATCHER_MP_SYNC_DATA *mSmmMpSyncData; -extern VOID *mGdtForAp; -extern VOID *mIdtForAp; -extern VOID *mMachineCheckHandlerForAp; extern UINTN mSmmStackArrayBase; extern UINTN mSmmStackArrayEnd; extern UINTN mSmmStackSize; extern EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService; extern IA32_DESCRIPTOR gcSmiInitGdtr; +extern SMM_CPU_SEMAPHORES mSmmCpuSemaphores; +extern UINTN mSemaphoreSize; +extern SPIN_LOCK *mPFLock; +extern SPIN_LOCK *mConfigSmmCodeAccessCheckLock; +extern SPIN_LOCK *mMemoryMappedLock; /** Create 4G PageTable in SMRAM. @param ExtraPages Additional page numbers besides for 4G memory + @param Is32BitPageTable Whether the page table is 32-bit PAE @return PageTable Address **/ UINT32 Gen4GPageTable ( - IN UINTN ExtraPages + IN UINTN ExtraPages, + IN BOOLEAN Is32BitPageTable ); @@ -539,26 +592,14 @@ FindSmramInfo ( ); /** - The function is invoked before SMBASE relocation in S3 path to restores CPU status. - - The function is invoked before SMBASE relocation in S3 path. It does first time microcode load - and restores MTRRs for both BSP and APs. - -**/ -VOID -EarlyInitializeCpu ( - VOID - ); - -/** - The function is invoked after SMBASE relocation in S3 path to restores CPU status. + Relocate SmmBases for each processor. - The function is invoked after SMBASE relocation in S3 path. It restores configuration according to - data saved by normal boot path for both BSP and APs. + Execute on first boot and all S3 resumes **/ VOID -InitializeCpu ( +EFIAPI +SmmRelocateBases ( VOID ); @@ -739,4 +780,49 @@ AllocatePageTableMemory ( IN UINTN Pages ); + +// +// S3 related global variable and function prototype. +// + +extern BOOLEAN mSmmS3Flag; + +/** + Initialize SMM S3 resume state structure used during S3 Resume. + + @param[in] Cr3 The base address of the page tables to use in SMM. + +**/ +VOID +InitSmmS3ResumeState ( + IN UINT32 Cr3 + ); + +/** + Get ACPI CPU data. + +**/ +VOID +GetAcpiCpuData ( + VOID + ); + +/** + Restore SMM Configuration in S3 boot path. + +**/ +VOID +RestoreSmmConfigurationInS3 ( + VOID + ); + +/** + Get ACPI S3 enable flag. + +**/ +VOID +GetAcpiS3EnableFlag ( + VOID + ); + #endif