From patchwork Mon Dec 5 17:31:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 1712418 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=ka1k+Td9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NQrPJ4ZXmz23np for ; Tue, 6 Dec 2022 04:38:28 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2FKs-0008CM-1z; Mon, 05 Dec 2022 12:32:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2FKS-0007vP-Vw for qemu-devel@nongnu.org; Mon, 05 Dec 2022 12:32:33 -0500 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2FJx-0007Q4-Ny for qemu-devel@nongnu.org; Mon, 05 Dec 2022 12:32:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=BTbmtRTWkaGpB084Oy/aaHAxrpUjT9n/cLcMxn66Nak=; b=ka1k+Td9DHaCTV72UN5G8eba/6 cacN0U+NHZmSRSd/tvTCXO63kV3dEcv8qYFw0Z63TcOXpih1EF+weFjTTkkvoPX0oPXiX2AmTHoDE n8XaW4iVu5OlyWP8y6efSImuE2t9sjZd640JEYe9Jke1O4bWrvJBF5z3xKWumXrpuLQO2gg15ENCW AYJnPKQijmL3+sMhKRyAo77mYM7ERZ2FSNH5AWuKwC3Av3SoZDD0Zvstkuw9P5dDHwPw+wNzTcfuz 36dun6Q6m4oqimUZQEK1aCylmK7A8Hega1TjG7lKt1DROe/L0aRXFN10ZsendvmEDb6Li1aET1cDi 0ez3pl9Q==; Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2FJw-003TwY-SN; Mon, 05 Dec 2022 17:32:01 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2FJo-002YKn-Q4; Mon, 05 Dec 2022 17:31:52 +0000 From: David Woodhouse To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Paul Durrant , Joao Martins , Ankur Arora Subject: [RFC PATCH 18/21] kvm/ioapic: mark gsi-2 used in ioapic routing init Date: Mon, 5 Dec 2022 17:31:34 +0000 Message-Id: <20221205173137.607044-19-dwmw2@infradead.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221205173137.607044-1-dwmw2@infradead.org> References: <20221205173137.607044-1-dwmw2@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Received-SPF: none client-ip=2001:8b0:10b:1236::1; envelope-from=BATV+f9b04eb53d39f4899ead+7043+infradead.org+dwmw2@casper.srs.infradead.org; helo=casper.infradead.org X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Ankur Arora GSI-2/IOAPIC pin-2 is treated specially while initing IRQ routing: PIC does not use it at all while the IOAPIC maps virq=0 to pin-2 and does not use GSI-2. (all other GSIs are identity mapped to pins.) This results in any later code which allocates a virq to be assigned GSI-2. This virq is in-turn used to remap interrupts to HYPERVISOR_CALLBACK_VECTOR (0xf3) to deliver to the guest. Ordinarily this would be okay, but if the event delivery is via direct injection via KVM_REQ_EVENT (without going through the LAPIC) we see vmentry failure. This works fine for any other values of GSI. As a workaround, mark GSI-2 used. Signed-off-by: Ankur Arora Signed-off-by: David Woodhouse --- accel/kvm/kvm-all.c | 5 +++++ hw/i386/kvm/ioapic.c | 1 + include/sysemu/kvm.h | 1 + 3 files changed, 7 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 8a227515b7..b40cfc4144 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1677,6 +1677,11 @@ static void set_gsi(KVMState *s, unsigned int gsi) set_bit(gsi, s->used_gsi_bitmap); } +void kvm_irqchip_set_gsi(KVMState *s, unsigned int gsi) +{ + set_gsi(s, gsi); +} + static void clear_gsi(KVMState *s, unsigned int gsi) { clear_bit(gsi, s->used_gsi_bitmap); diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index ee7c8ef68b..5fab0d35c9 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -43,6 +43,7 @@ void kvm_pc_setup_irq_routing(bool pci_enabled) } } } + kvm_irqchip_set_gsi(s, 2); kvm_irqchip_commit_routes(s); } diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 8e882fbe96..a249ea480f 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -512,6 +512,7 @@ static inline void kvm_irqchip_commit_route_changes(KVMRouteChange *c) } void kvm_irqchip_release_virq(KVMState *s, int virq); +void kvm_irqchip_set_gsi(KVMState *s, unsigned int gsi); int kvm_irqchip_add_adapter_route(KVMState *s, AdapterInfo *adapter); int kvm_irqchip_add_hv_sint_route(KVMState *s, uint32_t vcpu, uint32_t sint);