KVM: remove KVM_REQ_UNHALT
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 21 Sep 2022 00:32:01 +0000 (00:32 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 26 Sep 2022 16:37:21 +0000 (12:37 -0400)
KVM_REQ_UNHALT is now unnecessary because it is replaced by the return
value of kvm_vcpu_block/kvm_vcpu_halt.  Remove it.

No functional change intended.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Message-Id: <20220921003201.1441511-13-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 files changed:
Documentation/virt/kvm/vcpu-requests.rst
arch/arm64/kvm/arm.c
arch/mips/kvm/emulate.c
arch/powerpc/kvm/book3s_pr.c
arch/powerpc/kvm/book3s_pr_papr.c
arch/powerpc/kvm/booke.c
arch/powerpc/kvm/powerpc.c
arch/riscv/kvm/vcpu_insn.c
arch/s390/kvm/kvm-s390.c
arch/x86/kvm/x86.c
arch/x86/kvm/xen.c
include/linux/kvm_host.h
virt/kvm/kvm_main.c

index 31f62b64e07b9f75c2be45ad28c133e53bf9ad04..87f04c1fa53d1c3c1efef0dff1e2fb88d2f3a258 100644 (file)
@@ -97,7 +97,7 @@ VCPU requests are simply bit indices of the ``vcpu->requests`` bitmap.
 This means general bitops, like those documented in [atomic-ops]_ could
 also be used, e.g. ::
 
-  clear_bit(KVM_REQ_UNHALT & KVM_REQUEST_MASK, &vcpu->requests);
+  clear_bit(KVM_REQ_UNBLOCK & KVM_REQUEST_MASK, &vcpu->requests);
 
 However, VCPU request users should refrain from doing so, as it would
 break the abstraction.  The first 8 bits are reserved for architecture
@@ -126,17 +126,6 @@ KVM_REQ_UNBLOCK
   or in order to update the interrupt routing and ensure that assigned
   devices will wake up the vCPU.
 
-KVM_REQ_UNHALT
-
-  This request may be made from the KVM common function kvm_vcpu_block(),
-  which is used to emulate an instruction that causes a CPU to halt until
-  one of an architectural specific set of events and/or interrupts is
-  received (determined by checking kvm_arch_vcpu_runnable()).  When that
-  event or interrupt arrives kvm_vcpu_block() makes the request.  This is
-  in contrast to when kvm_vcpu_block() returns due to any other reason,
-  such as a pending signal, which does not indicate the VCPU's halt
-  emulation should stop, and therefore does not make the request.
-
 KVM_REQ_OUTSIDE_GUEST_MODE
 
   This "request" ensures the target vCPU has exited guest mode prior to the
@@ -297,21 +286,6 @@ architecture dependent.  kvm_vcpu_block() calls kvm_arch_vcpu_runnable()
 to check if it should awaken.  One reason to do so is to provide
 architectures a function where requests may be checked if necessary.
 
-Clearing Requests
------------------
-
-Generally it only makes sense for the receiving VCPU thread to clear a
-request.  However, in some circumstances, such as when the requesting
-thread and the receiving VCPU thread are executed serially, such as when
-they are the same thread, or when they are using some form of concurrency
-control to temporarily execute synchronously, then it's possible to know
-that the request may be cleared immediately, rather than waiting for the
-receiving VCPU thread to handle the request in VCPU RUN.  The only current
-examples of this are kvm_vcpu_block() calls made by VCPUs to block
-themselves.  A possible side-effect of that call is to make the
-KVM_REQ_UNHALT request, which may then be cleared immediately when the
-VCPU returns from the call.
-
 References
 ==========
 
index 2ff0ef62abadc8cbf01a23b4b1df4f46039b55f7..4f949b64fdc91afab531f36c55b5c177f610d03e 100644 (file)
@@ -666,7 +666,6 @@ void kvm_vcpu_wfi(struct kvm_vcpu *vcpu)
 
        kvm_vcpu_halt(vcpu);
        vcpu_clear_flag(vcpu, IN_WFIT);
-       kvm_clear_request(KVM_REQ_UNHALT, vcpu);
 
        preempt_disable();
        vgic_v4_load(vcpu);
index 1d7c56defe93915d9e43d81ba0a227016f5af017..edaec93a1a1feb6737e0ba8467ff76d2d66c6893 100644 (file)
@@ -958,7 +958,6 @@ enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu)
                 * We are runnable, then definitely go off to user space to
                 * check if any I/O interrupts are pending.
                 */
-               kvm_clear_request(KVM_REQ_UNHALT, vcpu);
                if (kvm_arch_vcpu_runnable(vcpu))
                        vcpu->run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
        }
