Skip to content

Commit c363d95

Browse files
dmatlackbonzini
authored andcommitted
KVM: selftests: Add a helper to check EPT/VPID capabilities
Create a small helper function to check if a given EPT/VPID capability is supported. This will be re-used in a follow-up commit to check for 1G page support. No functional change intended. Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: David Matlack <dmatlack@google.com> Message-Id: <20220520233249.3776001-7-dmatlack@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent b6c086d commit c363d95

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • tools/testing/selftests/kvm/lib/x86_64

tools/testing/selftests/kvm/lib/x86_64/vmx.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ bool load_vmcs(struct vmx_pages *vmx)
198198
return true;
199199
}
200200

201+
static bool ept_vpid_cap_supported(uint64_t mask)
202+
{
203+
return rdmsr(MSR_IA32_VMX_EPT_VPID_CAP) & mask;
204+
}
205+
201206
/*
202207
* Initialize the control fields to the most basic settings possible.
203208
*/
@@ -215,7 +220,7 @@ static inline void init_vmcs_control_fields(struct vmx_pages *vmx)
215220
struct eptPageTablePointer eptp = {
216221
.memory_type = VMX_BASIC_MEM_TYPE_WB,
217222
.page_walk_length = 3, /* + 1 */
218-
.ad_enabled = !!(rdmsr(MSR_IA32_VMX_EPT_VPID_CAP) & VMX_EPT_VPID_CAP_AD_BITS),
223+
.ad_enabled = ept_vpid_cap_supported(VMX_EPT_VPID_CAP_AD_BITS),
219224
.address = vmx->eptp_gpa >> PAGE_SHIFT_4K,
220225
};
221226

0 commit comments

Comments
 (0)