From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.8bytes.org (mail.8bytes.org [85.214.250.239]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 019DE3F8893; Mon, 8 Jun 2026 14:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.214.250.239 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780929814; cv=none; b=F8ZynQzDoiRoF91mTbYcCRmofnKRxFlEJsX7juMtSakmn8alGEEbt68aaI7Io7haCPAaJj42rq9T4fgRyKKu8H3j2hFHVft/eERlFZ1D8RRYPUSmV900MTRvt3KVPNj57qityDtR7e0mZDxIid1xseMk0/IEIQ/V/vANzkHnzWQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780929814; c=relaxed/simple; bh=eH3f+WuPMLAuoE2Ew5uwF/+/AYqpqginB/0ahvdEg0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rQkJAtti1O6TUIQbZ9kEkRZa74uNIZWt8AkyZSYKnIyPX6sMT88sUHEjYdVFRmt9sxlsBGGDevhntz1FnkXLOn/FNfc4IR94eVFvJzoYyTiIQD7TPtQTXgdC/ybL4sFh/jLlTYwAzyJ69OgOqWBJU0elGK5JmK+vuKnIA7981DQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=8bytes.org; spf=pass smtp.mailfrom=8bytes.org; arc=none smtp.client-ip=85.214.250.239 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=8bytes.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=8bytes.org Received: from io.home.8bytes.org (p4ffe1d30.dip0.t-ipconnect.de [79.254.29.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.8bytes.org (Postfix) with ESMTPSA id 3B9172028D7; Mon, 8 Jun 2026 16:43:16 +0200 (CEST) From: =?UTF-8?q?J=C3=B6rg=20R=C3=B6del?= To: Paolo Bonzini , Sean Christopherson Cc: Tom Lendacky , ashish.kalra@amd.com, michael.roth@amd.com, nsaenz@amazon.com, anelkz@amazon.de, James.Bottomley@HansenPartnership.com, Melody Wang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, x86@kernel.org, coconut-svsm@lists.linux.dev, joerg.roedel@amd.com Subject: [PATCH 52/60] kvm: x86: Switch to plane0 if it has events Date: Mon, 8 Jun 2026 16:42:44 +0200 Message-ID: <20260608144252.351443-53-joro@8bytes.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260608144252.351443-1-joro@8bytes.org> References: <20260608144252.351443-1-joro@8bytes.org> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Joerg Roedel When there are IRQs or events pending for plane0, make sure it can handle it. Signed-off-by: Joerg Roedel --- arch/x86/kvm/x86.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 08fe65b8d57d..60b34bd4da9d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10962,6 +10962,20 @@ static int kvm_check_and_inject_events(struct kvm_vcpu *vcpu, return r; } +static inline bool kvm_check_plane0_events(struct kvm_vcpu *vcpu) +{ + struct kvm_vcpu *vcpu_plane0; + + if (vcpu->plane_level == 0) + return false; + + vcpu_plane0 = vcpu->common->vcpus[0]; + + return kvm_cpu_has_injectable_intr(vcpu_plane0) || + vcpu_plane0->arch.nmi_pending || + vcpu_plane0->arch.smi_pending; +} + static void process_nmi(struct kvm_vcpu *vcpu) { unsigned int limit; @@ -11410,12 +11424,19 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) goto out; } } + } - if (kvm_check_request(KVM_REQ_PLANE_RESCHED, vcpu)) { - vcpu->common->plane_switch = true; - r = 0; - goto out; - } + if (kvm_check_plane0_events(vcpu)) { + kvm_vcpu_set_plane_runnable(vcpu->common->vcpus[0]); + + kvm_make_request(KVM_REQ_EVENT, vcpu); + kvm_make_request(KVM_REQ_PLANE_RESCHED, vcpu); + } + + if (kvm_check_request(KVM_REQ_PLANE_RESCHED, vcpu)) { + vcpu->common->plane_switch = true; + r = 0; + goto out; } if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win || @@ -11737,6 +11758,9 @@ bool kvm_vcpu_has_events(struct kvm_vcpu *vcpu) if (kvm_test_request(KVM_REQ_UPDATE_PROTECTED_GUEST_STATE, vcpu)) return true; + if (kvm_test_request(KVM_REQ_PLANE_RESCHED, vcpu)) + return true; + if (kvm_arch_interrupt_allowed(vcpu) && kvm_cpu_has_interrupt(vcpu)) return true; -- 2.53.0