From ed6fe2f64b37d0c6161b23b20980f91e0be7a1ea Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Wed, 14 Dec 2016 16:12:43 -0600 Subject: cpu/intel/common: Add/Use common function to set virtualization Migrate duplicated enable_vmx() method from multiple CPUs to common folder. Add common virtualization option for CPUs which support it. Note that this changes the default to enable virtualization on CPUs that support it. Change-Id: Ib110bed6c9f5508e3f867dcdc6f341fc50e501d1 Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/17874 Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) --- src/cpu/intel/fsp_model_206ax/Kconfig | 5 +-- src/cpu/intel/fsp_model_206ax/Makefile.inc | 1 + src/cpu/intel/fsp_model_206ax/model_206ax_init.c | 42 ++---------------------- 3 files changed, 5 insertions(+), 43 deletions(-) (limited to 'src/cpu/intel/fsp_model_206ax') diff --git a/src/cpu/intel/fsp_model_206ax/Kconfig b/src/cpu/intel/fsp_model_206ax/Kconfig index 030c863e4b..878244861c 100644 --- a/src/cpu/intel/fsp_model_206ax/Kconfig +++ b/src/cpu/intel/fsp_model_206ax/Kconfig @@ -37,6 +37,7 @@ config CPU_SPECIFIC_OPTIONS select PARALLEL_CPU_INIT select TSC_SYNC_MFENCE select LAPIC_MONOTONIC_TIMER + select CPU_INTEL_COMMON config BOOTBLOCK_CPU_INIT string @@ -46,8 +47,4 @@ config SMM_TSEG_SIZE hex default 0x800000 -config ENABLE_VMX - bool "Enable VMX for virtualization" - default n - endif diff --git a/src/cpu/intel/fsp_model_206ax/Makefile.inc b/src/cpu/intel/fsp_model_206ax/Makefile.inc index d2d61ef883..65498f8652 100644 --- a/src/cpu/intel/fsp_model_206ax/Makefile.inc +++ b/src/cpu/intel/fsp_model_206ax/Makefile.inc @@ -1,6 +1,7 @@ ramstage-y += model_206ax_init.c subdirs-y += ../../x86/name subdirs-y += ../smm/gen1 +subdirs-y += ../common ramstage-y += acpi.c diff --git a/src/cpu/intel/fsp_model_206ax/model_206ax_init.c b/src/cpu/intel/fsp_model_206ax/model_206ax_init.c index 6789baedcf..1b3004c135 100644 --- a/src/cpu/intel/fsp_model_206ax/model_206ax_init.c +++ b/src/cpu/intel/fsp_model_206ax/model_206ax_init.c @@ -32,43 +32,7 @@ #include "model_206ax.h" #include "chip.h" #include - -static void enable_vmx(void) -{ - struct cpuid_result regs; - msr_t msr; - int enable = IS_ENABLED(CONFIG_ENABLE_VMX); - - regs = cpuid(1); - /* Check that the VMX is supported before reading or writing the MSR. */ - if (!((regs.ecx & CPUID_VMX) || (regs.ecx & CPUID_SMX))) - return; - - msr = rdmsr(IA32_FEATURE_CONTROL); - - if (msr.lo & (1 << 0)) { - printk(BIOS_ERR, "VMX is locked, so %s will do nothing\n", __func__); - /* VMX locked. If we set it again we get an illegal - * instruction - */ - return; - } - - /* The IA32_FEATURE_CONTROL MSR may initialize with random values. - * It must be cleared regardless of VMX config setting. - */ - msr.hi = msr.lo = 0; - - printk(BIOS_DEBUG, "%s VMX\n", enable ? "Enabling" : "Disabling"); - - if (enable) { - msr.lo |= (1 << 2); - if (regs.ecx & CPUID_SMX) - msr.lo |= (1 << 1); - } - - wrmsr(IA32_FEATURE_CONTROL, msr); -} +#include /* Convert time in seconds to POWER_LIMIT_1_TIME MSR value */ static const u8 power_limit_time_sec_to_msr[] = { @@ -390,8 +354,8 @@ static void model_206ax_init(struct device *cpu) enable_lapic_tpr(); setup_lapic(); - /* Enable virtualization if Kconfig option is set */ - enable_vmx(); + /* Set virtualization based on Kconfig option */ + set_vmx(); /* Configure Enhanced SpeedStep and Thermal Sensors */ configure_misc(); -- cgit v1.2.3