coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
SmmStm.c File Reference
#include <console/console.h>
#include <cpu/x86/cr.h>
#include <cpu/x86/mp.h>
#include <cpu/x86/msr.h>
#include <cpu/x86/cache.h>
#include <security/intel/stm/SmmStm.h>
#include <stdbool.h>
#include <string.h>
Include dependency graph for SmmStm.c:

Go to the source code of this file.

Data Structures

struct  VMX_BASIC_MSR_BITS
 
union  VMX_BASIC_MSR
 
struct  SMM_MONITOR_CTL_MSR_BITS
 
struct  mp_state
 
union  SMM_MONITOR_CTL_MSR
 

Macros

#define TXT_EVTYPE_BASE   0x400
 
#define TXT_EVTYPE_STM_HASH   (TXT_EVTYPE_BASE + 14)
 
#define RDWR_ACCS   3
 
#define FULL_ACCS   7
 
#define SIZE_4KB   0x00001000
 
#define SIZE_4MB   0x00400000
 
#define PTP_SIZE   SIZE_4KB
 
#define IA32_PG_P   (1 << 0)
 
#define IA32_PG_RW   (1 << 1)
 
#define IA32_PG_PS   (1 << 7)
 
#define STM_PAGE_SHIFT   12
 
#define STM_PAGE_MASK   0xFFF
 
#define STM_SIZE_TO_PAGES(a)    (((a) >> STM_PAGE_SHIFT) + (((a)&STM_PAGE_MASK) ? 1 : 0))
 
#define STM_PAGES_TO_SIZE(a)   ((a) << STM_PAGE_SHIFT)
 
#define STM_ACCESS_DENIED   15
 
#define STM_UNSUPPORTED   3
 
#define STM_BUFFER_TOO_SMALL   1
 
#define STM_SM_MONITOR_STATE_ENABLED   1
 

Functions

static bool handle_single_resource (STM_RSC *resource, STM_RSC *record)
 
static void add_single_resource (STM_RSC *resource)
 
static void add_resource (STM_RSC *resource_list, uint32_t num_entries)
 
static bool validate_resource (STM_RSC *resource_list, uint32_t num_entries)
 
static uint32_t get_resource_size (STM_RSC *resource_list, uint32_t num_entries)
 
int add_pi_resource (STM_RSC *resource_list, uint32_t num_entries)
 
int32_t delete_pi_resource (STM_RSC *resource_list, uint32_t num_entries)
 
int32_t get_pi_resource (STM_RSC *resource_list, uint32_t *resource_size)
 
static uint32_t get_vmcs_size (void)
 
void stm_gen_4g_pagetable_x64 (uint32_t pagetable_base)
 
bool stm_check_stm_image (void *stm_image, uint32_t stm_imagesize)
 
voidget_stm_resource (void)
 

Variables

struct mp_state mp_state
 
STM_RSC_END m_rsc_end_node
 
uint8_tm_stm_resources_ptr = NULL
 
uint32_t m_stm_resource_total_size = 0x0
 
uint32_t m_stm_resource_size_used = 0x0
 
uint32_t m_stm_resource_size_available = 0x0
 
uint8_tstm_resource_heap = NULL
 
uint32_t m_stm_state = 0
 

Macro Definition Documentation

◆ FULL_ACCS

#define FULL_ACCS   7

Definition at line 16 of file SmmStm.c.

◆ IA32_PG_P

#define IA32_PG_P   (1 << 0)

Definition at line 23 of file SmmStm.c.

◆ IA32_PG_PS

#define IA32_PG_PS   (1 << 7)

Definition at line 25 of file SmmStm.c.

◆ IA32_PG_RW

#define IA32_PG_RW   (1 << 1)

Definition at line 24 of file SmmStm.c.

◆ PTP_SIZE

#define PTP_SIZE   SIZE_4KB

Definition at line 21 of file SmmStm.c.

◆ RDWR_ACCS

#define RDWR_ACCS   3

Definition at line 15 of file SmmStm.c.

◆ SIZE_4KB

#define SIZE_4KB   0x00001000

Definition at line 18 of file SmmStm.c.

◆ SIZE_4MB

#define SIZE_4MB   0x00400000

Definition at line 19 of file SmmStm.c.

◆ STM_ACCESS_DENIED

#define STM_ACCESS_DENIED   15

Definition at line 33 of file SmmStm.c.

◆ STM_BUFFER_TOO_SMALL

#define STM_BUFFER_TOO_SMALL   1

Definition at line 36 of file SmmStm.c.

◆ STM_PAGE_MASK

#define STM_PAGE_MASK   0xFFF

Definition at line 28 of file SmmStm.c.

◆ STM_PAGE_SHIFT

#define STM_PAGE_SHIFT   12

Definition at line 27 of file SmmStm.c.

◆ STM_PAGES_TO_SIZE

#define STM_PAGES_TO_SIZE (   a)    ((a) << STM_PAGE_SHIFT)

Definition at line 31 of file SmmStm.c.

◆ STM_SIZE_TO_PAGES

#define STM_SIZE_TO_PAGES (   a)     (((a) >> STM_PAGE_SHIFT) + (((a)&STM_PAGE_MASK) ? 1 : 0))

Definition at line 29 of file SmmStm.c.

◆ STM_SM_MONITOR_STATE_ENABLED

#define STM_SM_MONITOR_STATE_ENABLED   1

Definition at line 38 of file SmmStm.c.

◆ STM_UNSUPPORTED

#define STM_UNSUPPORTED   3

Definition at line 34 of file SmmStm.c.

◆ TXT_EVTYPE_BASE

#define TXT_EVTYPE_BASE   0x400

Definition at line 12 of file SmmStm.c.

