From nobody Sat May 11 09:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1638194128; cv=none; d=zohomail.com; s=zohoarc; b=baMEaTRjExUMQb/8v8yW/PQ4yN0ygDX2i31xaTkgEcg0xkA270+6OvNv9w7YgK//dJglaFOGS0U66JCemAZP9fQejgEcrtGVRKSpnJMu+svscfaeBncajmpgDfuj/YtIQ3kDuSCzRJuRqvKAbgKDpIMRIRqLdDzM8TghugrhRog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638194128; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N5K2k3q0Eo2Jy2p/psCpdv+cQiRiNwsxEPx+PrsAvqg=; b=k/Gv6T/y6je6bqs6qNZI1NZcSljr4JPBwHUvPA5yKTEOeObLmovyJx/9/Ki90LHcxfo8c8/G02YvKbzRq86bRPcrEvDy83UKf2Uxp+vSEqqrf3SShkAbn2rHCtSQ0G8Nnqu0RWp9g5246O4e7AzELbiblJdJYzCApYMBmD1/Ymg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638194128773921.6647256314468; Mon, 29 Nov 2021 05:55:28 -0800 (PST) Received: from localhost ([::1]:58552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrh7v-0000NO-6l for importer@patchew.org; Mon, 29 Nov 2021 08:55:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh3r-0003OA-Et for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh3p-0002zB-DE for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:14 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-231-RqPE7zXZOkWLCppxRUfM-g-1; Mon, 29 Nov 2021 08:51:11 -0500 Received: by mail-ed1-f71.google.com with SMTP id v1-20020aa7cd41000000b003e80973378aso13732035edw.14 for ; Mon, 29 Nov 2021 05:51:11 -0800 (PST) Received: from redhat.com ([45.15.19.35]) by smtp.gmail.com with ESMTPSA id qb21sm7589942ejc.78.2021.11.29.05.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 05:51:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638193872; 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: in-reply-to:in-reply-to:references:references; bh=N5K2k3q0Eo2Jy2p/psCpdv+cQiRiNwsxEPx+PrsAvqg=; b=U9e0brAX6VIBUb1JNB77Wb0DTO76j7dyp2Twiha6M1L1qrVfz1hNUoqUB0XKgezJdpLsjb zPzXJU5TZw7hDVHp/bX89bd8NhWsGWsRXF216RkWRx4s6B0whoRZHfuchxQrKdqsltN9tQ V+Lx/8U9uDEId/4uXdspbFyMZSNrN4E= X-MC-Unique: RqPE7zXZOkWLCppxRUfM-g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=N5K2k3q0Eo2Jy2p/psCpdv+cQiRiNwsxEPx+PrsAvqg=; b=xmZUuO39IDOSjkkSU5HrrH3TLcF/sWX1aonX1dC1NzXqzpGtiUCFOYvbB566vzTHw8 sKmmseuPKWYmPMsFoMdOgc+yWr7jtcDtvcW05W+S7u2fygUHIZCX2d2xdomqGyLlc4hk QIOB8DvunT/kf8T9mIeQ1SVwgvr9hyKK3tq3cv0krLfre0TBnAhjPD/0yf8wEhIimlVr LnhB4a9+zK4uHzAZKIG2R5a27aDJNyq0GeS9kiFfpmm+pAzsqHxAv7eHZynTEuELv7KD pR9S4aySds/160wJ4l3Ve9FoE2qEADaiER0elqRInzcKY41doGMqeoM3ouHwbwVIPdDN DqbA== X-Gm-Message-State: AOAM532aFbF1rm0C+q0OJvBIakBZ6R66iuZC3sxDP5qAUs2+Wo2wf/37 ulAK55qYqrdd3GEPZFwNiHKh5dOEtnHQWa3HHGpkd8rHvnObQXR4zrUQRYu/tf7Z/2eFuEFWhNI 22ITFkPe1c5E4ZemzrDfp4MC4f3YlQ7DIMrLI8r5xfmSk8djQLEZI51XL+umi X-Received: by 2002:a17:907:2454:: with SMTP id yw20mr60743884ejb.428.1638193869947; Mon, 29 Nov 2021 05:51:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyn9amtWBrvEH29E6qrxygAttv8TNOMaG4An+53m98jeickEwg+zUPo8vsvzO8J7+oHIOeqwQ== X-Received: by 2002:a17:907:2454:: with SMTP id yw20mr60743855ejb.428.1638193869661; Mon, 29 Nov 2021 05:51:09 -0800 (PST) Date: Mon, 29 Nov 2021 08:51:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 1/7] virtio-mmio : fix the crash in the vm shutdown Message-ID: <20211129135053.560225-2-mst@redhat.com> References: <20211129135053.560225-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211129135053.560225-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Cc: Peter Maydell , Cindy Lu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1638194130759100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu The root cause for this crash is the ioeventfd not stopped while the VM sto= p. The callback for vmstate_change was not implement in virtio-mmio bus Reproduce step load the vm with -M microvm \ -netdev tap,id=3Dnet0,vhostforce,script=3Dno,downscript=3Dno \ -device virtio-net-device,netdev=3Dnet0\ After the VM boot, login the vm and then shutdown the vm System will crash [Current thread is 1 (Thread 0x7ffff6edde00 (LWP 374378))] (gdb) bt 0 0x00005555558f18b4 in qemu_flush_or_purge_queued_packets (purge=3Dfalse,= nc=3D0x55500252e850) at ../net/net.c:636 1 qemu_flush_queued_packets (nc=3D0x55500252e850) at ../net/net.c:656 2 0x0000555555b6c363 in virtio_queue_notify_vq (vq=3D0x7fffe7e2b010) at ..= /hw/virtio/virtio.c:2339 3 virtio_queue_host_notifier_read (n=3D0x7fffe7e2b08c) at ../hw/virtio/vir= tio.c:3583 4 0x0000555555de7b5a in aio_dispatch_handler (ctx=3Dctx@entry=3D0x5555567c= 5780, node=3D0x555556b83fd0) at ../util/aio-posix.c:329 5 0x0000555555de8454 in aio_dispatch_ready_handlers (ready_list=3D, ctx=3D) at ../util/aio-posix.c:359 6 aio_poll (ctx=3D0x5555567c5780, blocking=3Dblocking@entry=3Dfalse) at ..= /util/aio-posix.c:662 7 0x0000555555cce0cc in monitor_cleanup () at ../monitor/monitor.c:645 8 0x0000555555b06bd2 in qemu_cleanup () at ../softmmu/runstate.c:822 9 0x000055555586e693 in main (argc=3D, argv=3D, envp=3D) at ../softmmu/main.c:51 Signed-off-by: Cindy Lu Message-Id: <20211109023744.22387-1-lulu@redhat.com> Acked-by: Jason Wang Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 7b3ebca178..72da12fea5 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -817,6 +817,17 @@ static char *virtio_mmio_bus_get_dev_path(DeviceState = *dev) return path; } =20 +static void virtio_mmio_vmstate_change(DeviceState *d, bool running) +{ + VirtIOMMIOProxy *proxy =3D VIRTIO_MMIO(d); + + if (running) { + virtio_mmio_start_ioeventfd(proxy); + } else { + virtio_mmio_stop_ioeventfd(proxy); + } +} + static void virtio_mmio_bus_class_init(ObjectClass *klass, void *data) { BusClass *bus_class =3D BUS_CLASS(klass); @@ -832,6 +843,7 @@ static void virtio_mmio_bus_class_init(ObjectClass *kla= ss, void *data) k->ioeventfd_enabled =3D virtio_mmio_ioeventfd_enabled; k->ioeventfd_assign =3D virtio_mmio_ioeventfd_assign; k->pre_plugged =3D virtio_mmio_pre_plugged; + k->vmstate_change =3D virtio_mmio_vmstate_change; k->has_variable_vring_alignment =3D true; bus_class->max_dev =3D 1; bus_class->get_dev_path =3D virtio_mmio_bus_get_dev_path; --=20 MST From nobody Sat May 11 09:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163819404690034.49314399154832; Mon, 29 Nov 2021 05:54:06 -0800 (PST) Received: from localhost ([::1]:54350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrh6b-0005vt-JD for importer@patchew.org; Mon, 29 Nov 2021 08:54:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh3w-0003Zj-53 for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44590) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh3u-000302-5F for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:19 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-530-rF3B4Fl9Od6b2ulZPVsyFQ-1; Mon, 29 Nov 2021 08:51:15 -0500 Received: by mail-ed1-f69.google.com with SMTP id t9-20020aa7d709000000b003e83403a5cbso13789775edq.19 for ; Mon, 29 Nov 2021 05:51:15 -0800 (PST) Received: from redhat.com ([45.15.19.35]) by smtp.gmail.com with ESMTPSA id hx21sm7389570ejc.85.2021.11.29.05.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 05:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638193877; 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: in-reply-to:in-reply-to:references:references; bh=3+0pbbrfn/qHP6LtjNcDnY9pfhSUSvMOuMXSePsEHYw=; b=E+tL9oZzzJBw6uGY/AKFjmKwWuWo3KzKYPCPfOYCeyow0d9UYqMrshF0Zkfvhi58Dfbpfh l5ymny89kNy1OmAQaxjdn3wVFN2ynzAq1zEg7CMWQBObqyJatUCyXbklHKqWATEv/XPivP fumlyuofQUuc08yiOo0M3AJfn+umNxs= X-MC-Unique: rF3B4Fl9Od6b2ulZPVsyFQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3+0pbbrfn/qHP6LtjNcDnY9pfhSUSvMOuMXSePsEHYw=; b=TKMDJ5Up7FhedOv2H1YP9m+NifUtQgoQcxiQSPBqDd9Kx/a5znaRciGPoAXZN8IDwF NV4OXBgOOaP4hrhkbRxQ/RTlgEp1nwFybkzIvvfp8gMLMIXFYJ2ky1Z7/rTIcykG3Sf9 fyWKZEmKXQK6TYWNYNmRqthK3qazVkhzF07D5iaRG1xjcG91P4/+JCkrMMCVHAPKzvUb C2c8aUTbxSCCqQwDsnwraM0508D6HfVdPPVf+YFfbJikeCzVF0+a5xcJWnjE2zvs57mc FkfQfZedujOMBHoqUqAXfgg2Vl+lM6u2OW9rYKZ9C6CQzyumxPBFBEToi4l1pl6ZGbtn jnzQ== X-Gm-Message-State: AOAM533n3nJzoiiZ/Pp+Z1TKFURKxDQA6RrhDEDAS0aqwZxwQrYDvc27 Ic9gYTCEHb2d7nLQPQRAyUB1563DfmLSQ6ANjAZyKGHw0TfYu2/kUmrBv0tbsWYvzEXh8EJxPVX krzjinpuSt2cxSjfsdz7SksDUfwkfRTHfQIu+MJXMrTiIno3m16P53dwHDG2Z X-Received: by 2002:a17:906:3489:: with SMTP id g9mr59592346ejb.17.1638193874060; Mon, 29 Nov 2021 05:51:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwJjnv3O9nK66U5zWe5mk1oLVT+sbVu4rtH+IKUyCAE4SN6RdbapFGZwLJzJv781ZtLR4lCg== X-Received: by 2002:a17:906:3489:: with SMTP id g9mr59592318ejb.17.1638193873849; Mon, 29 Nov 2021 05:51:13 -0800 (PST) Date: Mon, 29 Nov 2021 08:51:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 2/7] failover: fix unplug pending detection Message-ID: <20211129135053.560225-3-mst@redhat.com> References: <20211129135053.560225-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211129135053.560225-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Cc: Laurent Vivier , Peter Maydell , Ani Sinha , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1638194049059100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged. To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in pcie_unplug_device(). But since 17858a169508 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35") we have switched to ACPI unplug and these functions are not called anymore and the flag not set. So failover migration is not able to detect if card is really unplugged and acts as it's done as soon as it's started. So it doesn't wait the end of the unplug to start the migration. We don't see any problem when we test that because ACPI unplug is faster than PCIe native hotplug and when the migration really starts the unplug operation is already done. See c000a9bd06ea ("pci: mark device having guest unplug request pending") a99c4da9fc2a ("pci: mark devices partially unplugged") Signed-off-by: Laurent Vivier Reviewed-by: Ani Sinha Message-Id: <20211118133225.324937-4-lvivier@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/pcihp.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index f610a25d2e..30405b5113 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -222,9 +222,27 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, u= nsigned bsel, unsigned slo PCIDevice *dev =3D PCI_DEVICE(qdev); if (PCI_SLOT(dev->devfn) =3D=3D slot) { if (!acpi_pcihp_pc_no_hotplug(s, dev)) { - hotplug_ctrl =3D qdev_get_hotplug_handler(qdev); - hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abort); - object_unparent(OBJECT(qdev)); + /* + * partially_hotplugged is used by virtio-net failover: + * failover has asked the guest OS to unplug the device + * but we need to keep some references to the device + * to be able to plug it back in case of failure so + * we don't execute hotplug_handler_unplug(). + */ + if (dev->partially_hotplugged) { + /* + * pending_deleted_event is set to true when + * virtio-net failover asks to unplug the device, + * and set to false here when the operation is done + * This is used by the migration loop to detect the + * end of the operation and really start the migration. + */ + qdev->pending_deleted_event =3D false; + } else { + hotplug_ctrl =3D qdev_get_hotplug_handler(qdev); + hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abor= t); + object_unparent(OBJECT(qdev)); + } } } } @@ -396,6 +414,12 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandle= r *hotplug_dev, return; } =20 + /* + * pending_deleted_event is used by virtio-net failover to detect the + * end of the unplug operation, the flag is set to false in + * acpi_pcihp_eject_slot() when the operation is completed. + */ + pdev->qdev.pending_deleted_event =3D true; s->acpi_pcihp_pci_status[bsel].down |=3D (1U << slot); acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS); } --=20 MST From nobody Sat May 11 09:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638194228293584.5347689778108; Mon, 29 Nov 2021 05:57:08 -0800 (PST) Received: from localhost ([::1]:37812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrh9X-0005bl-6n for importer@patchew.org; Mon, 29 Nov 2021 08:57:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh44-0003dq-TP for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh42-00030y-Qe for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:28 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-259-pTWGYr4sP4ebcmXIFbCMOw-1; Mon, 29 Nov 2021 08:51:19 -0500 Received: by mail-ed1-f70.google.com with SMTP id q17-20020aa7da91000000b003e7c0641b9cso13784248eds.12 for ; Mon, 29 Nov 2021 05:51:19 -0800 (PST) Received: from redhat.com ([45.15.19.35]) by smtp.gmail.com with ESMTPSA id qa31sm7475891ejc.33.2021.11.29.05.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 05:51:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638193881; 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=UihEY1SXLbY91vozy6vIng0o2j8rRpby6Zz/fyXU1q8=; b=DV4s6/DPi1idikuunTgHcZ5T4Nhehvatyo6Z0r3LzCTTrXwtyYOOZTOy+E5oRkGlfQOOEG batbQl9p2NAx6DP8QAkeOwa+GNIHIUeP8EVwJX9v6nAv/FgIkXVhOdIAU+nTzbxFsB53BR lodprA7MM0nD0hyju1zvOaOGl/yumYs= X-MC-Unique: pTWGYr4sP4ebcmXIFbCMOw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=UihEY1SXLbY91vozy6vIng0o2j8rRpby6Zz/fyXU1q8=; b=mOYCaDEQHxxv9Lsa0LlUbmreIRUUhtUQzl/DcgSEpljNDCnK8/BO4KlkGU61JtVr3O PkditbInN3PD/du48vdwKW9J1zx67GVLa5bo2nmfd71KrVOtusKF6PC1hXl6AERYEWYG IeFJy8gltlaozlOeZuZqTwLFEXOSyIR1fDbbfMd26xUvDMFlOFK5BT1seKwniFtjVVEF x0WVTX6f+IAc9z/PaWy68b/8gTvh+oWoApfDCvq17nzgTbCCStyyEpsRuHQcBgNSd+hR sPNPN/6eUXm+iW910W+mPh8UsnTdD3xz/C8sWe8mSz67hdeCuC3fUqsfIcnIGhKYjcY+ +Z8Q== X-Gm-Message-State: AOAM5338vRIZUZdFLrAg0SBEagMp9yp+Ea+qbYeJHXPVk/z9G9jv0FDF 98o5CCU+vpjbNXK67E2bkIoh63TRRBvb2ZQfRMx6J6jaTRc6VxRMX7+omsFhwW/RseACRRjboHh w9shan1u+gBFzdZy4NkuQ5Xx0831LOE8NhhtTRxoL//gAU9npXJS01+/AhNDx X-Received: by 2002:a50:fe8e:: with SMTP id d14mr76254423edt.51.1638193878363; Mon, 29 Nov 2021 05:51:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzD/+9g2YN3amhtLlDHx0qvTDIrGQB9hTArcABiZNegkp6pspCS87yK21AcEYFqcjFPvwrkWQ== X-Received: by 2002:a50:fe8e:: with SMTP id d14mr76254392edt.51.1638193878137; Mon, 29 Nov 2021 05:51:18 -0800 (PST) Date: Mon, 29 Nov 2021 08:51:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 3/7] vdpa: Add dummy receive callback Message-ID: <20211129135053.560225-4-mst@redhat.com> References: <20211129135053.560225-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211129135053.560225-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Cc: Peter Maydell , Jason Wang , Eugenio =?utf-8?B?UMOpcmV6?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1638194229514100003 From: Eugenio P=C3=A9rez Qemu falls back on userland handlers even if vhost-user and vhost-vdpa cases. These assumes a tap device can handle the packets. If a vdpa device fail to start, it can trigger a sigsegv because of that. Add dummy receiver that returns no progress so it can keep running. Fixes: 1e0a84ea49 ("vhost-vdpa: introduce vhost-vdpa net client") Signed-off-by: Eugenio P=C3=A9rez Message-Id: <20211125101614.76927-2-eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- net/vhost-vdpa.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 2e3c22a8c7..25dd6dd975 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -170,9 +170,17 @@ static bool vhost_vdpa_check_peer_type(NetClientState = *nc, ObjectClass *oc, return true; } =20 +/** Dummy receive in case qemu falls back to userland tap networking */ +static ssize_t vhost_vdpa_receive(NetClientState *nc, const uint8_t *buf, + size_t size) +{ + return 0; +} + static NetClientInfo net_vhost_vdpa_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), + .receive =3D vhost_vdpa_receive, .cleanup =3D vhost_vdpa_cleanup, .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, .has_ufo =3D vhost_vdpa_has_ufo, --=20 MST From nobody Sat May 11 09:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1638194445; cv=none; d=zohomail.com; s=zohoarc; b=XtXWN8EAml+iPagW64+Zld5GB0YXU1g8oay5uAq0NKr6pb7LpjRHRDMGmxF8LHwLt68M2/6jHyFttLrNFBhGvJGVNRI9CZkcw5TQBZqKI8gwGCQBsYdBlWi/Y+y/IlxBHO4zBHhhj+jLkyqCFs+1wmll66um3fLw1xam8y20LaU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638194445; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LVLwpiU67LdLjERzs2TvjGxNupilX2wDR1L6Rld+HNM=; b=NACswBDyjDXQUhPHohyI5Fr1lv4i5n6jMV9H8/G4EaUzQA5imzTpWcnlpaCNrhFUKx441eL3+BQKIZbCIFPqh5gtNZseHEg0P4dkRb7/hobL6jgpsbpYAmjYh0NgdJs6rr7i+vxevQf5iXPw5A6ueTDntDjXMC8lklXi6wBgr1w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638194445404800.8603851344909; Mon, 29 Nov 2021 06:00:45 -0800 (PST) Received: from localhost ([::1]:45610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrhD2-0002i4-5N for importer@patchew.org; Mon, 29 Nov 2021 09:00:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh46-0003g8-PK for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36686) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh42-00031K-QV for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:28 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-436-JC9zig1lP8azrROHiNvrXQ-1; Mon, 29 Nov 2021 08:51:23 -0500 Received: by mail-ed1-f69.google.com with SMTP id m12-20020a056402430c00b003e9f10bbb7dso13749473edc.18 for ; Mon, 29 Nov 2021 05:51:23 -0800 (PST) Received: from redhat.com ([45.15.19.35]) by smtp.gmail.com with ESMTPSA id sa17sm7888222ejc.123.2021.11.29.05.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 05:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638193885; 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: in-reply-to:in-reply-to:references:references; bh=LVLwpiU67LdLjERzs2TvjGxNupilX2wDR1L6Rld+HNM=; b=DFhAPJ21K599KOtNDfVzyHECs3SKvnoQnI3/lM4vGzmJ0fjlHyZzskcXwTWL3Yz7eaEf0p aa4v3u/cpK3r0U2KFg2F+BBHxiz2nfNnpvV2HakCkFvI6iNsYYlMLufrL5nXfWshnERlAZ aYxo4yQLHloJ08VRhT8cHp7G3JPugSk= X-MC-Unique: JC9zig1lP8azrROHiNvrXQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LVLwpiU67LdLjERzs2TvjGxNupilX2wDR1L6Rld+HNM=; b=uv+Iz11eB1GX9ABG2xBmlV2yWReCQ6eLQ4uW8SGeEWGyoZ+nnooealDxtIArQawiux VPhY3l5M5VRQERelVujLm2UPsTGnX6YA3ip0Z5QBe2EGzoF9PDGscfsPIo3T1LOe2GnP 97vSs9+aZ3x0vHZ1TnWrU8IP3UtZz95Yc+l7Q2W1Zbv7tXWN/kpYWZYdTRYJUiAgycuH 1BYW4sgmeUM1DLLhzfALal6eQ2QTV0aTjMpoOJVPGw79JNu7353vmFkF2ZxvBQBlcmQv 8u3x8oaXpak6AournxyU/xwiCbdDc5OW4M97lP4xg+RDT2+gdOgUsdGvl5fCJsDkzfm3 9oDQ== X-Gm-Message-State: AOAM530w++ivE4fToC7tPwi5T+RewIBbq+bPRVhmPQ4I4IEfVhcjfjVU EbMrBanoTc7scpq/wpGyq6MHvz2pB5U9kh8mCPcLkmIdVlk5e1lVltA0WsmdHqxMS6KCRjZaagt /d+ctytPqOLwZV4ia5tErx2vPszYtpgxjDcv3pVwiXfg/uRtCph8ADSnnPNSm X-Received: by 2002:a05:6402:268e:: with SMTP id w14mr74523036edd.48.1638193882239; Mon, 29 Nov 2021 05:51:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBxhuEs9BCa5i6xnr43doK12VIxHW7paqq/mrxBikhH4Y1vwNPjd9V0Ja3gup2uyG0PvnW2Q== X-Received: by 2002:a05:6402:268e:: with SMTP id w14mr74523007edd.48.1638193882093; Mon, 29 Nov 2021 05:51:22 -0800 (PST) Date: Mon, 29 Nov 2021 08:51:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 4/7] virtio-balloon: process all in sgs for free_page_vq Message-ID: <20211129135053.560225-5-mst@redhat.com> References: <20211129135053.560225-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211129135053.560225-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Cc: Peter Maydell , Jason Wang , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1638194449806100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang We only process the first in sg which may lead to the bitmap of the pages belongs to following sgs were not cleared. This may result more pages to be migrated. Fixing this by process all in sgs for free_page_vq. Acked-by: David Hildenbrand Signed-off-by: Jason Wang Message-Id: <20211129030841.3611-1-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-balloon.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index c6962fcbfe..17de2558cb 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -510,6 +510,7 @@ static bool get_free_page_hints(VirtIOBalloon *dev) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtQueue *vq =3D dev->free_page_vq; bool ret =3D true; + int i; =20 while (dev->block_iothread) { qemu_cond_wait(&dev->free_page_cond, &dev->free_page_lock); @@ -544,8 +545,10 @@ static bool get_free_page_hints(VirtIOBalloon *dev) } =20 if (elem->in_num && dev->free_page_hint_status =3D=3D FREE_PAGE_HINT_S= _START) { - qemu_guest_free_page_hint(elem->in_sg[0].iov_base, - elem->in_sg[0].iov_len); + for (i =3D 0; i < elem->in_num; i++) { + qemu_guest_free_page_hint(elem->in_sg[i].iov_base, + elem->in_sg[i].iov_len); + } } =20 out: --=20 MST From nobody Sat May 11 09:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1638194631; cv=none; d=zohomail.com; s=zohoarc; b=c5k0lv92Q8u6w/5xPsryhUhet5KXIrT5Wi4KS3VffeEoV1PJH+ArhRk/4+c6d4tGRs5xs+Q9IDWfK/ffgqJ3n4sx0wAOhfhJaX88jRj1JsmDnn3h4ShmarMVJbU7MS0Mr9PGa+GE4GKTSSikt4h2Y33S4M9MB2YXkIZseKBxicM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638194631; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gmN91jDcIZU9UtpuPrQVYTn7kPEJb0WLyI2q45YuAMw=; b=n9Yg8YpC1CyfHyiWCmramA4h0PUPucwL2WaYFOK7M4OWp8PVUwqpag6uHTBjfILqzf2OtKFPfMy4m81FTv21p9fU3sj8zeN1m4FIaQvFezdMfs58XNf6ZFskEztLUv3SSp+RESEHOtWbXjJaIJ4FqNzzmLTw4jPzAnpKKnDwOMY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638194631376797.2565935110341; Mon, 29 Nov 2021 06:03:51 -0800 (PST) Received: from localhost ([::1]:51950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrhG2-0007HO-72 for importer@patchew.org; Mon, 29 Nov 2021 09:03:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh4N-0003oQ-5L for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh48-00033I-DQ for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:43 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-372-jdgSMOYfOfS41T5yjutcWw-1; Mon, 29 Nov 2021 08:51:27 -0500 Received: by mail-ed1-f72.google.com with SMTP id k7-20020aa7c387000000b003e7ed87fb31so13874384edq.3 for ; Mon, 29 Nov 2021 05:51:27 -0800 (PST) Received: from redhat.com ([45.15.19.35]) by smtp.gmail.com with ESMTPSA id i8sm10534211edc.12.2021.11.29.05.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 05:51:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638193890; 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: in-reply-to:in-reply-to:references:references; bh=gmN91jDcIZU9UtpuPrQVYTn7kPEJb0WLyI2q45YuAMw=; b=EuYJH8eTzwT8ekezP/kqIBc9NrmoXxTLDFNCs9xSL4VpTJ1Y6yzwlfT7RjI6p/tpSZI1ra lPP7AQCj4e+f4GE9YiaUXiUgNUv6HehGP1Bq3GUIUnxnA9JdrwO7cFsqR9rMyqkGUklaqe HuR91yMQ1idxAtfyJnsoYfL7PtSRZLE= X-MC-Unique: jdgSMOYfOfS41T5yjutcWw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gmN91jDcIZU9UtpuPrQVYTn7kPEJb0WLyI2q45YuAMw=; b=W+fVWtUIBUZqsPRper6vyClLaQf77ohQGKUdNkqbIXjIUhKrhXQW5DxHPBZBLo4F8L HSQamKfdwEXVQn1APiVmhmKBpJ7X0RvQ8Uz6VRoDgPtTkIbALq1DNhKVSe8d5nbqYZFV DjcNPztOjPjl0KHDQznWw+psDBFN2FtSTCcKWxBc1Lk4++WsyXCgQXvSpngkWbCxcqHd fFq5MvzKGZKIwBnR87TBaM55VF+SIpSXtnAZrF+xxtJlDizk5bgdBJthcPNNPlQgCxQm 4tdIx1LORuHctW4kIn1LmVX0CxSxuOINviA/joj5eEF2/5kEk9/2Qpiy3WvByczjfAPq TYCQ== X-Gm-Message-State: AOAM531CoFpHsTLvVlOFFn4Hws+qzRT03q3ugMIUqK7ScNNYIModFLkW 5bjrDvHDC3bG5y336kBAye4uaVO7D2kOv0i2dptBvrFeqA4MfiSJr164ufjsv2CTin5PZa5hUy4 +fM0vwTZJeTf2L9ezPDk8nM2+tRvjittQrlQ8XYjDKfdHrqCExzt6skj7o8BK X-Received: by 2002:aa7:c783:: with SMTP id n3mr74937302eds.121.1638193885987; Mon, 29 Nov 2021 05:51:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSvgTLFa+cYcVGIz+FfzFIF+ao6OdcPem63+tMn+WTpej1J5PwUvrHYCaPdFt2o2mXkGbdfQ== X-Received: by 2002:aa7:c783:: with SMTP id n3mr74937280eds.121.1638193885814; Mon, 29 Nov 2021 05:51:25 -0800 (PST) Date: Mon, 29 Nov 2021 08:51:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 5/7] virtio-balloon: correct used length Message-ID: <20211129135053.560225-6-mst@redhat.com> References: <20211129135053.560225-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211129135053.560225-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Cc: Peter Maydell , Jason Wang , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1638194648168100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang Spec said: "and len the total of bytes written into the buffer." For inflateq, deflateq and statsq, we don't process in_sg so the used length should be zero. For free_page_vq, tough the pages could be changed by the device (in the destination), spec said: "Note: len is particularly useful for drivers using untrusted buffers: if a driver does not know exactly how much has been written by the device, the driver would have to zero the buffer in advance to ensure no data leakage occurs." So 0 should be used as well here. Signed-off-by: Jason Wang Message-Id: <20211129030841.3611-2-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand --- hw/virtio/virtio-balloon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 17de2558cb..9a4f491b54 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -231,7 +231,7 @@ static void balloon_stats_poll_cb(void *opaque) return; } =20 - virtqueue_push(s->svq, s->stats_vq_elem, s->stats_vq_offset); + virtqueue_push(s->svq, s->stats_vq_elem, 0); virtio_notify(vdev, s->svq); g_free(s->stats_vq_elem); s->stats_vq_elem =3D NULL; @@ -438,7 +438,7 @@ static void virtio_balloon_handle_output(VirtIODevice *= vdev, VirtQueue *vq) memory_region_unref(section.mr); } =20 - virtqueue_push(vq, elem, offset); + virtqueue_push(vq, elem, 0); virtio_notify(vdev, vq); g_free(elem); virtio_balloon_pbp_free(&pbp); @@ -552,7 +552,7 @@ static bool get_free_page_hints(VirtIOBalloon *dev) } =20 out: - virtqueue_push(vq, elem, 1); + virtqueue_push(vq, elem, 0); g_free(elem); return ret; } --=20 MST From nobody Sat May 11 09:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638194348682629.0320468146248; Mon, 29 Nov 2021 05:59:08 -0800 (PST) Received: from localhost ([::1]:41810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrhBO-0008UU-4m for importer@patchew.org; Mon, 29 Nov 2021 08:59:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh4J-0003nb-9v for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:20927) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh4A-00033c-B3 for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:35 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-DAJ0-QPIP528ufTiJvhjKQ-1; Mon, 29 Nov 2021 08:51:32 -0500 Received: by mail-ed1-f72.google.com with SMTP id bx28-20020a0564020b5c00b003e7c42443dbso13727360edb.15 for ; Mon, 29 Nov 2021 05:51:32 -0800 (PST) Received: from redhat.com ([45.15.19.35]) by smtp.gmail.com with ESMTPSA id s16sm9127972edt.30.2021.11.29.05.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 05:51:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638193893; 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: in-reply-to:in-reply-to:references:references; bh=dNA74JogDW+OTgGs6tOWW2D5DT75AYZMnUaKYfmi5IQ=; b=MJBrjY3/Nd+ufiQh2I2DvCtNBGgJui5AnV09DupnerN9R1NE3XPNYJU8fR+2fyKdnhBrvL X+jkf2mMPeBmH2unLZRSTsWlwe49JzKeG1KkcPZFjHHfHzzral/7WouyLQFNtmjPfG7bsw 3VvLwftnMmuRn94Ajiphxx9en3TPW+A= X-MC-Unique: DAJ0-QPIP528ufTiJvhjKQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dNA74JogDW+OTgGs6tOWW2D5DT75AYZMnUaKYfmi5IQ=; b=iFy4B0gJJfo0t3nuR/mU8ZpkeapYpWzA6fSmoN+u/5hQvWFa3HBTb6hm+0NrAb7Mx/ HYGGphBHZNs6PfFsnxQahJs8/XZ/1jbnSEIs8Q2SIyDEQlP16/9S9md3agoJgmc09fgh 8fQ9O9XhvhR+vfA9EzLM9e85MMP98ZAvEWTbgz0Q8F3tFK9U1irzbjhwY5cU6hHPdijl WwAz0EwhH/pbpLbSfY52RRAUmyyX9MZyyvsRbTcWp2HIv7SrXqJbIf7PaGkkhAIcpNdT ocFGmxv7fpSUDzMoz1TvffLCb1HRTKBBnZeAwD7HtNiyv7lbvRt9uwO/BInWr8B85w+J lq0Q== X-Gm-Message-State: AOAM532VY+hZGrHkdPyoeHz2Y3ICbBvjosldK8wWG3/d311X4ViBHRZK hpROxXFwBGxg8LBzO9WlhApkl9QqbGX43/IKvDxAQOWagb3Ag2wLUqc//IVI66TOTtJmMIZ7veM X+PYSVutH8l4nTOY88OearsF9s3bD9TQZA5LxizGtPpYe8zNHFnpKWrVgOoaM X-Received: by 2002:aa7:c783:: with SMTP id n3mr74937960eds.121.1638193891228; Mon, 29 Nov 2021 05:51:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6JUTvAWr8SJ8MnVNvB5CIDwffDRfMI0mrZR5ZC0RpkqQSqzXD798XXP5DSsey1I6jYZdwmw== X-Received: by 2002:aa7:c783:: with SMTP id n3mr74937920eds.121.1638193890993; Mon, 29 Nov 2021 05:51:30 -0800 (PST) Date: Mon, 29 Nov 2021 08:51:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 6/7] intel-iommu: ignore leaf SNP bit in scalable mode Message-ID: <20211129135053.560225-7-mst@redhat.com> References: <20211129135053.560225-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211129135053.560225-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Cc: Peter Maydell , Eduardo Habkost , Jason Wang , Richard Henderson , Peter Xu , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1638194350321100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang When booting with scalable mode, I hit this error: qemu-system-x86_64: vtd_iova_to_slpte: detected splte reserve non-zero iova= =3D0xfffff002, level=3D0x1slpte=3D0x102681803) qemu-system-x86_64: vtd_iommu_translate: detected translation failure (dev= =3D01:00:00, iova=3D0xfffff002) qemu-system-x86_64: New fault is not recorded due to compression of faults This is because the SNP bit is set for second level page table since Linux kernel commit 6c00612d0cba1 ("iommu/vt-d: Report right snoop capability when using FL for IOVA") even if SC is not supported by the hardware. To unbreak the guest, ignore the leaf SNP bit for scalable mode first. In the future we may consider to add SC support. Signed-off-by: Jason Wang Message-Id: <20211129033618.3857-1-jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Peter Xu --- hw/i386/intel_iommu_internal.h | 2 ++ hw/i386/intel_iommu.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 3d5487fe2c..a6c788049b 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -388,6 +388,8 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0fff8 =20 /* Rsvd field masks for spte */ +#define VTD_SPTE_SNP 0x800ULL + #define VTD_SPTE_PAGE_L1_RSVD_MASK(aw, dt_supported) \ dt_supported ? \ (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM | VTD_SL_TM)) : \ diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 294499ee20..f584449d8d 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3629,6 +3629,12 @@ static void vtd_init(IntelIOMMUState *s) vtd_spte_rsvd_large[3] =3D VTD_SPTE_LPAGE_L3_RSVD_MASK(s->aw_bits, x86_iommu->dt_sup= ported); =20 + if (s->scalable_mode) { + vtd_spte_rsvd[1] &=3D ~VTD_SPTE_SNP; + vtd_spte_rsvd_large[2] &=3D ~VTD_SPTE_SNP; + vtd_spte_rsvd_large[3] &=3D ~VTD_SPTE_SNP; + } + if (x86_iommu_ir_supported(x86_iommu)) { s->ecap |=3D VTD_ECAP_IR | VTD_ECAP_MHMV; if (s->intr_eim =3D=3D ON_OFF_AUTO_ON) { --=20 MST From nobody Sat May 11 09:40:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1638194419369446.74007309941123; Mon, 29 Nov 2021 06:00:19 -0800 (PST) Received: from localhost ([::1]:44070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrhCc-0001cw-6A for importer@patchew.org; Mon, 29 Nov 2021 09:00:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh4N-0003oS-6H for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48204) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrh4F-00036n-Dn for qemu-devel@nongnu.org; Mon, 29 Nov 2021 08:51:44 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-283-79Ut3w_kPASTPoXriqsD9w-1; Mon, 29 Nov 2021 08:51:36 -0500 Received: by mail-ed1-f70.google.com with SMTP id eg20-20020a056402289400b003eb56fcf6easo13702896edb.20 for ; Mon, 29 Nov 2021 05:51:36 -0800 (PST) Received: from redhat.com ([45.15.19.35]) by smtp.gmail.com with ESMTPSA id w18sm9189169edx.55.2021.11.29.05.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 05:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638193898; 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: in-reply-to:in-reply-to:references:references; bh=Bxt+L8k1GZjsKtb7c8tzi14JSMlMCVQgRMRp4CiqFKo=; b=UP9gEC9QHJknW+cBBqReiA+4ypj5IEiCyhwFCpnqK8VuJeJYCa2/EhbzaQPHdtJlsoM2lA 5hqseIIpjzOc+UUK+7OFGB5hcPmWUkO/UnRsHR2if7VYOHR96nZfDJfwBJn2dbyoqJE27i PsrBXf4w4Sft+LRVJyuEK2YqZI9en5g= X-MC-Unique: 79Ut3w_kPASTPoXriqsD9w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bxt+L8k1GZjsKtb7c8tzi14JSMlMCVQgRMRp4CiqFKo=; b=buBXgFdZ2P4azrpAtElZwjykreqlkwpEH08HLkF1j4GYZh1/fIccvYGsHkeQDp7X7W KYc8eI67eLIB9APBIfA4SDe9gWBfWxJpSqF+G8ps05Z5Vkd/XEMyYP4DOu3sJxUgst9r GWNqRIAr3sQqto41kGnf7/ZtkK5fAuPzKXoomE77YiMjjzj7meC2oY0auS8xtli89GC5 b1OQ1f0r4eqnWHaQjeOFU1IaQaQu3kGR+Qyt3QSmsr8JqmmJgMyiwy6Q0hGimhcnwegQ usa+7ZG0yZTyIQyG24sOeaDGLww8VFW+X0kF70dAJ7IjxPDnh2vW3tn650iRcsPz9CFP GYhQ== X-Gm-Message-State: AOAM533ymPq84v9MLwMSv65NwjgCzBkSZ2YaCTZ0vrCs+fe18SIPPZsE yzcRZrfezeYcF6U+iyN498q+QQl9W9Pj7YVbRxgRH+9TZEjjrhJcbe9xI8NgKOvSo+z12HEFRzE jVRARUS0VMCAR1zdFVm5LWLd3EaD6LyTaua/Pt2wV3DZysShkLDys+jhoiIik X-Received: by 2002:aa7:ca46:: with SMTP id j6mr31327335edt.234.1638193895318; Mon, 29 Nov 2021 05:51:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdU7ye2ncZAocRyq4VF3avfUtGtkN9CAGlPFLRTNajwzKT6Zom4wsbykJfPBcSL8OULs5MCg== X-Received: by 2002:aa7:ca46:: with SMTP id j6mr31327308edt.234.1638193895123; Mon, 29 Nov 2021 05:51:35 -0800 (PST) Date: Mon, 29 Nov 2021 08:51:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 7/7] Fix bad overflow check in hw/pci/pcie.c Message-ID: <20211129135053.560225-8-mst@redhat.com> References: <20211129135053.560225-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20211129135053.560225-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Cc: Peter Maydell , Daniella Lee Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1638194425538100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniella Lee Orginal qemu commit hash:14d02cfbe4adaeebe7cb833a8cc71191352cf03b In function pcie_add_capability, an assert contains the "offset < offset + size" expression. Both variable offset and variable size are uint16_t, the comparison is always true due to type promotion. The next expression may be the same. It might be like this: Thread 1 "qemu-system-x86" hit Breakpoint 1, pcie_add_capability ( dev=3D0x555557ce5f10, cap_id=3D1, cap_ver=3D2 '\002', offset=3D256, siz= e=3D72) at ../hw/pci/pcie.c:930 930 { (gdb) n 931 assert(offset >=3D PCI_CONFIG_SPACE_SIZE); (gdb) n 932 assert(offset < offset + size); (gdb) p offset $1 =3D 256 (gdb) p offset < offset + size $2 =3D 1 (gdb) set offset=3D65533 (gdb) p offset < offset + size $3 =3D 1 (gdb) p offset < (uint16_t)(offset + size) $4 =3D 0 Signed-off-by: Daniella Lee Message-Id: <20211126061324.47331-1-daniellalee111@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index c5ed266337..d7d73a31e4 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -929,8 +929,8 @@ void pcie_add_capability(PCIDevice *dev, uint16_t offset, uint16_t size) { assert(offset >=3D PCI_CONFIG_SPACE_SIZE); - assert(offset < offset + size); - assert(offset + size <=3D PCIE_CONFIG_SPACE_SIZE); + assert(offset < (uint16_t)(offset + size)); + assert((uint16_t)(offset + size) <=3D PCIE_CONFIG_SPACE_SIZE); assert(size >=3D 8); assert(pci_is_express(dev)); =20 --=20 MST