[PATCH V3 2/4] HV: enable #AC for Splitlock Access #ac


Tao, Yuhong
 

If CPU support rise #AC for Splitlock Access, then enable this
feature at each CPU.

Tracked-On: #4496
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
---
hypervisor/arch/x86/cpu.c | 15 +++++++++++++++
hypervisor/include/arch/x86/msr.h | 1 +
2 files changed, 16 insertions(+)

diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c
index 384587c..0c61d0c 100644
--- a/hypervisor/arch/x86/cpu.c
+++ b/hypervisor/arch/x86/cpu.c
@@ -98,6 +98,17 @@ uint64_t get_active_pcpu_bitmap(void)
return pcpu_active_bitmap;
}

+static void enable_ac_for_splitlock(void)
+{
+ uint64_t test_ctl;
+
+ if(has_core_cap(1U << 5U)) {
+ test_ctl = msr_read(MSR_TEST_CTL);
+ test_ctl |= (1U<<29U);
+ msr_write(MSR_TEST_CTL, test_ctl);
+ }
+}
+
void init_pcpu_pre(bool is_bsp)
{
uint16_t pcpu_id;
@@ -112,6 +123,8 @@ void init_pcpu_pre(bool is_bsp)
*/
init_pcpu_capabilities();

+ enable_ac_for_splitlock();
+
if (detect_hardware_support() != 0) {
panic("hardware not support!");
}
@@ -166,6 +179,8 @@ void init_pcpu_pre(bool is_bsp)
*/
pci_switch_to_mmio_cfg_ops();
} else {
+ enable_ac_for_splitlock();
+
/* Switch this CPU to use the same page tables set-up by the
* primary/boot CPU
*/
diff --git a/hypervisor/include/arch/x86/msr.h b/hypervisor/include/arch/x86/msr.h
index 39c161f..d311f8d 100644
--- a/hypervisor/include/arch/x86/msr.h
+++ b/hypervisor/include/arch/x86/msr.h
@@ -18,6 +18,7 @@
#define MSR_IA32_TIME_STAMP_COUNTER 0x00000010U
#define MSR_IA32_PLATFORM_ID 0x00000017U
#define MSR_IA32_APIC_BASE 0x0000001BU
+#define MSR_TEST_CTL 0x00000033U
#define MSR_IA32_FEATURE_CONTROL 0x0000003AU
#define MSR_IA32_TSC_ADJUST 0x0000003BU
/* Speculation Control */
--
2.7.4