]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Use kvm_has_cap(), not kvm_check_cap(), where possible
authorSean Christopherson <seanjc@google.com>
Mon, 13 Jun 2022 16:19:42 +0000 (16:19 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 14 Jun 2022 16:44:47 +0000 (12:44 -0400)
Replace calls to kvm_check_cap() that treat its return as a boolean with
calls to kvm_has_cap().  Several instances of kvm_check_cap() were missed
when kvm_has_cap() was introduced.

Reported-by: Andrew Jones <drjones@redhat.com>
Fixes: 22d8dd02e9ed ("KVM: selftests: Add kvm_has_cap() to provide syntactic sugar")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220613161942.1586791-5-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/aarch64/psci_test.c
tools/testing/selftests/kvm/lib/x86_64/processor.c
tools/testing/selftests/kvm/s390x/sync_regs_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/smm_test.c
tools/testing/selftests/kvm/x86_64/state_test.c

index a889e1cf5e4dc69375f6ee8af1939377c784a66a..b665b534cb78985ff1afc2b5a6c521a6f7226541 100644 (file)
@@ -192,7 +192,7 @@ static void host_test_system_suspend(void)
 
 int main(void)
 {
-       TEST_REQUIRE(kvm_check_cap(KVM_CAP_ARM_SYSTEM_SUSPEND));
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_SYSTEM_SUSPEND));
 
        host_test_cpu_on();
        host_test_system_suspend();
index 4a7de11d6f377f3e283646708a50f56ce35b9fe0..906132e70fa430db5a19dc6b4713f8314e8e2683 100644 (file)
@@ -991,7 +991,7 @@ struct kvm_x86_state *vcpu_save_state(struct kvm_vcpu *vcpu)
        vcpu_regs_get(vcpu, &state->regs);
        vcpu_save_xsave_state(vcpu, state);
 
-       if (kvm_check_cap(KVM_CAP_XCRS))
+       if (kvm_has_cap(KVM_CAP_XCRS))
                vcpu_xcrs_get(vcpu, &state->xcrs);
 
        vcpu_sregs_get(vcpu, &state->sregs);
@@ -1022,7 +1022,7 @@ void vcpu_load_state(struct kvm_vcpu *vcpu, struct kvm_x86_state *state)
        vcpu_sregs_set(vcpu, &state->sregs);
        vcpu_msrs_set(vcpu, &state->msrs);
 
-       if (kvm_check_cap(KVM_CAP_XCRS))
+       if (kvm_has_cap(KVM_CAP_XCRS))
                vcpu_xcrs_set(vcpu, &state->xcrs);
 
        vcpu_xsave_set(vcpu,  state->xsave);
index b69710822c4746a9a956963fad902ce48ea96c3c..3fdb6e2598ebed4c22ff11f14009100c84b2d9c9 100644 (file)
@@ -229,7 +229,7 @@ int main(int argc, char *argv[])
        struct kvm_vm *vm;
        int idx;
 
-       TEST_REQUIRE(kvm_check_cap(KVM_CAP_SYNC_REGS));
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_SYNC_REGS));
 
        /* Tell stdout not to buffer its content */
        setbuf(stdout, NULL);
index 786b3a794f842b16b58d239abacd150d5ac95efc..530a75fee92c9bfdc3a15ad558dd1176ba0ce121 100644 (file)
@@ -450,7 +450,7 @@ int main(int argc, char *argv[])
        /* Tell stdout not to buffer its content */
        setbuf(stdout, NULL);
 
-       TEST_REQUIRE(kvm_check_cap(KVM_CAP_PMU_EVENT_FILTER));
+       TEST_REQUIRE(kvm_has_cap(KVM_CAP_PMU_EVENT_FILTER));
 
        TEST_REQUIRE(use_intel_pmu() || use_amd_pmu());
        guest_code = use_intel_pmu() ? intel_guest_code : amd_guest_code;
index 76ba6fc80e37d9d2c36245fde06bd3feb1fb7699..46018b247a04fc4fe9f3d1eb663143163b9939b6 100644 (file)
@@ -411,16 +411,16 @@ int main(int argc, char *argv[])
 
        have_sev_es = !!(cpuid->eax & X86_FEATURE_SEV_ES);
 
-       if (kvm_check_cap(KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM)) {
+       if (kvm_has_cap(KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM)) {
                test_sev_migrate_from(/* es= */ false);
                if (have_sev_es)
                        test_sev_migrate_from(/* es= */ true);
                test_sev_migrate_locking();
                test_sev_migrate_parameters();
-               if (kvm_check_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM))
+               if (kvm_has_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM))
                        test_sev_move_copy();
        }
-       if (kvm_check_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM)) {
+       if (kvm_has_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM)) {
                test_sev_mirror(/* es= */ false);
                if (have_sev_es)
                        test_sev_mirror(/* es= */ true);
index 3cd1da388b5292e8afdb319b4a3f68331a6ce669..921cbf1173294937c14efcee300bba23b56ec27c 100644 (file)
@@ -153,7 +153,7 @@ int main(int argc, char *argv[])
 
        vcpu_set_msr(vcpu, MSR_IA32_SMBASE, SMRAM_GPA);
 
-       if (kvm_check_cap(KVM_CAP_NESTED_STATE)) {
+       if (kvm_has_cap(KVM_CAP_NESTED_STATE)) {
                if (nested_svm_supported())
                        vcpu_alloc_svm(vm, &nested_gva);
                else if (nested_vmx_supported())
index 0bcd78cf7c7943e75fbf8257690cf7eb0e97f605..e2f1f35e51ff09574e661194b2f3711ace867131 100644 (file)
@@ -169,7 +169,7 @@ int main(int argc, char *argv[])
 
        vcpu_regs_get(vcpu, &regs1);
 
-       if (kvm_check_cap(KVM_CAP_NESTED_STATE)) {
+       if (kvm_has_cap(KVM_CAP_NESTED_STATE)) {
                if (nested_svm_supported())
                        vcpu_alloc_svm(vm, &nested_gva);
                else if (nested_vmx_supported())