@@ -844,6 +844,12 @@ static inline bool is_invept_type_supported(u64 type)
return ept_vpid.val & (EPT_CAP_INVEPT_SINGLE << (type - INVEPT_SINGLE));
}
+static inline bool is_vpid_supported(void)
+{
+ return (ctrl_cpu_rev[0].clr & CPU_SECONDARY) &&
+ (ctrl_cpu_rev[1].clr & CPU_VPID);
+}
+
static inline bool is_invvpid_supported(void)
{
return ept_vpid.val & VPID_CAP_INVVPID;
@@ -3304,8 +3304,7 @@ static void invvpid_test(void)
unsigned types = 0;
unsigned type;
- if (!(ctrl_cpu_rev[0].clr & CPU_SECONDARY) ||
- !(ctrl_cpu_rev[1].clr & CPU_VPID))
+ if (!is_vpid_supported())
test_skip("VPID not supported");
if (!is_invvpid_supported())
@@ -4099,8 +4098,7 @@ static void test_vpid(void)
u16 vpid = 0x0000;
int i;
- if (!((ctrl_cpu_rev[0].clr & CPU_SECONDARY) &&
- (ctrl_cpu_rev[1].clr & CPU_VPID))) {
+ if (!is_vpid_supported()) {
printf("Secondary controls and/or VPID not supported\n");
return;
}
Add a helper to check for VPID support to deduplicate code, now and in the future. Signed-off-by: Sean Christopherson <seanjc@google.com> --- x86/vmx.h | 6 ++++++ x86/vmx_tests.c | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-)