@@ -26,6 +26,20 @@ static int __init vt_check_processor_compatibility(void)
return 0;
}
+static __init void vt_set_ept_masks(void)
+{
+ const u64 u_mask = VMX_EPT_READABLE_MASK;
+ const u64 a_mask = enable_ept_ad_bits ? VMX_EPT_ACCESS_BIT : 0ull;
+ const u64 d_mask = enable_ept_ad_bits ? VMX_EPT_DIRTY_BIT : 0ull;
+ const u64 p_mask = cpu_has_vmx_ept_execute_only() ? 0ull :
+ VMX_EPT_READABLE_MASK;
+ const u64 x_mask = VMX_EPT_EXECUTABLE_MASK;
+ const u64 nx_mask = 0ull;
+
+ kvm_mmu_set_mask_ptes(u_mask, a_mask, d_mask, nx_mask, x_mask, p_mask,
+ VMX_EPT_RWX_MASK, 0ull);
+}
+
static __init int vt_hardware_setup(void)
{
int ret;
@@ -34,6 +48,9 @@ static __init int vt_hardware_setup(void)
if (ret)
return ret;
+ if (enable_ept)
+ vt_set_ept_masks();
+
return 0;
}
@@ -5411,16 +5411,6 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu)
}
}
-static void vmx_enable_tdp(void)
-{
- kvm_mmu_set_mask_ptes(VMX_EPT_READABLE_MASK,
- enable_ept_ad_bits ? VMX_EPT_ACCESS_BIT : 0ull,
- enable_ept_ad_bits ? VMX_EPT_DIRTY_BIT : 0ull,
- 0ull, VMX_EPT_EXECUTABLE_MASK,
- cpu_has_vmx_ept_execute_only() ? 0ull : VMX_EPT_READABLE_MASK,
- VMX_EPT_RWX_MASK, 0ull);
-}
-
/*
* Indicate a busy-waiting vcpu in spinlock. We do not enable the PAUSE
* exiting, so only get here on cpu with PAUSE-Loop-Exiting.
@@ -7602,9 +7592,6 @@ static __init int hardware_setup(struct kvm_x86_ops *x86_ops)
set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */
- if (enable_ept)
- vmx_enable_tdp();
-
if (!enable_ept)
ept_lpage_level = 0;
else if (cpu_has_vmx_ept_1g_page())