mirror of https://review.coreboot.org/STM.git
Make sure that BSS is initialized
Since the STM is created as a stand-alone set of code, certain compiler initializations are not included. This patch ensures that the BSS area is initialized to zero. Also, the page tables are moved to after the STM image Signed-off-by: Eugene D. Myers <edmyers@tycho.nsa.gov>
This commit is contained in:
parent
652d93d593
commit
6174e7fc64
|
@ -668,11 +668,6 @@ BspInit (
|
|||
|
||||
StmHeader = (STM_HEADER *)(UINTN)((UINT32)AsmReadMsr64(IA32_SMM_MONITOR_CTL_MSR_INDEX) & 0xFFFFF000);
|
||||
|
||||
// on a platform that does not start with TXT, cannot assume the data space has been set to zero
|
||||
ZeroMem(&mHostContextCommon, sizeof(STM_HOST_CONTEXT_COMMON));
|
||||
ZeroMem(&mGuestContextCommonSmi, sizeof(STM_HOST_CONTEXT_COMMON));
|
||||
ZeroMem(&mGuestContextCommonSmm, sizeof(STM_HOST_CONTEXT_COMMON) * NUM_PE_TYPE);
|
||||
|
||||
InitHeap (StmHeader);
|
||||
// after that we can use mHostContextCommon
|
||||
|
||||
|
@ -1270,15 +1265,28 @@ LaunchBack (
|
|||
|
||||
**/
|
||||
|
||||
extern UINT64 _BSS_start, _BSS_end;
|
||||
|
||||
VOID
|
||||
InitializeSmmMonitor (
|
||||
IN X86_REGISTER *Register
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
UINT64 MSEG;
|
||||
UINT64 BSS_location;
|
||||
UINT64 BSS_size;
|
||||
|
||||
Index = GetIndexFromStack (Register);
|
||||
if (Index == 0) {
|
||||
// Initialize the BSS before anyone has a chance to use it
|
||||
|
||||
MSEG = (UINT64) AsmReadMsr64(IA32_SMM_MONITOR_CTL_MSR_INDEX) & 0xFFFFF000;
|
||||
BSS_location = (UINT64) &_BSS_start | (UINT64) MSEG;
|
||||
BSS_size = (UINT64)&_BSS_end - (UINT64) &_BSS_start;
|
||||
ZeroMem ((void *)BSS_location, BSS_size);
|
||||
AsmWbinvd(); // flush caches
|
||||
|
||||
// The build process should make sure "virtual address" is same as "file pointer to raw data",
|
||||
// in final PE/COFF image, so that we can let StmLoad load binrary to memory directly.
|
||||
// If no, GenStm tool will "load image". So here, we just need "relocate image"
|
||||
|
|
|
@ -38,8 +38,8 @@ SECTIONS
|
|||
.StmSpecVerMajor ALIGN(2048) : {BYTE(1)}
|
||||
.StmSpecVerMinor : {BYTE(0)}
|
||||
.Reserved : {SHORT(0)}
|
||||
/* page tables are at the end of the static section and the data section */
|
||||
.StaticImageSize : {LONG(_StmImageEnd)}
|
||||
/* page tables are after the Stm Image */
|
||||
.StaticImageSize : {LONG( ((_StmImageEnd + 0xFFF) & 0xFFFFF000) )}
|
||||
.PerProcDynamicMemorySize : {LONG(SizeOfPerProcessorStack)}
|
||||
.AdditionalDynamicMemorySize : {LONG(HeapSize + PageTableSize)}
|
||||
|
||||
|
@ -111,7 +111,6 @@ SECTIONS
|
|||
.Attribute8 : {BYTE(0x93)}
|
||||
.LimitHi8 : {BYTE(0xCF)}
|
||||
.BaseHi8 : {BYTE(0)}
|
||||
|
||||
|
||||
.fill3 : { FILL(0x0); . = ALIGN(0x1000);}
|
||||
|
||||
|
@ -132,15 +131,15 @@ SECTIONS
|
|||
|
||||
. = ALIGN(0x20);
|
||||
|
||||
_ElfRelocTablesStart = .;
|
||||
.reloc : {
|
||||
*(.rela.*)
|
||||
}
|
||||
_ElfRelocTablesEnd = .;
|
||||
_ElfRelocTablesStart = .;
|
||||
.reloc : {
|
||||
*(.rela.*)
|
||||
}
|
||||
_ElfRelocTablesEnd = .;
|
||||
|
||||
_StmImageEnd = .;
|
||||
|
||||
. = ALIGN(0X1000);
|
||||
. = ALIGN(0X1000);
|
||||
.data : {
|
||||
*(.data.*)
|
||||
}
|
||||
|
@ -150,17 +149,23 @@ SECTIONS
|
|||
*(.rdata.*)
|
||||
}
|
||||
. = ALIGN(0x20);
|
||||
|
||||
_BSS_start = .;
|
||||
.bss : {
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
*(.bss)
|
||||
/* dummy */
|
||||
/* LONG (0x12345678) */
|
||||
}
|
||||
_BSS_end = .;
|
||||
|
||||
. = ALIGN(0x20);
|
||||
.edata : {
|
||||
}
|
||||
. = ALIGN(0x20);
|
||||
}
|
||||
. = ALIGN(0x20);
|
||||
|
||||
_StmImageEnd = .;
|
||||
|
||||
. = ALIGN(0x1000);
|
||||
_StmPageTables = .;
|
||||
|
|
Loading…
Reference in New Issue