Commit f8cd457f authored by Lai Jiangshan's avatar Lai Jiangshan Committed by Paolo Bonzini

KVM: VMX: Use ept_caps_to_lpage_level() in hardware_setup()

Using ept_caps_to_lpage_level is simpler.
Signed-off-by: default avatarLai Jiangshan <laijs@linux.alibaba.com>
Message-Id: <20211124122055.64424-9-jiangshanlai@gmail.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent cc022ae1
...@@ -7700,7 +7700,7 @@ static __init int hardware_setup(void) ...@@ -7700,7 +7700,7 @@ static __init int hardware_setup(void)
{ {
unsigned long host_bndcfgs; unsigned long host_bndcfgs;
struct desc_ptr dt; struct desc_ptr dt;
int r, ept_lpage_level; int r;
store_idt(&dt); store_idt(&dt);
host_idt_base = dt.address; host_idt_base = dt.address;
...@@ -7797,16 +7797,8 @@ static __init int hardware_setup(void) ...@@ -7797,16 +7797,8 @@ static __init int hardware_setup(void)
kvm_mmu_set_ept_masks(enable_ept_ad_bits, kvm_mmu_set_ept_masks(enable_ept_ad_bits,
cpu_has_vmx_ept_execute_only()); cpu_has_vmx_ept_execute_only());
if (!enable_ept)
ept_lpage_level = 0;
else if (cpu_has_vmx_ept_1g_page())
ept_lpage_level = PG_LEVEL_1G;
else if (cpu_has_vmx_ept_2m_page())
ept_lpage_level = PG_LEVEL_2M;
else
ept_lpage_level = PG_LEVEL_4K;
kvm_configure_mmu(enable_ept, 0, vmx_get_max_tdp_level(), kvm_configure_mmu(enable_ept, 0, vmx_get_max_tdp_level(),
ept_lpage_level); ept_caps_to_lpage_level(vmx_capability.ept));
/* /*
* Only enable PML when hardware supports PML feature, and both EPT * Only enable PML when hardware supports PML feature, and both EPT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment