From b45b22f6b217d1b7aebe2583188839e7906c0a52 Mon Sep 17 00:00:00 2001 From: Pratik Prajapati Date: Wed, 13 Sep 2017 13:45:31 -0700 Subject: soc/intel/common/sgx: Define and use soc_fill_sgx_param() To remove chip.h dependency from SGX common code - Create API soc_fill_sgx_param() and use it in sgx.c - Implement same API for skylake/kabylake - define sgx_param structure Also include intelblocks/sgx.h instead of soc/msr.h Change-Id: I358f0817bec5dd6cd147a645675b5688969a04e0 Signed-off-by: Pratik Prajapati Reviewed-on: https://review.coreboot.org/21528 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/soc/intel/common/block/sgx/sgx.c | 49 +++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'src/soc/intel/common/block/sgx/sgx.c') diff --git a/src/soc/intel/common/block/sgx/sgx.c b/src/soc/intel/common/block/sgx/sgx.c index ec1b6386df..f12bfb9955 100644 --- a/src/soc/intel/common/block/sgx/sgx.c +++ b/src/soc/intel/common/block/sgx/sgx.c @@ -15,15 +15,40 @@ #include #include -#include #include #include #include #include +#include #include #include -#include #include +#include + +static bool sgx_param_valid; +static struct sgx_param g_sgx_param; + +static const struct sgx_param *get_sgx_param(void) +{ + if (sgx_param_valid) + return &g_sgx_param; + + memset(&g_sgx_param, 0, sizeof(g_sgx_param)); + if (soc_fill_sgx_param(&g_sgx_param) < 0) { + printk(BIOS_ERR, "SGX : Failed to get soc sgx param\n"); + return NULL; + } + sgx_param_valid = true; + printk(BIOS_INFO, "SGX : param.enable = %d\n", g_sgx_param.enable); + + return &g_sgx_param; +} + +static int soc_sgx_enabled(void) +{ + const struct sgx_param *sgx_param = get_sgx_param(); + return sgx_param ? sgx_param->enable : 0; +} static int is_sgx_supported(void) { @@ -40,16 +65,8 @@ void prmrr_core_configure(void) msr_t prmrr_base; msr_t prmrr_mask; msr_t msr; - device_t dev = SA_DEV_ROOT; - assert(dev != NULL); - config_t *conf = dev->chip_info; - - if (!conf) { - printk(BIOS_ERR, "SGX: failed to get chip_info\n"); - return; - } - if (!conf->sgx_enable || !is_sgx_supported()) + if (!soc_sgx_enabled() || !is_sgx_supported()) return; /* PRMRR base and mask are read from the UNCORE PRMRR MSRs @@ -160,17 +177,9 @@ static int is_prmrr_approved(void) void sgx_configure(void) { - device_t dev = SA_DEV_ROOT; - assert(dev != NULL); - config_t *conf = dev->chip_info; const void *microcode_patch = intel_mp_current_microcode(); - if (!conf) { - printk(BIOS_ERR, "SGX: failed to get chip_info\n"); - return; - } - - if (!conf->sgx_enable || !is_sgx_supported() || !is_prmrr_set()) { + if (!soc_sgx_enabled() || !is_sgx_supported() || !is_prmrr_set()) { printk(BIOS_ERR, "SGX: pre-conditions not met\n"); return; } -- cgit v1.2.3