◆ TXT_EVTYPE_STM_HASH

#define TXT_EVTYPE_STM_HASH   (TXT_EVTYPE_BASE + 14)

Definition at line 13 of file SmmStm.c.

Function Documentation

◆ add_pi_resource()

int add_pi_resource ( STM_RSC resource_list,
uint32_t  num_entries 
)

Definition at line 470 of file SmmStm.c.

References add_resource(), BIOS_DEBUG, get_resource_size(), m_rsc_end_node, m_stm_resource_size_available, m_stm_resource_size_used, m_stm_resource_total_size, m_stm_resources_ptr, memcpy(), memset(), NULL, printk, stm_resource_heap, validate_resource(), and wbinvd().

Referenced by add_msr_resources(), and add_simple_resources().

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

◆ add_resource()

static void add_resource ( STM_RSC resource_list,
uint32_t  num_entries 
)
static

Definition at line 276 of file SmmStm.c.

References add_single_resource(), count, and END_OF_RESOURCES.

Referenced by add_pi_resource().

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

◆ add_single_resource()

static void add_single_resource ( STM_RSC resource)
static

Definition at line 234 of file SmmStm.c.

References END_OF_RESOURCES, handle_single_resource(), STM_RSC::header, STM_RSC_DESC_HEADER::length, m_rsc_end_node, m_stm_resource_size_available, m_stm_resource_size_used, m_stm_resource_total_size, m_stm_resources_ptr, memcpy(), and STM_RSC_DESC_HEADER::rsc_type.

Referenced by add_resource().

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

◆ delete_pi_resource()

int32_t delete_pi_resource ( STM_RSC resource_list,
uint32_t  num_entries 
)

Definition at line 523 of file SmmStm.c.

References m_rsc_end_node, m_stm_resource_size_available, m_stm_resource_size_used, m_stm_resource_total_size, m_stm_resources_ptr, memcpy(), and NULL.

Here is the call graph for this function:

◆ get_pi_resource()

int32_t get_pi_resource ( STM_RSC resource_list,
uint32_t resource_size 
)

Definition at line 551 of file SmmStm.c.

References m_stm_resource_size_used, m_stm_resources_ptr, and memcpy().

Here is the call graph for this function:

◆ get_resource_size()

static uint32_t get_resource_size ( STM_RSC resource_list,
uint32_t  num_entries 
)
static

Definition at line 431 of file SmmStm.c.

References count, and END_OF_RESOURCES.

Referenced by add_pi_resource().

Here is the caller graph for this function:

◆ get_stm_resource()

void* get_stm_resource ( void  )

Definition at line 675 of file SmmStm.c.

References m_stm_resources_ptr.

Referenced by setup_smm_descriptor().

Here is the caller graph for this function:

◆ get_vmcs_size()

static uint32_t get_vmcs_size ( void  )
static

Definition at line 567 of file SmmStm.c.

References BIOS_DEBUG, VMX_BASIC_MSR::bits, IA32_VMX_BASIC_MSR, VMX_BASIC_MSR::msr, printk, rdmsr(), STM_PAGES_TO_SIZE, STM_SIZE_TO_PAGES, VMX_BASIC_MSR_BITS::stm_supported, and VMX_BASIC_MSR_BITS::vmcs_size.

Referenced by stm_check_stm_image().

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

◆ handle_single_resource()

◆ stm_check_stm_image()

bool stm_check_stm_image ( void stm_image,
uint32_t  stm_imagesize 
)

◆ stm_gen_4g_pagetable_x64()

void stm_gen_4g_pagetable_x64 ( uint32_t  pagetable_base)

Definition at line 592 of file SmmStm.c.

References IA32_PG_P, IA32_PG_PS, IA32_PG_RW, PTP_SIZE, and SIZE_4KB.

Referenced by load_stm_image().

Here is the caller graph for this function:

◆ validate_resource()

static bool validate_resource ( STM_RSC resource_list,
uint32_t  num_entries 
)
static

Definition at line 308 of file SmmStm.c.

References resource::base, BIOS_DEBUG, count, END_OF_RESOURCES, FULL_ACCS, IO_RANGE, MACHINE_SPECIFIC_REG, MEM_RANGE, MMIO_RANGE, PCI_CFG_RANGE, printk, and TRAPPED_IO_RANGE.

Referenced by add_pi_resource().

Here is the caller graph for this function:

Variable Documentation

◆ m_rsc_end_node

STM_RSC_END m_rsc_end_node
Initial value:
= {
}
#define END_OF_RESOURCES
Definition: StmApi.h:325

Definition at line 86 of file SmmStm.c.

Referenced by add_pi_resource(), add_single_resource(), and delete_pi_resource().

◆ m_stm_resource_size_available

uint32_t m_stm_resource_size_available = 0x0

Definition at line 93 of file SmmStm.c.

Referenced by add_pi_resource(), add_single_resource(), and delete_pi_resource().

◆ m_stm_resource_size_used

uint32_t m_stm_resource_size_used = 0x0

Definition at line 92 of file SmmStm.c.

Referenced by add_pi_resource(), add_single_resource(), delete_pi_resource(), and get_pi_resource().

◆ m_stm_resource_total_size

uint32_t m_stm_resource_total_size = 0x0

Definition at line 91 of file SmmStm.c.

Referenced by add_pi_resource(), add_single_resource(), and delete_pi_resource().

◆ m_stm_resources_ptr

◆ m_stm_state

uint32_t m_stm_state = 0

Definition at line 97 of file SmmStm.c.

◆ mp_state

◆ stm_resource_heap

uint8_t* stm_resource_heap = NULL

Definition at line 95 of file SmmStm.c.

Referenced by add_pi_resource(), and stm_setup().