coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
smm_module_loader.c File Reference
#include <acpi/acpi_gnvs.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <rmodule.h>
#include <cbmem.h>
#include <cpu/x86/smm.h>
#include <commonlib/helpers.h>
#include <console/console.h>
#include <security/intel/stm/SmmStm.h>
Include dependency graph for smm_module_loader.c:

Go to the source code of this file.

Data Structures

struct  cpu_smm_info
 

Macros

#define FXSAVE_SIZE   512
 
#define SMM_CODE_SEGMENT_SIZE   0x10000
 
#define SMM_MINIMUM_STACK_SIZE   32
 

Functions

static int smm_create_map (uintptr_t smbase, unsigned int num_cpus, const struct smm_loader_params *params)
 
u32 smm_get_cpu_smbase (unsigned int cpu_num)
 
static int smm_place_entry_code (uintptr_t smbase, unsigned int num_cpus, uintptr_t stack_top, const struct smm_loader_params *params)
 
int smm_setup_stack (const uintptr_t perm_smbase, const size_t perm_smram_size, const unsigned int total_cpus, const size_t stack_size)
 
static int smm_stub_place_staggered_entry_points (char *base, const struct smm_loader_params *params, const struct rmodule *smm_stub)
 
static int smm_module_setup_stub (const uintptr_t smbase, const size_t smm_size, struct smm_loader_params *params, void *const fxsave_area)
 
int smm_setup_relocation_handler (struct smm_loader_params *params)
 
static int smm_load_module_aseg (const uintptr_t smram_base, const size_t smram_size, struct smm_loader_params *params)
 
int smm_load_module (const uintptr_t smram_base, const size_t smram_size, struct smm_loader_params *params)
 

Variables

static uint8_t fxsave_area_relocation [CONFIG_MAX_CPUS][FXSAVE_SIZE]
 
unsigned char _binary_smmstub_start []
 
struct cpu_smm_info cpus [CONFIG_MAX_CPUS] = { 0 }
 
static uintptr_t stack_top
 
static size_t g_stack_size
 

Macro Definition Documentation

◆ FXSAVE_SIZE

#define FXSAVE_SIZE   512

Definition at line 14 of file smm_module_loader.c.

◆ SMM_CODE_SEGMENT_SIZE

#define SMM_CODE_SEGMENT_SIZE   0x10000

Definition at line 15 of file smm_module_loader.c.

◆ SMM_MINIMUM_STACK_SIZE

#define SMM_MINIMUM_STACK_SIZE   32

Definition at line 39 of file smm_module_loader.c.

Function Documentation

◆ smm_create_map()

static int smm_create_map ( uintptr_t  smbase,
unsigned int  num_cpus,
const struct smm_loader_params params 
)
static

◆ smm_get_cpu_smbase()

u32 smm_get_cpu_smbase ( unsigned int  cpu_num)

Definition at line 159 of file smm_module_loader.c.

References cpus, and cpu_smm_info::smbase.

Referenced by smm_do_relocation().

Here is the caller graph for this function:

◆ smm_load_module()

◆ smm_load_module_aseg()

◆ smm_module_setup_stub()

◆ smm_place_entry_code()

static int smm_place_entry_code ( uintptr_t  smbase,
unsigned int  num_cpus,
uintptr_t  stack_top,
const struct smm_loader_params params 
)
static

Definition at line 196 of file smm_module_loader.c.

References BIOS_DEBUG, BIOS_ERR, BIOS_INFO, cpu_smm_info::code_end, cpu_smm_info::code_start, cpus, memcpy(), printk, SMM_ENTRY_OFFSET, and stack_top.

Referenced by smm_stub_place_staggered_entry_points().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smm_setup_relocation_handler()

int smm_setup_relocation_handler ( struct smm_loader_params params)

Definition at line 406 of file smm_module_loader.c.

References BIOS_SPEW, fxsave_area_relocation, NULL, params, printk, SMM_DEFAULT_BASE, SMM_DEFAULT_SIZE, and smm_module_setup_stub().

Here is the call graph for this function:

◆ smm_setup_stack()

int smm_setup_stack ( const uintptr_t  perm_smbase,
const size_t  perm_smram_size,
const unsigned int  total_cpus,
const size_t  stack_size 
)

Definition at line 235 of file smm_module_loader.c.

References BIOS_ERR, g_stack_size, printk, SMM_MINIMUM_STACK_SIZE, and stack_top.

Referenced by load_smm_handlers().

Here is the caller graph for this function:

◆ smm_stub_place_staggered_entry_points()

static int smm_stub_place_staggered_entry_points ( char *  base,
const struct smm_loader_params params,
const struct rmodule smm_stub 
)
static

Definition at line 259 of file smm_module_loader.c.

References base, params, rmodule_entry_offset(), smm_place_entry_code(), and stack_top.

Referenced by smm_module_setup_stub().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _binary_smmstub_start

unsigned char _binary_smmstub_start[]
extern

◆ cpus

struct cpu_smm_info cpus[CONFIG_MAX_CPUS] = { 0 }

◆ fxsave_area_relocation

uint8_t fxsave_area_relocation[CONFIG_MAX_CPUS][FXSAVE_SIZE]
static

Definition at line 19 of file smm_module_loader.c.

Referenced by smm_setup_relocation_handler().

◆ g_stack_size

size_t g_stack_size
static

Definition at line 233 of file smm_module_loader.c.

Referenced by smm_module_setup_stub(), and smm_setup_stack().

◆ stack_top