diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cpu/x86/smm/smm_module_handler.c | 6 | ||||
-rw-r--r-- | src/cpu/x86/smm/smm_module_loader.c | 17 | ||||
-rw-r--r-- | src/drivers/smmstore/ramstage.c | 38 | ||||
-rw-r--r-- | src/drivers/smmstore/smi.c | 25 | ||||
-rw-r--r-- | src/drivers/smmstore/store.c | 13 | ||||
-rw-r--r-- | src/include/cpu/x86/smm.h | 4 | ||||
-rw-r--r-- | src/include/smmstore.h | 2 |
7 files changed, 45 insertions, 60 deletions
diff --git a/src/cpu/x86/smm/smm_module_handler.c b/src/cpu/x86/smm/smm_module_handler.c index 0daae00ebb..6322e59beb 100644 --- a/src/cpu/x86/smm/smm_module_handler.c +++ b/src/cpu/x86/smm/smm_module_handler.c @@ -60,6 +60,12 @@ int get_console_loglevel(void) } #endif +void smm_get_smmstore_com_buffer(uintptr_t *base, size_t *size) +{ + *base = smm_runtime.smmstore_com_buffer_base; + *size = smm_runtime.smmstore_com_buffer_size; +} + void smm_get_cbmemc_buffer(void **buffer_out, size_t *size_out) { *buffer_out = smm_runtime.cbmemc; diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index ea51d63e83..646f3bb551 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -10,6 +10,7 @@ #include <device/device.h> #include <device/mmio.h> #include <rmodule.h> +#include <smmstore.h> #include <stdio.h> #include <string.h> #include <types.h> @@ -350,6 +351,22 @@ static void setup_smihandler_params(struct smm_runtime *mod_params, if (CONFIG(SMM_PCI_RESOURCE_STORE)) smm_pci_resource_store_init(mod_params); + + if (CONFIG(SMMSTORE_V2)) { + struct smmstore_params_info info; + if (smmstore_get_info(&info) < 0) { + printk(BIOS_INFO, "SMMSTORE: Failed to get meta data\n"); + return; + } + + void *ptr = cbmem_add(CBMEM_ID_SMM_COMBUFFER, info.block_size); + if (!ptr) { + printk(BIOS_ERR, "SMMSTORE: Failed to add com buffer\n"); + return; + } + mod_params->smmstore_com_buffer_base = (uintptr_t)ptr; + mod_params->smmstore_com_buffer_size = info.block_size; + } } static void print_region(const char *name, const struct region region) diff --git a/src/drivers/smmstore/ramstage.c b/src/drivers/smmstore/ramstage.c index e59090dad3..e897aa2d67 100644 --- a/src/drivers/smmstore/ramstage.c +++ b/src/drivers/smmstore/ramstage.c @@ -10,8 +10,6 @@ #include <types.h> #include <cbmem.h> -static struct smmstore_params_info info; - void lb_smmstorev2(struct lb_header *header) { struct lb_record *rec; @@ -22,6 +20,9 @@ void lb_smmstorev2(struct lb_header *header) if (!e) return; + struct smmstore_params_info info; + smmstore_get_info(&info); + rec = lb_new_record(header); store = (struct lb_smmstorev2 *)rec; @@ -34,36 +35,3 @@ void lb_smmstorev2(struct lb_header *header) store->block_size = info.block_size; store->apm_cmd = APM_CNT_SMMSTORE; } - -static void init_store(void *unused) -{ - struct smmstore_params_init args; - uint32_t ret = ~0; - - if (smmstore_get_info(&info) < 0) { - printk(BIOS_INFO, "SMMSTORE: Failed to get meta data\n"); - return; - } - - void *ptr = cbmem_add(CBMEM_ID_SMM_COMBUFFER, info.block_size); - if (!ptr) { - printk(BIOS_ERR, "SMMSTORE: Failed to add com buffer\n"); - return; - } - - args.com_buffer = (uintptr_t)ptr; - args.com_buffer_size = info.block_size; - - printk(BIOS_INFO, "SMMSTORE: Setting up SMI handler\n"); - - /* Issue SMI using APM to update the com buffer and to lock the SMMSTORE */ - ret = call_smm(APM_CNT_SMMSTORE, SMMSTORE_CMD_INIT, &args); - - if (ret != SMMSTORE_RET_SUCCESS) { - printk(BIOS_ERR, "SMMSTORE: Failed to install com buffer\n"); - return; - } -} - -/* The SMI APM handler is installed at DEV_INIT phase */ -BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_EXIT, init_store, NULL); diff --git a/src/drivers/smmstore/smi.c b/src/drivers/smmstore/smi.c index 6ea447ffe6..4f7b4bdac0 100644 --- a/src/drivers/smmstore/smi.c +++ b/src/drivers/smmstore/smi.c @@ -78,24 +78,19 @@ static uint32_t smmstorev1_exec(uint8_t command, void *param) static uint32_t smmstorev2_exec(uint8_t command, void *param) { uint32_t ret = SMMSTORE_RET_FAILURE; + static bool initialized = false; - switch (command) { - case SMMSTORE_CMD_INIT: { - printk(BIOS_DEBUG, "Init SMM store\n"); - struct smmstore_params_init *params = param; - - if (range_check(params, sizeof(*params)) != 0) - break; - - void *buf = (void *)(uintptr_t)params->com_buffer; + if (!initialized) { + uintptr_t base; + size_t size; + smm_get_smmstore_com_buffer(&base, &size); - if (range_check(buf, params->com_buffer_size) != 0) - break; - - if (smmstore_init(buf, params->com_buffer_size) == 0) - ret = SMMSTORE_RET_SUCCESS; - break; + if (smmstore_init((void *)base, size)) + return SMMSTORE_RET_FAILURE; + initialized = true; } + + switch (command) { case SMMSTORE_CMD_RAW_READ: { printk(BIOS_DEBUG, "Raw read from SMM store, param = %p\n", param); struct smmstore_params_raw_read *params = param; diff --git a/src/drivers/smmstore/store.c b/src/drivers/smmstore/store.c index bc3dcdccac..fd9cdf596f 100644 --- a/src/drivers/smmstore/store.c +++ b/src/drivers/smmstore/store.c @@ -1,11 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include <boot_device.h> -#include <fmap.h> -#include <fmap_config.h> #include <commonlib/helpers.h> #include <commonlib/region.h> #include <console/console.h> +#include <cpu/x86/smm.h> +#include <fmap.h> +#include <fmap_config.h> #include <smmstore.h> #include <types.h> @@ -283,14 +284,10 @@ int smmstore_clear_region(void) /* Implementation of Version 2 */ -static bool store_initialized; static struct region_device mdev_com_buf; static int smmstore_rdev_chain(struct region_device *rdev) { - if (!store_initialized) - return -1; - return rdev_chain_full(rdev, &mdev_com_buf); } @@ -303,13 +300,11 @@ int smmstore_init(void *buf, size_t len) if (!buf || len < SMM_BLOCK_SIZE) return -1; - if (store_initialized) + if (smm_points_to_smram(buf, len)) return -1; rdev_chain_mem_rw(&mdev_com_buf, buf, len); - store_initialized = true; - return 0; } diff --git a/src/include/cpu/x86/smm.h b/src/include/cpu/x86/smm.h index a12065b90b..44a1086e4f 100644 --- a/src/include/cpu/x86/smm.h +++ b/src/include/cpu/x86/smm.h @@ -93,6 +93,8 @@ struct smm_runtime { #endif uintptr_t save_state_top[CONFIG_MAX_CPUS]; int smm_log_level; + uintptr_t smmstore_com_buffer_base; + size_t smmstore_com_buffer_size; } __packed; struct smm_module_params { @@ -231,4 +233,6 @@ bool smm_pci_resource_store_fill_resources(struct smm_pci_resource_info *slots, void smm_pci_resource_store_init(struct smm_runtime *smm_runtime); +void smm_get_smmstore_com_buffer(uintptr_t *base, size_t *size); + #endif /* CPU_X86_SMM_H */ diff --git a/src/include/smmstore.h b/src/include/smmstore.h index d3940abc3f..6805cbc069 100644 --- a/src/include/smmstore.h +++ b/src/include/smmstore.h @@ -16,7 +16,7 @@ #define SMMSTORE_CMD_APPEND 3 /* Version 2 */ -#define SMMSTORE_CMD_INIT 4 +#define SMMSTORE_CMD_INIT_DEPRECATED 4 #define SMMSTORE_CMD_RAW_READ 5 #define SMMSTORE_CMD_RAW_WRITE 6 #define SMMSTORE_CMD_RAW_CLEAR 7 |