index d6abed6e51e6995a66df51b59d544fce56a6dfee..9fc4dd8f66ebc365b1e211c880f298d90266167e 100644 (file)
@@ -499,7 +499,6 @@ static void kvmppc_set_msr_pr(struct kvm_vcpu *vcpu, u64 msr)
        if (msr & MSR_POW) {
                if (!vcpu->arch.pending_exceptions) {
                        kvm_vcpu_halt(vcpu);
-                       kvm_clear_request(KVM_REQ_UNHALT, vcpu);
                        vcpu->stat.generic.halt_wakeup++;
 
                        /* Unset POW bit after we woke up */
index a1f2978b2a8654ff2daddc6834a66e5166d41229..b2c89e850d7ae84f87b658057318dca9c8bfc3dc 100644 (file)
@@ -393,7 +393,6 @@ int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd)
        case H_CEDE:
                kvmppc_set_msr_fast(vcpu, kvmppc_get_msr(vcpu) | MSR_EE);
                kvm_vcpu_halt(vcpu);
-               kvm_clear_request(KVM_REQ_UNHALT, vcpu);
                vcpu->stat.generic.halt_wakeup++;
                return EMULATE_DONE;
        case H_LOGICAL_CI_LOAD:
index 06c5830a93f9d6cd8f849dbd7aad0f619e5aceb3..7b4920e9fd26304bcf47ee43dd746d162f8d63a8 100644 (file)
@@ -719,7 +719,6 @@ int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
        if (vcpu->arch.shared->msr & MSR_WE) {
                local_irq_enable();
                kvm_vcpu_halt(vcpu);
-               kvm_clear_request(KVM_REQ_UNHALT, vcpu);
                hard_irq_disable();
 
                kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS);
index fb1490761c87e973c4f5f322ab16cccaf5eff19d..ec9c1e3c2ff4d373ee244635948a1b749f5bcce5 100644 (file)
@@ -239,7 +239,6 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
        case EV_HCALL_TOKEN(EV_IDLE):
                r = EV_SUCCESS;
                kvm_vcpu_halt(vcpu);
-               kvm_clear_request(KVM_REQ_UNHALT, vcpu);
                break;
        default:
                r = EV_UNIMPLEMENTED;
index 7eb90a47b57168c4e271ceea14784f07ac3d0dd6..0bb52761a3f73ee92fa23b189b317954525d596a 100644 (file)
@@ -191,7 +191,6 @@ void kvm_riscv_vcpu_wfi(struct kvm_vcpu *vcpu)
                kvm_vcpu_srcu_read_unlock(vcpu);
                kvm_vcpu_halt(vcpu);
                kvm_vcpu_srcu_read_lock(vcpu);
-               kvm_clear_request(KVM_REQ_UNHALT, vcpu);
        }
 }
 
index edfd4bbd0cbae345c8375b35e9ffa2b9e368bdf7..aa39ea4582bd1acfa83f33d360ba1d1b69bac8f7 100644 (file)
@@ -4343,8 +4343,6 @@ retry:
                goto retry;
        }
 
-       /* nothing to do, just clear the request */
-       kvm_clear_request(KVM_REQ_UNHALT, vcpu);
        /* we left the vsie handler, nothing to do, just clear the request */
        kvm_clear_request(KVM_REQ_VSIE_RESTART, vcpu);
 
index 20c56be1fcf1a9dc3cc7724de8dcc52028715da5..eb9d2c23fb04ecdd94728f4541c18655c6e3579c 100644 (file)
@@ -10813,8 +10813,6 @@ static inline int vcpu_block(struct kvm_vcpu *vcpu)
                if (hv_timer)
                        kvm_lapic_switch_to_hv_timer(vcpu);
 
-               kvm_clear_request(KVM_REQ_UNHALT, vcpu);
-
                /*
                 * If the vCPU is not runnable, a signal or another host event
                 * of some kind is pending; service it without changing the
@@ -11034,7 +11032,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
                        r = 0;
                        goto out;
                }
-               kvm_clear_request(KVM_REQ_UNHALT, vcpu);
                r = -EAGAIN;
                if (signal_pending(current)) {
                        r = -EINTR;
index 280cb5dc7341af1a6d61f7da26729d81f4bc702d..93c628d3e3a92cc7e4792ca2f7a734126a01e838 100644 (file)
@@ -1065,7 +1065,6 @@ static bool kvm_xen_schedop_poll(struct kvm_vcpu *vcpu, bool longmode,
                        del_timer(&vcpu->arch.xen.poll_timer);
 
                vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
-               kvm_clear_request(KVM_REQ_UNHALT, vcpu);
        }
 
        vcpu->arch.xen.poll_evtchn = 0;
index 04c7e5f2f727f36a33eb47c3a9d9be19bb4ed046..32f259fa58013eca0af1ea419b6a6a21d88e8272 100644 (file)
@@ -151,12 +151,11 @@ static inline bool is_error_page(struct page *page)
 #define KVM_REQUEST_NO_ACTION      BIT(10)
 /*
  * Architecture-independent vcpu->requests bit members
- * Bits 4-7 are reserved for more arch-independent bits.
+ * Bits 3-7 are reserved for more arch-independent bits.
  */
 #define KVM_REQ_TLB_FLUSH         (0 | KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
 #define KVM_REQ_VM_DEAD           (1 | KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
 #define KVM_REQ_UNBLOCK           2
-#define KVM_REQ_UNHALT            3
 #define KVM_REQUEST_ARCH_BASE     8
 
 /*
index dcf47da44844e5db782d28a0c2aed694bed22a28..26383e63d9dd352aa2fadd320f96844a8459498e 100644 (file)
@@ -3409,10 +3409,8 @@ static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu)
        int ret = -EINTR;
        int idx = srcu_read_lock(&vcpu->kvm->srcu);
 
-       if (kvm_arch_vcpu_runnable(vcpu)) {
-               kvm_make_request(KVM_REQ_UNHALT, vcpu);
+       if (kvm_arch_vcpu_runnable(vcpu))
                goto out;
-       }
        if (kvm_cpu_has_pending_timer(vcpu))
                goto out;
        if (signal_pending(current))