From nobody Mon Apr 13 12:01:50 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17816C19F2A for ; Thu, 11 Aug 2022 21:06:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236595AbiHKVGx (ORCPT ); Thu, 11 Aug 2022 17:06:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236412AbiHKVGT (ORCPT ); Thu, 11 Aug 2022 17:06:19 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 45E8B85A85 for ; Thu, 11 Aug 2022 14:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660251977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zssSnyjhXO8Y+VaC40NbtnI4nznRbo22yC14BgkmKUU=; b=Ni3t6vO2X+VEhy22dbOFVcbqyzohcy92x/FUUJZrVZEcGsZgWN9dTfv/BeXEKYoWGjyE9R WF33ig6+2QlThyhedlAGeQt6Uz3x0rax1rYyGLOTO/TE/LqrvQ3APOqvD94cLd3yxTRs2M hhIwy6XkTEQl3KO88NgxywKwjwVwkZQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-n-MfIhBBM4uPTIlgrGS62Q-1; Thu, 11 Aug 2022 17:06:07 -0400 X-MC-Unique: n-MfIhBBM4uPTIlgrGS62Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D55A85A59A; Thu, 11 Aug 2022 21:06:07 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB67B492C3B; Thu, 11 Aug 2022 21:06:06 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, mlevitsk@redhat.com, vkuznets@redhat.com Subject: [PATCH v2 4/9] KVM: mips, x86: do not rely on KVM_REQ_UNHALT Date: Thu, 11 Aug 2022 17:06:00 -0400 Message-Id: <20220811210605.402337-5-pbonzini@redhat.com> In-Reply-To: <20220811210605.402337-1-pbonzini@redhat.com> References: <20220811210605.402337-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" KVM_REQ_UNHALT is now available as the return value from kvm_vcpu_halt or kvm_vcpu_block, so the request can be simply cleared just like all other architectures do. No functional change intended. Signed-off-by: Paolo Bonzini --- arch/mips/kvm/emulate.c | 8 ++++---- arch/x86/kvm/x86.c | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c index b494d8d39290..77d760d45c48 100644 --- a/arch/mips/kvm/emulate.c +++ b/arch/mips/kvm/emulate.c @@ -944,6 +944,7 @@ enum hrtimer_restart kvm_mips_count_timeout(struct kvm_= vcpu *vcpu) =20 enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu) { + int r; kvm_debug("[%#lx] !!!WAIT!!! (%#lx)\n", vcpu->arch.pc, vcpu->arch.pending_exceptions); =20 @@ -952,16 +953,15 @@ enum emulation_result kvm_mips_emul_wait(struct kvm_v= cpu *vcpu) if (!vcpu->arch.pending_exceptions) { kvm_vz_lose_htimer(vcpu); vcpu->arch.wait =3D 1; - kvm_vcpu_halt(vcpu); + r =3D kvm_vcpu_halt(vcpu); =20 /* * We we are runnable, then definitely go off to user space to * check if any I/O interrupts are pending. */ - if (kvm_check_request(KVM_REQ_UNHALT, vcpu)) { - kvm_clear_request(KVM_REQ_UNHALT, vcpu); + kvm_clear_request(KVM_REQ_UNHALT, vcpu); + if (r > 0) vcpu->run->exit_reason =3D KVM_EXIT_IRQ_WINDOW_OPEN; - } } =20 return EMULATE_DONE; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c44348bb6ef2..416df0fc7fda 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10611,6 +10611,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) static inline int vcpu_block(struct kvm_vcpu *vcpu) { bool hv_timer; + int r; =20 if (!kvm_arch_vcpu_runnable(vcpu)) { /* @@ -10626,15 +10627,16 @@ static inline int vcpu_block(struct kvm_vcpu *vcp= u) =20 kvm_vcpu_srcu_read_unlock(vcpu); if (vcpu->arch.mp_state =3D=3D KVM_MP_STATE_HALTED) - kvm_vcpu_halt(vcpu); + r =3D kvm_vcpu_halt(vcpu); else - kvm_vcpu_block(vcpu); + r =3D kvm_vcpu_block(vcpu); kvm_vcpu_srcu_read_lock(vcpu); =20 if (hv_timer) kvm_lapic_switch_to_hv_timer(vcpu); =20 - if (!kvm_check_request(KVM_REQ_UNHALT, vcpu)) + kvm_clear_request(KVM_REQ_UNHALT, vcpu); + if (r <=3D 0) return 1; } =20 --=20 2.31.1