KVM: rename kvm_arch_can_inject_async_page_present() to kvm_arch_can_dequeue_async_pa...
authorVitaly Kuznetsov <vkuznets@redhat.com>
Mon, 25 May 2020 14:41:18 +0000 (16:41 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 1 Jun 2020 08:26:07 +0000 (04:26 -0400)
An innocent reader of the following x86 KVM code:

bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu)
{
        if (!(vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED))
                return true;
...

may get very confused: if APF mechanism is not enabled, why do we report
that we 'can inject async page present'? In reality, upon injection
kvm_arch_async_page_present() will check the same condition again and,
in case APF is disabled, will just drop the item. This is fine as the
guest which deliberately disabled APF doesn't expect to get any APF
notifications.

Rename kvm_arch_can_inject_async_page_present() to
kvm_arch_can_dequeue_async_page_present() to make it clear what we are
checking: if the item can be dequeued (meaning either injected or just
dropped).

On s390 kvm_arch_can_inject_async_page_present() always returns 'true' so
the rename doesn't matter much.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20200525144125.143875-4-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/s390/include/asm/kvm_host.h
arch/s390/kvm/kvm-s390.c
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/x86.c
virt/kvm/async_pf.c

index 176f74cc22573229b5dbf95289c76104a2546edf..9d23bde1363bd0e6622a3f7c5d9bf130d0caf9f6 100644 (file)
@@ -973,7 +973,7 @@ struct kvm_arch_async_pf {
        unsigned long pfault_token;
 };
 
-bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu);
+bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu);
 
 void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu,
                               struct kvm_async_pf *work);
index a560a368f92c2acacf67b043cb0a01f98d4b3c74..06bde4bad20593e92debf16beb9b82040af7319b 100644 (file)
@@ -3943,7 +3943,7 @@ void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu,
        /* s390 will always inject the page directly */
 }
 
-bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu)
+bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu)
 {
        /*
         * s390 will always inject the page directly,
index 033f6173a8574e7fe7c8cbb179177107129bc1cc..f3897e417b696e8db496e37278aeb069d8fe0487 100644 (file)
@@ -1660,7 +1660,7 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
                                 struct kvm_async_pf *work);
 void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu,
                               struct kvm_async_pf *work);
-bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu);
+bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu);
 extern bool kvm_find_async_pf_gfn(struct kvm_vcpu *vcpu, gfn_t gfn);
 
 int kvm_skip_emulated_instruction(struct kvm_vcpu *vcpu);
index 84aa3c1519edb884420d296ea574d9d2b0b10afd..0e79b37b2b7ee6e42e2684e1ee4b2bab9b0c300a 100644 (file)
@@ -10521,7 +10521,7 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
        vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
 }
 
-bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu)
+bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu)
 {
        if (!(vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED))
                return true;
index 10b533f641a6500f13d504f26b95151c964f9ebd..82e53f180a1a71036a4b3c2b191ec026f84de5d5 100644 (file)
@@ -134,7 +134,7 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu)
        struct kvm_async_pf *work;
 
        while (!list_empty_careful(&vcpu->async_pf.done) &&
-             kvm_arch_can_inject_async_page_present(vcpu)) {
+             kvm_arch_can_dequeue_async_page_present(vcpu)) {
                spin_lock(&vcpu->async_pf.lock);
                work = list_first_entry(&vcpu->async_pf.done, typeof(*work),
                                              link);