summaryrefslogtreecommitdiffstats
path: root/src/cpu/x86/smm/smm_module_loader.c
diff options
context:
space:
mode:
authorEugene Myers <edmyers@tycho.nsa.gov>2020-01-21 17:01:47 -0500
committerPatrick Georgi <pgeorgi@google.com>2021-02-22 07:33:43 +0000
commitbff4cb055875e59bf436de5ca4f5c5666626abaf (patch)
tree2a5c912f2a3c41154a66eb4f11c22c5b3dd7b683 /src/cpu/x86/smm/smm_module_loader.c
parent2085d6f46ad54d7148de38ddd0d183911c2732cc (diff)
downloadcoreboot-bff4cb055875e59bf436de5ca4f5c5666626abaf.tar.gz
coreboot-bff4cb055875e59bf436de5ca4f5c5666626abaf.tar.bz2
coreboot-bff4cb055875e59bf436de5ca4f5c5666626abaf.zip
security/intel/stm: Add STM support
This update is a combination of all four of the patches so that the commit can be done without breaking parts of coreboot. This possible breakage is because of the cross-dependencies between the original separate patches would cause failure because of data structure changes. security/intel/stm This directory contains the functions that check and move the STM to the MSEG, create its page tables, and create the BIOS resource list. The STM page tables is a six page region located in the MSEG and are pointed to by the CR3 Offset field in the MSEG header. The initial page tables will identity map all memory between 0-4G. The STM starts in IA32e mode, which requires page tables to exist at startup. The BIOS resource list defines the resources that the SMI Handler is allowed to access. This includes the SMM memory area where the SMI handler resides and other resources such as I/O devices. The STM uses the BIOS resource list to restrict the SMI handler's accesses. The BIOS resource list is currently located in the same area as the SMI handler. This location is shown in the comment section before smm_load_module in smm_module_loader.c Note: The files within security/intel/stm come directly from their Tianocore counterparts. Unnecessary code has been removed and the remaining code has been converted to meet coreboot coding requirements. For more information see: SMI Transfer Monitor (STM) User Guide, Intel Corp., August 2015, Rev 1.0, can be found at firmware.intel.com include/cpu/x86: Addtions to include/cpu/x86 for STM support. cpu/x86: STM Set up - The STM needs to be loaded into the MSEG during BIOS initialization and the SMM Monitor Control MSR be set to indicate that an STM is in the system. cpu/x86/smm: SMI module loader modifications needed to set up the SMM descriptors used by the STM during its initialization Original-Change-Id: If4adcd92c341162630ce1ec357ffcf8a135785ec Original-Signed-off-by: Eugene D. Myers <edmyers@tycho.nsa.gov> Original-Reviewed-on: https://review.coreboot.org/c/coreboot/+/33234 Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Original-Reviewed-by: Patrick Georgi <pgeorgi@google.com> Original-Reviewed-by: ron minnich <rminnich@gmail.com> (cherry picked from commit ae438be57856e994774ec0e2521d49f1ad09bd6f) Signed-off-by: Marc Jones <marcjones@sysproconsulting.com> Change-Id: Ic0131fcada9f43c9817c8a0a942d0419c7023130 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50308 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/cpu/x86/smm/smm_module_loader.c')
-rw-r--r--src/cpu/x86/smm/smm_module_loader.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c
index c6c6b3873769..a421436893fa 100644
--- a/src/cpu/x86/smm/smm_module_loader.c
+++ b/src/cpu/x86/smm/smm_module_loader.c
@@ -17,6 +17,7 @@
#include <cpu/x86/cache.h>
#include <commonlib/helpers.h>
#include <console/console.h>
+#include <security/intel/stm/SmmStm.h>
#define FXSAVE_SIZE 512
@@ -267,6 +268,7 @@ static int smm_module_setup_stub(void *smbase, struct smm_loader_params *params,
stub_params->fxsave_area_size = FXSAVE_SIZE;
stub_params->runtime.smbase = (uintptr_t)smbase;
stub_params->runtime.save_state_size = params->per_cpu_save_state_size;
+ stub_params->runtime.num_cpus = params->num_concurrent_stacks;
/* Initialize the APIC id to CPU number table to be 1:1 */
for (i = 0; i < params->num_concurrent_stacks; i++)
@@ -313,6 +315,11 @@ int smm_setup_relocation_handler(struct smm_loader_params *params)
* +-----------------+ <- smram + size
* | stacks |
* +-----------------+ <- smram + size - total_stack_size
+ * | fxsave area |
+ * +-----------------+ <- smram + size - total_stack_size - fxsave_size
+ * | BIOS resource |
+ * | list (STM) |
+ * +-----------------+ <- .. - CONFIG_BIOS_RESOURCE_LIST_SIZE
* | ... |
* +-----------------+ <- smram + handler_size + SMM_DEFAULT_SIZE
* | handler |
@@ -353,7 +360,12 @@ int smm_load_module(void *smram, size_t size, struct smm_loader_params *params)
/* Stacks start at the top of the region. */
base = smram;
- base += size;
+
+ if (CONFIG(STM))
+ base += size - CONFIG_MSEG_SIZE; // take out the mseg
+ else
+ base += size;
+
params->stack_top = base;
/* SMM module starts at offset SMM_DEFAULT_SIZE with the load alignment
@@ -382,6 +394,11 @@ int smm_load_module(void *smram, size_t size, struct smm_loader_params *params)
/* Does the required amount of memory exceed the SMRAM region size? */
total_size = total_stack_size + handler_size;
total_size += fxsave_size + SMM_DEFAULT_SIZE;
+
+ // account for the bios resource list
+ if (CONFIG(STM))
+ total_size += CONFIG_BIOS_RESOURCE_LIST_SIZE;
+
if (total_size > size)
return -1;