From patchwork Tue Sep 12 15:16:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keir Fraser X-Patchwork-Id: 13381854 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 43B56CA0EEB for ; Tue, 12 Sep 2023 15:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236256AbjILPQh (ORCPT ); Tue, 12 Sep 2023 11:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236227AbjILPQg (ORCPT ); Tue, 12 Sep 2023 11:16:36 -0400 Received: from mail-wm1-x34a.google.com (mail-wm1-x34a.google.com [IPv6:2a00:1450:4864:20::34a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 331191BB for ; Tue, 12 Sep 2023 08:16:32 -0700 (PDT) Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-4011fa32e99so43924575e9.0 for ; Tue, 12 Sep 2023 08:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694531790; x=1695136590; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DSSb3wJwwJOYnhbMDsHN3g3fU/f9wd1vkngB6Xy4Iy8=; b=qH8MMekUaNKjIFq6ExyQSELZbuipSQzLPs6fzvWx71+za7wtPUdcT1Aj+0Ybuki+Sx anTgSSpMGOfwYXCsfuEyCdHhcdgAWT2Oe/V3XItg76vZGEe3FaY4uPE9Q/bMkEB5xgW6 TJ0r8FRgyeA/oLgYBQZ8OZDA6lWfo8avUsdDNP7lGABjj4Fy5dV3cIfK24tTu+tFb7IR X/6I7s2dS+F3Y176AH7H0CTKQ4r7GMOk9CVZRcIF4V5qmmf4/6cCDcbHfdmvwtYHu2UJ CRC1sqWQ34SWVOCBjSz2a4Z/j2mLYrrNt41vGDmuoL0iuIgZ69ZKHZku1NBK2XPDgQJi +KHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694531790; x=1695136590; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DSSb3wJwwJOYnhbMDsHN3g3fU/f9wd1vkngB6Xy4Iy8=; b=LUg4UZfKfNtw1EwN5QEFLigaE05T+fr9ZBZ34Y7tFozAs5Sk8tJ9y5vo5ufyGXb+Mf 8XzAqHkEuZQR7JDtlWKJ1sM5eT6GfVqPZG0tle6yR7RlcWUYhQsOj8j/vQPrSH64kzGk f2yBTE2CquaHTkF2+maw9CLkAKlOLRUbCGnjgRFo7lRVYBoZFcGrFRWGy50047E1JTM+ wseKPmA9ldiaXXB3NFfI9fnvRB1SH+tOpAAyfKUHkk4iE6kdQHjeCzsbfmezQcv8RGY/ qV1vO28kd8iIMQty2rWJ/FsxKt+wyKmdi0qouVyYj3LiCfdeBhDMQ/2IU9RiMYNNDBq5 tsxw== X-Gm-Message-State: AOJu0YzaP7mhsFLqE0fFEBvtwQHMBG+oPVL8ICpzt8O0YEBkZ0eiBWaf hsvZ6+to5kw0F3yMlkA57Nwk5Z+V4nRte4eKcSh8brd72t6rRMaamvw5VZzJVgN+CTZFK7huyxW tVe80UO4RrKtblM49SC9fk8FI6eCbpBX8uCtXssMqOBNZChYieRav70Y= X-Google-Smtp-Source: AGHT+IEAzg6mUToilyQxjWdZq12Fyey0jhHzClgFcPgfc+oz8wvtDI0/fZ/5iPyq71/u3XlrVw1BVK8clQ== X-Received: from keirf-cvd.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:23a8]) (user=keirf job=sendgmr) by 2002:a5d:4388:0:b0:317:6b94:b700 with SMTP id i8-20020a5d4388000000b003176b94b700mr150488wrq.9.1694531790591; Tue, 12 Sep 2023 08:16:30 -0700 (PDT) Date: Tue, 12 Sep 2023 15:16:21 +0000 In-Reply-To: <20230912151623.2558794-1-keirf@google.com> Mime-Version: 1.0 References: <20230912151623.2558794-1-keirf@google.com> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912151623.2558794-2-keirf@google.com> Subject: [PATCH 1/3] virtio/pci: Level-trigger the legacy IRQ line in all cases From: Keir Fraser To: kvm@vger.kernel.org Cc: Marc Zyngier , Will Deacon , Julien Thierry , Keir Fraser Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The PCI legacy IRQ line is level triggered, but is treated as edge triggered via kvm__irq_trigger() for signalling of config changes. Fix this by using kvm__irq_level(), as for queue signalling. Signed-off-by: Keir Fraser --- virtio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtio/pci.c b/virtio/pci.c index 701f456..7a206be 100644 --- a/virtio/pci.c +++ b/virtio/pci.c @@ -264,7 +264,7 @@ int virtio_pci__signal_config(struct kvm *kvm, struct virtio_device *vdev) kvm__irq_trigger(kvm, vpci->config_gsi); } else { vpci->isr = VIRTIO_PCI_ISR_CONFIG; - kvm__irq_trigger(kvm, vpci->legacy_irq_line); + kvm__irq_line(kvm, vpci->legacy_irq_line, VIRTIO_IRQ_HIGH); } return 0; From patchwork Tue Sep 12 15:16:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keir Fraser X-Patchwork-Id: 13381855 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 99FAACA0EF1 for ; Tue, 12 Sep 2023 15:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236280AbjILPQk (ORCPT ); Tue, 12 Sep 2023 11:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236270AbjILPQj (ORCPT ); Tue, 12 Sep 2023 11:16:39 -0400 Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB6DCC3 for ; Tue, 12 Sep 2023 08:16:35 -0700 (PDT) Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-31f3eaa5c5eso3793013f8f.3 for ; Tue, 12 Sep 2023 08:16:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694531793; x=1695136593; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=huKCk2g0BNIHM38+AvbfGWcHeU/DmBmWJoZhqWvPsM4=; b=wu/xgyme8153Jup6tAMM6dOw2WM8LFgFGIi/9fobS+fbB5OAX/iU9aDD3G8xxPTDOZ DJPKGl/xwsqTz6U4TCQcN7FPNsqv/9x3zhx2qJcc2ayZhWBO4TuoBN4fupwIpAdkx9MW 35zhdvb3YYx3JwbKvN77NX3SY7saLp9nXKzXdH3l2p/P73+9z8jJ6hb2UJBisJla8qPf rXZlcmmSxTsJfdCuiCHsXUfP5+6o51xsnF8TcGZArfExDURrweO7h8lW2Gz/s/3Rhsmk 6nNgE2JqGj2i7a7My+tPU8VZp8NZTd7SiKsSc0hoPs6aDYNeeuzmOmiuoZXP2yRnK6KS gKlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694531793; x=1695136593; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=huKCk2g0BNIHM38+AvbfGWcHeU/DmBmWJoZhqWvPsM4=; b=XU2ZpZWtokVodPWHwPORB9QxB8N+/e2JOpGJtfAnHYY4fEZmZGMy9r0MydXrG6wK13 Zu6brUREvrevMZA1SqwQ/d2R5myhIJ7OC1sZVzSLQd+fcP/OyK0XObucHpSDxLPpCZ4y 8h/h8ofOVQnFQGG4DQDHm7A04+/PpgzpIQc9rAHm+WN2lMlrHoVUTaeZuvB7gT8ZnGxy h2lYkmSpMQnNaKMkRU02K67llWCqYHsznZJA47baKDz80BvuLWLdNnad4Wyu5KDj+Mw0 x49J6oqHuzJ39l9YaFUL2ElPdf+eJNUkAJ8YPXQWJh0EhWLCPTgAeinsie6Uy3fVI0a9 gkNQ== X-Gm-Message-State: AOJu0Yx5hZNFUUj0tpczlkBo4w0Mu+LAEnL3z9RKeMtJzMoZqPyCkw1l fl6YjwTUnwuuxxGFhEoaL+UIJwnMhRAXysZUHPynXZykp8zTdvlz17SncMJjyItehXH6Bsy90NT 5BjqpwYrp4FeoOcKYzjQVVnfclqfxPJ04QgWMKH8TlmYXEvB4q/zNGDI= X-Google-Smtp-Source: AGHT+IGmlLu47hxXQnTWd7rLTnheFI+x83cIVvm4q1qUWWGb4JZIClZADrikyh+gkHn+VgZrYenETdYNOg== X-Received: from keirf-cvd.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:23a8]) (user=keirf job=sendgmr) by 2002:a05:6000:118f:b0:313:f8d6:8884 with SMTP id g15-20020a056000118f00b00313f8d68884mr146316wrx.11.1694531793602; Tue, 12 Sep 2023 08:16:33 -0700 (PDT) Date: Tue, 12 Sep 2023 15:16:22 +0000 In-Reply-To: <20230912151623.2558794-1-keirf@google.com> Mime-Version: 1.0 References: <20230912151623.2558794-1-keirf@google.com> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912151623.2558794-3-keirf@google.com> Subject: [PATCH 2/3] virtio/pci: Treat PCI ISR as a set of bit flags From: Keir Fraser To: kvm@vger.kernel.org Cc: Marc Zyngier , Will Deacon , Julien Thierry , Keir Fraser Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The PCI ISR is defined in the virtio spec as a set of flags which can be bitwise ORed together. Therefore we should avoid clearing previously-set flags. Signed-off-by: Keir Fraser --- virtio/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtio/pci.c b/virtio/pci.c index 7a206be..74bc9a4 100644 --- a/virtio/pci.c +++ b/virtio/pci.c @@ -239,7 +239,7 @@ int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq) else kvm__irq_trigger(kvm, vpci->gsis[vq]); } else { - vpci->isr = VIRTIO_IRQ_HIGH; + vpci->isr |= VIRTIO_IRQ_HIGH; kvm__irq_line(kvm, vpci->legacy_irq_line, VIRTIO_IRQ_HIGH); } return 0; @@ -263,7 +263,7 @@ int virtio_pci__signal_config(struct kvm *kvm, struct virtio_device *vdev) else kvm__irq_trigger(kvm, vpci->config_gsi); } else { - vpci->isr = VIRTIO_PCI_ISR_CONFIG; + vpci->isr |= VIRTIO_PCI_ISR_CONFIG; kvm__irq_line(kvm, vpci->legacy_irq_line, VIRTIO_IRQ_HIGH); } From patchwork Tue Sep 12 15:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keir Fraser X-Patchwork-Id: 13381856 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 6C6DECA0EEB for ; Tue, 12 Sep 2023 15:16:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236313AbjILPQo (ORCPT ); Tue, 12 Sep 2023 11:16:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236270AbjILPQm (ORCPT ); Tue, 12 Sep 2023 11:16:42 -0400 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D932F1BB for ; Tue, 12 Sep 2023 08:16:37 -0700 (PDT) Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-31aed15ce6fso3553979f8f.3 for ; Tue, 12 Sep 2023 08:16:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694531796; x=1695136596; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FDBjc8Im/9KAKESp/lLrvFpvxpkV7sdZwugiSM3Gs/k=; b=k8BL/UeFPcpzDflZ10yfiJE0dRXZE4x/da7mHqswQTNcpBezDY2OjNNYVedaFrhDib WsjeTEolKC/fmDpmNMBDxSuMKz+4zlGdOj85FmK4oLM/X30QoQN+H/fSX3nCeQpoDHmy 7omPsBO1VwmKeoZu6X9pl8jNUHIblyfB+iGrrEBPyZu/zAsnRXRYByo//7rBob1IH7+j EhjxRPe+Im5SCqI/dLQn7slhM3hM7ZoBIqZCoKJIzzZ816K9ILLm3z53yePrERyaYmtt 2eMInypuZzCB7DPkmR4HuFy6sl2iwN1dHZjC03ypDoi+r9pZj6pOxXEmK9fAw8fYBuGo Ca8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694531796; x=1695136596; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FDBjc8Im/9KAKESp/lLrvFpvxpkV7sdZwugiSM3Gs/k=; b=g/RKIfD2Aey7iRd4sa6WgsemMX3xQV1VKV52/4D2vXkAW9/6IShMBQBbPQy3n6TP2Y dU7piJy0ejzYTWEejbT7iU3rjNzt6tAFQeomo07KqCunHYilSecsOSOLc/0gBJVJfdu8 zKFr8R+nPzjxx6JXmJ1q5UA1GFG3z/oI2ahIoik+Z3xBmzk7dQaMtKeBqVx1Sd5PGeRf B4ArcoLZ9ezgbkV+4uIQdMyfK8guQbpjfEsAWgJHdtTf94ln+/xyv1mxT0+UoCBWf35q ZybTNmhZ+dup1ogM7WpwumQ5182zlXb2LOnmwfJGm9K4B6wSOEzcfk9XUdfWFOwtAQ5r 1AxA== X-Gm-Message-State: AOJu0YwBHj7XJrUVk5gtCx3uR1WIzTvTg3XFRCunQXhxF5X0MIEKvoR5 RwfZpiX7tre9Ldv1yUhupVjbLoHE9U0H3fYNbS27RvLJVVsWyrx6UWDPBpb8+XJBfatT7kGn+FF njuJFkvfavcjYVciBL9QyNjhQx23ibiOtiGv0Y5ffZl9r8w40ZlLdF5s= X-Google-Smtp-Source: AGHT+IGhfsNqinwNcE/SuhOX7TrjdPzE2djzHmGMbFBCgY9RGfFM94X87qOj3NK79McSS0T4ayclqiAIdQ== X-Received: from keirf-cvd.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:23a8]) (user=keirf job=sendgmr) by 2002:adf:d049:0:b0:31f:8875:e17a with SMTP id v9-20020adfd049000000b0031f8875e17amr106145wrh.10.1694531796350; Tue, 12 Sep 2023 08:16:36 -0700 (PDT) Date: Tue, 12 Sep 2023 15:16:23 +0000 In-Reply-To: <20230912151623.2558794-1-keirf@google.com> Mime-Version: 1.0 References: <20230912151623.2558794-1-keirf@google.com> X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912151623.2558794-4-keirf@google.com> Subject: [PATCH 3/3] virtio/pci: Use consistent naming for the PCI ISR bit flags From: Keir Fraser To: kvm@vger.kernel.org Cc: Marc Zyngier , Will Deacon , Julien Thierry , Keir Fraser Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Avoid using VIRTIO_IRQ_{HIGH,LOW} which belong to a different namespace. Instead define VIRTIO_PCI_ISR_QUEUE as a logical extension of the VIRTIO_PCI_ISR_* namespace. Since this bit flag is missing from a header imported verbatim from Linux, define it directly in pci.c. Signed-off-by: Keir Fraser --- virtio/pci-legacy.c | 2 +- virtio/pci.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/virtio/pci-legacy.c b/virtio/pci-legacy.c index 5804796..02a8f8c 100644 --- a/virtio/pci-legacy.c +++ b/virtio/pci-legacy.c @@ -61,7 +61,7 @@ static bool virtio_pci__data_in(struct kvm_cpu *vcpu, struct virtio_device *vdev case VIRTIO_PCI_ISR: ioport__write8(data, vpci->isr); kvm__irq_line(kvm, vpci->legacy_irq_line, VIRTIO_IRQ_LOW); - vpci->isr = VIRTIO_IRQ_LOW; + vpci->isr = 0; break; default: ret = virtio_pci__specific_data_in(kvm, vdev, data, size, offset); diff --git a/virtio/pci.c b/virtio/pci.c index 74bc9a4..8a34cec 100644 --- a/virtio/pci.c +++ b/virtio/pci.c @@ -14,6 +14,9 @@ #include #include +/* The bit of the ISR which indicates a queue change. */ +#define VIRTIO_PCI_ISR_QUEUE 0x1 + int virtio_pci__add_msix_route(struct virtio_pci *vpci, u32 vec) { int gsi; @@ -239,7 +242,7 @@ int virtio_pci__signal_vq(struct kvm *kvm, struct virtio_device *vdev, u32 vq) else kvm__irq_trigger(kvm, vpci->gsis[vq]); } else { - vpci->isr |= VIRTIO_IRQ_HIGH; + vpci->isr |= VIRTIO_PCI_ISR_QUEUE; kvm__irq_line(kvm, vpci->legacy_irq_line, VIRTIO_IRQ_HIGH); } return 0;