Attention is currently required from: Jérémy Compostella, Shuo Liu.
Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/87177?usp=email )
Change subject: [HACK] cpu/x86/smm: Use PML4E in SMM ......................................................................
[HACK] cpu/x86/smm: Use PML4E in SMM
Give SMM the same address space access as the remaining stages by using the same page tables inserted into the rmodule.
It still requires the 4GiB identity mapped pages tables in SMM for the SMM stub, but will switch on SMM module entry to the extended page tables.
TEST: Could access ROM3 BAR at 0xfd00000000 in SMM.
Change-Id: Ia493dc813f50df273d13053f1c9a0ae5335638d6 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/cpu/x86/64bit/Makefile.mk M src/cpu/x86/smm/Makefile.mk M src/cpu/x86/smm/smm_module_handler.c A src/cpu/x86/smm/smm_module_handler_entry.S 4 files changed, 30 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/77/87177/1
diff --git a/src/cpu/x86/64bit/Makefile.mk b/src/cpu/x86/64bit/Makefile.mk index 8ce3665..1f67bb5 100644 --- a/src/cpu/x86/64bit/Makefile.mk +++ b/src/cpu/x86/64bit/Makefile.mk @@ -10,6 +10,7 @@ endif
all_x86-y += $(PAGETABLE_SRC) +smm-y += $(PAGETABLE_SRC)
# Add --defsym=_start=0 to suppress a linker warning. $(objcbfs)/pt: $(dir)/$(PAGETABLE_SRC) $(obj)/config.h diff --git a/src/cpu/x86/smm/Makefile.mk b/src/cpu/x86/smm/Makefile.mk index a104a87..bbaec4c 100644 --- a/src/cpu/x86/smm/Makefile.mk +++ b/src/cpu/x86/smm/Makefile.mk @@ -43,6 +43,7 @@ smmstub-y += smm_stub.S
smm-y += smm_module_handler.c +smm-y += smm_module_handler_entry.S
ramstage-srcs += $(obj)/cpu/x86/smm/smmstub.manual
diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c index d25b5f4..03da480 100644 --- a/src/cpu/x86/smm/smm_module_handler.c +++ b/src/cpu/x86/smm/smm_module_handler.c @@ -209,8 +209,6 @@ } #endif
-RMODULE_ENTRY(smm_handler_start); - /* Provide a default implementation for all weak handlers so that relocation * entries in the modules make sense. Without default implementations the * weak relocations w/o a symbol have a 0 address which is where the modules diff --git a/src/cpu/x86/smm/smm_module_handler_entry.S b/src/cpu/x86/smm/smm_module_handler_entry.S new file mode 100644 index 0000000..0991851 --- /dev/null +++ b/src/cpu/x86/smm/smm_module_handler_entry.S @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +/* + * The stub is a generic wrapper for bootstrapping a C-based SMM handler. Its + * primary purpose is to put the CPU into protected mode with a stack and call + * into the C handler. + * + * The stub_entry_params structure needs to correspond to the C structure + * found in smm.h. + */ + +#include <cpu/x86/cr.h> + +.text +.extern smm_handler_start +.global _start +_start: + +#if ENV_X86_64 +.code64 + /* Use rmodule's page tables */ + movabs $PML4E, %rax + mov %rax, %cr3 + jmp smm_handler_start +#else +.code32 + jmp smm_handler_start +#endif