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
0447a0fb3c
commit
5eda06e2e8
|
@ -1265,28 +1265,29 @@ LaunchBack (
|
|||
|
||||
**/
|
||||
|
||||
extern UINT64 _BSS_start, _BSS_end;
|
||||
|
||||
extern UINT64 _BSS_start, _BSS_end;
|
||||
|
||||
VOID
|
||||
InitializeSmmMonitor (
|
||||
IN X86_REGISTER *Register
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
UINT64 MSEG;
|
||||
UINT64 BSS_location;
|
||||
UINT64 BSS_size;
|
||||
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
|
||||
|
||||
|
||||
// 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 after the Stm Image */
|
||||
.StaticImageSize : {LONG( ((_StmImageEnd + 0xFFF) & 0xFFFFF000) )}
|
||||
/* 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);}
|
||||
|
||||
.text : {
|
||||
|
@ -129,7 +128,7 @@ SECTIONS
|
|||
*(.data.rel.ro.local)
|
||||
} =0x0
|
||||
|
||||
. = ALIGN(0x20);
|
||||
. = ALIGN(0x20);
|
||||
|
||||
_ElfRelocTablesStart = .;
|
||||
.reloc : {
|
||||
|
@ -137,9 +136,8 @@ SECTIONS
|
|||
}
|
||||
_ElfRelocTablesEnd = .;
|
||||
|
||||
_StmImageEnd = .;
|
||||
|
||||
. = ALIGN(0X1000);
|
||||
. = ALIGN(0X1000);
|
||||
.data : {
|
||||
*(.data.*)
|
||||
}
|
||||
|
@ -150,24 +148,23 @@ SECTIONS
|
|||
}
|
||||
. = ALIGN(0x20);
|
||||
|
||||
_BSS_start = .;
|
||||
_BSS_start = .;
|
||||
.bss : {
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
*(.bss)
|
||||
*(.bss)
|
||||
/* dummy */
|
||||
/* LONG (0x12345678) */
|
||||
}
|
||||
_BSS_end = .;
|
||||
_BSS_end = .;
|
||||
|
||||
. = ALIGN(0x20);
|
||||
.edata : {
|
||||
}
|
||||
. = ALIGN(0x20);
|
||||
}
|
||||
. = ALIGN(0x20);
|
||||
_StmImageEnd = .;
|
||||
|
||||
_StmImageEnd = .;
|
||||
|
||||
. = ALIGN(0x1000);
|
||||
_StmPageTables = .;
|
||||
. = . + 24K; /* 6 pages for STM page tables, filled by BIOS and/or SINIT */
|
||||
. = ALIGN(0x1000);
|
||||
_StmPageTables = .;
|
||||
. = . + 24K; /* 6 pages for STM page tables, filled by BIOS and/or SINIT */
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue