]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Simplify KVM_ENABLE_CAP helper APIs
authorSean Christopherson <seanjc@google.com>
Thu, 2 Jun 2022 20:19:09 +0000 (13:19 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 11 Jun 2022 15:46:26 +0000 (11:46 -0400)
Rework the KVM_ENABLE_CAP helpers to take the cap and arg0; literally
every current user, and likely every future user, wants to set 0 or 1
arguments and nothing else.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
16 files changed:
tools/testing/selftests/kvm/aarch64/psci_test.c
tools/testing/selftests/kvm/dirty_log_perf_test.c
tools/testing/selftests/kvm/dirty_log_test.c
tools/testing/selftests/kvm/include/kvm_util_base.h
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/lib/x86_64/vmx.c
tools/testing/selftests/kvm/x86_64/emulator_error_test.c
tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c
tools/testing/selftests/kvm/x86_64/hyperv_features.c
tools/testing/selftests/kvm/x86_64/kvm_pv_test.c
tools/testing/selftests/kvm/x86_64/max_vcpuid_cap_test.c
tools/testing/selftests/kvm/x86_64/platform_info_test.c
tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c
tools/testing/selftests/kvm/x86_64/triple_fault_event_test.c
tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c

index 024a84064f1f6989e4f8ab608ba07c336ab8af87..1a351f3f443d385f6c1c092c3c722e0d6880ecc9 100644 (file)
@@ -156,15 +156,6 @@ static void host_test_cpu_on(void)
        kvm_vm_free(vm);
 }
 
-static void enable_system_suspend(struct kvm_vm *vm)
-{
-       struct kvm_enable_cap cap = {
-               .cap = KVM_CAP_ARM_SYSTEM_SUSPEND,
-       };
-
-       vm_enable_cap(vm, &cap);
-}
-
 static void guest_test_system_suspend(void)
 {
        uint64_t ret;
@@ -183,7 +174,7 @@ static void host_test_system_suspend(void)
        struct kvm_vm *vm;
 
        vm = setup_vm(guest_test_system_suspend);
-       enable_system_suspend(vm);
+       vm_enable_cap(vm, KVM_CAP_ARM_SYSTEM_SUSPEND, 0);
 
        vcpu_power_off(vm, VCPU_ID_TARGET);
        run = vcpu_state(vm, VCPU_ID_SOURCE);
index d60a34cdfaee1fb58195c71e07cf20efbd038166..8aaa0949707a3518e4a9a984c1a0c5b10d54e1b9 100644 (file)
@@ -213,7 +213,6 @@ static void run_test(enum vm_guest_mode mode, void *arg)
        struct timespec get_dirty_log_total = (struct timespec){0};
        struct timespec vcpu_dirty_total = (struct timespec){0};
        struct timespec avg;
-       struct kvm_enable_cap cap = {};
        struct timespec clear_dirty_log_total = (struct timespec){0};
 
        vm = perf_test_create_vm(mode, nr_vcpus, guest_percpu_mem_size,
@@ -229,11 +228,9 @@ static void run_test(enum vm_guest_mode mode, void *arg)
 
        bitmaps = alloc_bitmaps(p->slots, pages_per_slot);
 
-       if (dirty_log_manual_caps) {
-               cap.cap = KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2;
-               cap.args[0] = dirty_log_manual_caps;
-               vm_enable_cap(vm, &cap);
-       }
+       if (dirty_log_manual_caps)
+               vm_enable_cap(vm, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2,
+                             dirty_log_manual_caps);
 
        arch_setup_vm(vm, nr_vcpus);
 
index 5752486764c90b37385a9a22da299fe3dd8d5b60..9dfc861a3cf3bb07f99dd54d255d831a8d5334db 100644 (file)
@@ -217,16 +217,13 @@ static bool clear_log_supported(void)
 
 static void clear_log_create_vm_done(struct kvm_vm *vm)
 {
-       struct kvm_enable_cap cap = {};
        u64 manual_caps;
 
        manual_caps = kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
        TEST_ASSERT(manual_caps, "MANUAL_CAPS is zero!");
        manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
                        KVM_DIRTY_LOG_INITIALLY_SET);
-       cap.cap = KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2;
-       cap.args[0] = manual_caps;
-       vm_enable_cap(vm, &cap);
+       vm_enable_cap(vm, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, manual_caps);
 }
 
 static void dirty_log_collect_dirty_pages(struct kvm_vm *vm, int slot,
index f0afc1dce8ba714c994afa91ff2aa91087ae6999..c9d94c9f20310b9e7fa37907bcebf2be0a1e9f5e 100644 (file)
@@ -231,13 +231,17 @@ static inline int vm_check_cap(struct kvm_vm *vm, long cap)
        return ret;
 }
 
-static inline int __vm_enable_cap(struct kvm_vm *vm, struct kvm_enable_cap *cap)
+static inline int __vm_enable_cap(struct kvm_vm *vm, uint32_t cap, uint64_t arg0)
 {
-       return __vm_ioctl(vm, KVM_ENABLE_CAP, cap);
+       struct kvm_enable_cap enable_cap = { .cap = cap, .args = { arg0 } };
+
+       return __vm_ioctl(vm, KVM_ENABLE_CAP, &enable_cap);
 }
-static inline void vm_enable_cap(struct kvm_vm *vm, struct kvm_enable_cap *cap)
+static inline void vm_enable_cap(struct kvm_vm *vm, uint32_t cap, uint64_t arg0)
 {
-       vm_ioctl(vm, KVM_ENABLE_CAP, cap);
+       struct kvm_enable_cap enable_cap = { .cap = cap, .args = { arg0 } };
+
+       vm_ioctl(vm, KVM_ENABLE_CAP, &enable_cap);
 }
 
 void vm_enable_dirty_ring(struct kvm_vm *vm, uint32_t ring_size);
@@ -363,9 +367,11 @@ void vcpu_run_complete_io(struct kvm_vm *vm, uint32_t vcpuid);
 struct kvm_reg_list *vcpu_get_reg_list(struct kvm_vm *vm, uint32_t vcpuid);
 
 static inline void vcpu_enable_cap(struct kvm_vm *vm, uint32_t vcpu_id,
-                                  struct kvm_enable_cap *cap)
+                                  uint32_t cap, uint64_t arg0)
 {
-       vcpu_ioctl(vm, vcpu_id, KVM_ENABLE_CAP, cap);
+       struct kvm_enable_cap enable_cap = { .cap = cap, .args = { arg0 } };
+
+       vcpu_ioctl(vm, vcpu_id, KVM_ENABLE_CAP, &enable_cap);
 }
 
 static inline void vcpu_set_guest_debug(struct kvm_vm *vm, uint32_t vcpuid,
index 2d82b5720737aa02a7c31c532b00e83ebedc0c6f..8f670cef6faa1fa92ed0381ac78dc278b61dfd9a 100644 (file)
@@ -85,11 +85,7 @@ int kvm_check_cap(long cap)
 
 void vm_enable_dirty_ring(struct kvm_vm *vm, uint32_t ring_size)
 {
-       struct kvm_enable_cap cap = { 0 };
-
-       cap.cap = KVM_CAP_DIRTY_LOG_RING;
-       cap.args[0] = ring_size;
-       vm_enable_cap(vm, &cap);
+       vm_enable_cap(vm, KVM_CAP_DIRTY_LOG_RING, ring_size);
        vm->dirty_ring_size = ring_size;
 }
 
index dbfca8ed79aa773020196e96f6de537516e1cfd3..a12c0e1224af7f7c5aa8b899fa4e2736d67ff4bb 100644 (file)
@@ -46,12 +46,8 @@ int vcpu_enable_evmcs(struct kvm_vm *vm, int vcpu_id)
 {
        uint16_t evmcs_ver;
 
-       struct kvm_enable_cap enable_evmcs_cap = {
-               .cap = KVM_CAP_HYPERV_ENLIGHTENED_VMCS,
-                .args[0] = (unsigned long)&evmcs_ver
-       };
-
-       vcpu_enable_cap(vm, vcpu_id, &enable_evmcs_cap);
+       vcpu_enable_cap(vm, vcpu_id, KVM_CAP_HYPERV_ENLIGHTENED_VMCS,
+                       (unsigned long)&evmcs_ver);
 
        /* KVM should return supported EVMCS version range */
        TEST_ASSERT(((evmcs_ver >> 8) >= (evmcs_ver & 0xff)) &&
index aeb3850f81bd10a6d8474de9b5bfcdb14afb9528..9c156f9cfa15401bbd944f8ef52ad4e19b354be9 100644 (file)
@@ -161,10 +161,6 @@ static uint64_t process_ucall(struct kvm_vm *vm)
 
 int main(int argc, char *argv[])
 {
-       struct kvm_enable_cap emul_failure_cap = {
-               .cap = KVM_CAP_EXIT_ON_EMULATION_FAILURE,
-               .args[0] = 1,
-       };
        struct kvm_cpuid_entry2 *entry;
        struct kvm_cpuid2 *cpuid;
        struct kvm_vm *vm;
@@ -192,7 +188,7 @@ int main(int argc, char *argv[])
 
        rc = kvm_check_cap(KVM_CAP_EXIT_ON_EMULATION_FAILURE);
        TEST_ASSERT(rc, "KVM_CAP_EXIT_ON_EMULATION_FAILURE is unavailable");
-       vm_enable_cap(vm, &emul_failure_cap);
+       vm_enable_cap(vm, KVM_CAP_EXIT_ON_EMULATION_FAILURE, 1);
 
        vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS,
                                    MEM_REGION_GPA, MEM_REGION_SLOT,
index 1f5c32146f3dcfca24b8eafa747cbcc32f4e2599..81f9f5b1f655661322fdfec1886ef0ca402ee86c 100644 (file)
@@ -140,15 +140,13 @@ static void test_fix_hypercall(void)
 
 static void test_fix_hypercall_disabled(void)
 {
-       struct kvm_enable_cap cap = {0};
        struct kvm_vm *vm;
 
        vm = vm_create_default(VCPU_ID, 0, guest_main);
        setup_ud_vector(vm);
 
-       cap.cap = KVM_CAP_DISABLE_QUIRKS2;
-       cap.args[0] = KVM_X86_QUIRK_FIX_HYPERCALL_INSN;
-       vm_enable_cap(vm, &cap);
+       vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2,
+                     KVM_X86_QUIRK_FIX_HYPERCALL_INSN);
 
        ud_expected = true;
        sync_global_to_guest(vm, ud_expected);
index 672915ce73d8f6a363b5e2ea690f3fc44e7c9b01..7ff6e4d70333215ffca020beb67e4c483436fe49 100644 (file)
@@ -182,10 +182,6 @@ static void guest_test_msrs_access(void)
        };
        struct kvm_cpuid2 *best;
        vm_vaddr_t msr_gva;
-       struct kvm_enable_cap cap = {
-               .cap = KVM_CAP_HYPERV_ENFORCE_CPUID,
-               .args = {1}
-       };
        struct msr_data *msr;
 
        while (true) {
@@ -196,7 +192,7 @@ static void guest_test_msrs_access(void)
                msr = addr_gva2hva(vm, msr_gva);
 
                vcpu_args_set(vm, VCPU_ID, 1, msr_gva);
-               vcpu_enable_cap(vm, VCPU_ID, &cap);
+               vcpu_enable_cap(vm, VCPU_ID, KVM_CAP_HYPERV_ENFORCE_CPUID, 1);
 
                vcpu_set_hv_cpuid(vm, VCPU_ID);
 
@@ -337,9 +333,7 @@ static void guest_test_msrs_access(void)
                         * Remains unavailable even with KVM_CAP_HYPERV_SYNIC2
                         * capability enabled and guest visible CPUID bit unset.
                         */
-                       cap.cap = KVM_CAP_HYPERV_SYNIC2;
-                       cap.args[0] = 0;
-                       vcpu_enable_cap(vm, VCPU_ID, &cap);
+                       vcpu_enable_cap(vm, VCPU_ID, KVM_CAP_HYPERV_SYNIC2, 0);
                        break;
                case 22:
                        feat.eax |= HV_MSR_SYNIC_AVAILABLE;
@@ -518,10 +512,6 @@ static void guest_test_hcalls_access(void)
        struct kvm_cpuid_entry2 dbg = {
                .function = HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES
        };
-       struct kvm_enable_cap cap = {
-               .cap = KVM_CAP_HYPERV_ENFORCE_CPUID,
-               .args = {1}
-       };
        vm_vaddr_t hcall_page, hcall_params;
        struct hcall_data *hcall;
        struct kvm_cpuid2 *best;
@@ -542,7 +532,7 @@ static void guest_test_hcalls_access(void)
                memset(addr_gva2hva(vm, hcall_params), 0x0, getpagesize());
 
                vcpu_args_set(vm, VCPU_ID, 2, addr_gva2gpa(vm, hcall_page), hcall_params);
-               vcpu_enable_cap(vm, VCPU_ID, &cap);
+               vcpu_enable_cap(vm, VCPU_ID, KVM_CAP_HYPERV_ENFORCE_CPUID, 1);
 
                vcpu_set_hv_cpuid(vm, VCPU_ID);
 
index 04ed975662c96ca0aa403a72c468e69e1188caa7..5eea3ac7958e707080341002c79da77884726fe0 100644 (file)
@@ -206,7 +206,6 @@ static void enter_guest(struct kvm_vm *vm)
 
 int main(void)
 {
-       struct kvm_enable_cap cap = {0};
        struct kvm_cpuid2 *best;
        struct kvm_vm *vm;
 
@@ -217,9 +216,7 @@ int main(void)
 
        vm = vm_create_default(VCPU_ID, 0, guest_main);
 
-       cap.cap = KVM_CAP_ENFORCE_PV_FEATURE_CPUID;
-       cap.args[0] = 1;
-       vcpu_enable_cap(vm, VCPU_ID, &cap);
+       vcpu_enable_cap(vm, VCPU_ID, KVM_CAP_ENFORCE_PV_FEATURE_CPUID, 1);
 
        best = kvm_get_supported_cpuid();
        clear_kvm_cpuid_features(best);
index c6fd36a31c8c4ee3e248b38b517cc6de618eb6a5..7211fd8d5d24302527b9267f1638fd2f507bf8e7 100644 (file)
@@ -14,7 +14,6 @@
 int main(int argc, char *argv[])
 {
        struct kvm_vm *vm;
-       struct kvm_enable_cap cap = { 0 };
        int ret;
 
        vm = vm_create(0);
@@ -23,21 +22,16 @@ int main(int argc, char *argv[])
        ret = vm_check_cap(vm, KVM_CAP_MAX_VCPU_ID);
 
        /* Try to set KVM_CAP_MAX_VCPU_ID beyond KVM cap */
-       cap.cap = KVM_CAP_MAX_VCPU_ID;
-       cap.args[0] = ret + 1;
-       ret = __vm_enable_cap(vm, &cap);
+       ret = __vm_enable_cap(vm, KVM_CAP_MAX_VCPU_ID, ret + 1);
        TEST_ASSERT(ret < 0,
                    "Setting KVM_CAP_MAX_VCPU_ID beyond KVM cap should fail");
 
        /* Set KVM_CAP_MAX_VCPU_ID */
-       cap.cap = KVM_CAP_MAX_VCPU_ID;
-       cap.args[0] = MAX_VCPU_ID;
-       vm_enable_cap(vm, &cap);
+       vm_enable_cap(vm, KVM_CAP_MAX_VCPU_ID, MAX_VCPU_ID);
 
 
        /* Try to set KVM_CAP_MAX_VCPU_ID again */
-       cap.args[0] = MAX_VCPU_ID + 1;
-       ret = __vm_enable_cap(vm, &cap);
+       ret = __vm_enable_cap(vm, KVM_CAP_MAX_VCPU_ID, MAX_VCPU_ID + 1);
        TEST_ASSERT(ret < 0,
                    "Setting KVM_CAP_MAX_VCPU_ID multiple times should fail");
 
index 1e89688cbbbfff47298c044d4012f26a67c930e8..e79c04581ca81ef870b31d1a64a8e5b0cc4bd2d5 100644 (file)
@@ -35,22 +35,12 @@ static void guest_code(void)
        }
 }
 
-static void set_msr_platform_info_enabled(struct kvm_vm *vm, bool enable)
-{
-       struct kvm_enable_cap cap = {};
-
-       cap.cap = KVM_CAP_MSR_PLATFORM_INFO;
-       cap.flags = 0;
-       cap.args[0] = (int)enable;
-       vm_enable_cap(vm, &cap);
-}
-
 static void test_msr_platform_info_enabled(struct kvm_vm *vm)
 {
        struct kvm_run *run = vcpu_state(vm, VCPU_ID);
        struct ucall uc;
 
-       set_msr_platform_info_enabled(vm, true);
+       vm_enable_cap(vm, KVM_CAP_MSR_PLATFORM_INFO, true);
        vcpu_run(vm, VCPU_ID);
        TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
                        "Exit_reason other than KVM_EXIT_IO: %u (%s),\n",
@@ -69,7 +59,7 @@ static void test_msr_platform_info_disabled(struct kvm_vm *vm)
 {
        struct kvm_run *run = vcpu_state(vm, VCPU_ID);
 
-       set_msr_platform_info_enabled(vm, false);
+       vm_enable_cap(vm, KVM_CAP_MSR_PLATFORM_INFO, false);
        vcpu_run(vm, VCPU_ID);
        TEST_ASSERT(run->exit_reason == KVM_EXIT_SHUTDOWN,
                        "Exit_reason other than KVM_EXIT_SHUTDOWN: %u (%s)\n",
index 84cd5e717fcf89a583ad7ae8598e9b662963ed6a..9ec6ba2ad89b5bccdcac911d9a448348a95dd4af 100644 (file)
@@ -360,7 +360,6 @@ static void test_pmu_config_disable(void (*guest_code)(void))
 {
        int r;
        struct kvm_vm *vm;
-       struct kvm_enable_cap cap = { 0 };
 
        r = kvm_check_cap(KVM_CAP_PMU_CAPABILITY);
        if (!(r & KVM_PMU_CAP_DISABLE))
@@ -368,9 +367,7 @@ static void test_pmu_config_disable(void (*guest_code)(void))
 
        vm = vm_create_without_vcpus(VM_MODE_DEFAULT, DEFAULT_GUEST_PHY_PAGES);
 
-       cap.cap = KVM_CAP_PMU_CAPABILITY;
-       cap.args[0] = KVM_PMU_CAP_DISABLE;
-       vm_enable_cap(vm, &cap);
+       vm_enable_cap(vm, KVM_CAP_PMU_CAPABILITY, KVM_PMU_CAP_DISABLE);
 
        vm_vcpu_add_default(vm, VCPU_ID, guest_code);
        vm_init_descriptor_tables(vm);
index f127f2fccca67bb10b8ed60e1977ff55384ec305..e814748bf7bad65396a045de0e706daf54b15f09 100644 (file)
@@ -82,12 +82,7 @@ static struct kvm_vm *aux_vm_create(bool with_vcpus)
 
 static int __sev_migrate_from(struct kvm_vm *dst, struct kvm_vm *src)
 {
-       struct kvm_enable_cap cap = {
-               .cap = KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM,
-               .args = { src->fd }
-       };
-
-       return __vm_enable_cap(dst, &cap);
+       return __vm_enable_cap(dst, KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM, src->fd);
 }
 
 
@@ -223,12 +218,7 @@ out:
 
 static int __sev_mirror_create(struct kvm_vm *dst, struct kvm_vm *src)
 {
-       struct kvm_enable_cap cap = {
-               .cap = KVM_CAP_VM_COPY_ENC_CONTEXT_FROM,
-               .args = { src->fd }
-       };
-
-       return __vm_enable_cap(dst, &cap);
+       return __vm_enable_cap(dst, KVM_CAP_VM_COPY_ENC_CONTEXT_FROM, src->fd);
 }
 
 
index 66378140764d35924e8084b679d90ecfe1beb1f1..68e0f1c5ec5a5e3054362631918f853458de0037 100644 (file)
@@ -46,11 +46,6 @@ int main(void)
        vm_vaddr_t vmx_pages_gva;
        struct ucall uc;
 
-       struct kvm_enable_cap cap = {
-               .cap = KVM_CAP_X86_TRIPLE_FAULT_EVENT,
-               .args = {1}
-       };
-
        if (!nested_vmx_supported()) {
                print_skip("Nested VMX not supported");
                exit(KSFT_SKIP);
@@ -62,7 +57,7 @@ int main(void)
        }
 
        vm = vm_create_default(VCPU_ID, 0, (void *) l1_guest_code);
-       vm_enable_cap(vm, &cap);
+       vm_enable_cap(vm, KVM_CAP_X86_TRIPLE_FAULT_EVENT, 1);
 
        run = vcpu_state(vm, VCPU_ID);
        vcpu_alloc_vmx(vm, &vmx_pages_gva);
index e3e20e8848d0c61c0b25db9ad1a949256ff2f6ed..23e9292580c91e75b30ae77ce4fd8585afbe264b 100644 (file)
@@ -550,11 +550,8 @@ static void run_guest_then_process_ucall_done(struct kvm_vm *vm)
        process_ucall_done(vm);
 }
 
-static void test_msr_filter_allow(void) {
-       struct kvm_enable_cap cap = {
-               .cap = KVM_CAP_X86_USER_SPACE_MSR,
-               .args[0] = KVM_MSR_EXIT_REASON_FILTER,
-       };
+static void test_msr_filter_allow(void)
+{
        struct kvm_vm *vm;
        int rc;
 
@@ -564,7 +561,7 @@ static void test_msr_filter_allow(void) {
 
        rc = kvm_check_cap(KVM_CAP_X86_USER_SPACE_MSR);
        TEST_ASSERT(rc, "KVM_CAP_X86_USER_SPACE_MSR is available");
-       vm_enable_cap(vm, &cap);
+       vm_enable_cap(vm, KVM_CAP_X86_USER_SPACE_MSR, KVM_MSR_EXIT_REASON_FILTER);
 
        rc = kvm_check_cap(KVM_CAP_X86_MSR_FILTER);
        TEST_ASSERT(rc, "KVM_CAP_X86_MSR_FILTER is available");
@@ -673,13 +670,8 @@ static void handle_wrmsr(struct kvm_run *run)
        }
 }
 
-static void test_msr_filter_deny(void) {
-       struct kvm_enable_cap cap = {
-               .cap = KVM_CAP_X86_USER_SPACE_MSR,
-               .args[0] = KVM_MSR_EXIT_REASON_INVAL |
-                          KVM_MSR_EXIT_REASON_UNKNOWN |
-                          KVM_MSR_EXIT_REASON_FILTER,
-       };
+static void test_msr_filter_deny(void)
+{
        struct kvm_vm *vm;
        struct kvm_run *run;
        int rc;
@@ -691,7 +683,9 @@ static void test_msr_filter_deny(void) {
 
        rc = kvm_check_cap(KVM_CAP_X86_USER_SPACE_MSR);
        TEST_ASSERT(rc, "KVM_CAP_X86_USER_SPACE_MSR is available");
-       vm_enable_cap(vm, &cap);
+       vm_enable_cap(vm, KVM_CAP_X86_USER_SPACE_MSR, KVM_MSR_EXIT_REASON_INVAL |
+                                                     KVM_MSR_EXIT_REASON_UNKNOWN |
+                                                     KVM_MSR_EXIT_REASON_FILTER);
 
        rc = kvm_check_cap(KVM_CAP_X86_MSR_FILTER);
        TEST_ASSERT(rc, "KVM_CAP_X86_MSR_FILTER is available");
@@ -726,11 +720,8 @@ done:
        kvm_vm_free(vm);
 }
 
-static void test_msr_permission_bitmap(void) {
-       struct kvm_enable_cap cap = {
-               .cap = KVM_CAP_X86_USER_SPACE_MSR,
-               .args[0] = KVM_MSR_EXIT_REASON_FILTER,
-       };
+static void test_msr_permission_bitmap(void)
+{
        struct kvm_vm *vm;
        int rc;
 
@@ -740,7 +731,7 @@ static void test_msr_permission_bitmap(void) {
 
        rc = kvm_check_cap(KVM_CAP_X86_USER_SPACE_MSR);
        TEST_ASSERT(rc, "KVM_CAP_X86_USER_SPACE_MSR is available");
-       vm_enable_cap(vm, &cap);
+       vm_enable_cap(vm, KVM_CAP_X86_USER_SPACE_MSR, KVM_MSR_EXIT_REASON_FILTER);
 
        rc = kvm_check_cap(KVM_CAP_X86_MSR_FILTER);
        TEST_ASSERT(rc, "KVM_CAP_X86_MSR_FILTER is available");