From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117315; cv=none; d=zohomail.com; s=zohoarc; b=iC5sRN2NQLzznouCvr9RdPQj+0Gp592mhQumdi8LOd3LBKm/EWlujbQUt0GRqFN4kMgSL1qvHkOZ8Ma3SUbGEvfbeRr4JVkFyLrPQq5H5UDi8o2FMEIuVLk+kS/ZwdoEEwlJyx1s3pjx3fdRIh+ay3M47i5IBZ+qCATgQOM6yLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117315; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cY4K5hEbqA2jAPtmBdYZErh868yrTmlvKXQA8mwMwzI=; b=A88IiImI5SRPU7jX8Q87FX1h/XlCqCVAFJsGGNaEf86wTyNNViDiJwzemqKUrwLUy05U0dilDdkrnYgKpcNqDfJdX8a/9kAzaGl+xt0cl/nDYzegFCBw2OAzxlu5Exku3pYPJukCNbUQWz+aU8Vhu0VMZZsXaYbN4bwg8ekU04I= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117315066206.4066528706977; Fri, 11 Sep 2026 02:01:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8h-0001hB-LS; Fri, 11 Sep 2026 05:01:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8T-0001Wu-3o for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8R-00080I-02 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:28 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-530-YEVAvbGLNEmJHnoK9AY-jg-1; Fri, 11 Sep 2026 05:01:22 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49e64b80b94so2852425e9.3 for ; Fri, 11 Sep 2026 02:01:21 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c2985dsm238995795e9.6.2026.09.11.02.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117285; 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=cY4K5hEbqA2jAPtmBdYZErh868yrTmlvKXQA8mwMwzI=; b=J0Hc8pUk4BxRfU9QK82Ox/IkVuKFcTNfRVOjTOCffwZF85/ZE1StLvQVbZPHGBSvYU8w3e TnQEr5Hhc7IDD3gbF2bkm4/v0vFLwUTAoTmc631KibqfBtO14bgtZ+YcxrObqMhZAQ/5oX YRLq8TXq+zyrwEpWktPkw7REjyoD+uI= X-MC-Unique: YEVAvbGLNEmJHnoK9AY-jg-1 X-Mimecast-MFC-AGG-ID: YEVAvbGLNEmJHnoK9AY-jg_1789117281 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117281; x=1789722081; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=cY4K5hEbqA2jAPtmBdYZErh868yrTmlvKXQA8mwMwzI=; b=VfEq2RRGApK9w49Pc5X3vNlq+DLbib81h7pzKUCn4MrAsnXh3mHcIOUoxdJmJOcWsu oiphGifuAmptyEa7xuR/rhnuOis94tooJkHwWpqevfM+ptSJmrgXgr/fjnJOC5VdXvQE BCqhQvHDJ6vWbJCukxqj1Si0u/tVGLTJ6bnC6g4mVt9wO9LdVn3Dss5fECiQSUkUpE/B +9Nl6ZZkUSMOTSfgb4//M+183UbbkHngJYJdzk2EXLw3v9t15ad82pjcHrUplIxS/uUn Emgw7dGYa42eR1xBV5wqbNW5NYgAUUFKGSAzEFIXeXNLUFcC8S2VUKxnvgZvLHWmIoG5 ZD0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117281; x=1789722081; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cY4K5hEbqA2jAPtmBdYZErh868yrTmlvKXQA8mwMwzI=; b=mBAll5e5dRed0eSAKSVNKX3CI+LetIWHkwMvKxaQVBPjLPxZ3lCqroxSsUT6q1LQXA 7TU0+gJNpqVWAVbko8aSflgaWZ3aYEWGINWZ4f3dTNCvQpGmaw1mVs7W9JlAWyx/6y5S BfpdME8lZgeqTFuTgWyUtwguyZ9/gQ/ROMHU2t6QOc06rlL6McIltcIPk8EC0YAdh5hK tss1HVMO1I6WS9USTbfpE3Z3eOybYgNBI5F3hKp8vOq9EKQJrd2F/5/cqIywWH9rNinT vFlAtCu1zFOFA4acg0WXJlDmNBBNnSB8q5owPRBXHZqerk68MfftdWpxUrULOn3dTFuE z0TA== X-Gm-Message-State: AFuF++n1VAlVnLYfmVQaDHDcSGIR9NHCTPlvCqiTDeFMaT7ABVa8750B U67Yrx/gzQcb46xaz7xTRGXKAMg/e/BmAxTRanwJXFfMXzyMa4jhLnhaJiLgbdmsfFo4cqDPv7N UYnipAbiG5a0wFR44Nb+Sm3odx1cryN6bykyrmOE5+T7JO73zs4sodOSK8kgZ5AYQAC7HbZ1Ozm e8z5rogHoTj748omdjVoWJQDLC7Q6uvmjLRQ== X-Gm-Gg: AYBFou1g2kA2BTHCpFwKTK+bbzn0VU31yxCNpiAWqVFXF35VIHO5qvimjY3RO19yyU9 tIAZ1vDPRXcIyh4GT6G+P2HoNDDJFfSCAdWXi19H5Gwux0qnEi8VYQEB1mU5YJSU/9zBCS7P4Xt WxNI/eORYQ7ZuRhHi2ZTLecBQgxsEaz8yjLOPZ22yRgvH4RId+i2mlrp8CReg9wqmgJ/l4Arm4L 7cdlqYdbGLQ9XXysuOcOqwONGlCmpN4hBhokCdhSsIdMKeAH4gqseTUeY3MNCcEk3ZiQp9/KrrL QRenWYpYq2z0Wg1q0RmrZYATQMFINVIbVu/eFlAp3iyMAXcGXUia9yNkwO07pF+gxfO1dm4gJUI ohZ0XTmTkecotuskAozC8zp4= X-Received: by 2002:a05:600c:b99:b0:49c:dca4:94c with SMTP id 5b1f17b1804b1-49e619b9d57mr70274255e9.13.1789117280827; Fri, 11 Sep 2026 02:01:20 -0700 (PDT) X-Received: by 2002:a05:600c:b99:b0:49c:dca4:94c with SMTP id 5b1f17b1804b1-49e619b9d57mr70272475e9.13.1789117280084; Fri, 11 Sep 2026 02:01:20 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , Laurent Vivier , Amit Shah , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini , Fam Zheng , qemu-block@nongnu.org Subject: [PULL v2 01/75] virtio: fix exit(1) on DMA mapping failure during migration restore Message-ID: <5ec2a0b21fe5b8e1419a94a753636088d6b0409b.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117317876158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When QEMU restores pending virtio requests from a migration stream, it calls qemu_get_virtqueue_element(), which calls virtqueue_map() and virtqueue_map_iovec() to re-map the saved DMA fragment addresses into the destination address space. If the addresses in the migration stream are corrupted, and as a result dma_memory_map() returns NULL or a shorter-than-expected length, virtqueue_map_iovec() calls exit(1), terminating the destination QEMU process instead of failing the migration cleanly. Convert virtqueue_map_iovec() and virtqueue_map() from void to bool. On failure, virtqueue_map_iovec() unmaps any entries it has already mapped and returns false; virtqueue_map() similarly cleans up the in_sg entries if out_sg mapping fails. qemu_get_virtqueue_element() now checks the return value, frees the element and returns NULL on failure, allowing the migration restore path to propagate a clean error. The callers in virtio-blk, virtio-serial-bus and virtio-scsi that invoke qemu_get_virtqueue_element() during load are updated to check for NULL and return an error code. Fixes: 3b3b062821 ("virtio: slim down allocation of VirtQueueElements") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3888 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 2 +- hw/block/virtio-blk.c | 4 +++ hw/char/virtio-serial-bus.c | 4 +++ hw/scsi/virtio-scsi.c | 4 +++ hw/virtio/virtio.c | 49 +++++++++++++++++++++++++++---------- 5 files changed, 49 insertions(+), 14 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index c99cb19d88..27c5fe3a6b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -320,7 +320,7 @@ bool virtqueue_rewind(VirtQueue *vq, unsigned int num); void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len, unsigned int idx); =20 -void virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem); +bool virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem); void *virtqueue_pop(VirtQueue *vq, size_t sz); unsigned int virtqueue_drop_all(VirtQueue *vq); void *qemu_get_virtqueue_element(VirtIODevice *vdev, QEMUFile *f, size_t s= z); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 6b92066aff..cb6a276a82 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1384,6 +1384,10 @@ static int virtio_blk_load_device(VirtIODevice *vdev= , QEMUFile *f, } =20 req =3D qemu_get_virtqueue_element(vdev, f, sizeof(VirtIOBlockReq)= ); + if (!req) { + error_report("Failed to restore virtio-blk request"); + return -EINVAL; + } virtio_blk_init_request(s, virtio_get_queue(vdev, vq_idx), req); =20 WITH_QEMU_LOCK_GUARD(&s->rq_lock) { diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 83a033ce85..81db0bdc91 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -764,6 +764,10 @@ static int fetch_active_ports_list(QEMUFile *f, =20 port->elem =3D qemu_get_virtqueue_element(vdev, f, sizeof(VirtQueueElemen= t)); + if (!port->elem) { + error_report("Failed to restore virtio-serial element"); + return -EINVAL; + } =20 /* * Port was throttled on source machine. Let's diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index bf64d1231a..132f833226 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -274,6 +274,10 @@ static void *virtio_scsi_load_request(QEMUFile *f, SCS= IRequest *sreq) assert(n < vs->conf.num_queues); req =3D qemu_get_virtqueue_element(vdev, f, sizeof(VirtIOSCSIReq) + vs->cdb_size); + if (!req) { + error_report("Failed to restore virtio-scsi request"); + return NULL; + } virtio_scsi_init_req(s, vs->cmd_vqs[n], req); =20 if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICmdReq) + vs->cdb_size, diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index daa5607338..34f1df260b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1680,36 +1680,56 @@ static void virtqueue_undo_map_desc(AddressSpace *a= s, } } =20 -static void virtqueue_map_iovec(VirtIODevice *vdev, struct iovec *sg, +static bool virtqueue_map_iovec(VirtIODevice *vdev, struct iovec *sg, hwaddr *addr, unsigned int num_sg, bool is_write) { unsigned int i; hwaddr len; + DMADirection dir =3D is_write ? DMA_DIRECTION_FROM_DEVICE : + DMA_DIRECTION_TO_DEVICE; =20 for (i =3D 0; i < num_sg; i++) { len =3D sg[i].iov_len; - sg[i].iov_base =3D dma_memory_map(vdev->dma_as, - addr[i], &len, is_write ? - DMA_DIRECTION_FROM_DEVICE : - DMA_DIRECTION_TO_DEVICE, - MEMTXATTRS_UNSPECIFIED); + sg[i].iov_base =3D dma_memory_map(vdev->dma_as, addr[i], &len, + dir, MEMTXATTRS_UNSPECIFIED); if (!sg[i].iov_base) { error_report("virtio: error trying to map MMIO memory"); - exit(1); + goto err_undo_map; } if (len !=3D sg[i].iov_len) { error_report("virtio: unexpected memory split"); - exit(1); + dma_memory_unmap(vdev->dma_as, sg[i].iov_base, len, dir, 0); + goto err_undo_map; } } + return true; + +err_undo_map: + while (i-- > 0) { + dma_memory_unmap(vdev->dma_as, sg[i].iov_base, sg[i].iov_len, + dir, 0); + } + return false; } =20 -void virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem) +bool virtqueue_map(VirtIODevice *vdev, VirtQueueElement *elem) { - virtqueue_map_iovec(vdev, elem->in_sg, elem->in_addr, elem->in_num, tr= ue); - virtqueue_map_iovec(vdev, elem->out_sg, elem->out_addr, elem->out_num, - fa= lse); + if (!virtqueue_map_iovec(vdev, elem->in_sg, elem->in_addr, + elem->in_num, true)) { + return false; + } + if (!virtqueue_map_iovec(vdev, elem->out_sg, elem->out_addr, + elem->out_num, false)) { + unsigned int i; + for (i =3D 0; i < elem->in_num; i++) { + dma_memory_unmap(vdev->dma_as, elem->in_sg[i].iov_base, + elem->in_sg[i].iov_len, + DMA_DIRECTION_FROM_DEVICE, 0); + } + return false; + } + return true; } =20 static void *virtqueue_alloc_element(size_t sz, unsigned out_num, unsigned= in_num) @@ -2206,7 +2226,10 @@ void *qemu_get_virtqueue_element(VirtIODevice *vdev,= QEMUFile *f, size_t sz) qemu_get_be32s(f, &elem->ndescs); } =20 - virtqueue_map(vdev, elem); + if (!virtqueue_map(vdev, elem)) { + g_free(elem); + return NULL; + } return elem; } =20 --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117335; cv=none; d=zohomail.com; s=zohoarc; b=EP9GxGQjND0pa1Gb+rXL1XhmxzyC3lkLuqkELf0GgxHw6QTbz3jhyawEgYZ1QfiZJKyhF3IlZV9bezaHa3Fy3zpbjWauwh3GZ7nKAHL4n1oZ5WdL6lYyk9dowmHEZTCF2ncQ5Lux9KsDgSNnc7exsoMf0PUab5X5VgoKAhfpszI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117335; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P/dt9G1EklZEpM1Y9s4cFZiMEKzuwD4r1pjdVZY4uXc=; b=IkCpWC1wxuvcPExrqRv6yRiW1LwRB8H48oYW9uwj/xYszekLt8dUeuwraIclS01rGSP6ruxTYrgKQNRYp1CwlME77jfaGV71+MiYny23E6e6hP+uYx7iDnGcVDV/eNfafYZraqquC+3RqV5HNpIu75ZZopO8KjyLl6uE3tCclCE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178911733564435.874273563644465; Fri, 11 Sep 2026 02:02:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8h-0001h1-MV; Fri, 11 Sep 2026 05:01:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8U-0001Zi-GB for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8S-00080S-LE for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:30 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-252-WWIlYM9-Nla8Y40IuBeVag-1; Fri, 11 Sep 2026 05:01:26 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-c293743f5cdso72308466b.0 for ; Fri, 11 Sep 2026 02:01:26 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c2966063a2asm56268466b.27.2026.09.11.02.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117288; 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=P/dt9G1EklZEpM1Y9s4cFZiMEKzuwD4r1pjdVZY4uXc=; b=IhxEFZ1jgherkgJZ6GWl1zmSXbmHfSLP3qfmdPBolkB6R3GJn2eeTpavhEoYFXfQEc4y6o KaEoPUmG5SAdcU/z/hbVfJ4eGj4ff7qojrUFAmcGXaOebdKX3Yp4rh9ZUExleqmzl+oRtL zLn4d6E6siKcEMpdu4GYwiQZ4Ssf4/o= X-MC-Unique: WWIlYM9-Nla8Y40IuBeVag-1 X-Mimecast-MFC-AGG-ID: WWIlYM9-Nla8Y40IuBeVag_1789117285 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117285; x=1789722085; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=P/dt9G1EklZEpM1Y9s4cFZiMEKzuwD4r1pjdVZY4uXc=; b=qq7Lmgyo/9N9jkZ5Nf/EHzJ77HEJlog6sDahICoiiMohNc19shwml7C+aFEaCgyYUY jwzx+Baxu7iHLxCPK9j9E6iHMKAuyxWt/FOoJofBU5tnU3ynVNytXfthYE3RSOO6iDvX EU96r5HqGILdeKlm0g+0iyj6Sl2UM2UM1PBAYfbf003ukS+4xlYrtKjceyb9vgacUmnc dSNSS1MLVwsCDzfyJ1yLracTNdx45cib009AFin0GnC3ORU9g3YJXwrhG3SUieERim/R Y+hSvbt2M3xKCms/f5Mv13DQWWuwvZ/VFxfSmPWrn1hdr0qLa6/A9WTbwdwH/476d5m/ zJ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117285; x=1789722085; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=P/dt9G1EklZEpM1Y9s4cFZiMEKzuwD4r1pjdVZY4uXc=; b=fVFIYcPiAh6AoLzoNHoW342AqitVRLQXTVE4U5ZW/26SWqC0BTaCnjxgatDc8Bpk34 rVcWio39XV8UISOAcE1b6l0NmXDtW6x9EYqPlANP+VEvgOJcv9CyLI43vK6CNlBxOZzs 0YlMopjp4jpastbr/AMTHLfVCzdqrvqd+d39rLSMzv0hPsCg0xGynMGPdDwkaOqrrQBp KNB9koqUAmZjsblyjD2SkoK0Xlzii/P7Zk0WL1NO49mjuuVlJbOwR+PgS1p4tTYKDOeJ upMLE+VmfwQgGJwOishnypQTnnIkZ6DIMUDZI8hLjiZENUQgUVP6jgfevnxfVHfTMeYE cCDQ== X-Gm-Message-State: AFuF++neiHpJuAbxhMtPh+pyVsmwmjPjJWefTET4TQFnZOsxD+fMv48z wH4XCa8MkSgHJwy/sULOVifQzZkx9if5E2nOgyHbIJkQjK8iPh1QIGUycfmW37E8watLPcyQ4F7 b7y9J4eDYst++OQsimvOn662Jg41HhPhoFsCGBtrJcT6vRl6lVgV2vNPYMANimBXbvbMPsR2XNU PWIeHW4ibdk+kceVWxEZvB7deBMZzv1doNgA== X-Gm-Gg: AYBFou2axnVoWrnUY9M0YvR0nXCBZvalzU+JJgqdnFD9g9/hCY8jokM0AeZxfKufEsQ rtAutCcNFcQiuRYrl05Pe1ezReW1xcxCWXbEkuADaniCn3/LCEoGnseX7+6PhOrOs35ZLO7N0d0 fuOMHrbowj8Z4hBAXEZI2g+eOmrvzOCkeT4E72E1ibwH7lqEBxzBhCmNx64rmHKdzzLtEJu8YOH 3A1mf6pU8KBpcP0Pt136qxkx14CwoIMgnTRWSFWPQOvK+mAWUTtO2yi2z7+AToZgwIXW1Ws/p8y 17t9P3usIj/iVG0eQ2CzhEycYffbZ3HCwPIPBWUXnrl1NEHB5DxS0WXBiGRicXf9deNvbmdffL0 TcjjfjKui+uLQ1YBMx4TxzFU= X-Received: by 2002:a17:907:6088:b0:c26:19de:913a with SMTP id a640c23a62f3a-c296674aa4cmr139061966b.45.1789117283919; Fri, 11 Sep 2026 02:01:23 -0700 (PDT) X-Received: by 2002:a17:907:6088:b0:c26:19de:913a with SMTP id a640c23a62f3a-c296674aa4cmr139055366b.45.1789117283036; Fri, 11 Sep 2026 02:01:23 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , "Dr. David Alan Gilbert" Subject: [PULL v2 02/75] virtio: fix config_len DoS in migration restore path Message-ID: <2b35ded9c235145cfb31a8553b29e6faf65899fb.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117337646158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtio_load() reads config_len from the migration stream into a local int32_t variable and then, if the incoming length exceeds the device's own config size, skips the surplus one byte at a time in a loop. Two defects in this loop allow a malicious or truncated migration stream to cause a prolonged CPU spin on the destination QEMU. First, the local variable is int32_t while vdev->config_len is size_t. The C standard converts the signed operand to the unsigned type for the comparison, so any value with the high bit set becomes a very large size_t that exceeds the device config length. The loop then counts the signed counter down through all negative values and back around, effectively running for up to 2^32 iterations. Second, once the file stream reaches EOF, qemu_get_byte() returns 0 without advancing the read position. Without a check for file errors, the loop spins until the counter reaches the device config length. An attacker who sends a large config_len and then closes the stream can hold the destination QEMU busy for attacker-controlled time. Change the local config_len to uint32_t so that the comparison with size_t is unsigned and values with the high bit set are treated as large-but-finite skip counts. In addition, check qemu_file_get_error() after each byte read and return failure immediately when the stream signals EOF or an I/O error. Fixes: 2f5732e964 ("Allow mismatched virtio config-len") Cc: Dr. David Alan Gilbert Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3891 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 34f1df260b..848fe8539e 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3584,6 +3584,9 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int vers= ion_id) return -1; } qemu_get_byte(f); + if (qemu_file_get_error(f)) { + return -1; + } config_len--; } =20 --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117428; cv=none; d=zohomail.com; s=zohoarc; b=klBGgKd5yQdV3clmqEubTzY4R2Lcg03FSAchkonDu+Xl5WiJhXOqhgSF1t5phA0bU8aCMIe6eESZW1zSIBgL3Ar0ckwV0310Ph+9Hi12EdLkVC/Wg/qpW/ZKfZOqIyMz9d7LwSTJjUf8Ypf8cKWsI7DD2oKzy7SDSS9NLUF2aPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117428; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cztzzK3RRsXNvSO1Mj0DbxdXP/qmCz45hPp6THADzZ0=; b=jc8kPEGnHtjhk7SoKJme9zWLonooLZGmcw+NEUT7te2zRJvRZJUq538wgYXOswwKBCJUKDpas5iB5iqry2/5/MAqMao0x5dd1u+GQCaFLncEKTYOpJfn/V2ITN8RU1H+gT9n7XhK7rb7Vq9uK58yUkQ7mOTkWHbIc6I/XNXqV9o= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117428955496.52471817719913; Fri, 11 Sep 2026 02:03:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8o-0001nX-2u; Fri, 11 Sep 2026 05:01:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8V-0001aC-EJ for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8T-00080k-VB for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:31 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-7daRJ0bvOQi_Ufi6DnhEiA-1; Fri, 11 Sep 2026 05:01:27 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-c29466736e3so77959266b.2 for ; Fri, 11 Sep 2026 02:01:27 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c296608dc91sm56569066b.39.2026.09.11.02.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117289; 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=cztzzK3RRsXNvSO1Mj0DbxdXP/qmCz45hPp6THADzZ0=; b=GVuRLuHU4uMiW+Df9ZqF/59+sWio9wSrVJSOvtzPRp4F6tkCRTBYX/ZFG2MjSy7A0L0scf NTLxXnxd2LyrU4m9XGIE1n74MfxMq6LePrEGetOzgtZ28xr4nGXPFQuXQvtuYKQiSVMAt2 8mFbvcm+o8QQgJjxMDuo1j0Tc5kHVAY= X-MC-Unique: 7daRJ0bvOQi_Ufi6DnhEiA-1 X-Mimecast-MFC-AGG-ID: 7daRJ0bvOQi_Ufi6DnhEiA_1789117287 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117286; x=1789722086; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=cztzzK3RRsXNvSO1Mj0DbxdXP/qmCz45hPp6THADzZ0=; b=KcYkn9xqDRVhhmeeFpcAr9a6r+3schAihduhMPM5A5jHNjyHQHqs3fRksxSfrKdEqj fvOUOGJQVscGufm+yr/ZuS7WV6EXYvpZhNxyV130HOXdQwLoHtTP7NwG1zIgcJE7l4Wc f3DZuMuqKQGnh5TRP7zrtIG/P6zINWZxFcc8thdehH5X4Hi+tXT7lHnfBwGA8uMyNjPo R0Vlx5AAaZ1AnG57f+hiP5oYyqxz4wZay1YcH0uFIucsS4nPRK+6uQ7Yd1R7o8QwDIas 9bTpmLQcY257F80Ew2vNqbv0nJlG6FNDSKsdrA9JlsLEZYLRwVYxQ4IBuPdq46sOLYcV kzbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117286; x=1789722086; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cztzzK3RRsXNvSO1Mj0DbxdXP/qmCz45hPp6THADzZ0=; b=eISa98iRmJDBCOjzAwe/zjU1OsMP2Hic3kMdaytJrMuj2szAglRC+aj9RN9mZ1sh9W CG9JjaHuAXYlFX79hEgDIRLVXzdoJwKSMnGiPtBwDKDVCeNFN5iSTxlZR61tQZNbEYQu 4qFASQ3XH58rN8YRWZ2FXyk0aTPE2/tkUKEBJoT6XbopKhRRrK6vpPlXpR7MlFWIEp0O 4jC2O65FrBTytqYUkJLBbZwrkzqY9SEuz0Nl9/OzCd3DDAncg8MuHAdlClLHdxXeXkMQ wkaALWaUqAY42p+HpXfur7wuLMA0MRMZ9VvuUlivmZBLVzkN84N0TW6tPquEg7O5ydQW 5UJA== X-Gm-Message-State: AFuF++nCAElY+uL414yFVXI5Qcf2BgC/LC4JL/hKFr9dpmJU6/ai34uX 6BbL7RMoqgf18Ah/OKHd2xB/pD5hfH8KgnnBHsX4M+hyMhwN3tFoKS6sKh8wS9WordWRKMZPmeM dxktilbkJu0dAsCL3u9ZK/YUCfVKbw+/H6MeX3MCTvRmwfFa6tNghwWhZy2wJO1uRn0Po1WreWM S24T2cYfEU/ALqicCgGKGXPrVcxqyUJLaYGg== X-Gm-Gg: AYBFou0U2V5C2Nz4rvwVNiz1y4xjm5ezqmpQgOPIu9JMz4riI90mCkr2IJCSzb2uS6M yJgMoh0XfNqX0VSZLn8DwRlH3zNQkdqNTDglyGx9bKrQvYrHDiuWv5MCM+D7WXyX+bQB/epPYOx Y5mnaiZVP6PyI2qVhbL8wv2zkolwWIGlxFtBLHoV9o8H0S0uvyuVr6coqpu5fHNyrtlmmR+KG+I c3wyqAuq/3V/SbNS6cR/gS88vAXd7nkMGLnd90o0tzt9k5S5CDLGDZVdk0P6Ly4Ia3my2qdqHVa lZZ5OLWe0R/+4P000uPxlEihiLiDbEY3/AIupy0clzPJqpI5eF5yWUu5asvpfMCe8FTbdoRanMX eviECUwGVCgnF56gWGLAyQfM= X-Received: by 2002:a17:907:a396:b0:c25:4b9c:5ed1 with SMTP id a640c23a62f3a-c29665502efmr119484566b.12.1789117286150; Fri, 11 Sep 2026 02:01:26 -0700 (PDT) X-Received: by 2002:a17:907:a396:b0:c25:4b9c:5ed1 with SMTP id a640c23a62f3a-c29665502efmr119477966b.12.1789117285116; Fri, 11 Sep 2026 02:01:25 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Kangjie Xu Subject: [PULL v2 03/75] virtio-pci: reject Q_ENABLE write on already-enabled queue Message-ID: <62976e8a2ea7fcc8c635754739fbaf2c499dc754.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117430257158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the guest writes 1 to the VIRTIO_PCI_COMMON_Q_ENABLE field of a queue that is already enabled, QEMU re-applies the ring geometry stored in the PCI proxy shadow registers by calling virtio_queue_set_num() and virtio_queue_set_rings(). Those functions update the vring descriptor, available, and used addresses and the region cache, but they do not touch the host-side progress fields - last_avail_idx, shadow_avail_idx, used_idx, inuse, and the packed-ring wrap counters - which are only zeroed by __virtio_queue_reset(). Because the progress indices are stale while the ring layout is new, the host can treat the new ring as though there are up to 65535 pending descriptors already waiting, causing virtqueue_pop() to iterate far beyond what the guest actually posted. On virtio-iommu this translates into a stream of ATTACH/DETACH/MAP/UNMAP commands, driving the QEMU process toward OOM from guest-controlled BAR writes. The virtio specification requires the driver to complete a full queue reset cycle before re-enabling a queue. Fix this by checking the proxy's per-queue enabled flag before processing the write. If the queue is already enabled, log the violation as a guest error and ignore the write. Fixes: d1060e3dc5 ("virtio-pci: support queue enable") Cc: Kangjie Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 6f5db5fc42..c73f1f546c 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1692,6 +1692,13 @@ static void virtio_pci_common_write(void *opaque, hw= addr addr, break; case VIRTIO_PCI_COMMON_Q_ENABLE: if (val =3D=3D 1) { + if (proxy->vqs[vdev->queue_sel].enabled) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: queue %d already enabled - " + "reset queue before re-enabling\n", + __func__, vdev->queue_sel); + break; + } virtio_queue_set_num(vdev, vdev->queue_sel, proxy->vqs[vdev->queue_sel].num); virtio_queue_set_rings(vdev, vdev->queue_sel, --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117432; cv=none; d=zohomail.com; s=zohoarc; b=eUTA1b6MOBup+htdgrMiIb1fzL8zAMvDwi9HfdV7wUrmH213OeU1/CpMV4jNRzh8UJyb6L5GLwbjdL9sw0tO6+1hlNpDuaeqoHlOJ5QE5ZyXzqACTZHhNGlySR/N30N5gpFwqevIWCuKW4QnReTzl9dl3I0CSb9i95Vpw+Qe1Bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117432; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=duT8sfy/1vmAKnbU6GKLoZk3/IV53fEkN7T7OylyeSg=; b=R6R2cIhbJY/1l59M4EXg+K4rd1PoTXNAJXTs4Z98DMj7yTEJZ9Zy/iNoPqT9CZrZ4XHE1arjrdFh4x4YpzzX/89Rddv8WZQcW7mrQlv1EL/2Wpqgh8qagtnOHB5UhU7AiThzLvt2SJOJj/lCSLeQgmkFyacoHt2kS7wykU0M8xA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117432966976.7330498782668; Fri, 11 Sep 2026 02:03:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8j-0001ju-Va; Fri, 11 Sep 2026 05:01:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8a-0001cg-Iz for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8X-00081E-T6 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:36 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649--RBpQmrMO--kpXcMl9R-sA-1; Fri, 11 Sep 2026 05:01:29 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490a767b782so5946025e9.2 for ; Fri, 11 Sep 2026 02:01:29 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e6576122bsm36196675e9.2.2026.09.11.02.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117293; 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=duT8sfy/1vmAKnbU6GKLoZk3/IV53fEkN7T7OylyeSg=; b=fahyY/lvZ8FptJTsZw7hnl8pslfmZmY+iDk6FQPFRHXaXJ22EJYshEnU5+7aR6409turam M3R168HyuRDWWDdSK6XXYvhpO28uO+yZBtZZ1JQ+ye0v4geLwII3crRnBLUI7Hvy3CkCtx iG2QGutk4ak1dwDWEFxnAReY1s5W38g= X-MC-Unique: -RBpQmrMO--kpXcMl9R-sA-1 X-Mimecast-MFC-AGG-ID: -RBpQmrMO--kpXcMl9R-sA_1789117288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117288; x=1789722088; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=duT8sfy/1vmAKnbU6GKLoZk3/IV53fEkN7T7OylyeSg=; b=BUZ3yhLBFMwK6LqnZVdCzVMvnbe5bs2kwatZyPCZOT2Itz4XdzlXjAazZ5NihXdJGZ ZHU+vzIdwaRgUJoyrSdJBqS3OPxS3EOLBPtyzcDcUdUo5jKeyxOYNkb8piUN4NN/VlJU oY7qGblHrn/dYsBKJr/5glpiaSz+VWw+XPfQ5+J02p8MQqXAncQhOmcljsfl5K7htPEx 8gNdG3dGUbBnt2rF9mgqbu/RU4cxXR9MTSwj8IH78RpWifkyOlFquivB8dfKcQ31L0Mw vqv/iEbliVjcsSpOGg9gUajBd87vvUoRSrDPXWu4xjIWWwkrZdZ1zQuuWX/SZBwWsVTl 4OPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117288; x=1789722088; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=duT8sfy/1vmAKnbU6GKLoZk3/IV53fEkN7T7OylyeSg=; b=nv6YZqCylKd/dX8wSSa+zvK2H2x+zZFTprm691Lhtgvu/jl8VbUY/BylptSk27Dfas EY23xFlp9aIYVelVLGQnJYBr/LqHzbhL5MBI4b/XTHjlb379W8t0wjYrRJzsT1/z9Mn/ quuyGSckUNp2aFSbC318lD1Cf/1m+PotTnu8v+R1wD1gk8fDYFb09nEwbd63Ao3+8z5K DQ+kSnwJ/Ik3nS+gO9K4gj06LOCNRakml8/3TQA1WHgEsJ5kKN27zKNHceJ54kg8kIgX xLNEDBfzk0oz2qR4CLLsjDw+Pw5JWuHYseC5/uCGiJ+Nf/E9fdWoprKJuU5abM8DHEsl dJdg== X-Gm-Message-State: AFuF++kcjF2KQW21i8ojdXr0GjcsW+G2nXcvm2PqCIemm5Y8YbPcC/W/ SarRUizVuV/OQswO2CCVfJRz/1HBNymbh56vdChddTpbbT5CGg1RqTXki5VZCJeIVod+rO/YzwH 6OumPBpo/0EvtOj/AIlOVivWRVr6Z0tnGpo2LNCXmss0UlMnXFPxHGm1Aw/zOFCL3xRvTWERPKV xRWI6JVRR7JuG6iXn7fm4ToqDx2LAG3m9mSw== X-Gm-Gg: AYBFou1m3pGs4zPQMvPx0CHlEx7Xp64wnNYmX0Md0r3IfIS8ptLZsAcKqAb4z9wthKT C3CzZ9rAnAaX+65W8bt3VnYvzNX7T1lX4QzA3zauaU0sKMoT5JqlZDmAsdDDQAhIw9ib1McLvHL SqH4n0T8FnvvQhbrumowRt2PaqIhEmEG90e05cw9fpmpOwbr3kdACdXJeOeer1zq7RjT94nmRKz 5Jsu4vZiRqdmolfl9d8SO7E6B4bUJkckgZTiJSJGb84BBmjiih1lsVlAtHX96mq95IY3Ekq7/3f CHZLLTQnAAZzVNRh4E5z4j8rMJSPMBicIW5oZx/CT2NKp3oUlh0p4blgWwDy6yqJglu8USbP2em m17+wSMDD4RjfMvDTdkQTbzk= X-Received: by 2002:a05:600d:8490:20b0:49d:e0c:e560 with SMTP id 5b1f17b1804b1-49e61983771mr26335675e9.4.1789117288135; Fri, 11 Sep 2026 02:01:28 -0700 (PDT) X-Received: by 2002:a05:600d:8490:20b0:49d:e0c:e560 with SMTP id 5b1f17b1804b1-49e61983771mr26334855e9.4.1789117287535; Fri, 11 Sep 2026 02:01:27 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Junjie Cao , qemu-stable@nongnu.org, Jonathan Cameron , linux-cxl@vger.kernel.org Subject: [PULL v2 04/75] hw/cxl: Fix guest-triggerable QEMU exit on reserved interleave ways Message-ID: <713e7e85a2b43e9d4e58d91643aef230d2c30b07.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117434271158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Junjie Cao A buggy or malicious guest can program a committed HDM decoder with a reserved Interleave Ways encoding (e.g. 0x5-0x7, 0xb-0xf). Two call sites pass &error_fatal to cxl_interleave_ways_dec(), which calls exit(1) on the reserved encoding before the subsequent decoded_iw =3D=3D 0 guards can run: - cxl-host.c update_non_interleaved(): called at commit time from hdm_decoder_commit() via cfmws_update_non_interleaved(), so a guest writing COMMIT with a reserved IW terminates QEMU immediately. This is the primary trigger on the current tree. - cxl_type3.c cxl_type3_dpa(): called on memory access while iterating past committed decoders to accumulate dpa_base. Once the commit-time exit is removed, the decoder stays committed with the reserved encoding, so a later guest access outside that decoder's range would otherwise hit this second &error_fatal; both are fixed here. Pass NULL instead of &error_fatal at both sites so that the reserved encoding returns zero and the existing guards handle it gracefully. This can be reproduced by writing the HDM Decoder 0 Control register with a reserved IW encoding and the COMMIT bit set (e.g. IW=3D0x5, COMMIT=3D1). Cc: qemu-stable@nongnu.org Fixes: 680935c9a6ff ("hw/cxl: Add a performant (and correct) path for the n= on interleaved cases") Fixes: 48461825af1b ("hw/mem/cxl_type3: Fix potential divide by zero report= ed by coverity") Signed-off-by: Junjie Cao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260618104316.557306-1-junjie.cao@intel.com> --- hw/cxl/cxl-host.c | 2 +- hw/mem/cxl_type3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index eba13c9e7c..369a985f9b 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -442,7 +442,7 @@ static int update_non_interleaved(Object *obj, void *op= aque) } } =20 - interleave_ways_dec =3D cxl_interleave_ways_dec(iw, &error_fatal); + interleave_ways_dec =3D cxl_interleave_ways_dec(iw, NULL); if (interleave_ways_dec =3D=3D 0) { return 0; } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 28f41fa623..6f44770db6 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1200,7 +1200,7 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr h= ost_addr, uint64_t *dpa) } if (((uint64_t)host_addr < decoder_base) || (hpa_offset >=3D decoder_size)) { - int decoded_iw =3D cxl_interleave_ways_dec(iw, &error_fatal); + int decoded_iw =3D cxl_interleave_ways_dec(iw, NULL); =20 if (decoded_iw =3D=3D 0) { return false; --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117322; cv=none; d=zohomail.com; s=zohoarc; b=Nu6zKVpEdgosFbIgcxrwrZ0NgwjHbRDLf1WP1rlbPl0PFWdTA7o3m07MXqRwhjUetWs2Shg2jy+BGgAnWnpx2kMdnqCapSCrNKc66I7TQD8h2XQi9mAHGn30mTf9hBAt2LYkl7v7PHGiCYwJ/FOY6xwLZmTXuYYSlH3qJImlo+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117322; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cK0jKLb9Y25sWTW+STMCp41/svnDlrpZe9udpBmpYJc=; b=SCz2x9DSe6JJ3GzHSo9BpbRialt5cuyaNEbFu/V1qRgzHwcxbNbmHv+4URoZEEOKEKuhiTELaMMbnKtfr2GlBLVF8J3pyCNvlgK/5OSZoubgM4CUqSkzhQY/IGpzehoudJU40O9yg/vCIdNGKghG1o+AtqvOELcQhRXXgI1jq2c= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117322046608.5811274569746; Fri, 11 Sep 2026 02:02:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8l-0001m7-DJ; Fri, 11 Sep 2026 05:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8a-0001cf-FI for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8Y-00081R-KW for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:36 -0400 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-100-p0CVLyvtNeupMD86e1zGdQ-1; Fri, 11 Sep 2026 05:01:32 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-6a98570af94so1915015a12.1 for ; Fri, 11 Sep 2026 02:01:32 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c2966021d0dsm58249166b.10.2026.09.11.02.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117294; 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=cK0jKLb9Y25sWTW+STMCp41/svnDlrpZe9udpBmpYJc=; b=JuOLgIVG4d/gZbEdK/Zrkk6+9EmY+B75yqDYhEPy4ZjxidyKD5EEEW7MU1iPd4TOYjbLEt IfBL5uliwnofkFm1mqKmAA1murfMM1bXxkuaaepJeMhf84l+I1tzAITxY/PU16/NuuCxyn qkfiaDInWZC4ot9N/EYqeiOLcNanU2Y= X-MC-Unique: p0CVLyvtNeupMD86e1zGdQ-1 X-Mimecast-MFC-AGG-ID: p0CVLyvtNeupMD86e1zGdQ_1789117291 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117291; x=1789722091; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=cK0jKLb9Y25sWTW+STMCp41/svnDlrpZe9udpBmpYJc=; b=PPTmO4Av2682/TAuMzMcCarLOLQZeVzyASfBibJn5FEcdi17C5WUNUG8llmOHY7JNn 1VQXjMdGmNhk9jzRfr10FdmhGZiuZJ76K/gL8bgxCR5lR+vIPA/UH6kNhit5Vs/MABFM DvGF7XINZxncnLn5n/FZVSaiBIwLmGY9B1JINHJULqU04LktWCRZ3H9U0+YAtpif9syN ovgcrN7T2ZNSXf7mgDuVMdeObEtWlPOTpHxNxnDTaj7v85zihHWbu+YSmkGITaGXF0B3 AvsCEP1c7hH/xj/+Lf1D+T8tJAyIqv3LvOfhose1ppYNZ5Ez/tvtl/SrKCZsDSSrbkie z3cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117291; x=1789722091; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cK0jKLb9Y25sWTW+STMCp41/svnDlrpZe9udpBmpYJc=; b=DbtZsshwNjmjqnRYbsyKf0Qeg4hMJXx+uPU1tiEabqunQRVDepmhzSY9K+e9DRlQKk Gt9dzTMMzzaXo0qfAHY18AHNvSrVt6PVupwvEnovjmYkgeLTDpOgEEyikm5W2u1L6mJV fVZae2gtCP1Pzfr5i9h2FYjes4lnzrcPoWP/AZqi/8BkVX2uW+7PtfsZUdn0FLCcJGai DdSgGMzLfgGT/e+RkDACAHDppKOZw9bH+p61hmWlBOJy48WyDXXNPGPa4t3+IyhvkFw9 9Mu1D2x/d7z+WvQQcs9ZA09zdSz/NTSmPW6uRn0TodqhEDoK8jrbs1CP6TwV1SEOFKqG wztg== X-Gm-Message-State: AFuF++nTTAODtgPYkTy03w6gkUgiXs2bOo3y+w4uuLY8DUQoI6xhqCJs vvHthYhGvs7ocn7fkER0SgMnrLUsROorFs8GkCQqovgRXUFW0jwhQkJIwdArh88+NXfW6JMyXl5 ckOHhirrp3w9Uz374zdpP74Oe8SnQ1gBBR9615rq42AzVo31TiuotcHVMgr04volXyncFqwuAcV yEuI18Yq5tGC9tKI3lD6BKSW3MYJFgqArS0g== X-Gm-Gg: AYBFou2n+XCH0ZKyujX/BaoCwCKMclc1lxfuZqZ+M8SlWH+eiWJ4xQi92ovITiOEaU0 yzVlatFrEbV36VB7ESoappwSg4w2W4NVTZIRTtyN6sENycIJvFuSrVSuwaOGUNK3HhnKjy/+np3 GYihmSf4z9YSH8tUG8u9E/RW3qB/weiUNOF3UPVwUH2SFClfjZaGdFqx6CVgzSXW8Vtp06lhz0y fuacF62iVF76hSu5k8YkKEgMUaanKAGJM0OQ7wed6IYkGgIOxvPjn/zsk2y4uFHbX2JXJWCjka9 DQfTgqTcwIjT3KEZt4DLdJvpweb1YA6gN4q19kVQSAQ9ouBS5WNyPGIgydL0YbLP4MS7XN99OQi SMw6BTuEEU+DWPdZwImuQvhs= X-Received: by 2002:a17:907:3e0f:b0:c25:5159:6a25 with SMTP id a640c23a62f3a-c2945db2ce7mr402583366b.6.1789117290812; Fri, 11 Sep 2026 02:01:30 -0700 (PDT) X-Received: by 2002:a17:907:3e0f:b0:c25:5159:6a25 with SMTP id a640c23a62f3a-c2945db2ce7mr402578366b.6.1789117289954; Fri, 11 Sep 2026 02:01:29 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Albert Esteve , Dorinda Bassey , Cornelia Huck , Paolo Bonzini Subject: [PULL v2 05/75] linux-headers: add VIRTIO_ID_MEDIA Message-ID: <90cb8b107339ae32360e954bd26357ea6e5fe3de.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117323628158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Albert Esteve The ID was added in Linux commit 2187be212179 ("virtio: Add ID for virtio media") and is included in v7.3-rc1. Signed-off-by: Albert Esteve Reviewed-by: Michael S. Tsirkin Tested-by: Dorinda Bassey Signed-off-by: Michael S. Tsirkin Message-ID: <20260901-virtio-media-v2-1-bd3cc9347ab9@redhat.com> --- include/standard-headers/linux/virtio_ids.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/standard-headers/linux/virtio_ids.h b/include/standard= -headers/linux/virtio_ids.h index 6c12db16fa..f9056af0c6 100644 --- a/include/standard-headers/linux/virtio_ids.h +++ b/include/standard-headers/linux/virtio_ids.h @@ -69,6 +69,7 @@ #define VIRTIO_ID_BT 40 /* virtio bluetooth */ #define VIRTIO_ID_GPIO 41 /* virtio gpio */ #define VIRTIO_ID_SPI 45 /* virtio spi */ +#define VIRTIO_ID_MEDIA 48 /* virtio media */ =20 /* * Virtio Transitional IDs --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117350; cv=none; d=zohomail.com; s=zohoarc; b=nfe3ZlaZ+XzK8s8HTqBN0gj0LAl23f9Wz85AJ2eSU+HFNFZ+mLS5HArPvdn76MHipdTJtr7SRn1V+zPtrgzwTiaB8RLEkYvSDw6iuQ8sFln41quJVqpsBXjjN4Qpjl49DrcJkWdQypybGr+zcoVotTipcA8kl9yOSjIZ0Qf0ji8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117350; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7Pkx3kxAuiL1nB7bUYs1e0dAYEeoWG4XC8UPSEM/wlk=; b=KK1Btfm8sI+taQh+no4B+f2TJow+/sHyp1XD+pEbFlhMbOtrOrg0Micnka7k3ya1yiQaTQPR9SAQwK9hDXxQ5leESrwt942N1JcFoV0i/iD6ho+YcuJgbhJBDQOadf9YNjSyNCu+F7zN6F2E1V5BKTZFucnDU0PZ2RbiqHFR83A= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117349990738.9897361245936; Fri, 11 Sep 2026 02:02:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8t-0001ux-GT; Fri, 11 Sep 2026 05:01:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8j-0001kD-Jk for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8f-00082N-PG for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:45 -0400 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-498-ILn_4RnGOtqNNoMIWxN5lg-1; Fri, 11 Sep 2026 05:01:39 -0400 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-6a99446422cso689321a12.2 for ; Fri, 11 Sep 2026 02:01:39 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb34e74esm4567513f8f.25.2026.09.11.02.01.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117301; 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=7Pkx3kxAuiL1nB7bUYs1e0dAYEeoWG4XC8UPSEM/wlk=; b=b0W6Lx5wC7AFLNpOne5stVEEzrbaR6lrQZqjf730XPJFIk7p7XG8V85O9U+ZZZtV6V7Q/K B5yfe2eVKkIGzC+0RNBO7jZVKT+rqMQQ4qiYMjG90unPGmdggFi0N2iFIir3Rypv+EfVzB c+z9FrTuCwsTHCVOg3CmWFeyl62rsuo= X-MC-Unique: ILn_4RnGOtqNNoMIWxN5lg-1 X-Mimecast-MFC-AGG-ID: ILn_4RnGOtqNNoMIWxN5lg_1789117298 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117298; x=1789722098; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=7Pkx3kxAuiL1nB7bUYs1e0dAYEeoWG4XC8UPSEM/wlk=; b=jteXImJPM3Sf0EUorH692w+069jZZTaqTyC831pUoYpEI/cbDPBAqecqWBZXN9FktN lZZ7Wm/fyXbfuAOhHaRoYQhft+1bTMvOnsI25A11agz0bvjenBajRtaLb9d5sIWgptBU jFBadANHOuIizz6zcSBKz/3Q18M5xl8GYHeeYRii+iszvMvP37wtwpf6kQVeDkhYFKhI CjJyqjw4djuRaP4IWDnXrxZ9r4pMBNqO/C3GxbrRX+vDXKocAouDgYQILTPCxqnggJIm 86W4Kb5jKyNWpERCnoXDt7gk6jhIfsVg6KoqAmrBsYj+rmhyU4tLveyFYktSjR6mMaRC zJ3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117298; x=1789722098; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7Pkx3kxAuiL1nB7bUYs1e0dAYEeoWG4XC8UPSEM/wlk=; b=dQ33akH2A6Ie3iDwsR1YWZnjQ8Cte9qqoeqo+sbiDRL1l5ltT1irsLmHgdBSbq9bS5 lqsC4XYl/TxmpshkAOhkOBIXeVyW6ZhY+4X9CphYGudwHlbjcqcGdiHbw3JtgfWL5njB elg6V9ZnR4rT1v7qBChoDh7PpsuWQ1jsW/Z4HJDSYsc0jzUKQITm1h+jslz15rSUtJXe +kS+DyRKHDoMUeCAMPjwpg+mYVvonD7KMK0KxOxu6pakYsz0xuvXN9VTbt7u36Nc6R+Q h8QY+pq90U1UBB8qvMP+SyaMz7+2lDJHvnGJQo6hi4f8/IkVnQl21ke+YFU56Fks6JD2 JHhA== X-Gm-Message-State: AFuF++lzwKMgAgZhvoBH0mVU/RFN5FAIU9JWsqieQJ7FkciEgyfPkZvU AC7YoaXzOv4N6SiwwOfF6sXxBTaF4m5rdjrfAqZG85fYMrUUDw3o4YcP3KChFJ3zaWVhNnHcNLZ Eqz99NRet3KKuMJVN1n3xjQa1rxNB9fTJlAIqgJuHMHqS4tNYJYX8QVp0/yYRkwi/cV4hE4HRAC jLui+G4ymjanbEU8NjR1wH6P/APDiWL7OSMw== X-Gm-Gg: AYBFou3FFY+M4yX6ulk1as2cDwMVjaZu6278fXM2/HbE64FIiCwNNy34sh8DGvRK+rL m3P0CiRpAyNq2cBMG+IgTIkaGEaQLtzOHncoIPdG7HJUYc4+wvA0GTgzcNKfv00pl95H7fHTTa/ 4c0poqcqOFugH9eRxxG2KP6tGuKzJeKLRDI11XzW/CcW2jF34FMu5Z/jh8zMBw3ocJ3yIpPfZfK CcqT2+p2JdNA2XnVIMRfPEJHKKIZomybOJadAzTYuqkL09nv1fEYKLHyyT7ONbNqpPlpraUwv+3 DyqH1eAE//QB4i33QPhXUzOV3uGaE+hGQKuJoosH9BdhOdMFY5nrUB+ImHazUm/LUufhd/626Gx KuD3cxV3DE0LGIootWhtBEvk= X-Received: by 2002:a05:6402:4547:b0:6a9:2a18:fcf9 with SMTP id 4fb4d7f45d1cf-6a9b56f7cc8mr950890a12.45.1789117295271; Fri, 11 Sep 2026 02:01:35 -0700 (PDT) X-Received: by 2002:a05:6402:4547:b0:6a9:2a18:fcf9 with SMTP id 4fb4d7f45d1cf-6a9b56f7cc8mr950397a12.45.1789117292443; Fri, 11 Sep 2026 02:01:32 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Albert Esteve , Dorinda Bassey , Paolo Bonzini , Stefano Garzarella , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Subject: [PULL v2 06/75] hw/display: add vhost-user-media device Message-ID: <866efe842a8a51f614090b4d88ec57e906d75235.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117351848158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Albert Esteve Add the QEMU side of the vhost-user-media device, which connects to a virtio-media vhost-user backend daemon implementing the V4L2 API over the virtio-media protocol. The virtio-media device is specified in the VirtIO specification v1.4, section 5.22: https://docs.oasis-open.org/virtio/virtio/v1.4/cs01/virtio-v1.4-cs01.ht= ml Tested with the rust-vmm vhost-device-media backend [1]: cargo run -- -s /path/to/media.sock -d /dev/video0 --backend v4l2-proxy Example invocation: qemu-system-x86_64 \ -chardev socket,path=3D/path/to/media.sock,id=3Dmedia \ -device vhost-user-media-pci,chardev=3Dmedia,id=3Dmedia [1] https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-media Tested-by: Dorinda Bassey Signed-off-by: Albert Esteve Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260901-virtio-media-v2-2-bd3cc9347ab9@redhat.com> --- MAINTAINERS | 6 + include/hw/virtio/vhost-user-media.h | 46 ++++ hw/display/vhost-user-media-pci.c | 80 ++++++ hw/display/vhost-user-media.c | 348 +++++++++++++++++++++++++++ hw/virtio/virtio.c | 3 +- hw/display/Kconfig | 5 + hw/display/meson.build | 3 + 7 files changed, 490 insertions(+), 1 deletion(-) create mode 100644 include/hw/virtio/vhost-user-media.h create mode 100644 hw/display/vhost-user-media-pci.c create mode 100644 hw/display/vhost-user-media.c diff --git a/MAINTAINERS b/MAINTAINERS index 7183babd6a..ec313c3259 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2690,6 +2690,12 @@ S: Supported F: include/hw/virtio/vhost-user-rtc.h F: hw/virtio/vhost-user-rtc* =20 +vhost-user-media +M: Albert Esteve +S: Supported +F: hw/display/vhost-user-media* +F: include/hw/virtio/vhost-user-media.h + virtio-crypto M: Gonglei S: Supported diff --git a/include/hw/virtio/vhost-user-media.h b/include/hw/virtio/vhost= -user-media.h new file mode 100644 index 0000000000..d040c70f63 --- /dev/null +++ b/include/hw/virtio/vhost-user-media.h @@ -0,0 +1,46 @@ +/* + * vhost-user-media virtio device + * + * Copyright Red Hat, Inc. 2026 + * + * Authors: + * Albert Esteve + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_VHOST_USER_MEDIA_H +#define QEMU_VHOST_USER_MEDIA_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "qom/object.h" + +#define TYPE_VHOST_USER_MEDIA "vhost-user-media-device" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserMEDIA, VHOST_USER_MEDIA) + +/* virtio-media config layout, spec 5.22.4 */ +struct virtio_media_config { + uint32_t device_caps; + uint32_t device_type; + uint8_t card[32]; +} QEMU_PACKED; + +typedef struct { + CharFrontend chardev; +} VHostUserMEDIAConf; + +struct VHostUserMEDIA { + /*< private >*/ + VirtIODevice parent; + VHostUserMEDIAConf conf; + struct vhost_dev vhost_dev; + VhostUserState vhost_user; + VirtQueue *command_vq; + VirtQueue *event_vq; + bool connected; + /*< public >*/ +}; + +#endif /* QEMU_VHOST_USER_MEDIA_H */ diff --git a/hw/display/vhost-user-media-pci.c b/hw/display/vhost-user-medi= a-pci.c new file mode 100644 index 0000000000..3e09fcfdd0 --- /dev/null +++ b/hw/display/vhost-user-media-pci.c @@ -0,0 +1,80 @@ +/* + * Vhost-user MEDIA virtio device PCI glue + * + * Copyright Red Hat, Inc. 2026 + * Authors: Albert Esteve + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/core/qdev-properties.h" +#include "hw/virtio/vhost-user-media.h" +#include "hw/virtio/virtio-pci.h" + +#define TYPE_VHOST_USER_MEDIA_PCI "vhost-user-media-pci-base" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserMEDIAPCI, VHOST_USER_MEDIA_PCI) + +struct VHostUserMEDIAPCI { + VirtIOPCIProxy parent_obj; + VHostUserMEDIA vdev; +}; + +static const Property vumedia_pci_properties[] =3D { + DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, + VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), + DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, + DEV_NVECTORS_UNSPECIFIED), +}; + +static void vumedia_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserMEDIAPCI *dev =3D VHOST_USER_MEDIA_PCI(vpci_dev); + DeviceState *dev_state =3D DEVICE(&dev->vdev); + + if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { + vpci_dev->nvectors =3D 1; + } + + if (!qdev_realize(dev_state, BUS(&vpci_dev->bus), errp)) { + return; + } +} + +static void vumedia_pci_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); + k->realize =3D vumedia_pci_realize; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + device_class_set_props(dc, vumedia_pci_properties); + pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id =3D 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision =3D 0x00; + pcidev_k->class_id =3D PCI_CLASS_MULTIMEDIA_VIDEO; +} + +static void vumedia_pci_instance_init(Object *obj) +{ + VHostUserMEDIAPCI *dev =3D VHOST_USER_MEDIA_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_MEDIA); +} + +static const VirtioPCIDeviceTypeInfo vumedia_pci_info =3D { + .base_name =3D TYPE_VHOST_USER_MEDIA_PCI, + .non_transitional_name =3D "vhost-user-media-pci", + .instance_size =3D sizeof(VHostUserMEDIAPCI), + .instance_init =3D vumedia_pci_instance_init, + .class_init =3D vumedia_pci_class_init, +}; + +static void vumedia_pci_register(void) +{ + virtio_pci_types_register(&vumedia_pci_info); +} + +type_init(vumedia_pci_register); diff --git a/hw/display/vhost-user-media.c b/hw/display/vhost-user-media.c new file mode 100644 index 0000000000..14edc7c668 --- /dev/null +++ b/hw/display/vhost-user-media.c @@ -0,0 +1,348 @@ +/* + * Vhost-user Media device + * + * Copyright Red Hat, Inc. 2026 + * + * This is the boilerplate for instantiating a vhost-user device + * implementing a virtio-media device. + * + * Authors: + * Albert Esteve + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "hw/core/qdev-properties-system.h" +#include "standard-headers/linux/virtio_ids.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-media.h" + +static const int feature_bits[] =3D { + VIRTIO_F_VERSION_1, + VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_RING_F_INDIRECT_DESC, + VIRTIO_RING_F_EVENT_IDX, + VIRTIO_F_RING_RESET, + VHOST_INVALID_FEATURE_BIT +}; + +static void +vu_media_get_config(VirtIODevice *vdev, uint8_t *config_data) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + Error *local_err =3D NULL; + int ret; + + memset(config_data, 0, sizeof(struct virtio_media_config)); + + ret =3D vhost_dev_get_config(&media->vhost_dev, + config_data, sizeof(struct virtio_media_con= fig), + &local_err); + if (ret) { + error_report_err(local_err); + return; + } +} + +static void vu_media_start(VirtIODevice *vdev) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + int ret; + int i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret =3D vhost_dev_enable_notifiers(&media->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret =3D k->set_guest_notifiers(qbus->parent, media->vhost_dev.nvqs, tr= ue); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + media->vhost_dev.acked_features =3D vdev->guest_features; + + media->vhost_dev.vq_index_end =3D media->vhost_dev.nvqs; + ret =3D vhost_dev_start(&media->vhost_dev, vdev, true); + if (ret < 0) { + error_report("Error starting vhost-user-media: %d", -ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i =3D 0; i < media->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&media->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, media->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&media->vhost_dev, vdev); +} + +static void vu_media_stop(VirtIODevice *vdev) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&media->vhost_dev, vdev, true); + + ret =3D k->set_guest_notifiers(qbus->parent, media->vhost_dev.nvqs, fa= lse); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&media->vhost_dev, vdev); +} + +static int vu_media_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + bool should_start =3D virtio_device_should_start(vdev, status); + + if (vhost_dev_is_started(&media->vhost_dev) =3D=3D should_start) { + return 0; + } + + if (should_start) { + vu_media_start(vdev); + } else { + vu_media_stop(vdev); + } + return 0; +} + +static uint64_t vu_media_get_features(VirtIODevice *vdev, + uint64_t requested_features, + Error **errp) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + return vhost_get_features(&media->vhost_dev, feature_bits, + requested_features); +} + +static void vu_media_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void vu_media_guest_notifier_mask(VirtIODevice *vdev, int idx, + bool mask) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } + + vhost_virtqueue_mask(&media->vhost_dev, vdev, idx, mask); +} + +static bool vu_media_guest_notifier_pending(VirtIODevice *vdev, int idx) +{ + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } + + return vhost_virtqueue_pending(&media->vhost_dev, idx); +} + +static int vu_media_handle_config_change(struct vhost_dev *dev) +{ + virtio_notify_config(dev->vdev); + return 0; +} + +static const VhostDevConfigOps media_ops =3D { + .vhost_dev_config_notifier =3D vu_media_handle_config_change, +}; + +static int vu_media_connect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + if (media->connected) { + return 0; + } + media->connected =3D true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vu_media_start(vdev); + } + + return 0; +} + +static void vu_media_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + if (!media->connected) { + return; + } + media->connected =3D false; + + if (vhost_dev_is_started(&media->vhost_dev)) { + vu_media_stop(vdev); + } +} + +static void vu_media_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vu_media_connect(dev) < 0) { + qemu_chr_fe_disconnect(&media->conf.chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vu_media_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserMEDIA *medi= a, + struct vhost_virtqueue *vhost_vqs) +{ + virtio_delete_queue(media->command_vq); + virtio_delete_queue(media->event_vq); + g_free(vhost_vqs); + virtio_cleanup(vdev); + vhost_user_cleanup(&media->vhost_user); +} + +static void vu_media_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(dev); + struct vhost_virtqueue *vhost_vqs; + int ret; + + if (!media->conf.chardev.chr) { + error_setg(errp, "vhost-user-media: chardev is mandatory"); + return; + } + + if (!vhost_user_init(&media->vhost_user, &media->conf.chardev, errp)) { + return; + } + + virtio_init(vdev, VIRTIO_ID_MEDIA, sizeof(struct virtio_media_config)); + + media->command_vq =3D virtio_add_queue(vdev, 128, vu_media_handle_outp= ut); + media->event_vq =3D virtio_add_queue(vdev, 128, vu_media_handle_output= ); + media->vhost_dev.nvqs =3D 2; + media->vhost_dev.vqs =3D g_new0(struct vhost_virtqueue, + media->vhost_dev.nvqs); + vhost_vqs =3D media->vhost_dev.vqs; + + vhost_dev_set_config_notifier(&media->vhost_dev, &media_ops); + media->vhost_user.supports_config =3D true; + + ret =3D vhost_dev_init(&media->vhost_dev, &media->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + if (ret < 0) { + do_vhost_user_cleanup(vdev, media, vhost_vqs); + return; + } + + qemu_chr_fe_set_handlers(&media->conf.chardev, NULL, + NULL, vu_media_event, + NULL, (void *)dev, NULL, true); +} + +static void vu_media_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VHostUserMEDIA *media =3D VHOST_USER_MEDIA(dev); + struct vhost_virtqueue *vhost_vqs =3D media->vhost_dev.vqs; + + /* This will stop vhost backend if appropriate. */ + vu_media_set_status(vdev, 0); + vhost_dev_cleanup(&media->vhost_dev); + do_vhost_user_cleanup(vdev, media, vhost_vqs); +} + +static const VMStateDescription vu_media_vmstate =3D { + .name =3D "vhost-user-media", + .unmigratable =3D 1, +}; + +static const Property vu_media_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserMEDIA, conf.chardev), +}; + +static void vu_media_class_init(ObjectClass *klass, const void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vu_media_properties); + dc->vmsd =3D &vu_media_vmstate; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + vdc->realize =3D vu_media_device_realize; + vdc->unrealize =3D vu_media_device_unrealize; + vdc->get_features =3D vu_media_get_features; + vdc->get_config =3D vu_media_get_config; + vdc->set_status =3D vu_media_set_status; + vdc->guest_notifier_mask =3D vu_media_guest_notifier_mask; + vdc->guest_notifier_pending =3D vu_media_guest_notifier_pending; +} + +static const TypeInfo vu_media_info =3D { + .name =3D TYPE_VHOST_USER_MEDIA, + .parent =3D TYPE_VIRTIO_DEVICE, + .instance_size =3D sizeof(VHostUserMEDIA), + .class_init =3D vu_media_class_init, +}; + +static void vu_media_register_types(void) +{ + type_register_static(&vu_media_info); +} + +type_init(vu_media_register_types) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 848fe8539e..0b2fbbed3f 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -198,7 +198,8 @@ const char *virtio_device_names[] =3D { [VIRTIO_ID_AUDIO_POLICY] =3D "virtio-audio-pol", [VIRTIO_ID_BT] =3D "virtio-bluetooth", [VIRTIO_ID_GPIO] =3D "virtio-gpio", - [VIRTIO_ID_SPI] =3D "virtio-spi" + [VIRTIO_ID_SPI] =3D "virtio-spi", + [VIRTIO_ID_MEDIA] =3D "virtio-media", }; =20 static const char *virtio_id_to_name(uint16_t device_id) diff --git a/hw/display/Kconfig b/hw/display/Kconfig index b3593fe981..060274b1e6 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -120,6 +120,11 @@ config VHOST_USER_VGA default y depends on VIRTIO_VGA && VHOST_USER_GPU =20 +config VHOST_USER_MEDIA + bool + default y + depends on VIRTIO && VHOST_USER + config DPCD bool select AUX diff --git a/hw/display/meson.build b/hw/display/meson.build index ffecedbf70..d8b4e121fe 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -37,6 +37,9 @@ system_ss.add(when: 'CONFIG_NEXTCUBE', if_true: files('ne= xt-fb.c')) system_ss.add(when: 'CONFIG_VGA', if_true: files('vga.c')) system_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-dmabuf.c')) system_ss.add(when: 'CONFIG_DM163', if_true: files('dm163.c')) +system_ss.add(when: 'CONFIG_VHOST_USER_MEDIA', if_true: files('vhost-user-= media.c')) +system_ss.add(when: ['CONFIG_VHOST_USER_MEDIA', 'CONFIG_VIRTIO_PCI'], + if_true: files('vhost-user-media-pci.c')) =20 stub_ss.add([files('acpi-vga-stub.c'), pixman]) if (config_all_devices.has_key('CONFIG_VGA_CIRRUS') or --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117393; cv=none; d=zohomail.com; s=zohoarc; b=HV1ENGsppSAafceOn47odpmdHIfN+2IgJvHRiTeC99EjOhkr3jAPdy61ORcJT20IF1U+/vg9Q+lMu3jAeZpG5tKeQufJeIWMF0DgKOwaGL+hQheYn2iO9QhwuJE4XADfBJFVqIbxQqMO7VtlDcaQnOjaL6mZDbB5vMx0tpLDuPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117393; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HW5dHu/luwrYtl1kcOiBVGsiXZR8UnfoA5Cn0Bb40EU=; b=duDjM2cg1Z/HAlIqF9a8v429IxRRGemriTRkBF0xFsiaOIOmuGFHoLuiFMk7Q5k3BdfWVx3rNU9bxRnlm0iNB1Wg9XCQYbkTdqOQXIFv9JaggwIi/vz6rU8f3QOwE2blKJHlDYQnaL5sLXGqLSO6m3lVMG9CZjkg8KpMrc64C9k= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117393320496.80111952822926; Fri, 11 Sep 2026 02:03:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8p-0001oz-2R; Fri, 11 Sep 2026 05:01:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8f-0001fb-D1 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8d-000822-Ir for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:41 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-1rP5fKtgPT6D0NV4i9DHVg-1; Fri, 11 Sep 2026 05:01:37 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4955e865174so2881855e9.3 for ; Fri, 11 Sep 2026 02:01:37 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e0asm147459325e9.1.2026.09.11.02.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117299; 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=HW5dHu/luwrYtl1kcOiBVGsiXZR8UnfoA5Cn0Bb40EU=; b=VbOnRUSONPTQMeeprNRvcpe39VzQbMnssePFUDfQZm2CaiVqraWk46BkkzNN3FGXfefdRh tIxbMzFS3PhfoIVKeIcuBAMFTOnJWJyZ1GbXhtYKO1JKEVndk2dR547mpPguYhST4GbVTK GY9jnreyuBM56zESq4YH0kUGBAcRkOo= X-MC-Unique: 1rP5fKtgPT6D0NV4i9DHVg-1 X-Mimecast-MFC-AGG-ID: 1rP5fKtgPT6D0NV4i9DHVg_1789117296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117296; x=1789722096; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=HW5dHu/luwrYtl1kcOiBVGsiXZR8UnfoA5Cn0Bb40EU=; b=VxmN/9KEMtxYLSaMgX/WHS0gsUzihW6YsBW8/tTsJFopRIdjc9XZX65RQLMRNMXTgE 1htf+Pe++zp1bkcpyz1DCVsZ2FC3L3+mLzOfDG8m7vJLWOz97OqN7AJ1I8AIyOYU1/tG ixwyNtrJzJ+g5Gg/Fxu1PmnSCQFijmomvzJ3zF/q03hNasjqyy3DzwZPPuHM/Mw0NBFi YKu7Ys1uRhFmJgEPpKkK0geouP+TGbJ6e02PleRBLxSrtfNhrJDHwtsuP/jy4DceNs67 wayhG21yKcrX8lJiSXflov0Ad+fl6VqKJe7mmPOASiP/FQfeH4IzXYcp895lfHcB4IFq hjcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117296; x=1789722096; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HW5dHu/luwrYtl1kcOiBVGsiXZR8UnfoA5Cn0Bb40EU=; b=N5DSMaOsN1CPZ4fFgLn6J3PDHU8Y8LuKOjTVTXXBxD7/0PB/7qxoQR06v2dRggyvax RRCax3knNB/lDjgRYQGcOyr3wxeOEGIBjzuZ52FUHRawKgWg4DXqJP5Dhe2RvV5eeRo0 tJY9ubvY28dtvTV9TuqXokP42dJMwzLJPgVRkOOFeGoZNee7y9CbHC+JQXdRrziL+Lwg ACcHxF1AXQ6xvfHZDFgVqnaK943UEtLApst7qga2XlyLSJ6QAsnEIpalTKO2jbctAKpF 6AmLyjBwWvJIgZbA2iAcKxpmgn8ANqunf6LsjaqXsZ5bwaOOoD9cJRuv0G4DhKH3PyuD 8VKQ== X-Gm-Message-State: AFuF++k5CYyjzZjD+bIRKt/2KnAyJZx28WvJ5AK+frxFV53skLV6C8EU eUnqjzyA2WojrRNoeGqXN5C+YYx6wXE9NNnH0QUWA87GGptCs/onNfkTUj3Rrskvj6oID+3cYEy Ojp7PJjELJX+FIiY+ESHgzmkvdVYuHMue3WVPx0lbhj/Kl905Rg34h1FGzUMYl0ksTPBpGK2Aee BYfoYj3TiMbBfIKutdd3wGastREMtuPWi1Xw== X-Gm-Gg: AYBFou1J6/CiSfB7KGDbvv4cCOdyOeuY1MABDOLdW7xLvvRH88NAHAEJ9go1Oyx0orL 9djbqIHYQ18Eaps8WjiEEuAgXhaBn4lmj1IDQZnyoUSMr6pJecSE85CGJ1eN1sVoToBCPcImkGy DgGcFznaoIT0yCA3lvGJpSRvGY3+70SCsVge5y9A/cBg1SN0KMAZN9V2ZvFcdGFG3CPvFYX0Ar3 LtGUc+vgl0arho4tcEfwX9YzYMVw1R3f5fhtRPJQqWOQPRzP0350gdr/DOdDtR/T6K/zAYKxpRs ux9Un1NeNe5yeI0xAfRHp40sgtkHa+DXQZRbEE8yDgDXBv5G3UqFshPkP+MwscA+Z8Bj2efdHlU tCGUpGqkFmLDsoUCPDNeDL/s= X-Received: by 2002:a05:600c:c4a8:b0:49d:1df6:2592 with SMTP id 5b1f17b1804b1-49e619e0f7amr31508935e9.21.1789117295828; Fri, 11 Sep 2026 02:01:35 -0700 (PDT) X-Received: by 2002:a05:600c:c4a8:b0:49d:1df6:2592 with SMTP id 5b1f17b1804b1-49e619e0f7amr31508015e9.21.1789117294803; Fri, 11 Sep 2026 02:01:34 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Albert Esteve , Dorinda Bassey , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Stefano Garzarella Subject: [PULL v2 07/75] hw/display/vhost-user-media: add shared memory region BAR Message-ID: <6439ee6195d23d7bfdb366986bfdd24f7cdb19d6.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117394189158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Albert Esteve Expose virtio-media shared memory region 0 (spec 5.22.6.1.6) as a prefetchable 64-bit PCI BAR (BAR 2) with a VirtIO shm capability. The size is obtained through GET_SHMEM_CONFIG and requires at least one shared region. The guest maps host-provisioned MMAP buffers into this window; QEMU creates a container region on realize, not a full-sized RAM allocation. modern-pio-notify is rejected because it claims BAR 2. vhost-user still needs shareable guest RAM, e.g.: -object memory-backend-memfd,id=3Dmem,size=3D4G,share=3Don \ -numa node,memdev=3Dmem Tested-by: Dorinda Bassey Signed-off-by: Albert Esteve Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260901-virtio-media-v2-3-bd3cc9347ab9@redhat.com> --- hw/display/vhost-user-media-pci.c | 35 ++++++++++++++++++++++++++ hw/display/vhost-user-media.c | 42 ++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/hw/display/vhost-user-media-pci.c b/hw/display/vhost-user-medi= a-pci.c index 3e09fcfdd0..7681f7505d 100644 --- a/hw/display/vhost-user-media-pci.c +++ b/hw/display/vhost-user-media-pci.c @@ -13,12 +13,18 @@ #include "hw/virtio/vhost-user-media.h" #include "hw/virtio/virtio-pci.h" =20 +/* BAR 2 is used for the shared memory region exposed to the guest */ +#define VIRTIO_MEDIA_PCI_SHM_BAR 2 + +#define VIRTIO_MEDIA_PCI_SHMCAP_ID_SHM 0 + #define TYPE_VHOST_USER_MEDIA_PCI "vhost-user-media-pci-base" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserMEDIAPCI, VHOST_USER_MEDIA_PCI) =20 struct VHostUserMEDIAPCI { VirtIOPCIProxy parent_obj; VHostUserMEDIA vdev; + MemoryRegion shmbar; }; =20 static const Property vumedia_pci_properties[] =3D { @@ -32,14 +38,43 @@ static void vumedia_pci_realize(VirtIOPCIProxy *vpci_de= v, Error **errp) { VHostUserMEDIAPCI *dev =3D VHOST_USER_MEDIA_PCI(vpci_dev); DeviceState *dev_state =3D DEVICE(&dev->vdev); + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev_state); + VirtioSharedMemory *shmem; + uint64_t shm_size; =20 if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { vpci_dev->nvectors =3D 1; } =20 + if (vpci_dev->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY) { + error_setg(errp, "modern-pio-notify is not supported due to PCI BA= R " + "layout limitations"); + return; + } + if (!qdev_realize(dev_state, BUS(&vpci_dev->bus), errp)) { return; } + + shmem =3D virtio_find_shmem_region(vdev, VIRTIO_MEDIA_PCI_SHMCAP_ID_SH= M); + if (!shmem) { + error_setg(errp, "vhost-user-media: missing shared memory region"); + return; + } + shm_size =3D memory_region_size(&shmem->mr); + + memory_region_init(&dev->shmbar, OBJECT(vpci_dev), + "vhost-media-pci-shmbar", shm_size); + memory_region_add_subregion(&dev->shmbar, 0, &shmem->mr); + virtio_pci_add_shm_cap(vpci_dev, VIRTIO_MEDIA_PCI_SHM_BAR, 0, + shm_size, VIRTIO_MEDIA_PCI_SHMCAP_ID_SHM); + + /* After 'realized' so the memory region exists */ + pci_register_bar(&vpci_dev->pci_dev, VIRTIO_MEDIA_PCI_SHM_BAR, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + &dev->shmbar); } =20 static void vumedia_pci_class_init(ObjectClass *klass, const void *data) diff --git a/hw/display/vhost-user-media.c b/hw/display/vhost-user-media.c index 14edc7c668..eaf99dc6a2 100644 --- a/hw/display/vhost-user-media.c +++ b/hw/display/vhost-user-media.c @@ -19,6 +19,7 @@ #include "standard-headers/linux/virtio_ids.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/vhost-user-media.h" +#include "migration/blocker.h" =20 static const int feature_bits[] =3D { VIRTIO_F_VERSION_1, @@ -259,8 +260,9 @@ static void vu_media_device_realize(DeviceState *dev, E= rror **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VHostUserMEDIA *media =3D VHOST_USER_MEDIA(dev); + uint64_t memory_sizes[VIRTIO_MAX_SHMEM_REGIONS]; struct vhost_virtqueue *vhost_vqs; - int ret; + int ret, nregions; =20 if (!media->conf.chardev.chr) { error_setg(errp, "vhost-user-media: chardev is mandatory"); @@ -290,9 +292,47 @@ static void vu_media_device_realize(DeviceState *dev, = Error **errp) return; } =20 + ret =3D media->vhost_dev.vhost_ops->vhost_get_shmem_config(&media->vho= st_dev, + &nregions, + memory_sizes, + errp); + if (ret < 0) { + goto q_fail; + } + + if (!nregions || !memory_sizes[0]) { + error_setg(errp, "vhost-user-media: backend did not provide " + "shared memory region 0"); + goto q_fail; + } + + if (memory_sizes[0] % qemu_real_host_page_size() !=3D 0) { + error_setg(errp, "shared memory region 0 size must be a multiple " + "of the host page size"); + goto q_fail; + } + + if (media->vhost_dev.migration_blocker =3D=3D NULL) { + error_setg(&media->vhost_dev.migration_blocker, + "Migration disabled: devices with VIRTIO Shared Memory " + "Regions do not support migration yet."); + ret =3D migrate_add_blocker_normal(&media->vhost_dev.migration_blo= cker, + errp); + if (ret < 0) { + goto q_fail; + } + } + + virtio_new_shmem_region(vdev, 0, memory_sizes[0]); + qemu_chr_fe_set_handlers(&media->conf.chardev, NULL, NULL, vu_media_event, NULL, (void *)dev, NULL, true); + return; + +q_fail: + vhost_dev_cleanup(&media->vhost_dev); + do_vhost_user_cleanup(vdev, media, vhost_vqs); } =20 static void vu_media_device_unrealize(DeviceState *dev) --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117352; cv=none; d=zohomail.com; s=zohoarc; b=jYRyD+dBghSttltx3LHqzbGh0lnG2j1f9pFuSI7rYu1puYBzi5avQYUUMDz1MsAF9f4+sxwnQCEIsp0fcc175a/NsBiul6ntKDgz+qfzogGb38la0YFKURFJqlZtNIa1WoXQDN8/e5MfGfkjF8O3prU8yAwqia0HYcq+UeXTtus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117352; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UIh1PwEycfZASKTI05iblD1tmogo/rlgL3ovx7Py+Kg=; b=RwqLY72I/a+Str5CNWZGziCA7ddBOgn68hb3FLIxyH+46o4CBJEHSl+5AX2T6sT5yUXscZNoMwSTzuo0WHPT/fM7PRkJvFQW8xCkm4Xr3DN4N3movLCp3QUn3HV7AigSWtNa05YcgSU+TJTbhbtsBFNINm+WjOYvxqHtlFqb7h0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117352157604.9388185852931; Fri, 11 Sep 2026 02:02:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8l-0001n9-R5; Fri, 11 Sep 2026 05:01:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8g-0001hC-UL for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8f-00082G-CD for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:42 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-458-3HTsdQOfN4CJIelo3Nf2IQ-1; Fri, 11 Sep 2026 05:01:39 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49e6683d48fso1156525e9.0 for ; Fri, 11 Sep 2026 02:01:39 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e6499d57bsm44735785e9.3.2026.09.11.02.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117300; 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=UIh1PwEycfZASKTI05iblD1tmogo/rlgL3ovx7Py+Kg=; b=E7DF/5OXxus99HTw3uYRStp0qbmaJSJh1KA/jReyCe3Bqy+O4IP38rHBCNc98O4oAkL73a 8aw4RgeXmMdHYD25UpTG4DbAt82769lWeYZP+rChSkZxKpVPrYqFZPHwkTNrIQOnvdV+uF Cs/bmJalHWcFcUCGFah1BfOFYgETDo4= X-MC-Unique: 3HTsdQOfN4CJIelo3Nf2IQ-1 X-Mimecast-MFC-AGG-ID: 3HTsdQOfN4CJIelo3Nf2IQ_1789117298 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117298; x=1789722098; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=UIh1PwEycfZASKTI05iblD1tmogo/rlgL3ovx7Py+Kg=; b=GQtz/bjUTFciPfZBqD+r3ZaOUMQqCie13Tc9sL1N+aJ7agXjAsmPFf0VoMNUrwvgzh fMNs3pFZUtHJtsfu03LgxHk80LxIceGz+nT32II+lhk/Ez/O/RY0Y3fOUNqYrYbZ/1k4 ojqqU764DUwWoHeQJoEZzT+34ThoZlrV8rocLFZwCxWoUXTIQ/vzyUidb6sTdKZZ2eoB LqzUpHbbqVfsEo0qUSXWCmmDkDTFbAfSTLeC3FokCd7lLqYltnwpJq33tUnZ/9pZyjcC V1CvmOUuUQfBYpcDkNoU5Orpa5aHdjall4nwKhOKlj6RH72COAiu7WY0hzZQAKI2wDD0 8UVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117298; x=1789722098; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UIh1PwEycfZASKTI05iblD1tmogo/rlgL3ovx7Py+Kg=; b=rR2kpHKCXzT/EOMbs6dvoROv+t4XESsEsw4EzgFtam23ZRUUDh986TqHheKm609/Qg JLGFCQupNux2d55W1UVBcbzSl98fPn/9r/Xp90AcbygGKHBPNiUpvrZOIQgitRT8Nadh M6lqj/Kb78ywT5ET4lAiQ4nUJCNZUsml9xxBJic7XGGQcqeWZ7nsNoe2Tc5odycOwEm6 zNgs8fd7c2psIf2c/Obd/br375CYqyhSPM80+uv7AaPobZvmAokj6LygiKGmm3kRoSfE eFaSRr/PEvLvei9L1kTLqxIXthyQKrKuFXP21GSS0PT6FLqOxEJ5XfFQhn2Gq2HVyUre JRcg== X-Gm-Message-State: AFuF++lUNJlznvrZpRNnDPL2cgBsO/fZ3NT0ZrLvXU6T6Pel5yPJnYcu aNiPUckb0xSWL+89nwZKLVVwOwfJKEHEGTscBynjPFYz7kck0G6VNc40uXZTV5hQyAiUEXE1lI8 iFUpdIvUTn87W3heFcHPvw8imM5M9Y7/cnhI6ejVLfwukGzPR7q3Nzy8Cz4SBMjzraL2eIMYPxD Dm+ewtVlX2cDm2AkYqhPTsYNO/1Z/JyOtIhw== X-Gm-Gg: AYBFou1DBgGFuDzygmH92r/okxeL3D92+OSTp9aVoSRSZpqGjRbbmmf9uDMIdl7AGjA da1Ym5fB9lb+gHF15MP6Td4uJE8BHrpjsPJqE8XsS9teRuGboqarPSC22tuwpORqf3RGWA4iLhZ WmppVnXMkI9WJsIrFVn2UZOAab2+mJxnlJV56e0tHseHB56E13Yp80BOmWYUsYqbgr0uJ9dFpsu za9Rl7Hlz09c0nXFK4lC36BTAdDchnHaCmWf3CybNExpfkyp6zlp/QJjETa50IRtb7zEOrZQkUM RyVlfBl8YK8z44h4Bb6lqus9gQrWLzESdcNhjcZb3vFeBgSeUcBwy/r32G4PQ9gvMWWZ3WdUbP3 bh4E0Oxw341zuq3B3O2/9vdo= X-Received: by 2002:a05:600c:4743:b0:49c:fe46:7219 with SMTP id 5b1f17b1804b1-49e619bbccfmr33201745e9.20.1789117297674; Fri, 11 Sep 2026 02:01:37 -0700 (PDT) X-Received: by 2002:a05:600c:4743:b0:49c:fe46:7219 with SMTP id 5b1f17b1804b1-49e619bbccfmr33200875e9.20.1789117296930; Fri, 11 Sep 2026 02:01:36 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jia Jia Subject: [PULL v2 08/75] virtio: reduce code duplication for split ring Message-ID: <47676bc33601a25a86fbe32f15a8eed2c5e1ce75.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117353889158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jia Jia virtio_queue_empty_rcu duplicates virtqueue_num_heads for no good reason, let's not do it. As a nice side effect, we gain better handling for misbehaving guests. The virtio_device_disabled() check in virtio_queue_empty_rcu is redundant because virtqueue_split_pop() is only called through virtqueue_pop(), which already performs the check. Signed-off-by: Jia Jia Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260726012857.1580646-1-physicalmtea@gmail.com> --- hw/virtio/virtio.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 0b2fbbed3f..c9f9e5b511 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -717,26 +717,6 @@ static inline bool is_desc_avail(uint16_t flags, bool = wrap_counter) return (avail !=3D used) && (avail =3D=3D wrap_counter); } =20 -/* Fetch avail_idx from VQ memory only when we really need to know if - * guest has added some buffers. - * Called within rcu_read_lock(). */ -static int virtio_queue_empty_rcu(VirtQueue *vq) -{ - if (virtio_device_disabled(vq->vdev)) { - return 1; - } - - if (unlikely(!vq->vring.avail)) { - return 1; - } - - if (vq->shadow_avail_idx !=3D vq->last_avail_idx) { - return 0; - } - - return vring_avail_idx(vq) =3D=3D vq->last_avail_idx; -} - static int virtio_queue_split_empty(VirtQueue *vq) { bool empty; @@ -1773,12 +1753,14 @@ static void *virtqueue_split_pop(VirtQueue *vq, siz= e_t sz) address_space_cache_init_empty(&indirect_desc_cache); =20 RCU_READ_LOCK_GUARD(); - if (virtio_queue_empty_rcu(vq)) { + if (unlikely(!vq->vring.avail)) { + goto done; + } + + rc =3D virtqueue_num_heads(vq, vq->last_avail_idx); + if (rc <=3D 0) { goto done; } - /* Needed after virtio_queue_empty(), see comment in - * virtqueue_num_heads(). */ - smp_rmb(); =20 /* When we start there are none of either input nor output. */ out_num =3D in_num =3D elem_entries =3D 0; --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117325; cv=none; d=zohomail.com; s=zohoarc; b=EpUNfVcr6+uh0XEAkDZIv4glB7DoEeiFbvGxi1GRbO4L+iulVD3jp5iQpoF2hzxTTixUX65yDOJ4c2o4/l06L95l4FnRpF9qVEZXsStmYiFFsLj/Ahb3CGgT3+K7fq5BGA8G/zUynoh+52b5nzGXByoP/BcJZBg9sP1dmaFNAzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117325; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hrTN7OVSCNm9vbc/NCEC/WvGaVnoOJUhrqiC5Yh7fcA=; b=IW8w4KEJgBkA0XiEy5wjBRS1ZVdIhmvlYaFvDJoxOD3ieqY6SV2QWr9g4ma+WXQaFyRjg9P0W75jrTTyMax7CzOJ/ZA3fp7W57/podDVXI+U9oqint6n23mkYt2qcwDxKpoBLZtSrPlY5WX5Us2BKc9eoFP1tUkvf12XgFSdddc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117325526394.6817696429862; Fri, 11 Sep 2026 02:02:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8r-0001rF-37; Fri, 11 Sep 2026 05:01:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8j-0001jI-4D for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8h-00082v-Iy for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:44 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-WoB3_NbnNV6CbdH1I7cShw-1; Fri, 11 Sep 2026 05:01:41 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49ccfad90f1so3707835e9.0 for ; Fri, 11 Sep 2026 02:01:41 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a7a686sm40644845e9.1.2026.09.11.02.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117302; 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=hrTN7OVSCNm9vbc/NCEC/WvGaVnoOJUhrqiC5Yh7fcA=; b=ZDSz2EJbfWChx8MaHu4Z4R83pAuBd28TF7By9q7G4yBpQgUKXeR/rZsU7a5zsX6UXJAJqQ 8W/8abiraNKYAS7MjKV7K993aJGFdohwaERizXi1EEbBciIWvXcLCTdFycFQeYBZe7+vAw wsNTV4D1jLjUFONfIt2gp59RTJIgZtg= X-MC-Unique: WoB3_NbnNV6CbdH1I7cShw-1 X-Mimecast-MFC-AGG-ID: WoB3_NbnNV6CbdH1I7cShw_1789117300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117300; x=1789722100; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=hrTN7OVSCNm9vbc/NCEC/WvGaVnoOJUhrqiC5Yh7fcA=; b=oH2Dt51rHWFKRkYmKfp13btVrhhYp8t9u1pxehDbdLjHPxIO5ukyIB1z9DzvQowy2E 1nNs3sKsIuVaNhh65MnrHtRgThCfc1SgCA788mPRVMAxn+paem3/5dxn5k9R+U73NPEv YjH1QIJ//wj5e+7jQrEDwiGYNJXuFzIFRZCXAsI2JoAqkrh311v7Z7SQiyJ2FyAaM35l miYKbORXWRu8yX2Thm8YwJNASv6U++9qpafeUAb0dQLkuEENLs5M1VBX4hRcZyavR0YE J0lWui8p5IvNnaJyWOg4WXEB12AfHzG4aYWnH38XWEzHNBnxd1+aSHR81rdjEdhePfux ITlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117300; x=1789722100; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hrTN7OVSCNm9vbc/NCEC/WvGaVnoOJUhrqiC5Yh7fcA=; b=MDikhgtr8DJyRqVAqV+YFpAGEIE7upcwYfHLWAPSqiqGffXhItj3iWUrLZaVxJZxk+ +3C/ca3/Zr39zcCBcwQQlIMyaZmHartoJ1sQ+FWJQdwP07QL7B7FUsMRInLqkiNz63un UVRLyWyy+LyHpkQ3EBBCRSfEBIZz1+/Ysz4wGl+PEkA9Q5QrbrR4jO37rVYXSksElqgn QuU4Eg452E9sLsDPKTOduZVFIJWaloyX7sPBEIFlMfG751vuxWxqGLtk6mQcTUMPlyDP lgubhrUUbwAIlTc1Q9Qp3YjtU/SC0DI7J8/0AP+wXAnRzHYEdmxf4Rs7peCHOJvuX9um ugVQ== X-Gm-Message-State: AFuF++l2A7xNhkgmal3qwbYXKB1h6LMHcyCKGmQ4AjcZHHzHsdTow9Bf nz2YS+379BWL5mUvHl7UbieUZafO8+7tY7MzNrl+Uk/RCUxZAW3EVLB6sTZQPKbyFGVSYY540KS yam4BQ7fFBItfAf8lU8pcIv6KT57W6kx2Y1IVKoxrje77anOzhcYIPFH7y0A1YM+LAc/9SSJ25X yoaXW5sMbSStCTiUNb7dbbA/9spZ063uIwUA== X-Gm-Gg: AYBFou1dbkQ6je6Yoha3LJeQvfBRphhVkrK5OiHOYtRzo+W7i1WLi7G/8McMgqQUpMY AS1ChiomL4i0pnsC3wFvYZlrpj+85fLhPzfbWCbIbkOlDBdGaqtRm4S82UGJqC3T1XVOK787a5U MtwigjQj8EsZdTyb5hMBMwz/Pgzk3tTzWMcAgo1nmDkr8uuTlze8OWV2WVDIBOQJEb1sQC3iLrh uQA4DOLLLquRVTKF8TnDzvuI6eU8P6oASB+D7BaWovOObIHQGGHZnuCy7+42cW/JmgMAysTTboq UiIi+3kG12xuP8z/JAO+gtW/JW8TLRkh8ypXvlmeh/ZxOQ4WVBDWA5wjdDRkfepBU7BiYviPA9V aycJYDPL7OV00VEcF4+6Oxo4= X-Received: by 2002:a05:600c:c490:b0:49c:fc6c:bdfa with SMTP id 5b1f17b1804b1-49e619e1cf0mr31421755e9.17.1789117300326; Fri, 11 Sep 2026 02:01:40 -0700 (PDT) X-Received: by 2002:a05:600c:c490:b0:49c:fc6c:bdfa with SMTP id 5b1f17b1804b1-49e619e1cf0mr31420675e9.17.1789117299211; Fri, 11 Sep 2026 02:01:39 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Markus Armbruster , Jason Wang Subject: [PULL v2 09/75] net/tap: rework tap_parse_script Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117327868158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Factor out tap_is_explicit_no_script() helper, to simplify further changes. Avoid extra copying by simpler code flow: first check for NULL / empty / "no" cases, then get default or do copying respectively. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Markus Armbruster Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-2-vsementsov@yandex-team.ru> --- net/tap.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/net/tap.c b/net/tap.c index 57ffb09885..2076f5b780 100644 --- a/net/tap.c +++ b/net/tap.c @@ -92,19 +92,35 @@ static void launch_script(const char *setup_script, con= st char *ifname, static void tap_send(void *opaque); static void tap_writable(void *opaque); =20 -static char *tap_parse_script(const char *script_arg, const char *default_= path) +static bool tap_is_explicit_no_script(const char *script_arg_value) { - g_autofree char *res =3D g_strdup(script_arg); - - if (!res) { - res =3D get_relocated_path(default_path); + if (!script_arg_value) { + return false; } =20 - if (res[0] =3D=3D '\0' || strcmp(res, "no") =3D=3D 0) { + if (script_arg_value[0] =3D=3D '\0') { + return true; + } + + if (strcmp(script_arg_value, "no") =3D=3D 0) { + return true; + } + + return false; +} + +static char *tap_parse_script(const char *script_arg_value, + const char *default_path) +{ + if (tap_is_explicit_no_script(script_arg_value)) { return NULL; } =20 - return g_steal_pointer(&res); + if (!script_arg_value) { + return get_relocated_path(default_path); + } + + return g_strdup(script_arg_value); } =20 static void tap_update_fd_handler(TAPState *s) --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117325; cv=none; d=zohomail.com; s=zohoarc; b=D0h5B5ngFd0hYLKoOyiGY7uSqSvvx9azunJFtNk9mJ0I8MFTewyp8iqy0YRbF0uWt50U+zFksmxDFpQPp9bFyKgjpSXuRe0KkWjg5Sm0pjPRSBJgolEH8zdCP2vcwCNPSki5n35f5w4hGHxdhBDkwXb3Z6xlXVpnt8DrmoEPvzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117325; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gBSHhMDPj1wNd+THvAUfp3LvU17AmLFoV6OMcA35G6I=; b=jIpcI3tIUQJGx29l25hryAPImW2HgODA76i59l+n2BLf1zZdlaXljf/+CfOEeU3//A9ethRguDi6vVmxZcsQNIQ3niCV1dqCuls9SESklXPVr+qRNNgTzZ9PqV2dpsZ8cQGdxX4+TcE04ISUAyyAPOm+y0r3tyKRNZUioLieRKY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117325646659.8491953052655; Fri, 11 Sep 2026 02:02:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x8t-0001v3-Uv; Fri, 11 Sep 2026 05:01:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8m-0001nT-15 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8k-00083d-3i for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:47 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-479-l61MYQPuPCC8GHcH9i0SXA-1; Fri, 11 Sep 2026 05:01:44 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4858f06e142so498972f8f.0 for ; Fri, 11 Sep 2026 02:01:43 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb2ecfc3sm4359780f8f.4.2026.09.11.02.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117305; 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=gBSHhMDPj1wNd+THvAUfp3LvU17AmLFoV6OMcA35G6I=; b=hMSKRwpS/McfX6GxLfXYQMD5Vj01Pj6qLvoOhLA/r36jS9lagFPTbDOKUwZ3omYGp8Lt0S nn6ENzLG7Ujdd1Z5hdUVKzDcf/zUfqBRzT0rJNOTraCMdkh1o0WMSaBM5LMWbYRzew4gRt 0+978IFx8w/rWXWhacNUWHx9BJWDSWY= X-MC-Unique: l61MYQPuPCC8GHcH9i0SXA-1 X-Mimecast-MFC-AGG-ID: l61MYQPuPCC8GHcH9i0SXA_1789117303 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117303; x=1789722103; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=gBSHhMDPj1wNd+THvAUfp3LvU17AmLFoV6OMcA35G6I=; b=a7yniP5E4RduKG2fAqOy7wq2tdBsj9cok+t0PIpU+uesRCFIoQRUQ5aHP6IS2lGN2H pkqlT35MHtqazfIEbiGj6e0LfO2FOmfHeYFodxxYzV4YIuWr3lxsIFaR4rnA4hiyRagk Zx6oFgsiZnUlmIaza4a8C+3y1XmqSGVkQvf2iSLnF7+G0PvH5yOnSrNAG8jhGpZr0PZd uLOIgg8t3nQd43cMMY/3Br0R1NO0rIotRaBgjYFhFkBDkK7npD+LQlBIMdhSDbp0qeQs eGjQ1OVlZdoXdYov7l52d7+Y78JgbWz01R9PVVbkIrAOvwbbK2iTL0Cv4baNSYZFcjHP Nd/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117303; x=1789722103; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=gBSHhMDPj1wNd+THvAUfp3LvU17AmLFoV6OMcA35G6I=; b=R7dsvU0USN4vYDnTqAiAhcFvDeN8FP0ZE0syj+mXw1osceHD0H7Qxo2AsPHwPcLB26 Qj+ierqFczFBOS1muTBvAXA5zr3n5E7gabguNB0RAlYWydQovrDGcVlkbu0ipKCEvVIJ K/1em59bWQ4a3dWB6cQkHU/HVBR2gbZeJ0v3Wv0exLBFOKJl0maHx1qMZ67IjwaVknv8 1cG8p6NnlKLx5RgbsRJcdsu0bh8YNANcpout1wPQHHym67jtjPNRZwt5FRwy8ny2irj7 RP4szYfRV7W1haj4vXR/oiul+8hHgUTfiH7YhyuJ5TOT2/HjKDJS86M2tT/09r52yFv2 7L9g== X-Gm-Message-State: AFuF++n4AOJ+vcNWXrcMmsk2cY8zavxgFIpqfFXBlmWZU6bs9U5ubSNu 6QnTOX2ky1UPX6Tq5JxKR393pnzwIOgjzBiPHIFBHq8GZSKhj758XzHeyB1xjJgoSWklM6HsfgL 8dZnuJ0iGSnYjpkwo5bF25dg5JC4wTZZT9eZ8o9GunM/VL+QtDmaf/YEjUmlOihzbHAlC2gbcun kEjgKBsTcGJpXYUnb2V4oSlBNpGHrMOOBmFQ== X-Gm-Gg: AYBFou081sKCaWtI4nbOwSGVyZfhlpCryefL4IR1dRWqoaOfDKxK0OvhWS55QrdLTru SVyZnIcWRz15jiHSHSvr3Dtap/uFPXZ9QegXR1yQX8zv2TdAQOPH2Sfvxyg3tdAcc4XUZVcAnVa vvvE2qj92OZganYoKYZsFH4kjl9v2YRzBSUWg0BCTOnVKV7VXnBBCXuQ/3vkkEMcHmGFwaYU0K9 jkkhA1EJRcTDR43vWp23uwdVvgb2xbU8l2/VG4SaxhiAXJw+aj+3MZgDO2Q/hXy+bh0CnudMvC3 VKFu+zML8PD4OFn2tF0fzRziyKxukbxag2r+VRkEHsdK+lBgKqZ0r/t4oVgql20eVHeaT3fzAxi mhvcWTiYocnKQCl2FdmMngQQ= X-Received: by 2002:a05:6000:646:b0:485:8ca8:caa with SMTP id ffacd0b85a97d-486eb34c229mr2627882f8f.52.1789117302587; Fri, 11 Sep 2026 02:01:42 -0700 (PDT) X-Received: by 2002:a05:6000:646:b0:485:8ca8:caa with SMTP id ffacd0b85a97d-486eb34c229mr2627810f8f.52.1789117301580; Fri, 11 Sep 2026 02:01:41 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Markus Armbruster , Ben Chaney , Jason Wang , Eric Blake Subject: [PULL v2 10/75] net/tap: improve script/downscript options documentation Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117327887158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Properly document defaults and special values of "" and "no". Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-3-vsementsov@yandex-team.ru> --- qapi/net.json | 10 ++++++++-- qemu-options.hx | 9 +++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/qapi/net.json b/qapi/net.json index 85c78710fe..ab8ed9c086 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -399,9 +399,15 @@ # @fds: multiple file descriptors of already opened multiqueue capable # tap # -# @script: script to initialize the interface +# @script: script to initialize the interface. An empty string or +# "no" disables script execution. Defaults to +# ``/qemu-ifup``, where ```` is the +# system configuration directory at build time (typically /etc). # -# @downscript: script to shut down the interface +# @downscript: script to shut down the interface. An empty string or +# "no" disables script execution. Defaults to +# ``/qemu-ifdown``, where ```` is the +# system configuration directory at build time (typically /etc). # # @br: bridge name (since 2.8) # diff --git a/qemu-options.hx b/qemu-options.hx index 6c1713ed61..16ef7d5455 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3022,7 +3022,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " use network scripts 'file' (default=3D" DEFAULT_NETWO= RK_SCRIPT ")\n" " to configure it and 'dfile' (default=3D" DEFAULT_NETW= ORK_DOWN_SCRIPT ")\n" " to deconfigure it\n" - " use '[down]script=3Dno' to disable script execution\n" + " use '[down]script=3Dno' or '[down]script=3D' to disab= le script execution\n" " use network helper 'helper' (default=3D" DEFAULT_BRID= GE_HELPER ") to\n" " configure it\n" " use 'fd=3Dh' to connect to an already opened TAP inte= rface\n" @@ -3558,9 +3558,10 @@ SRST Use the network script file to configure it and the network script dfile to deconfigure it. If name is not provided, the OS automatically provides one. The default network configure script is - ``/etc/qemu-ifup`` and the default network deconfigure script is - ``/etc/qemu-ifdown``. Use ``script=3Dno`` or ``downscript=3Dno`` to - disable script execution. + ``/qemu-ifup`` and the default network deconfigure script = is + ``/qemu-ifdown``, where ```` is the system + configuration directory at build time (typically ``/etc``). + Use ``[down]script=3Dno`` or ``[down]script=3D`` to disable script exe= cution. =20 If running QEMU as an unprivileged user, use the network helper to configure the TAP interface and attach it to the bridge. --=20 MST From nobody Sat Sep 26 20:50:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117348; cv=none; d=zohomail.com; s=zohoarc; b=M4ZjWlzevaL3klLH8u1fyaVFwSRDAj85tIxF90DeWmv/kySfFnGWalLUWzK4rp6iUdVPZJwcBKxpWSzKNgwdgkROrTSq/zUSVnG0JQufNUbd6Vu446Yukc91kucSR6R3oFbFL8q0X7PTWDVtJLGtgpvGaVK7TWRj4GmFUAtFqb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117348; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g9mLgS0ybrUUaTMFusFVuyMEvSQGJ2PNYaEiCYholds=; b=Gbr2UnEy8YMXejSnP5Cmh+gyYxMjlTEtFNVMFG+68E1SFlS9LTeQPXrY6fZn2usC8GHnF9QxgnOSYokjXkv62ohGwbkV7EIm59NS2XRD8R4KMqy05B9JaygOiJt+5h2yfgN78ZK1mj7E1AmHZE7tRET2NOdNXgFr+FmjgFmWVPo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789117348163366.386270789058; Fri, 11 Sep 2026 02:02:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1416038.1645206 (Exim 4.92) (envelope-from ) id 1x4x8r-00055N-3Z; Fri, 11 Sep 2026 09:01:53 +0000 Received: by outflank-mailman (output) from mailman id 1416038.1645206; Fri, 11 Sep 2026 09:01:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4x8q-00055G-Vr; Fri, 11 Sep 2026 09:01:52 +0000 Received: by outflank-mailman (input) for mailman id 1416038; Fri, 11 Sep 2026 09:01:51 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4x8p-000559-Mp for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 09:01:51 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4x8p-007pxH-1z for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 11:01:51 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa3c37a-e002-0a2a0a5209dd-0a2a4501d846-22 for ; Fri, 11 Sep 2026 11:01:50 +0200 Received: from [170.10.129.124] (helo=us-smtp-delivery-124.mimecast.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa3c37d-5984-0a2a45010019-aa0a817c7281-3 for ; Fri, 11 Sep 2026 11:01:50 +0200 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-2EAmKVKxMTmiFB9fcY4olA-1; Fri, 11 Sep 2026 05:01:47 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-495689bfcc8so4972605e9.1 for ; Fri, 11 Sep 2026 02:01:47 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a32803sm43926005e9.0.2026.09.11.02.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:45 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mimecast20190719 header.d=redhat.com header.i="@redhat.com" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117309; 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=g9mLgS0ybrUUaTMFusFVuyMEvSQGJ2PNYaEiCYholds=; b=Tc+5QtfAP0yomD5Z9QaVRpEVwav0vAsYZiS6/THJZvoJ9KD3FWTt+Whp/3ldpzlMkyV69S e5CX54UGa2u421g8Y9lsamXfloY+a5lIlGPgZPESGEeqf5Fz0CRFr5XE8kUtAuQPW7RGF3 w/T1x1TlqTSUNK03cNcr36DA73ffFPo= X-MC-Unique: 2EAmKVKxMTmiFB9fcY4olA-1 X-Mimecast-MFC-AGG-ID: 2EAmKVKxMTmiFB9fcY4olA_1789117307 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117306; x=1789722106; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=g9mLgS0ybrUUaTMFusFVuyMEvSQGJ2PNYaEiCYholds=; b=Ea9DiW08z4W5m/tB7Ijj55400vFTB6QRc5o7BokaiqvePM9D6LyTIs2oS1ljw8zkrx R69vpslY6cOzawyHT1DQgeXcJtVkAPAEWdr8Ys7oAaCBFjODNBVvO/TwsK0vCFVFECnQ cY7jyeopy4byYV5nyaTlIwd1765daU3XwbxNu+6RuKRjVWp2OGbPQ+LrbvSfIZqSvewT a3c5Y0wz1qXVdUEMdlQst3IhbkzkYoRKuPK8ZTmsw+IVxasY87+W9nVK7c5tHFAlDRmV NDpANJVwNZj84cApmeO0k1uDI4qasADc5MVrG23aBEoGj9sqVml63blIyDMPBK1YvGrW ojxA== X-Forwarded-Encrypted: i=1; AKwUvByNXsPg+Dwsuy9rIWJn5QnUOW3PPtwLKNMt6/952knWzLphRt7TX/K2DJO1drhs7KCGNK/ODG25O3c=@lists.xenproject.org X-Gm-Message-State: AFuF++lq5oY/wUPtqynT7L31Ft5YM1wW8ZnEuhCq8dQC1KVvJUsdEjZz 0JCxc2WtuJtkneliu/4tQwZNDJPUHntL9RNr2DU/qbL8tqNfkyT/AHAJn8XoJQzuFSu78TLc4B3 j13tOYvZPYM4gO5SzTNn2NumKiAbphaP/vJ80FYz0GWWrmFIcr1Ch6ZhRwjIhc1+nkfXS X-Gm-Gg: AYBFou1kXZ1C0RRgEEOoTVZ9PUZ7M8wMqm2HejZ9Bo7OwH9i8L4fjk9MNOAg0RHx8vJ aRKjbDcILgpNRGhK9pjgLyq/p+CHOA3l7kgJSQa0vR2HG5mjzKjdJAmE8XAn2cd4RvA0vTYjaKc MtvMXv5y0rDM8ThWB4ajfWaIpKp0myNyhblOpq2Pj/sH7CG9vfBzeh2MxJy3byszWVwsFJnSUUz N1PtZEvGD6cvepHepUcXoL7QwtA9HAnpuBWt6HyKpsQEn3qj2eAaQqe9+4ddI2gIsWWeVCpYkJ3 PLsHdsWz0i/JN4OoL3ySdXMoMlAu637O+ftQlxiklvT01zp9I+Rp/hCTVEFeTG84dBz89Nr1MkL CIe40znHntWNGpFkj04Ol0FI= X-Received: by 2002:a05:600c:6289:b0:49c:de80:b833 with SMTP id 5b1f17b1804b1-49e61983067mr32623595e9.2.1789117306102; Fri, 11 Sep 2026 02:01:46 -0700 (PDT) X-Received: by 2002:a05:600c:6289:b0:49c:de80:b833 with SMTP id 5b1f17b1804b1-49e61983067mr32623015e9.2.1789117305570; Fri, 11 Sep 2026 02:01:45 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Markus Armbruster , Pierrick Bouvier , Sergio Lopez , Paolo Bonzini , Zhao Liu , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Bernhard Beschow , Conor Dooley , Sebastian Huber , Alistair Francis , Palmer Dabbelt , Jason Wang , Eric Blake , devel@lists.libvirt.org, xen-devel@lists.xenproject.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org Subject: [PULL v2 11/75] net/tap: deprecate "no" as special value for script/downscript Message-ID: <3e4c54739a7e3409a477197fa300104202eb3570.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: dUpS0tgg2_cUp1glRC8Crui4Sxo7JiuobiHLMIcqWUw_1789117307 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1789117310-C495A757-A50FD0FD/0/0 X-purgate-type: clean X-purgate-size: 12712 X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117350170158500 From: Vladimir Sementsov-Ogievskiy The interface is ambiguous, as "no" is valid file name. So, using "no" as a special value to disable script is deprecated. Use an empty string ("script=3D" / "downscript=3D") instead. In a future version, "no" will be treated as a plain file name, just like any other non-empty value. Document the deprecation in docs/about/deprecated.rst, qapi/net.json, and qemu-options.hx. Update other docs to use empty string instead of "no". Add a warning. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Markus Armbruster Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-4-vsementsov@yandex-team.ru> --- docs/about/deprecated.rst | 18 ++++++++++++++++++ docs/system/i386/microvm.rst | 4 ++-- docs/system/i386/xenpvh.rst | 2 +- docs/system/ppc/ppce500.rst | 4 ++-- docs/system/riscv/microchip-icicle-kit.rst | 2 +- docs/system/riscv/sifive_u.rst | 2 +- qapi/net.json | 14 ++++++++++---- net/tap.c | 17 +++++++++++------ qemu-options.hx | 8 ++++++-- 9 files changed, 52 insertions(+), 19 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 98c32991c9..61e775373d 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -71,6 +71,15 @@ flexible enough. The monitor objects have been converted= to QOM, so ``-mon mode=3Dcontrol`` is replaced by ``-object monitor-qmp``. The short convenience options are not deprecated, only ``-mon``. =20 +``script=3Dno`` and ``downscript=3Dno`` for ``-netdev tap`` (since 11.2) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The special value ``"no"`` for the ``script`` and ``downscript`` +parameters of ``-netdev tap`` disables script execution. This special +treatment of ``"no"`` is deprecated. Use an empty string (``script=3D`` +or ``downscript=3D``) to disable script execution instead. In a future +version, ``"no"`` will be treated as a plain file name. + QEMU Machine Protocol (QMP) commands ------------------------------------ =20 @@ -164,6 +173,15 @@ Use ``job-finalize`` instead. =20 Use ``query-accelerators`` instead. =20 +``"no"`` as value of ``script``/``downscript`` for tap in ``netdev_add`` (= since 11.2) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''= ''''''''''' + +The special value ``"no"`` for the ``script`` and ``downscript`` +parameters of ``netdev_add`` with ``type=3Dtap`` disables script +execution. This special treatment of ``"no"`` is deprecated. Use an +empty string instead. In a future version, ``"no"`` will be treated as +a plain file name. + Human Machine Protocol (HMP) commands ------------------------------------- =20 diff --git a/docs/system/i386/microvm.rst b/docs/system/i386/microvm.rst index 1675e37d3e..077ea15751 100644 --- a/docs/system/i386/microvm.rst +++ b/docs/system/i386/microvm.rst @@ -79,7 +79,7 @@ legacy ``ISA serial`` device as console:: -serial stdio \ -drive id=3Dtest,file=3Dtest.img,format=3Draw,if=3Dnone \ -device virtio-blk-device,drive=3Dtest \ - -netdev tap,id=3Dtap0,script=3Dno,downscript=3Dno \ + -netdev tap,id=3Dtap0,script=3D,downscript=3D \ -device virtio-net-device,netdev=3Dtap0 =20 While the example above works, you might be interested in reducing the @@ -103,7 +103,7 @@ disabled:: -device virtconsole,chardev=3Dvirtiocon0 \ -drive id=3Dtest,file=3Dtest.img,format=3Draw,if=3Dnone \ -device virtio-blk-device,drive=3Dtest \ - -netdev tap,id=3Dtap0,script=3Dno,downscript=3Dno \ + -netdev tap,id=3Dtap0,script=3D,downscript=3D \ -device virtio-net-device,netdev=3Dtap0 =20 =20 diff --git a/docs/system/i386/xenpvh.rst b/docs/system/i386/xenpvh.rst index 904778e3f5..862f38830b 100644 --- a/docs/system/i386/xenpvh.rst +++ b/docs/system/i386/xenpvh.rst @@ -42,7 +42,7 @@ case you need to construct one manually: -vnc none \ -display none \ -device virtio-net-pci,id=3Dnic0,netdev=3Dnet0,mac=3D00:16:3e:5c:81:= 78 \ - -netdev type=3Dtap,id=3Dnet0,ifname=3Dvif3.0-emu,br=3Dxenbr0,script= =3Dno,downscript=3Dno \ + -netdev type=3Dtap,id=3Dnet0,ifname=3Dvif3.0-emu,br=3Dxenbr0,script= =3D,downscript=3D \ -smp 4,maxcpus=3D4 \ -nographic \ -machine xenpvh,ram-low-base=3D0,ram-low-size=3D2147483648,ram-high-= base=3D4294967296,ram-high-size=3D2147483648,pci-ecam-base=3D824633720832,p= ci-ecam-size=3D268435456,pci-mmio-base=3D4026531840,pci-mmio-size=3D3355443= 2,pci-mmio-high-base=3D824902156288,pci-mmio-high-size=3D68719476736 \ diff --git a/docs/system/ppc/ppce500.rst b/docs/system/ppc/ppce500.rst index c9fe0915dc..ec5aaf14fd 100644 --- a/docs/system/ppc/ppce500.rst +++ b/docs/system/ppc/ppce500.rst @@ -158,14 +158,14 @@ interface at PCI address 0.1.0, but we can switch tha= t to an e1000 NIC by: $ qemu-system-ppc64 -M ppce500 -smp 4 -m 2G \ -display none -serial stdio \ -bios u-boot \ - -nic tap,ifname=3Dtap0,script=3Dno,downscript=3Dno,m= odel=3De1000 + -nic tap,ifname=3Dtap0,script=3D,downscript=3D,model= =3De1000 =20 The QEMU ``ppce500`` machine can also dynamically instantiate an eTSEC dev= ice if =E2=80=9C-device eTSEC=E2=80=9D is given to QEMU: =20 .. code-block:: bash =20 - -netdev tap,ifname=3Dtap0,script=3Dno,downscript=3Dno,id=3Dnet0 -device = eTSEC,netdev=3Dnet0 + -netdev tap,ifname=3Dtap0,script=3D,downscript=3D,id=3Dnet0 -device eTSE= C,netdev=3Dnet0 =20 Root file system on flash drive ------------------------------- diff --git a/docs/system/riscv/microchip-icicle-kit.rst b/docs/system/riscv= /microchip-icicle-kit.rst index 9809e94b84..7fdb96601a 100644 --- a/docs/system/riscv/microchip-icicle-kit.rst +++ b/docs/system/riscv/microchip-icicle-kit.rst @@ -84,7 +84,7 @@ Then we can boot the machine by: $ qemu-system-riscv64 -M microchip-icicle-kit -smp 5 -m 2G \ -sd path/to/sdcard.img \ -nic user,model=3Dcadence_gem \ - -nic tap,ifname=3Dtap,model=3Dcadence_gem,script=3Dno \ + -nic tap,ifname=3Dtap,model=3Dcadence_gem,script=3D \ -display none -serial stdio \ -kernel path/to/u-boot/build/dir/u-boot.bin \ -dtb path/to/u-boot/build/dir/u-boot.dtb diff --git a/docs/system/riscv/sifive_u.rst b/docs/system/riscv/sifive_u.rst index 8f55ae8e31..0e4dcf3e70 100644 --- a/docs/system/riscv/sifive_u.rst +++ b/docs/system/riscv/sifive_u.rst @@ -199,7 +199,7 @@ To boot the VxWorks kernel in QEMU with the ``sifive_u`= ` machine, use: =20 $ qemu-system-riscv64 -M sifive_u -smp 5 -m 2G \ -display none -serial stdio \ - -nic tap,ifname=3Dtap0,script=3Dno,downscript=3Dno \ + -nic tap,ifname=3Dtap0,script=3D,downscript=3D \ -kernel /path/to/vxWorks \ -append "gem(0,0)host:vxWorks h=3D192.168.200.1 e=3D192.168.200.2:ff= ffff00 u=3Dtarget pw=3DvxTarget f=3D0x01" =20 diff --git a/qapi/net.json b/qapi/net.json index ab8ed9c086..dccf95bbbc 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -399,15 +399,21 @@ # @fds: multiple file descriptors of already opened multiqueue capable # tap # -# @script: script to initialize the interface. An empty string or -# "no" disables script execution. Defaults to +# @script: script to initialize the interface. An empty string +# disables script execution. Defaults to # ``/qemu-ifup``, where ```` is the # system configuration directory at build time (typically /etc). +# Using "no" to disable script execution is deprecated (since +# 11.2); use an empty string instead. In a future version, "no" +# will be treated as a plain file name. # -# @downscript: script to shut down the interface. An empty string or -# "no" disables script execution. Defaults to +# @downscript: script to shut down the interface. An empty string +# disables script execution. Defaults to # ``/qemu-ifdown``, where ```` is the # system configuration directory at build time (typically /etc). +# Using "no" to disable script execution is deprecated (since +# 11.2); use an empty string instead. In a future version, "no" +# will be treated as a plain file name. # # @br: bridge name (since 2.8) # diff --git a/net/tap.c b/net/tap.c index 2076f5b780..f4051e8d4b 100644 --- a/net/tap.c +++ b/net/tap.c @@ -92,7 +92,8 @@ static void launch_script(const char *setup_script, const= char *ifname, static void tap_send(void *opaque); static void tap_writable(void *opaque); =20 -static bool tap_is_explicit_no_script(const char *script_arg_value) +static bool tap_is_explicit_no_script(const char *script_arg_name, + const char *script_arg_value) { if (!script_arg_value) { return false; @@ -103,16 +104,19 @@ static bool tap_is_explicit_no_script(const char *scr= ipt_arg_value) } =20 if (strcmp(script_arg_value, "no") =3D=3D 0) { + warn_report("'%s=3Dno' is deprecated; use '%s=3D' instead", + script_arg_name, script_arg_name); return true; } =20 return false; } =20 -static char *tap_parse_script(const char *script_arg_value, +static char *tap_parse_script(const char *script_arg_name, + const char *script_arg_value, const char *default_path) { - if (tap_is_explicit_no_script(script_arg_value)) { + if (tap_is_explicit_no_script(script_arg_name, script_arg_value)) { return NULL; } =20 @@ -741,7 +745,7 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, qemu_set_info_str(&s->nc, "helper=3D%s", tap->helper); } else { qemu_set_info_str(&s->nc, "ifname=3D%s,script=3D%s,downscript=3D%s= ", ifname, - script ?: "no", downscript ?: "no"); + script ?: "", downscript ?: ""); =20 if (downscript) { snprintf(s->down_script, sizeof(s->down_script), "%s", downscr= ipt); @@ -947,9 +951,10 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, } } else { g_autofree char *script =3D - tap_parse_script(tap->script, DEFAULT_NETWORK_SCRIPT); + tap_parse_script("script", tap->script, DEFAULT_NETWORK_SCRIPT= ); g_autofree char *downscript =3D - tap_parse_script(tap->downscript, DEFAULT_NETWORK_DOWN_SCRIPT); + tap_parse_script("downscript", tap->downscript, + DEFAULT_NETWORK_DOWN_SCRIPT); =20 if (tap->ifname) { pstrcpy(ifname, sizeof ifname, tap->ifname); diff --git a/qemu-options.hx b/qemu-options.hx index 16ef7d5455..2f6863180b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3022,7 +3022,8 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, " use network scripts 'file' (default=3D" DEFAULT_NETWO= RK_SCRIPT ")\n" " to configure it and 'dfile' (default=3D" DEFAULT_NETW= ORK_DOWN_SCRIPT ")\n" " to deconfigure it\n" - " use '[down]script=3Dno' or '[down]script=3D' to disab= le script execution\n" + " use '[down]script=3D' to disable script execution\n" + " ('[down]script=3Dno' is deprecated and will be treate= d as a file name in future)\n" " use network helper 'helper' (default=3D" DEFAULT_BRID= GE_HELPER ") to\n" " configure it\n" " use 'fd=3Dh' to connect to an already opened TAP inte= rface\n" @@ -3561,7 +3562,10 @@ SRST ``/qemu-ifup`` and the default network deconfigure script = is ``/qemu-ifdown``, where ```` is the system configuration directory at build time (typically ``/etc``). - Use ``[down]script=3Dno`` or ``[down]script=3D`` to disable script exe= cution. + Use ``[down]script=3D`` to disable script execution. + Using ``[down]script=3Dno`` is deprecated; it disables script + execution now, but in a future version it will be treated as a + plain file name. =20 If running QEMU as an unprivileged user, use the network helper to configure the TAP interface and attach it to the bridge. --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789118059; cv=none; d=zohomail.com; s=zohoarc; b=TOUQmeE3WkK+Zxc3bIn1DEG7Oj4loE/9eEG4dRaWHwjUjShPVDJSoSWMSh0dFctAXbhEULk4dlB3r8P+POPl1GUc6kM4/6TdGJxMeyrAQBmsX6qmN59zMAlad6xva0sun/Dk9gPf6mjDMkIiSsR05KI2mZIG0qIR1K2lhkrnLH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789118059; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pzQMAUIV8a8b91Vm/oUOdfGDZskrETDwBh/Nv2MWtB8=; b=EZXN0cSfm61p8hksEEEAkX7scVeZALi89Y4EXYobxgSzAQ3CnfCbaUXp4cMqOZnBIzHBrRlRVUKdCmR0b3JyXaoT+lu9gLtK7B9cinVeNZnkNkVscvZGUTkRQKkY/A8LlEnxxl/Ob0VNvDlFUMEsCW7Eufb/+I/dJHBfG8mpXMA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789118059827803.8545074810991; Fri, 11 Sep 2026 02:14:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x91-00023N-01; Fri, 11 Sep 2026 05:02:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8s-0001tN-6A for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8q-00085H-BP for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:53 -0400 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-55-qLeuzqE5Mcad5D2cIA6hUg-1; Fri, 11 Sep 2026 05:01:50 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-6a178080182so733643a12.2 for ; Fri, 11 Sep 2026 02:01:49 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a9b5964c7asm570305a12.30.2026.09.11.02.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117311; 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=pzQMAUIV8a8b91Vm/oUOdfGDZskrETDwBh/Nv2MWtB8=; b=dK416B9fWLdKznKnoEYZ1tTRHD6p7oe5y6grV9nZNdLSwCBKiRq4Ppipz7p1JG0qw1yz7f L0xa0Wt/YN3OdzjlFWCyRVgWUkIfXQKbycbOeN6aepfI2kU21exjZVdOtJNzrrBOd2Y2gs dZF3BOp2Lkt89oWwVM5Ph3IBU9mKaZo= X-MC-Unique: qLeuzqE5Mcad5D2cIA6hUg-1 X-Mimecast-MFC-AGG-ID: qLeuzqE5Mcad5D2cIA6hUg_1789117309 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117309; x=1789722109; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=pzQMAUIV8a8b91Vm/oUOdfGDZskrETDwBh/Nv2MWtB8=; b=NN3kG0/YtinMhepxxnPiIT71NeMOblez0jstfTQOgXc7g0Je+Fc/8ZlkwsSweGcDs8 J5At8ndpupO0ZRmvFjKpkpU1s/pU4OUbX8PiajRDJMk2vr0FOwV1mk5K2JMNkFmcQklJ evJxBGGNRTpjQH+eJUSbFtJXrY8gRQv8nM38FZWTHwTsUUMZ+XqaUYK1smqUct2+OVHk gIaCe6bckgk5sfWWK3nBbKC48J5+HiTKNkqKqvAlnTXJBCLHq/0fmlfnt8YSDTS6UTim qE+TrxokaBCxTi/SEa1abANxNWRRuG6qm+qdVq1yPVG3at2X6AlVbuN5cwFhEPaqyG2C 78fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117309; x=1789722109; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pzQMAUIV8a8b91Vm/oUOdfGDZskrETDwBh/Nv2MWtB8=; b=doSCLH0itXGB/2P3kgASfvn3v6UsS0AJYRdrLZOP1SYIOw3BABSmor2r+C4XcvGUDG rfAk0OpZg47i96oeeK3akKyCSgNJYo18ekmIEV+nX9EtMMwL8CjNduDYXTvekfPh0T0n CuRMk8LvcwWhp4pwcwVuDDED01nYHCxL9krIuGo9Db3zR7ftsl5d0AvyUrGd00L8kqnw XBoqZNvbEB61ZD25c8aVWDs3ZMCMMy5hWZtm4SvTB1anxskBqRvk0K//4BCsg0BDTdrr KKsK4DBUdzXzAxjovD1pjXFMlbOKfMxRFYjyRTKgSoXcD1PXmYVjBefYDkNc3a21DF6L dsew== X-Gm-Message-State: AFuF++k4Q/32D5RpFG11kI8QfBPnzOgxjGE5bkFqyhJnLdg/uSUkugZP shi8EaBb6k/xM7bXlf6uZO2PqT3/sZugN5/cQHBOBINIZydaSWvTH09mEanprA4XNDIUMibolDR Mc+/84F97Uhb4Ryu5yJ/CLeoq+33uGHPrwXIlkAeN+D8wryYXBE9WoHmjJaGMTdptP74PWKoSpX LhmTYjvZJ17hhB0vKIUnUzpASJghBYzs79XA== X-Gm-Gg: AYBFou3tpXHIA8HcyPTwWkiNVbYXat4qqkdP50VdUr4uKcuyTgv8MWmJsRsJqX8+a3Y p9Os27J5wJc1Mu3bHDeRqu72AYFp/T4hJkm7zqItNv/NJHPhNspxG5gMqcr7MnB9RwFHoz3Og0J 2RhsailODxWnD13Y9KiPV9+Eve6/1C5XQLU1OGkrGGcZguj7q0qJnO8fxox6Y4sctgCMNDcI3rZ uoV4SP7ttZgJD6K4tobAuk1biUwHZKnZXTPP7AvL3k+p+RdX3KtNrHx73oeXk9sWpLhHL/psyoS lB6RrT3X+gZpWduPhvyxm3zt9Z2plI8z7WHFnegvUwvvCLlkjBt0S+kS+F8sPj9gQ+UwLiRyN8l Cb/bqYILrSeWPZxazHycvoRo= X-Received: by 2002:a05:6402:21cd:b0:6a8:372:edbd with SMTP id 4fb4d7f45d1cf-6a9b56264e9mr1102647a12.10.1789117308595; Fri, 11 Sep 2026 02:01:48 -0700 (PDT) X-Received: by 2002:a05:6402:21cd:b0:6a8:372:edbd with SMTP id 4fb4d7f45d1cf-6a9b56264e9mr1102608a12.10.1789117307945; Fri, 11 Sep 2026 02:01:47 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL v2 12/75] net/tap: move vhost-net open() calls to tap_parse_vhost_fds() Message-ID: <31ce34c2366741dd387631a2688fbd83bed5f627.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789118068644158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 1. Simplify code path: get vhostfds for all cases in one function. 2. Prepare for further tap-fd-migraton feature, when we'll need to postpone vhost initialization up to post-load stage. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Based-on: <20260318113144.15697-1-vsementsov@yandex-team.ru> Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-5-vsementsov@yandex-team.ru> --- net/tap.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/net/tap.c b/net/tap.c index f4051e8d4b..bec2cd48fd 100644 --- a/net/tap.c +++ b/net/tap.c @@ -756,8 +756,7 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, } } =20 - if (tap->has_vhost ? tap->vhost : - (vhostfd !=3D -1) || (tap->has_vhostforce && tap->vhostforce)) { + if (vhostfd !=3D -1) { VhostNetOptions options; =20 options.backend_type =3D VHOST_BACKEND_TYPE_KERNEL; @@ -767,17 +766,6 @@ static bool net_init_tap_one(const NetdevTapOptions *t= ap, NetClientState *peer, } else { options.busyloop_timeout =3D 0; } - - if (vhostfd =3D=3D -1) { - vhostfd =3D open("/dev/vhost-net", O_RDWR); - if (vhostfd < 0) { - error_setg_file_open(errp, errno, "/dev/vhost-net"); - goto failed; - } - if (!qemu_set_blocking(vhostfd, false, errp)) { - goto failed; - } - } options.opaque =3D (void *)(uintptr_t)vhostfd; options.nvqs =3D 2; options.feature_bits =3D kernel_feature_bits; @@ -863,14 +851,31 @@ static int tap_parse_fds_and_queues(const NetdevTapOp= tions *tap, int **fds, static bool tap_parse_vhost_fds(const NetdevTapOptions *tap, int **vhost_f= ds, int queues, Error **errp) { - if (!(tap->vhostfd || tap->vhostfds)) { + bool need_vhost =3D tap->has_vhost ? tap->vhost : + ((tap->vhostfd || tap->vhostfds) || + (tap->has_vhostforce && tap->vhostforce)); + + if (!need_vhost) { *vhost_fds =3D NULL; return true; } =20 - if (net_parse_fds(tap->vhostfd ?: tap->vhostfds, - vhost_fds, queues, errp) < 0) { - return false; + if (tap->vhostfd || tap->vhostfds) { + if (net_parse_fds(tap->vhostfd ?: tap->vhostfds, + vhost_fds, queues, errp) < 0) { + return false; + } + } else { + *vhost_fds =3D g_new(int, queues); + for (int i =3D 0; i < queues; i++) { + int vhostfd =3D open("/dev/vhost-net", O_RDWR); + if (vhostfd < 0) { + error_setg_file_open(errp, errno, "/dev/vhost-net"); + net_free_fds(*vhost_fds, i); + return false; + } + (*vhost_fds)[i] =3D vhostfd; + } } =20 if (!unblock_fds(*vhost_fds, queues, errp)) { --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117331; cv=none; d=zohomail.com; s=zohoarc; b=CnAJ+bJluN05ZEC/Xydh5qORpZMWh1pGLAS1bG1IK+QFxil6XB0QQVdjC3kHiDhBNEgSAotc2ybrKOyUt3qRYHV6gjwPDE6dM1J1paUXoB/ss6sVlafCjDAawrudsRN0BKvjv8yc/pd+TbP1a5izrIku3hEz6Ion/EHdp/1y8DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117331; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hZQoGnwsXrICqagpiwSzGmzqnz5JLACVM0aRzU+Os8Y=; b=SXPi5Jthv3KjvDsw1m3PZDsbLJ87+czFF16R41nxAujbx4ixKwuzdwT+qPh5AIiYrgsf6KUvQqdyOAUkUqoKjXSVCqSuokNmfcbDq2hqDDO/1x3XhGWK7pWxDCvPJnUtG7bT+2MDs9iUK9jcC2UBCe2rRI4qAmf4b4dKL1dnPhU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178911733153045.309401911346185; Fri, 11 Sep 2026 02:02:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x92-00024g-Og; Fri, 11 Sep 2026 05:02:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8w-0001yF-NN for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8u-000860-Sn for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:01:58 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-Gui_1bLOMjKIfq-YkzfyKw-1; Fri, 11 Sep 2026 05:01:54 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4855e47d062so350851f8f.1 for ; Fri, 11 Sep 2026 02:01:53 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33ee5csm4530004f8f.20.2026.09.11.02.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117316; 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=hZQoGnwsXrICqagpiwSzGmzqnz5JLACVM0aRzU+Os8Y=; b=Bp/witqGEwjpULH8QBPREQNBj2+OIzIloTe516VgGmiynXktdk5/xfIcqy5K2pvlmSvBJk 3dj3IX4k2o6xNPsE7k6jBUt9dLYsbEGwgxUep9qQ59lbuqpCpqb47LJ9oHBpkfwQSgQEFy QNP7xrn4fgLeIFbaHUVAF3PfoEqyqOA= X-MC-Unique: Gui_1bLOMjKIfq-YkzfyKw-1 X-Mimecast-MFC-AGG-ID: Gui_1bLOMjKIfq-YkzfyKw_1789117313 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117313; x=1789722113; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=hZQoGnwsXrICqagpiwSzGmzqnz5JLACVM0aRzU+Os8Y=; b=QGgylghYTaK9dbyrIP58nBVrpInrgSlx2ax/s1En8asJV2JnrKxfdmNGrZsUeqX74y TkolHYfX84nESSuTUOHxlEUY95KX/3PWLgHVn2uqpqu7xA4kEZ7KRUKV1km94ExIdtma I4ShZVSI+aJ7EN+n83Jw3uNttjzGQbTuD+ku73Ncm+uLtFE4uLk6iaSuGAvaSrZK8yuJ wtrQflmwf4kxu5fbar1wmZ/Y1qwcdeyPMDDw1Erzhoy1PIVKOXXFGNXcmjpUVsmeD8Us dRCH+61xRuEDYg4BmL7FpVxJSEe/b+eTTiQNc3of6R7GFvAY3QuBXXbjEa+OynNKg7Mh IXKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117313; x=1789722113; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hZQoGnwsXrICqagpiwSzGmzqnz5JLACVM0aRzU+Os8Y=; b=V/95E4Y+aVcX2SxBuaAghEX4J9TyHccOKrIEX65YF1gToONwkywh1GxaEt5nY6WrzE CMLuNS6TpEIPi3mMJdTb/196rKUKIsVbNowtqGdYpMxv27yYryz24wU+XQ//DZHcfqc2 ZJFsIF8b+qMaBPE/uiaIIqWz7GQsruZYOjgXStsAY6KewkMm4GOwV6Hn2EIKM+2GqUM4 VN40cLCgchLDUG6AmCfdKpNFFGTq/T6KjTEIDSxOaMeGw64gSBuLDiPXUOpfGxoYC7tu ZNEOh2NpESjm/xWMIiAcSpvpmFZdNB5Jb3B9MGeszcUE02bZm1u9MZO+v+aZrLdAaXco sC3A== X-Gm-Message-State: AFuF++m6gCnyeURFago1+FdcZDFMFWJsFSD5ITdJLBAaR8oDonu8zohj 8ka6q8dGp6lfeLu9BLFQZ+gOIdMeYsWFZiWabpUNztawn41A+H4WB9JGv1+exfflQOKOgp8IOvm /LXvIMe9z8mXXWkOKwinwQ2FbnoGHucRBPv/eBZzZyj5lFtYMvWA6moLFDOuqhZp+dCYumlyJjj Eqz+OYTLC2NF2+oUoSzxelLlD15Z3MlpMkSw== X-Gm-Gg: AYBFou1u0q17JzdojloCx4UU55IpU5/lMsDFjPzMZpE2+J/WZBQQv64rQPdHtkOF527 HsmQTvAIWfgXEXrRrgKdy3Cq5eN2hAe5UE7F+usY7fTnF4wE9LBaq+gqMMaVmo61BcQXutYHL9k ANJKYU1t6z3hWov6+4BlYyQEeJBIT6+LGUNjn5/8Fo1kuehPAUHW8uNragGnoPYD0U+xER3Fz5f ZRKfVEFzQdNiHVV1/l9XH7XJm+eeIk9oqRLHnofGGDGLRAemwfmMoS/o+UAYzetsCEZ5rvYVqwX Q5cvLLMfvQMcKBioXkEZKSNWG0A3l+9sfUW1pQJRy+T4sqKN6pOGZHBgVsQbiBzC/RWrDnFbgfT MdTg9g4mg X-Received: by 2002:a05:6000:4b0c:b0:486:ecc0:b77a with SMTP id ffacd0b85a97d-486ecc0b879mr3086361f8f.3.1789117312434; Fri, 11 Sep 2026 02:01:52 -0700 (PDT) X-Received: by 2002:a05:6000:4b0c:b0:486:ecc0:b77a with SMTP id ffacd0b85a97d-486ecc0b879mr3086285f8f.3.1789117311612; Fri, 11 Sep 2026 02:01:51 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL v2 13/75] net/tap: move vhost initialization to tap_setup_vhost() Message-ID: <69036a8554924548235ca4e85cb11551346aef9f.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117334616158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Make a new helper function in a way it can be reused later for TAP fd-migration feature: we'll need to initialize vhost in a later point when we doesn't have access to QAPI parameters. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Based-on: <20260318113144.15697-1-vsementsov@yandex-team.ru> Based-on: <20260218202829.1322088-1-vsementsov@yandex-team.ru> Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-6-vsementsov@yandex-team.ru> --- net/tap.c | 62 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/net/tap.c b/net/tap.c index bec2cd48fd..f2b571dd11 100644 --- a/net/tap.c +++ b/net/tap.c @@ -71,6 +71,8 @@ static const int kernel_feature_bits[] =3D { typedef struct TAPState { NetClientState nc; int fd; + int vhostfd; + uint32_t vhost_busyloop_timeout; char down_script[1024]; char down_script_arg[128]; uint8_t buf[NET_BUFSIZE]; @@ -722,6 +724,38 @@ static int net_tap_init(const NetdevTapOptions *tap, i= nt *vnet_hdr, return fd; } =20 +static bool tap_setup_vhost(TAPState *s, Error **errp) +{ + VhostNetOptions options; + + if (s->vhostfd =3D=3D -1) { + return true; + } + + options.backend_type =3D VHOST_BACKEND_TYPE_KERNEL; + options.net_backend =3D &s->nc; + options.busyloop_timeout =3D s->vhost_busyloop_timeout; + options.opaque =3D (void *)(uintptr_t)s->vhostfd; + options.nvqs =3D 2; + options.feature_bits =3D kernel_feature_bits; + options.get_acked_features =3D NULL; + options.save_acked_features =3D NULL; + options.max_tx_queue_size =3D 0; + options.is_vhost_user =3D false; + + s->vhost_net =3D vhost_net_init(&options); + if (!s->vhost_net) { + error_setg(errp, + "vhost-net requested but could not be initialized"); + return false; + } + + /* vhostfd ownership is passed to s->vhost_net */ + s->vhostfd =3D -1; + + return true; +} + static bool net_init_tap_one(const NetdevTapOptions *tap, NetClientState *= peer, const char *name, const char *ifname, const char *script, @@ -756,30 +790,10 @@ static bool net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, } } =20 - if (vhostfd !=3D -1) { - VhostNetOptions options; - - options.backend_type =3D VHOST_BACKEND_TYPE_KERNEL; - options.net_backend =3D &s->nc; - if (tap->has_poll_us) { - options.busyloop_timeout =3D tap->poll_us; - } else { - options.busyloop_timeout =3D 0; - } - options.opaque =3D (void *)(uintptr_t)vhostfd; - options.nvqs =3D 2; - options.feature_bits =3D kernel_feature_bits; - options.get_acked_features =3D NULL; - options.save_acked_features =3D NULL; - options.max_tx_queue_size =3D 0; - options.is_vhost_user =3D false; - - s->vhost_net =3D vhost_net_init(&options); - if (!s->vhost_net) { - error_setg(errp, - "vhost-net requested but could not be initialized"); - goto failed; - } + s->vhostfd =3D vhostfd; + s->vhost_busyloop_timeout =3D tap->has_poll_us ? tap->poll_us : 0; + if (!tap_setup_vhost(s, errp)) { + return false; } =20 return true; --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117398; cv=none; d=zohomail.com; s=zohoarc; b=iBSiiQwlyPHOMk1i+48fAds1ZRN1lzAL4aEKqLqOzOIcsyiaaEJYm0ZCs5Z3Mp6o5mYYGrJbEfx9nay5GbQaV34NvVGnzabq67YSNKFrnCt2HfGGG/hKqzYINuS+RA0mhOyrK+D8I5nK5oqJwatnYq1M4e6vi8pUS5aImY/jsNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117398; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AWRhi/FGrwhxDDpXDBZ1js0/6fDRqICz+xroCDFuHEc=; b=jAQ1w+I/21mf1aMg89aLQQGSVI2bGAXM2ubvKJre1X+89RELEvj4xc4hmPMZTcXAPuKWiZicmeZ6+/Y/JU7h4t/IylDgNOb+KsezMqLkZzlrXp09BD8eAhqn/AhjwKThoHvb1snOgNIjZDTZDPym8d1cCsxt20hKdWyeNm1kZi4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117398873197.96048395383445; Fri, 11 Sep 2026 02:03:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x90-00023F-Ca; Fri, 11 Sep 2026 05:02:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8y-0001yv-Ce for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x8w-000867-6l for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:00 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-qGiCWp0ZPZ--uwhDSCuVtQ-1; Fri, 11 Sep 2026 05:01:55 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-499b99a8a10so14503795e9.0 for ; Fri, 11 Sep 2026 02:01:55 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49db038401fsm128642625e9.13.2026.09.11.02.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117317; 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=AWRhi/FGrwhxDDpXDBZ1js0/6fDRqICz+xroCDFuHEc=; b=FqS4v9Xk8K8XZ8Qt4aLxjnWcCCNxAwi/ILQPju75FtIqSpvpWE+rkiMCo+qPjTHcNmGWM3 kYYWxpYdhU10lrkCshbqQTqafDn5hwSXSRFqfXF7TFhXwbgAq8KrjTVZBPSHia2K1lHbR7 SHZlqzgmrcvZ90zmwBtvdZ4Wg1e+u3M= X-MC-Unique: qGiCWp0ZPZ--uwhDSCuVtQ-1 X-Mimecast-MFC-AGG-ID: qGiCWp0ZPZ--uwhDSCuVtQ_1789117315 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117315; x=1789722115; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=AWRhi/FGrwhxDDpXDBZ1js0/6fDRqICz+xroCDFuHEc=; b=el4ECAi3wleNb15aogRfP4zNqCmT2ao/tSALd6zyhKaASOJJ7hzl6cVgPb4tfkgvH4 9rzj9IzL8wa4Z5H6MzMS8L/5mawg8VBRAeciPXVXgSn5+SqcV569i+i5f5fxbLAC6vzB 1lHWh0mjZ4dcHs+MZiQ10FH8L5cPaX3FyTZjCXFtP6/77ECYg5sQwZcuFEC/R+xqf2RN MZ9ShXqyGIazGpnZ8DNHq+8N+JszhPR6rky9iDo8HtWJyJSMr0pwm7201SIScz1SeKrB 0PVQQ4o+lNuiTptg4YlLwonmEufl4XtJuEtEAEjnb82B3vAx18BfVE1Aey68BurpPsWP hO5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117315; x=1789722115; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AWRhi/FGrwhxDDpXDBZ1js0/6fDRqICz+xroCDFuHEc=; b=n3hIlWQwbiwe0UPYbgjnJ44aQhMyz/GkIVY7oqcDHxDCOQcukLeiS6ZmW5TGS1sZ2l z6YPgYvd04JUBNnu/9c8AFfhhYumt7MCPZpIUYifl/kknQ56NTWvAmBUu/k2FswKJrMA uLdLXea9OBz6X+Vsxj76IVqadyaBmJtzudxbbRunwDw/9SbObyvVlcH+Ld4Od4bux9DJ syTRgrLhtd6HSIq3rKIr7OQXOdcKNs2uT9KzOqPxJRUc1CTtoKgGTY3ZZNMg2rbjHPXj LW4u+D/FotnCC5KE7/u7UDiZtKP+pKBC47KX6zNPdo0TTlErBIxXFgcko+JivdBLP8Pc Z1hg== X-Gm-Message-State: AFuF++lmsYSJPAeMuhQYeygyz3d0cB+opETygOXs4jNEwxqtWRMuW16k nPP1VqBYnqUk1YAgn0DKZbcaiolOfHwoXktafB2vVLa2HIZjcDpHKoRUSMnR50Vtqom73SembcM KwXwLRXh3Ip4Jz4UmglkhGttgeMVPugK4o7w06gaGVmxPdas/gXjtEwr3GBmu5A3rT+8pH/+LMp fupUb4kvli+y6CgrToR9TnakUAK6cj/rrVAA== X-Gm-Gg: AYBFou1VFZN7utWxC/eHTdQhjI1F/EomY6qSFpi5/7CHsJlX+3CQiEYbZC3FjPA49fA mD0cvWTl/YZ9+1bIM0xKhfgZZIDrtpAMEp03uQ5sTwM69y5Ot68xwwi3uBYK04eZXbwuEsFqwya K6k8BwkX5jwX2CYPLDv248sM40a7wXyvR1Toj7egTM6RhFimjbcv9aCvmBt+EJDiRVEk7ASDFrO sF9eTSgOcXH3QYLouMIpdhtz4B1J6rMNuZwQk7RfIi+1W+rLUsT00hUIRj1xwcuEWheiyL+bo51 fVBHABdLxdH9h638bkZWA2Wpn05hRATqolJm67SN0LYmaT6ur3fStaPCPcT+zbTzYjtffUxin4C g+fEpeZBzIuQEUERR0EgID6M= X-Received: by 2002:a05:600c:e547:20b0:49e:63cc:6324 with SMTP id 5b1f17b1804b1-49e63cc640dmr14197015e9.6.1789117314527; Fri, 11 Sep 2026 02:01:54 -0700 (PDT) X-Received: by 2002:a05:600c:e547:20b0:49e:63cc:6324 with SMTP id 5b1f17b1804b1-49e63cc640dmr14196235e9.6.1789117313851; Fri, 11 Sep 2026 02:01:53 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL v2 14/75] net/tap: use container_of instead of DO_UPCAST Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117400275158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We are going to QOMify tap backend, which includes deriving TAPState from Object. So "NetClientState nc" will not be a first member. Let's parepare for this change, and use container_of(), which will work regardless position of "nc" field. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-7-vsementsov@yandex-team.ru> --- net/tap.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/net/tap.c b/net/tap.c index f2b571dd11..bfed74717e 100644 --- a/net/tap.c +++ b/net/tap.c @@ -175,7 +175,7 @@ static ssize_t tap_write_packet(TAPState *s, const stru= ct iovec *iov, int iovcnt static ssize_t tap_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); const struct iovec *iovp =3D iov; g_autofree struct iovec *iov_copy =3D NULL; struct virtio_net_hdr hdr =3D { }; @@ -211,7 +211,7 @@ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int ma= xlen) =20 static void tap_send_completed(NetClientState *nc, ssize_t len) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); tap_read_poll(s, true); } =20 @@ -271,7 +271,7 @@ static void tap_send(void *opaque) =20 static bool tap_has_ufo(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 @@ -280,7 +280,7 @@ static bool tap_has_ufo(NetClientState *nc) =20 static bool tap_has_uso(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 @@ -289,7 +289,7 @@ static bool tap_has_uso(NetClientState *nc) =20 static bool tap_has_tunnel(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); return s->has_tunnel; @@ -297,7 +297,7 @@ static bool tap_has_tunnel(NetClientState *nc) =20 static bool tap_has_vnet_hdr(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 @@ -311,7 +311,7 @@ static bool tap_has_vnet_hdr_len(NetClientState *nc, in= t len) =20 static void tap_set_vnet_hdr_len(NetClientState *nc, int len) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 @@ -322,21 +322,21 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, = int len) =20 static int tap_set_vnet_le(NetClientState *nc, bool is_le) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 return tap_fd_set_vnet_le(s->fd, is_le); } =20 static int tap_set_vnet_be(NetClientState *nc, bool is_be) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 return tap_fd_set_vnet_be(s->fd, is_be); } =20 static void tap_set_offload(NetClientState *nc, const NetOffloads *ol) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); if (s->fd < 0) { return; } @@ -357,7 +357,7 @@ static void tap_exit_notify(Notifier *notifier, void *d= ata) =20 static void tap_cleanup(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); =20 if (s->vhost_net) { vhost_net_cleanup(s->vhost_net); @@ -381,14 +381,14 @@ static void tap_cleanup(NetClientState *nc) =20 static void tap_poll(NetClientState *nc, bool enable) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); tap_read_poll(s, enable); tap_write_poll(s, enable); } =20 static bool tap_set_steering_ebpf(NetClientState *nc, int prog_fd) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); =20 return tap_fd_set_steering_ebpf(s->fd, prog_fd) =3D=3D 0; @@ -396,7 +396,7 @@ static bool tap_set_steering_ebpf(NetClientState *nc, i= nt prog_fd) =20 int tap_get_fd(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); return s->fd; } @@ -408,7 +408,7 @@ int tap_get_fd(NetClientState *nc) */ static VHostNetState *tap_get_vhost_net(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); return s->vhost_net; } @@ -447,7 +447,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, =20 nc =3D qemu_new_net_client(&net_tap_info, peer, model, name); =20 - s =3D DO_UPCAST(TAPState, nc, nc); + s =3D container_of(nc, TAPState, nc); =20 s->fd =3D fd; s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; @@ -1016,7 +1016,7 @@ fail: =20 int tap_enable(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); int ret; =20 if (s->enabled) { @@ -1033,7 +1033,7 @@ int tap_enable(NetClientState *nc) =20 int tap_disable(NetClientState *nc) { - TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + TAPState *s =3D container_of(nc, TAPState, nc); int ret; =20 if (s->enabled =3D=3D 0) { --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117336; cv=none; d=zohomail.com; s=zohoarc; b=WlgAD9ERhD+o1hdfS1eZs0Vfbwl0Xtygzyf6/jHez/yDpMuQGHbq2So3OBW99C/TUSaDZjhN7JfdSrPjLkkGxYFZkBZObCjX0sX3W4H27Xo69gjyYEMSCyY748dqlkUMTp4MHy3sRCLDsa0VRyW2Kt3c1szVzQkJV/JIltiPbB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117336; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ym7KMRqUcvU4ABujQuwWyzRgxAgmuy8bm1077mgBw+A=; b=NF3rvZUPc91PrLdwMlmBs/jQHtJC4kouG0gRDAy5uJ7lVui8dr/ALozX9XvQulWbiRiexrNXRMWglqRtyDkLyXIrzktP9HaLi1cs+vy5yQUTT/jBLKhtd4g6rzrnPlpT5Fu+ncAlMfi1X8XnDiYPkiRz8uhp6yFM/L4szkoFMJA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117336712862.109541765652; Fri, 11 Sep 2026 02:02:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9B-0002Fs-Tp; Fri, 11 Sep 2026 05:02:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x92-00027u-UY for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x91-00086S-2W for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:04 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-288-bgc80lx6OICt9u2wlmV7Sg-1; Fri, 11 Sep 2026 05:01:58 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49d1a778b9dso6290095e9.0 for ; Fri, 11 Sep 2026 02:01:58 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60ababd5sm80900555e9.4.2026.09.11.02.01.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117322; 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=ym7KMRqUcvU4ABujQuwWyzRgxAgmuy8bm1077mgBw+A=; b=U2ixPvN0FxTtBdg2cFJEaS1qAu4BwluLbRg0bgAM+T8psJYftiIoMTerxqxLd0Wy25VUST loBlIuV08OR0vO8sg4uJNm+rZayAhv+8KvxcmO7Ne7dOacA5s49V/HIpNkWylYP1Los4it HB5x918fpSH/iplb0/AZb5CsLgv7dbM= X-MC-Unique: bgc80lx6OICt9u2wlmV7Sg-1 X-Mimecast-MFC-AGG-ID: bgc80lx6OICt9u2wlmV7Sg_1789117317 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117317; x=1789722117; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=ym7KMRqUcvU4ABujQuwWyzRgxAgmuy8bm1077mgBw+A=; b=sFg5b8J7W70EGr13IMFlwb+Ormmn1msHiCyDEMKUsARBbfc4xne+6eQyKR/HSvs1sF H2jozykjvfIcZkoWLMxuiGRzdarbpNENvq2B3Jc7YufWYdB6GjzQA5zJYCCgh8knSa5c P38jz82IfpKmvhDIrnWEkv/vt2bomohDOaiwyS9bPOwmgnhZyfUL8aY+WjfXF0pgFvoL J33IQ7xeO406bBELMNYtYW38Q8pWYlX0uAp2XtHM/ls1G8BbOnZE/Uj5tFII02By2lCc zjOTm4nDEETIjVdtGfW74g06MqkLwBG7Tr+rYM9z/aEfQxsXTr+sZjypJyYorSrRYacQ IEZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117317; x=1789722117; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ym7KMRqUcvU4ABujQuwWyzRgxAgmuy8bm1077mgBw+A=; b=Lo9ALlHN9KtkN917Ata8B5hgfzRgvvJdHohUMDBSqrB2cVeGupSSGaIGVoZLtLS6Sh Kk+X2b6+Y01gIHq14yQhKaGso/oqllZfnl9XYKKkkIOBJ2AzJkBBRyiVUS42R3T7FVY1 hNfKLOTb+ynIMb222wHesho785QUrTDZfUVYKp0Hd9LJWNcUOoT99Dlm4iM0/bYFQ85N uWEIlWfBd3YUrhqvv1WGLtpMMU/720JjsTwayu7t0N0iTPkfT70I5fgx/zRM5HZCEnup yIJeKQb1lVzQZUIVcZ3/oUnmdbERhXPnHdLEMaYH98w0ZsY58dz7KexixL3nW9kU27sb IA2w== X-Gm-Message-State: AFuF++kXh4kGlTbT81FRoKih8T4Fo1GrJua5ED8bp3jdzTAq9VBftu4v yyVEP1EYNo76J8XRZT0ydKf/jdjMuVH5qXHficG5IpcAvhuyEjkaT2cVM4vaEeueNBcRyW0St8/ 0xCdQ7WnxIjqlkiuGPvAFHDVBOWBRkqMU93ahVLMff5RlkKaXwfO/EwXSVI02q+V77qPAyPsI+6 25Sx4y0pNHJLcp0oIu3zK4MgrFtDTCsUNFrg== X-Gm-Gg: AYBFou3+g1avi2Gt50Kr8HZnuPMfRYhA2vRICVzJ1fUjpeQSwOzCBdPTXOSGZS7DoCt ezI2QC1411Dv5pH06l8pMUMNEsWr+8A6p8krFbN0pcMqNc60k4I4fSsKFYAuj2Wm8SzWdQ7Opdi y2K/VIp8U1a+gsyuZxwASPD38gbLSTIgvS1bHCJuJemkx3Sc/Ho5xnB0AOQdLTbGzql76/XJ8du VyNkSf8CBt+pZubhJ7UoL3T1g7Za8bK6HZwVwovFAWgR8dEvRPFIbtEIcGwDMgKjHFgdXLhVBVM biO/mWQqkfpFmurx1nhkoIQDctfRW2bLCJowPjmUEYfzpSwzd1IqHwpJ9zxg/tJqWExgXuEj+zW Ri6oYBBGYnAzriPm7XH2f+ss= X-Received: by 2002:a05:600c:4505:b0:499:7a15:fcec with SMTP id 5b1f17b1804b1-49e61a03b32mr62613895e9.13.1789117316826; Fri, 11 Sep 2026 02:01:56 -0700 (PDT) X-Received: by 2002:a05:600c:4505:b0:499:7a15:fcec with SMTP id 5b1f17b1804b1-49e61a03b32mr62612785e9.13.1789117316260; Fri, 11 Sep 2026 02:01:56 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL v2 15/75] net/tap: QOMify tap backend Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117337848158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We prepare for being able to migrate TAP backend. We'll need a user change-able property for it, which can be set from machine type. So, let's QOMify it first. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-8-vsementsov@yandex-team.ru> --- include/net/net.h | 7 +++++++ include/net/tap.h | 2 ++ net/net.c | 14 +++++++------- net/tap.c | 48 +++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 626b997948..ea07760b56 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -161,6 +161,13 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr); NetClientState *qemu_find_netdev(const char *id); int qemu_find_net_clients_except(const char *id, NetClientState **ncs, NetClientDriver type, int max); +void qemu_net_client_setup(NetClientState *nc, + NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name, + NetClientDestructor *destructor, + bool is_datapath); NetClientState *qemu_new_net_client(NetClientInfo *info, NetClientState *peer, const char *model, diff --git a/include/net/tap.h b/include/net/tap.h index 6f34f13eae..268570571f 100644 --- a/include/net/tap.h +++ b/include/net/tap.h @@ -28,6 +28,8 @@ =20 #include "standard-headers/linux/virtio_net.h" =20 +#define TYPE_TAP_NETDEV "tap-netdev" + int tap_enable(NetClientState *nc); int tap_disable(NetClientState *nc); =20 diff --git a/net/net.c b/net/net.c index 1161183e18..d7fa637ce5 100644 --- a/net/net.c +++ b/net/net.c @@ -261,13 +261,13 @@ static ssize_t qemu_deliver_packet_iov(NetClientState= *sender, int iovcnt, void *opaque); =20 -static void qemu_net_client_setup(NetClientState *nc, - NetClientInfo *info, - NetClientState *peer, - const char *model, - const char *name, - NetClientDestructor *destructor, - bool is_datapath) +void qemu_net_client_setup(NetClientState *nc, + NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name, + NetClientDestructor *destructor, + bool is_datapath) { nc->info =3D info; nc->model =3D g_strdup(model); diff --git a/net/tap.c b/net/tap.c index bfed74717e..7392344200 100644 --- a/net/tap.c +++ b/net/tap.c @@ -43,6 +43,7 @@ #include "qemu/main-loop.h" #include "qemu/sockets.h" #include "hw/virtio/vhost.h" +#include "qom/object.h" =20 #include "net/tap.h" #include "net/util.h" @@ -68,7 +69,11 @@ static const int kernel_feature_bits[] =3D { VHOST_INVALID_FEATURE_BIT }; =20 -typedef struct TAPState { +OBJECT_DECLARE_SIMPLE_TYPE(TAPState, TAP_NETDEV) + +struct TAPState { + Object parent_obj; + NetClientState nc; int fd; int vhostfd; @@ -86,7 +91,7 @@ typedef struct TAPState { VHostNetState *vhost_net; unsigned host_vnet_hdr_len; Notifier exit; -} TAPState; +}; =20 static void launch_script(const char *setup_script, const char *ifname, int fd, Error **errp); @@ -413,6 +418,19 @@ static VHostNetState *tap_get_vhost_net(NetClientState= *nc) return s->vhost_net; } =20 + +static const TypeInfo tap_netdev_info =3D { + .name =3D TYPE_TAP_NETDEV, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(TAPState), +}; + +static void tap_net_client_destructor(NetClientState *nc) +{ + TAPState *s =3D container_of(nc, TAPState, nc); + object_unref(OBJECT(s)); +} + /* fd support */ =20 static NetClientInfo net_tap_info =3D { @@ -435,6 +453,18 @@ static NetClientInfo net_tap_info =3D { .get_vhost_net =3D tap_get_vhost_net, }; =20 +static TAPState *new_tap(NetClientState *peer, + const char *model, + const char *name) +{ + TAPState *s =3D TAP_NETDEV(object_new(TYPE_TAP_NETDEV)); + + qemu_net_client_setup(&s->nc, &net_tap_info, peer, model, name, + tap_net_client_destructor, true); + + return s; +} + static TAPState *net_tap_fd_init(NetClientState *peer, const char *model, const char *name, @@ -442,12 +472,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, int vnet_hdr) { NetOffloads ol =3D {}; - NetClientState *nc; - TAPState *s; - - nc =3D qemu_new_net_client(&net_tap_info, peer, model, name); - - s =3D container_of(nc, TAPState, nc); + TAPState *s =3D new_tap(peer, model, name); =20 s->fd =3D fd; s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; @@ -1048,3 +1073,10 @@ int tap_disable(NetClientState *nc) return ret; } } + +static void tap_register_types(void) +{ + type_register_static(&tap_netdev_info); +} + +type_init(tap_register_types) --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117432; cv=none; d=zohomail.com; s=zohoarc; b=AKpE1raIiUbX6MEyNPmNAwR++kkg9eURCd0nnXFjcbNODoXNvmQIMqA/aKH77tYwcReYpR0MhS2sKgo0hkPdPsxHpeokkmLN0CUdRUuZki/9nnG4ClYo8YSUVXNCy539uItVySvipqHvP2QfViWnb4H48iXfHt7GbXVEZb79Fmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117432; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RmU1ZVuK0eWJ8g7D4bDyVxoI5VfvIMF1jU9CZuz+FqI=; b=IP/G5lCrOujt5F86swbV/9yHJKcCNT5mzlj/NC1I+/Tsqg8a9K3B/5k2pfl3SWY6UfursAECysYcRmaRkvFDNahwDj+qXghFfbMWzUpZgmDjDBAioX2YMNK9DgIDw7ZCirGZwM+raOfKUzJPTNHO8lNh18OK4oFabwVC7Us+fF4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117432920491.7647238325542; Fri, 11 Sep 2026 02:03:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9I-0002PQ-Nz; Fri, 11 Sep 2026 05:02:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x94-00028y-8u for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x92-00086Z-DR for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:05 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-BLWcj7G7N92UKvxP6JqDoQ-1; Fri, 11 Sep 2026 05:02:00 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-47f4bff865cso359937f8f.0 for ; Fri, 11 Sep 2026 02:02:00 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486f301121asm310240f8f.0.2026.09.11.02.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117323; 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=RmU1ZVuK0eWJ8g7D4bDyVxoI5VfvIMF1jU9CZuz+FqI=; b=PfkwchiiJyyABKOh9UfbR3Ku2WVQWXA7najAu7TRKwj7tmK5GpqjFuKiFZt86bcWr5VOTf oDJlPvPsuDUY8OHplPLoeAl4TMTYRy7+IxePUQXTU78CnF7x832AqhBxZ8lCsxeUIISN+3 ycyXw4gkGlC3stGcApW06VnT5DNvrlY= X-MC-Unique: BLWcj7G7N92UKvxP6JqDoQ-1 X-Mimecast-MFC-AGG-ID: BLWcj7G7N92UKvxP6JqDoQ_1789117319 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117319; x=1789722119; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=RmU1ZVuK0eWJ8g7D4bDyVxoI5VfvIMF1jU9CZuz+FqI=; b=IEh6FHfUBH3RDv216M4yqKWUM0d9Za2Z+w8h+UZqkJuK7WSrTkkOpT6XyCA2wsNKkq Q1CLrHssr6T7jR050f+wkQATEMuQhVRMcFKHIm7A1Dj0yRPPY6bqs3XWOZ9GyDaotkIl M0YIRJn9NCtXycS4N85pLFL/a0Eysz9WT82lFy5q6mgvyivvU1fmqoUUts582RE8HGq9 1SmMFLu9B3HVHsK/VyrwZJrzYdqGrX3DnjUBzIZZxc/D6qB3W5Hr8YAYRyKCbeCwZekQ A/ImC0jX9x1ch4tj0OPf/6fHu4VPW1DgKfXg1ZzWgdpLAALYpvnDOWrpHB+uXG1A31uL tf5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117319; x=1789722119; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=RmU1ZVuK0eWJ8g7D4bDyVxoI5VfvIMF1jU9CZuz+FqI=; b=icozD3kO4ndHrYu5Av9uCsRNx8rAsHzVAKuj4VkQ9uQC3ylHiwm7gS5alNiYC6Ijyq Ve/XY1IjkKEdCMJfuoszjcJJWYNjbFis/EFgfpHSHX6lUrgiwkYYWjtGsPOleCyUQReO SCbRLOV2c5V04t4zZ+6oudX28atdndF0u9Wd659h3sC3+PbdLCY2tmteKntl1pHF0dzg GmUg6stUOAp4hcfa39GducdDPc1EUs+GFyiY4Vx0yVtVcPtoa6NVtCR7uAdDH55Aa8Nu EqkfmvZAZcwtsR7OQ5Drsn0MG2hNXcRcMA2fZa7D486kZwOxNnAvf1nLhj0GAz2rZtle 56Vw== X-Gm-Message-State: AFuF++n25GMr6/HGqkQV3GYyv9bDJ7VUI8f4geOCUI3cNVODd84R15fW OKA1N16PcO4//NuYeWE44zFyT+nuvGBXSA5glQwpT9OktaZ86tZjflGMuu8RK2sce0UN7dcU2DQ XyoOh31y31TCUWYiuN0Dlo1yR2KsqqvFDUZla9ebb3NVCOMU8ThlvKpITQfXVZLJh+pov2LSbNX SZF9sYPdyf9hwmgvp+Smkhx97D46f3hdlX2g== X-Gm-Gg: AYBFou1TgMnnKZQL52ytOyWZJ1ShLiTTrH67eto2ODfKeudPeFFnpGs7RAd1d9UPmp6 7cnIkXyDGJVW156PmQtEsJzeFoeoW1dC1CHQaVgY01/QaAiLguJ9y8u6SfDFvi4kyV8PnopqC3X co2meQ7bFaZmdnKnOMkBIHmMAIdslM3qR+d9bsLgoj+ppz1YnLNwbksfzqIDsES28b5Brsj2/7E F5dxrm3pgg7tA/pMwjXpkxICZySLpTR9TE++5mrM8APrq1HKsR+RUndFtbYWs5iJjbZsgMiL2SO kREPRVgfLw//v5ywgFels+ZN8ZAqAXU7WqgfjC4TsRnG77ojlj9QY9W07NshwYR6ZXpihWZN4Ft C/gvwILki28Sx2OX330kYg4c= X-Received: by 2002:adf:e00b:0:10b0:484:3310:710c with SMTP id ffacd0b85a97d-486eb351000mr4929127f8f.24.1789117319034; Fri, 11 Sep 2026 02:01:59 -0700 (PDT) X-Received: by 2002:adf:e00b:0:10b0:484:3310:710c with SMTP id ffacd0b85a97d-486eb351000mr4929027f8f.24.1789117318374; Fri, 11 Sep 2026 02:01:58 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang Subject: [PULL v2 16/75] net/tap: add TYPE_VMSTATE_IF interface Message-ID: <9fe286589d7c5f9c944a4855d932c40b24a82adc.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117434291158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We'll need it to implement TAP backend live migration. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-9-vsementsov@yandex-team.ru> --- net/tap.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/net/tap.c b/net/tap.c index 7392344200..dd0d134875 100644 --- a/net/tap.c +++ b/net/tap.c @@ -43,7 +43,6 @@ #include "qemu/main-loop.h" #include "qemu/sockets.h" #include "hw/virtio/vhost.h" -#include "qom/object.h" =20 #include "net/tap.h" #include "net/util.h" @@ -91,6 +90,8 @@ struct TAPState { VHostNetState *vhost_net; unsigned host_vnet_hdr_len; Notifier exit; + + int queue_index; }; =20 static void launch_script(const char *setup_script, const char *ifname, @@ -419,10 +420,29 @@ static VHostNetState *tap_get_vhost_net(NetClientStat= e *nc) } =20 =20 +static char *tap_vmstate_if_get_id(VMStateIf *obj) +{ + TAPState *s =3D TAP_NETDEV(obj); + char *res =3D g_strdup_printf("%s/%d", s->nc.name, s->queue_index); + return res; +} + +static void tap_class_init(ObjectClass *klass, const void *data) +{ + VMStateIfClass *vc =3D VMSTATE_IF_CLASS(klass); + + vc->get_id =3D tap_vmstate_if_get_id; +} + static const TypeInfo tap_netdev_info =3D { .name =3D TYPE_TAP_NETDEV, .parent =3D TYPE_OBJECT, .instance_size =3D sizeof(TAPState), + .class_init =3D tap_class_init, + .interfaces =3D (const InterfaceInfo[]) { + { TYPE_VMSTATE_IF }, + { } + }, }; =20 static void tap_net_client_destructor(NetClientState *nc) @@ -455,13 +475,16 @@ static NetClientInfo net_tap_info =3D { =20 static TAPState *new_tap(NetClientState *peer, const char *model, - const char *name) + const char *name, + int queue_index) { TAPState *s =3D TAP_NETDEV(object_new(TYPE_TAP_NETDEV)); =20 qemu_net_client_setup(&s->nc, &net_tap_info, peer, model, name, tap_net_client_destructor, true); =20 + s->queue_index =3D queue_index; + return s; } =20 @@ -469,10 +492,11 @@ static TAPState *net_tap_fd_init(NetClientState *peer, const char *model, const char *name, int fd, - int vnet_hdr) + int vnet_hdr, + int queue_index) { NetOffloads ol =3D {}; - TAPState *s =3D new_tap(peer, model, name); + TAPState *s =3D new_tap(peer, model, name, queue_index); =20 s->fd =3D fd; s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; @@ -709,7 +733,7 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, close(fd); return -1; } - s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr); + s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr, 0); =20 qemu_set_info_str(&s->nc, "helper=3D%s,br=3D%s", helper, br); =20 @@ -785,10 +809,11 @@ static bool net_init_tap_one(const NetdevTapOptions *= tap, NetClientState *peer, const char *name, const char *ifname, const char *script, const char *downscript, int vhostfd, - int vnet_hdr, int fd, Error **errp) + int vnet_hdr, int fd, int queue_index, + Error **errp) { TAPState *s =3D net_tap_fd_init(peer, tap->helper ? "bridge" : "tap", - name, fd, vnet_hdr); + name, fd, vnet_hdr, queue_index); bool sndbuf_required =3D tap->has_sndbuf; int sndbuf =3D (tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT= _MAX; @@ -989,7 +1014,7 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, if (!net_init_tap_one(tap, peer, name, ifname, NULL, NULL, vhost_fds ? vhost_fds[i] : -1, - vnet_hdr, fds[i], errp)) { + vnet_hdr, fds[i], i, errp)) { goto fail; } } @@ -1024,7 +1049,7 @@ int net_init_tap(const Netdev *netdev, const char *na= me, i >=3D 1 ? NULL : script, i >=3D 1 ? NULL : downscript, vhost_fds ? vhost_fds[i] : -1, - vnet_hdr, fd, errp)) { + vnet_hdr, fd, i, errp)) { goto fail; } } --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117442; cv=none; d=zohomail.com; s=zohoarc; b=UDj/uT42f8ZeaANUjrvtUP6+/QqEYCzYyGuxPnUq9tdV2IhoIMmC4UeZsZOOfQJL9pzqFU6WENA3Vs9NK0kUHakQkBKc0Z7Kucd9tSCjkiKDeX3gVpB8QgDXMP2veN3Ms3jt1Nxs8nR37I9TY8KxFlbiHdVgLRd1q33XkrMtfRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117442; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dveBwypMxxlS0tHYi3KN/e1QMBIv6aayFrNW2TY0wNY=; b=kmZMmc8Ez7xSSNjC063X6WzK3oBc09jWXTIX1AfXQKfLOYgt8v/jXpv2iYXDiuSpQNAnXX1KIZVQdhcTYYHJTlMr+d6qa45OrnZH5J45ekw+IrJHhzKKKuStjEce5pqhtRzzYtoFhQTxo8eFgjfo3fIp2YJIkA/bgxSC4Al6kDg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117442741167.64545121154868; Fri, 11 Sep 2026 02:04:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9R-0002dH-2E; Fri, 11 Sep 2026 05:02:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x94-0002BP-V5 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x92-00086c-VL for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:06 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-R18IH6Q2PcS_E0ZENTP7dg-1; Fri, 11 Sep 2026 05:02:02 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4843d9ab895so606764f8f.0 for ; Fri, 11 Sep 2026 02:02:02 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb360409sm4180360f8f.36.2026.09.11.02.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117324; 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=dveBwypMxxlS0tHYi3KN/e1QMBIv6aayFrNW2TY0wNY=; b=NTXkVvrfI3OCqW0JUBKZ7BZ22ob2W26zch6NlEJP2PtT+nzrL33MSoc8j88DEpQPJylfEn 9JA6oGwXvDNUgZGgJnDWYGF4NP2ZcFiZA6ObtffB4l9AmyBrva0U83aBFd2mtnOi5uoRv/ ekAi7TeZ+yNVA3MGycSh8G8eWFYOXNs= X-MC-Unique: R18IH6Q2PcS_E0ZENTP7dg-1 X-Mimecast-MFC-AGG-ID: R18IH6Q2PcS_E0ZENTP7dg_1789117322 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117321; x=1789722121; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=dveBwypMxxlS0tHYi3KN/e1QMBIv6aayFrNW2TY0wNY=; b=CFiJEwd8n31UGyZnCVs8dk0xubbzAHD+NiaHnUCpShU8iEJ9IhaA45arK/qouhbJ12 os8euJ4vH+t99MIkxWVpFNFN+QUptWpWxjRFs9F5DzrIhbosRP5I4zYD0OB69Ssepvcv lMquZHxmElfDpHoO2aCUUG8K8C8A9mnguZqTN6SjJe1RXixnVPKZqJaUiYlVUuHPYCjy +w/Cf/JP60gjs51PrgJk7aeGx3jCrmq02yifF8iY2NujqS/u99yifj0KML90HF1Ey1ia cL+zZGCLGhtFyjDBfRrcB+P66uswI4mOUrMIzNFGGvhhFlXOpeb4gPnL98oLVOPcLdML Utew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117321; x=1789722121; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=dveBwypMxxlS0tHYi3KN/e1QMBIv6aayFrNW2TY0wNY=; b=pCPh98AAP501djLbQdRBi8XcufFRNI1a0oUASwEM/yf2nVvYZ0oSKifAC89WeZlbEU 7Kt0YcSX/+vxWlCSzjBqAyeUJGqKJWNwXIDLVh966crS6wQlwOAFm99OnyPWNyLEGms+ +eTVJOGJIFtOG0Ezv6Z9yaUsjGGDWn8KtQM42+J06mh3ikNSiTdDPWGtePXsoNWXsjLR rpkuHwsLdKmaU88Ihm680CUTwdVBTCXo+09hnuntGwlt4v5n13bnjXi3QAECjltFLcjY AgUQF2lgB/OPFNNu4zfcwOChhEc67qtrQmWRtP8h7IF7C7ffxsoLn9Gb8bXMRB1mO1H9 5hPQ== X-Gm-Message-State: AFuF++lTESCefsPraQHDc7CysphK5Orpk8ENDhAm/6V8Uqqbb86Cy8y3 XXxkjpfMS6Eum4iWDMz0Wh50vKB4jR3bkE6V5Wua+r3frLAOjRFZAteBJiPX6IafKiVenKkILBW 5JT3NoRTvxiEGg0wG8bNXsLNrNuASD2o4KpAiogFrSGHeI1GDnPNiQLUB+8OnVGwqk7S/2IykZY heqiDoJ/8V2cWd8N7Pjdi9O5rl/1WU3JyoGQ== X-Gm-Gg: AYBFou3ukhgtBw75NaeBDignnmB6z6/kr+SzUvC8uYQNKUED+pB4fwopJyZL4SsFwLj hfpOHOxgq1NkGVqchPFXo6A3ju26MRCtEDwVjEa+e0lriKSyIaR4nBLaaUMu37Q+F0JSrXU+WT8 bNjIJAUccOpGylPC/+FmYFRdsV3hxWfx/e5SVuEPR/PzeTkbCqlgZBgqd3uoO0KZWBSyf335bXs cgCpx+Na8uBrANlZGCAr6AriCrt5MFaXJbql2MTmF3VMzfIJDR1O8AbRbpGNbbiLFfsHKsNh3uy CFXgYe42jzkrnxeuB/3NHhSC/k4kiIRcwFvJupSbDhOdPJINtr+tNffHq+3CjQw38aLuqMaWqDq hMkZSpSlSX9PMkO1uWRwxEPY= X-Received: by 2002:a5d:534b:0:b0:485:8c16:5ef6 with SMTP id ffacd0b85a97d-486eb30ac8dmr2606924f8f.48.1789117321427; Fri, 11 Sep 2026 02:02:01 -0700 (PDT) X-Received: by 2002:a5d:534b:0:b0:485:8c16:5ef6 with SMTP id ffacd0b85a97d-486eb30ac8dmr2606858f8f.48.1789117320719; Fri, 11 Sep 2026 02:02:00 -0700 (PDT) Date: Fri, 11 Sep 2026 05:01:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Markus Armbruster , Peter Xu , Fabiano Rosas , Eric Blake Subject: [PULL v2 17/75] qapi: add local migration parameter Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117444416158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy We are going to implement local-migration feature: some devices will be able to transfer open file descriptors through migration stream (which must UNIX domain socket for that purpose). This allows to transfer the whole backend state without reconnecting and restarting the backend service. For example, virtio-net will migrate its attached TAP netdev, together with its connected file descriptors. In this commit we introduce a migration parameter, which enables the feature for devices that support it (none at the moment). We can't simply auto-detect local migration by checking whether the migration channel is a UNIX domain socket: the UNIX socket may be only the first part of the transfer channel to a remote target. Hence an explicit parameter is needed. Moreover, "local" migration parameter may be useful in cpr-exec mode, when FDs are passed through exec instead of UNIX socket. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Markus Armbruster Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-10-vsementsov@yandex-team.ru> --- qapi/migration.json | 21 +++++++++++++++++---- include/migration/misc.h | 2 ++ migration/options.c | 18 +++++++++++++++++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index b1eaf7b054..f7628b55e9 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -830,7 +830,8 @@ 'zero-page-detection', 'direct-io', { 'name': 'x-rdma-chunk-size', 'features': [ 'unstable' ] }, - 'cpr-exec-command'] } + 'cpr-exec-command', + 'local'] } =20 ## # @migrate-set-parameters: @@ -1012,10 +1013,20 @@ # Must be set to the same value on both source and destination # before migration starts. (Since 11.1) # +# @local: Permit the use of optimizations for local migration. This +# must only be set when either both the source and destination +# QEMU processes are directly connected with a UNIX domain socket +# as the migration channel (to enable use of file descriptor +# passing) or cpr-exec migration mode is enabled (this way file +# descriptors are inherited by new process). Individual device +# backends may need additional configuration flags set to enable +# local migration optimizations. This will be documented against +# the device backends where it applies. (Since 11.2) +# # Features: # -# @unstable: Members @x-checkpoint-delay, @x-rdma-chunk-size, and -# @x-vcpu-dirty-limit-period are experimental. +# @unstable: Members @local, @x-checkpoint-delay, @x-rdma-chunk-size, +# and @x-vcpu-dirty-limit-period are experimental. # # Since: 2.4 ## @@ -1053,7 +1064,9 @@ '*direct-io': 'bool', '*x-rdma-chunk-size': { 'type': 'uint64', 'features': [ 'unstable' ] }, - '*cpr-exec-command': [ 'str' ]} } + '*cpr-exec-command': [ 'str' ], + '*local': { 'type': 'bool', + 'features': [ 'unstable' ] } } } =20 ## # @query-migrate-parameters: diff --git a/include/migration/misc.h b/include/migration/misc.h index 2b2fbb59a4..019717f4cd 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -161,4 +161,6 @@ bool multifd_join_device_state_save_threads(void); =20 void migration_request_switchover_ack_legacy(const char *requester); =20 +bool migrate_local(void); + #endif diff --git a/migration/options.c b/migration/options.c index d2575edb6c..05b026f4bf 100644 --- a/migration/options.c +++ b/migration/options.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "qemu/units.h" +#include "qapi/util.h" #include "exec/target_page.h" #include "qapi/clone-visitor.h" #include "qapi/error.h" @@ -25,6 +26,7 @@ #include "migration/colo.h" #include "migration/cpr.h" #include "migration/misc.h" +#include "migration/options.h" #include "migration.h" #include "migration-stats.h" #include "qemu-file.h" @@ -350,6 +352,12 @@ bool migrate_mapped_ram(void) return s->capabilities[MIGRATION_CAPABILITY_MAPPED_RAM]; } =20 +bool migrate_local(void) +{ + MigrationState *s =3D migrate_get_current(); + return s->parameters.local; +} + bool migrate_ignore_shared(void) { MigrationState *s =3D migrate_get_current(); @@ -1101,7 +1109,7 @@ static void migrate_mark_all_params_present(Migration= Parameters *p) &p->has_announce_step, &p->has_block_bitmap_mapping, &p->has_x_vcpu_dirty_limit_period, &p->has_vcpu_dirty_limit, &p->has_mode, &p->has_zero_page_detection, &p->has_direct_io, - &p->has_x_rdma_chunk_size, &p->has_cpr_exec_command, + &p->has_x_rdma_chunk_size, &p->has_cpr_exec_command, &p->has_local, }; =20 len =3D ARRAY_SIZE(has_fields); @@ -1449,6 +1457,10 @@ static void migrate_params_test_apply(MigrationParam= eters *params, qapi_free_strList(dest->cpr_exec_command); dest->cpr_exec_command =3D QAPI_CLONE(strList, params->cpr_exec_co= mmand); } + + if (params->has_local) { + dest->local =3D params->local; + } } =20 static void migrate_params_apply(MigrationParameters *params) @@ -1581,6 +1593,10 @@ static void migrate_params_apply(MigrationParameters= *params) s->parameters.cpr_exec_command =3D QAPI_CLONE(strList, params->cpr_exec_command); } + + if (params->has_local) { + s->parameters.local =3D params->local; + } } =20 void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117965; cv=none; d=zohomail.com; s=zohoarc; b=lnRnOY0xpksCtOsZz8qruEbJR/gCzUnBOIcTB3Kr2LboqdC4ybo5W+9TxizLTJ+IxivU4JhRh+wjQ/s+9RGDqzOPtzvN9P01LCR6EKJxkIw6f29V65N2wWPL/AydfO9tYzPyLrLmrUqRQ/OYNeUeWJAWgV5MkSAJ52wx1kG5Ajs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117965; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qnAlDO2QjRLH3bD583YkEJaCzSVpdg74aK2h0Y1Pq7U=; b=MpCtjEfRdTt5pgjpnou/EtJFAFbKQtacqBzSyBTIfpDik45lnCeCHPrK6q7daEWsguAAqEG/jf8zOsnyPbkn1ZzxfFBQEW0dOPEUkGaew4S7g1KKyDdboLOCnu5ngY22vt2wCx8ilK1LqvDP4v1U3QDRxtUnA/u77PD+9jdAJFQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117965662195.48173630888982; Fri, 11 Sep 2026 02:12:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9U-0002vn-62; Fri, 11 Sep 2026 05:02:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x96-0002Ft-SN for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x95-000878-C8 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:08 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-CXUgr5B8Pvu0XCGpQplybQ-1; Fri, 11 Sep 2026 05:02:05 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-484337a63bbso362022f8f.3 for ; Fri, 11 Sep 2026 02:02:04 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb350686sm4704823f8f.27.2026.09.11.02.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117326; 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=qnAlDO2QjRLH3bD583YkEJaCzSVpdg74aK2h0Y1Pq7U=; b=KqdLIbTgY+VbgyiGuhBiemQfq5HR6Oc8D3TvhPiHisfSOZkTJrpyckr35OUUmpz4YgJw9a Bshj+tkpihwTe9hye+XDqnQT/0MoghwPThQOAKe1BMoq7ZJYakl2ZQjymFF8o+O808Yrqg Zaz7/h+1FzraKGZFgD6x0jZKTLiMrqk= X-MC-Unique: CXUgr5B8Pvu0XCGpQplybQ-1 X-Mimecast-MFC-AGG-ID: CXUgr5B8Pvu0XCGpQplybQ_1789117324 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117324; x=1789722124; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=qnAlDO2QjRLH3bD583YkEJaCzSVpdg74aK2h0Y1Pq7U=; b=mSeSdlnRiB7EXWLYXJI8w/9sxgfgQ3RjefUJKbcu2jAVDPTbIUlZ7UBEbgH0U6NtE/ wOABm6nw1PAT2vlzec9SQ7wJbfWk1mXnU5dbPKM7Lt4/LaZOsdFdyhPiTPre9A+R8GAf rtO8pNZ4qHWPLrDTKbpngTsSxEJLth7TN7ea/Moe+45idbv8LX27Von0QvA9VgUGfcMj JPD9S83lqlqdP/iK7O1Pj7aA8k/fZ4LBpBdMYmTo6sJHcRm7M8QrFakq/evacHOuY9iJ 3oXhyMpjFk+zCqHYRv9LxFDlY/j+PuSOVOMw3JLOEcqmQtmbIFcL6CkkpymRqCiLvhN0 mvaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117324; x=1789722124; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=qnAlDO2QjRLH3bD583YkEJaCzSVpdg74aK2h0Y1Pq7U=; b=k5yMttojNQky6ORBySRN4nW5JWJ+axcmL48gDa/bGj1SIXAoFEJQEp5KcFllM0fxSC 8+yFkOOjfiHlw6LJwWPyfF5HqyD8jIXES9r0UO5mIH4jUmbs/hRxgd2O6NdBWrmO+Ao6 bGpugPtx4faP+Nh5WnnX1mb/o1RsJCn4KWhMUhFyXRwhMP+z5O+RMFT035Ro8TYsWXe/ Pim3eO0QKMPf84xQD4xNfgSx9wLeYMyJe3nBYlImynjZEvtzOe6d7bukkFF13NRG4CiX BAjJdAc3lkwniQjLZTnaPISMeqJfbLUKiIMWnMJhG5cGOhUrIs8Aq+AUetBBv0UcXoG+ gl9w== X-Gm-Message-State: AFuF++lIEqkj3iCR4xvzuoJl6x2wp/UDwisTSfReoro2n7pJ1sipEv1a Z1uGjkKCo1l8tTky5NfMyXnkxe+f3RGM4FyQlizocSP2NGCi/HKCCid//PCAFbP0RILmN0YbDTY TC20+X0TkzF+q2nht3cqutJUZ+LGYR6yjSl3zWLi/tECNXMAUh45B54NwhLhJQfVK1PadW+p4Ok 7S21q80btDSKkayNH+itkyZ7c1wIhWOHWTKg== X-Gm-Gg: AYBFou3+Ix+1PZot/xWeRZ854uBoeepLCiYUiDAmIi/0YgRfu5D0F+6zIUazEB52X+w hPG6aj+Z0YZL8I7fLYWSXgQVJDqrVagBqRv7fF55NmcQRYCA0xna0omb1HvDOtHbue6ZLdCHqPg YHL8F35FY0BbPGzROFGsqFx048FhOrdZEEXXoNnVRtdCKWA40bzoOc+KUj8/Yxen+NoVWtpRB95 X8fpoaIvG8vrziOG76nVloNTClixb7dGsHW9PiJMIxRO+9Py8ulG+/tIPTMoull0mJlvm2oPL+M m/AGjDIF20wlJEKoohw1ZLxubRG/HOUizNvptjkQZGiB0emdJxlwJG8AiJMFtJXSaWtW5WN0Exy yw2NqSmDeEI864YUr+ZrUVzs= X-Received: by 2002:a05:6000:4304:b0:486:f040:2e0e with SMTP id ffacd0b85a97d-486f04030f9mr1866658f8f.42.1789117323693; Fri, 11 Sep 2026 02:02:03 -0700 (PDT) X-Received: by 2002:a05:6000:4304:b0:486:f040:2e0e with SMTP id ffacd0b85a97d-486f04030f9mr1866599f8f.42.1789117323058; Fri, 11 Sep 2026 02:02:03 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Peter Xu , Fabiano Rosas Subject: [PULL v2 18/75] migration/fd: fix fd leak when fd is not valid for migration Message-ID: <8cd740302600dded57a9509eb8e9d408229d0d24.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117968175158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Both fd_connect_outgoing() and fd_connect_incoming() own the file descriptor after resolving it from the monitor, but forget to close it when migration_fd_valid() check fails. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Fixes: f1fcc1c101 ("migration: Remove fd: support on files") Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-11-vsementsov@yandex-team.ru> --- migration/fd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/fd.c b/migration/fd.c index f05f95992f..02b39b150e 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -62,6 +62,7 @@ QIOChannel *fd_connect_outgoing(MigrationState *s, const = char *fdname, if (!migration_fd_valid(fd)) { error_setg(errp, "fd: migration to a file is not supported." " Use file: instead."); + close(fd); goto out; } =20 @@ -97,6 +98,7 @@ void fd_connect_incoming(const char *fdname, Error **errp) if (!migration_fd_valid(fd)) { error_setg(errp, "fd: migration to a file is not supported." " Use file: instead."); + close(fd); return; } =20 --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117772; cv=none; d=zohomail.com; s=zohoarc; b=hvAvN+5p6/13T7vPmyst9QtsNKfMJFjdC8l8EUOk2rtXA3t9/bWEBzwK++kWKeVUmlceItZikLoRc3mLs9cBvFYFYVYlKaRgxmMUd0SJztRT+cMIr7NXouCBd5STAyDB/ofW1EGHwfidhp/352piVqvkga/pFRm2eTehxb4MRS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117772; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=beU7FjgyA0BsZQfNfNmJBUW0kDGthpqeSLUuh7lD0jw=; b=P0XhNMWHbakVn7BwZnYYKYexRsx1MltHr4ewYQjUZriuCk4fhGY6AbOJszOGeg/qcwQWWpHYd0KFKDpvO9+E6q7PM3GFwxXS+au/CBkzGMYjH22VU5tXo3MS1aTpXng2J4USM82VjoA6X4PWU1CeSXDksrBFQ0/jksXiLzHltuI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117772247630.817233291212; Fri, 11 Sep 2026 02:09:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9N-0002TG-Ng; Fri, 11 Sep 2026 05:02:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9B-0002I0-4Z for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x97-00087j-SJ for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:12 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-85rYGe7wM2Kzmx68RLoSmA-1; Fri, 11 Sep 2026 05:02:07 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49cced8309bso7107765e9.3 for ; Fri, 11 Sep 2026 02:02:07 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60ad08fcsm58970875e9.11.2026.09.11.02.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117329; 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=beU7FjgyA0BsZQfNfNmJBUW0kDGthpqeSLUuh7lD0jw=; b=UGZ60i7rJecYXT/EgFVmcWxV4I71otyxdB0fcz5nodt/Ju54XkEwbwbo20BIVmqtApK3kK G8tGb1xduwgumvzQ2mJWZNt/LKQ7kEbmWXbvzvEqigUtEdiLa5u7gFDXyW5ls1KKcRxpvH tVCgPiMRjCtbZp15ZkeaMHG8TdyqLbs= X-MC-Unique: 85rYGe7wM2Kzmx68RLoSmA-1 X-Mimecast-MFC-AGG-ID: 85rYGe7wM2Kzmx68RLoSmA_1789117326 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117326; x=1789722126; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=beU7FjgyA0BsZQfNfNmJBUW0kDGthpqeSLUuh7lD0jw=; b=CJVv6XiMM+O4iP+4dTeCRcb/sFHFzzidKQ3G9S18+dOFicuPH/75b9RcJefA1ccqul IBti3ByHPGUNuz9ZmCoqMG+9S2Rswi4PKJCFKsnR6yUPxtF/S0jg1FIf5AndHy+weHqC aBs/fg7Uh9qix5WjICIIGnoMfZMeD2ZAiCkt/L6y6xxlnBf8uGS6q9Y6Yt/oeXgzjW7Q z5rczR9DbqRVhjZt8K1R97mzTuqf3U+WyOWSGux3wmBdlRLXNAeZYFu8/AVHOq5oJjTd UFDcfC3rmvQNEQYjk8IbHxvJB2KRRFsb8G0iy5xI83itZwXE4g/OxTlw8NiqUMOVBhJD V4uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117326; x=1789722126; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=beU7FjgyA0BsZQfNfNmJBUW0kDGthpqeSLUuh7lD0jw=; b=PR+gndBcOZsnZJf5INulpiYGJTF3DT2vUmUIY07M4kbvUz7pYWDW+WUYqbSW2lINwG VS5c7jGQciwR3VkXK4K+4dld+WhMRaK8rmKJyHvPA8Obr7oPiGL9grPHvaU7wMT1tsWd 8Mmnq5RQVXqvVwYeJvY2Zh8fO4Nt7ZOHKvwMS60SJVb0/Aq17g7+CDGAIa4hJUbgHieG F5SuIUMWi80B9Ua0sjUYO2RjCypl+owXgYXKB7JwL63LMa7DtK99nU96ZIxfkNzcdCh/ dEpBek/PkK0WlTH/U54wZ/hhrlToWQYxLsq8NvzvhDlSGXsiWhnbQ1rvp98F+L5On8iR N8Jg== X-Gm-Message-State: AFuF++k+h6hMxQNq7xG2BBqZauBQeq+mw5hwZ/4oaoHt5hbJTJddRUEI cxIkj4Vksaz5BhFmIODDV1QfBD7cXyBhwMxpKv/ztx1E9/WY/Qy14bhyqDokK9Fr9q39PebiSyA DmNNVn/N/txLrhhUXRqVGn2dawIN9EQ1LLRF0tcWX2ZLSPmgs3Csyx2GmTxXfOd0UGONOqEhsYV SOnVS9qs3exVaxgfyh3yEbQYcDrVFDyl9lDA== X-Gm-Gg: AYBFou2V+WurktcDwNMBMpzqAzlxxHuGmvbUe1Eg8VbcX8B7Mi/16NaY5ugGiG3UILH owKCb4GOUHkoIgWoRKJso1CjzQeym8Lnvm1NUxchK/fQr5zymAoDUaoYGtlrvEogDJXnUwbS8N4 NoqwkV5j0PZgxPDOzSOwVX4onJnfwhXQcI90bIuH06PGzfOPB3trjPO83PT3C0GtaNAZ7NDQil2 QfKvoM7NRdRJnR5yG6PSRDM3FSlIx84SXIgUwDN5rcMYKluYWiRstz75Ok9uAgSJVBJWicOdLn1 iG2LcZoWXcREGCG8OeX72H0BvVrdWfU5Ngd90wfSIJIlyvMBLNUeyQotmKdgW5+q0w8z2HnGBz0 bgurA9pT0GefU/Hd33WAtD7o= X-Received: by 2002:a05:600c:1991:b0:49e:663c:c67e with SMTP id 5b1f17b1804b1-49e663cc7cdmr8298135e9.25.1789117325866; Fri, 11 Sep 2026 02:02:05 -0700 (PDT) X-Received: by 2002:a05:600c:1991:b0:49e:663c:c67e with SMTP id 5b1f17b1804b1-49e663cc7cdmr8297255e9.25.1789117325274; Fri, 11 Sep 2026 02:02:05 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Peter Xu , Fabiano Rosas Subject: [PULL v2 19/75] migration/fd: add errp parameter to migration_fd_valid() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117772930158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Let migration_fd_valid() report the error itself, instead of duplicating the error message in both callers. This also prepares for adding one more check (with a different error message) to the function. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-12-vsementsov@yandex-team.ru> --- migration/fd.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/migration/fd.c b/migration/fd.c index 02b39b150e..78a27caca2 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -37,16 +37,14 @@ static bool fd_is_pipe(int fd) return S_ISFIFO(statbuf.st_mode); } =20 -static bool migration_fd_valid(int fd) +static bool migration_fd_valid(int fd, Error **errp) { - if (fd_is_socket(fd)) { - return true; - } - - if (fd_is_pipe(fd)) { + if (fd_is_socket(fd) || fd_is_pipe(fd)) { return true; } =20 + error_setg(errp, "fd: migration to a file is not supported." + " Use file: instead."); return false; } =20 @@ -59,9 +57,7 @@ QIOChannel *fd_connect_outgoing(MigrationState *s, const = char *fdname, goto out; } =20 - if (!migration_fd_valid(fd)) { - error_setg(errp, "fd: migration to a file is not supported." - " Use file: instead."); + if (!migration_fd_valid(fd, errp)) { close(fd); goto out; } @@ -95,9 +91,7 @@ void fd_connect_incoming(const char *fdname, Error **errp) return; } =20 - if (!migration_fd_valid(fd)) { - error_setg(errp, "fd: migration to a file is not supported." - " Use file: instead."); + if (!migration_fd_valid(fd, errp)) { close(fd); return; } --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117434; cv=none; d=zohomail.com; s=zohoarc; b=DYLo3phADd3gFw7HAl0anhk3g0ECU4q8D3cjUbxTeBPCm48K20dVyvE/O/7BHJbIl6ocKmUZSPp50p1SL5AZe9hJeBfGii0VyGikLipY8M5O9JFU5XtVTTl6IopqkLJI5nEFGof8wB4KDb491jn6TNSuLHkaod5mxD/GJ9cElAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117434; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=f254NehgLbY8bvUcUnlxHVuzEfFRxr1y8JaeM6VB6uw=; b=OUUW+kHgzkZAshiX7Xee3VOntNzkii186F0xa+JLEMNFdkz19GhMSELxqtbFzYWQZC+fP8Ybs+NsmTeRD5Qbij+MmjTN70UZHlKQtpJypD23T0Cd2rSAHZe6VR5g8HLyG1L2+qZ4k3gaCBBYEg+vG3l1QK603JbUVxACi8YjVh0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117434314502.11459394336737; Fri, 11 Sep 2026 02:03:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9P-0002aQ-Ml; Fri, 11 Sep 2026 05:02:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9C-0002KK-D6 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9A-00087y-TW for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:14 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-183-1i56fiqTOUC8hKBAfrsRgw-1; Fri, 11 Sep 2026 05:02:09 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-c2939e341f7so82902666b.2 for ; Fri, 11 Sep 2026 02:02:09 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35bd1esm4525977f8f.31.2026.09.11.02.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117330; 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=f254NehgLbY8bvUcUnlxHVuzEfFRxr1y8JaeM6VB6uw=; b=SxnhtHK7E36RlO0IOVgb26GDx/wmc+j41pecSmvVfSLqPYkgFzAZ01nAuOqTFoESdGu8ng oE7wX+q/d5XOXutVKrOPqRXqWQhEN1o1B5m+X3v16q82e8e/RQ8vjEL7FtJGYfB1/W86a+ sVYd9CDpSSj8AM6qVV4q/NTGJHdmsM8= X-MC-Unique: 1i56fiqTOUC8hKBAfrsRgw-1 X-Mimecast-MFC-AGG-ID: 1i56fiqTOUC8hKBAfrsRgw_1789117328 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117328; x=1789722128; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=f254NehgLbY8bvUcUnlxHVuzEfFRxr1y8JaeM6VB6uw=; b=AEyixg4UKx+8gntK449twoxPvawcg61mzuLbtGrZHmK3BWT52k7zXiALq9RrkhhvuF W/4e4oqHFBClp1RTV741hOTgrFSh+6/ifFL9PE29XvE3NTkidF8VpSeQk/fpBUNS3qEX 4ZcGKgZE9c9cOMWzq4qKnvSYGHPn2Fza/NiCIzjRyhRq/dwVzkcYlaogf/n4MzDpe8Dz 8GRJZGOGwuo9YnpJJ9jSQWeO0NNSl6eo7AfB1IqmqGSEXxRuy8YzmOQIKLGp3VxE2kqT aWYbtRtX8LnFTP3Rd3bugkUR+mvotGTv+FQCp8UBWUQAONtbp6vXF0TnWxRejWblQEMk aTHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117328; x=1789722128; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=f254NehgLbY8bvUcUnlxHVuzEfFRxr1y8JaeM6VB6uw=; b=ooQBUvPiTLnjq8wGT9l98LDfpNpJmVlK0tns674v7//wSahcBfa7L7dpc5LU9NTUDg 0CsmOK1zMpUoQw+ijCit0jWBg9PW7Ygz+lynSMvQySPnfpE9AOef01y3lO9XcLKgOkiw Vq9iHOs8f80jLOCQc/cZzbyvd9M8YfnqEYMK4qw2O+z6epy7ZgHE7B5I0dut5EHSSpvY cDgttdCcYJWx3OewWAdTFD+8LA/DBGWkf/x+vzd7XPANWb4jA1swjwZ2TNWxzvNH2sPE sTmNFpaF2eaTCR3bri7Ya+Hekwrm6c13otII1SE6XDX6W5ARl4LNPNyvV06W2grSI3cX rX7g== X-Gm-Message-State: AFuF++liucr9yHdcnInoCZVuMyTNBHKFTWPGk01xlOh2QxVO3rBumSHg V+DK4Jm/27Z7f6bC7EQEkJT7Ss1px8ros/noNX9s2S70JG9Oc7sdV9m2H//Gu0ERzYd05FK6Fel XCr+3FNKGreqBlTMHa5Fcl3aJFTjPRpSkdN7I++kWpCf56M4hnkhLbzSJzecs60aPDPRQocjWEg c8HBkysBE7lYJkgIKFtRyN/jH+flK7EVyNfQ== X-Gm-Gg: AYBFou2agT3/IBh5MTu4w8jP/rJB/MOiI8Zl9ysIL4v10zc7YctOPEDZsQKqDTD2P+W /B4KESKGCPhQ2wlYqMw6y9iQ1AI8WjiWLeGcDXi9G4lTpDaPwYMx9k2nVF7/96wEMbodgRnekDr KOVfGkzgk7TO1aDLY1fajHby3YOLDgs2NYd3CCeBRETp2DN7rmMeTFrC1phx2eiIwvxGAmF8ZRv H+caVY/gUK5fujyY1U0pC2o27b1sooMMRDTFgh/uUIC4Y1BdcsJITl8n2LlyaoSWgZZdKu9lRRi Wh8mRNyB7/VxUZrpnySvGv3tGNVgZ7qdogWX6LIp9ig8ehgIaJOiBs+8tY8YjvvJcR8OChY5s5m xniwkDm18VkL61VWTycxnzMk= X-Received: by 2002:a17:907:c48d:b0:c26:19de:9133 with SMTP id a640c23a62f3a-c2966729628mr135538566b.38.1789117328026; Fri, 11 Sep 2026 02:02:08 -0700 (PDT) X-Received: by 2002:a17:907:c48d:b0:c26:19de:9133 with SMTP id a640c23a62f3a-c2966729628mr135534466b.38.1789117327365; Fri, 11 Sep 2026 02:02:07 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Peter Xu , Fabiano Rosas Subject: [PULL v2 20/75] migration: check that transfer is UNIX socket when "local" set Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117436439158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy As documented, for "local", the migration channel must be direct UNIX socket connection from source to target (except for CPR_EXEC mode). We can't check for it being "direct", but let's at least check that we deal with UNIX socket. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-13-vsementsov@yandex-team.ru> --- migration/fd.c | 14 ++++++++++++++ migration/migration.c | 13 +++++++++++++ 2 files changed, 27 insertions(+) diff --git a/migration/fd.c b/migration/fd.c index 78a27caca2..4a891e814a 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -39,6 +39,20 @@ static bool fd_is_pipe(int fd) =20 static bool migration_fd_valid(int fd, Error **errp) { + if (migrate_local() && migrate_mode() !=3D MIG_MODE_CPR_EXEC) { + struct sockaddr_storage ss; + socklen_t sslen =3D sizeof(ss); + + if (getsockname(fd, (struct sockaddr *)&ss, &sslen) < 0 || + ss.ss_family !=3D AF_UNIX) { + error_setg(errp, + "local migration requires a UNIX domain socket chan= nel"); + return false; + } + + return true; + } + if (fd_is_socket(fd) || fd_is_pipe(fd)) { return true; } diff --git a/migration/migration.c b/migration/migration.c index b413d28622..d8418e4582 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -260,6 +260,19 @@ migration_capabilities_and_transport_compatible(Migrat= ionAddress *addr, errp); } =20 + if (migrate_local() && migrate_mode() !=3D MIG_MODE_CPR_EXEC && + (addr->transport !=3D MIGRATION_ADDRESS_TYPE_SOCKET || + (addr->u.socket.type !=3D SOCKET_ADDRESS_TYPE_UNIX && + addr->u.socket.type !=3D SOCKET_ADDRESS_TYPE_FD))) { + /* + * For SOCKET_ADDRESS_TYPE_FD we do check the fd itself later + * in migration_fd_valid(). + */ + error_setg(errp, + "local migration requires a UNIX domain socket channel"= ); + return false; + } + return true; } =20 --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117664; cv=none; d=zohomail.com; s=zohoarc; b=Zc9kBkzbzEtLK+8QbaFow9xcCLQ+OZXTgE3Z62QecTfQqhiwzJl7T5Oc7lU+m4n6b2cd4OJFaoQ4RECvO1F1ejGmr/tC91ZTp1QbTfi8MJaDAnG96fls97WVq0SxZcHnPD/K7poxyrJsrMHCNrnCO4nDf/f5s2oDOranzoZ/wa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117664; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZhK7m7LfrlPcMC5A9kLcc4Id8ZYHnzxhU78CaEvxc74=; b=M/tmoRc4CgmKMo+tmWRy2e0Y8OIq8Sj/IK2LPKxRnrRByh+vjHeAyDtFrcJBJ4r5fDR0uiEl9waBU7Kochq7rjFGRVb9R1lnmnH2+fOiMehslqDhNlu6siMYZgs1JhLLACt0RHDGZb+GIvK8/H2P0NFwRAHv0/5IyQunvLl/L1U= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117664766358.04192014114983; Fri, 11 Sep 2026 02:07:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9R-0002j2-MG; Fri, 11 Sep 2026 05:02:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9E-0002Mv-6y for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9C-00088U-3M for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:15 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-193-A_VeqHRsPQaM4HMaMMr9Hg-1; Fri, 11 Sep 2026 05:02:12 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-c251c140b41so73869866b.3 for ; Fri, 11 Sep 2026 02:02:11 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e6f1sm4458260f8f.6.2026.09.11.02.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117333; 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=ZhK7m7LfrlPcMC5A9kLcc4Id8ZYHnzxhU78CaEvxc74=; b=NIe/R54FnMpGBPufHHLnj+Bp3e1artZ2gSRXahNpYTWXW+P7/hd9cyZVjiUVnfrvxuLOlY uJDXwMfrzaXxSiWpnAvY/kE375w5Rcjf1rbSl2Z9Uh2eyz3Gw+wlc25Pz7+UwCTwejX72S vC+yzew3gTKypxVG4ThdPwQctig9Ba4= X-MC-Unique: A_VeqHRsPQaM4HMaMMr9Hg-1 X-Mimecast-MFC-AGG-ID: A_VeqHRsPQaM4HMaMMr9Hg_1789117331 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117331; x=1789722131; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=ZhK7m7LfrlPcMC5A9kLcc4Id8ZYHnzxhU78CaEvxc74=; b=oYEtfJCNnReiOVIS7TOCxUmozTbamjbPwfCd2asCgD2dXsYZuNnqrKJSNv+Kfvra/F /6plx/AuFgQ4Q3065ZRPXOKsDDxclSg1OPnR6ZKGMD632nN7WruC+NDwyrDtzackPLgA TAYAyokCx7uVXeFRWalx0SGE1wkKV6dZye/ganffxLsplrmgfGYKRLnTwRCb6enFnC+7 BUnrEFTu5irjYAQA2gbg+OE0+F3UIXTEA/OEtqKYt8YB9DI1xLsbtcAIpJ6DV2ePQcrw mqlCdODTGxiH6rtyBkpKsKv+WyZjMzZtIcuB0Krwljm5wyz2zobEFnEv8knPbiEBUFL8 1SoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117331; x=1789722131; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZhK7m7LfrlPcMC5A9kLcc4Id8ZYHnzxhU78CaEvxc74=; b=m/t+C3PDmVKcNPlyDnhjSlSBMjLE0rKjZ616WoyhSMkjILU6vaFvMWodeOY4yQYRUG O2FvghS0n4m07jomoYdjUJHpsMLYwlXVWaApDkwKAIq4jyZZHUmL3heetOyRFbPpPWpE CDKwES8bEMrT/mhoh2oWIsf5Cy3EaMUY91qduHnGsNoJl9L7mbbH92ynqKEJG0U4KtFI mOGY97dCp9pRzTF4inq99U6PQNMzCAisPJjr856aM2XozYeELQADNuC1B9sIK45tkXBl dU/iQhDr+lMABPIyB40iskmgqtyhck/62kgXpoMbvAw65aKN8o9WbUzhEYW5TTxYxCfw 1A+A== X-Gm-Message-State: AFuF++lGUNKGuBCR164r6+fwKpu6bHcjWmf52l2sEnYtz88hOrAPD6Sx 460q8a/29R+MYRd8zoo6Ke4iqKOGZl+X87b7bj3geqOJ3YyOJmydl3YE1AkRNUqi9mM7DM65PSu Hq7DJazoGO8jWUMytXBrk+Ohg2TY3GHv3mMXV63KfF9SFitQaikpHq6P2edRLe9EVVROD65OqLN FXAgZoAA2qMj+nXQgq4Nhc19xCvCj0A9IIhQ== X-Gm-Gg: AYBFou1TrphdjOJ32ZZt91vh0gcnaMEsBcSxNRKODenaY9psTgZ/KAmCm+O6LWqvfDW DQ4M0qZXMOrcSObYYyY9G8EJjxp6p+YtOiT8Hm6vHIF0Cmg7ctqt4qygdM/azdUcda73y2QVsOt lNxYU4aZHXbruohNjJHDh95gBa26WEbWSuZ/HsGphj0yfLShVA/sObZCh4dPGeic3/NBDrH7zCq XZlb74Mc8l43dIlIf+ug3p/lFC4N8WQyCa6iO5lQ3U3JdJgHVe0RRq58PgbgZkEPQfb9R6rIihB shOatddUsUzE5tKLxel0lFqOqVIkCijPKGEgWOCjr0lfnlmwFXyc0XMpR9d1vNTeg73QEjsjGU0 ZrCaPywhF X-Received: by 2002:a17:907:d789:b0:c24:6445:d19 with SMTP id a640c23a62f3a-c29665b941fmr126527466b.17.1789117330457; Fri, 11 Sep 2026 02:02:10 -0700 (PDT) X-Received: by 2002:a17:907:d789:b0:c24:6445:d19 with SMTP id a640c23a62f3a-c29665b941fmr126521666b.17.1789117329718; Fri, 11 Sep 2026 02:02:09 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:07 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Jason Wang , Peter Xu , Fabiano Rosas Subject: [PULL v2 21/75] virtio-net: support local migration of backend Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117665964158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Next commit will introduce live-migration (with fd-passing) for TAP net backend. So, now we prepare virtio-net for it Add virtio-net option local-migration, which is true by default, but false for older machine types, which doesn't support the feature. We introduce interface for live-migrating backends: 1. ->is_wait_incoming() handler, so that virtio-net knows, that backend is not fully intialized, as it waits for incoming migration stream. 2. MIG_PRI_BACKEND priority: backends should migrate with higher priority than virtio-net, so that we can do final preparations here in post-load handlers and be sure, that backends are already prepared. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-14-vsementsov@yandex-team.ru> --- include/hw/virtio/virtio-net.h | 1 + include/migration/vmstate.h | 2 + include/net/net.h | 2 + hw/net/virtio-net.c | 89 +++++++++++++++++++++++++++++++++- 4 files changed, 93 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 371e376428..8c967760c2 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -230,6 +230,7 @@ struct VirtIONet { struct EBPFRSSContext ebpf_rss; uint32_t nr_ebpf_rss_fds; char **ebpf_rss_fds; + bool peers_wait_incoming; }; =20 size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev, diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index e72c3fae9a..7d2b786382 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -169,6 +169,8 @@ typedef enum { =20 MIG_PRI_LOW, /* Must happen after default */ MIG_PRI_DEFAULT, + MIG_PRI_BACKEND, /* Must happen before emulated devices, */ + /* e.g. virtio-net */ MIG_PRI_IOMMU, /* Must happen before PCI devices */ MIG_PRI_PCI_BUS, /* Must happen before IOMMU */ MIG_PRI_VIRTIO_MEM, /* Must happen before IOMMU */ diff --git a/include/net/net.h b/include/net/net.h index ea07760b56..fdf6a2ddd4 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -82,6 +82,7 @@ typedef void (SocketReadStateFinalize)(SocketReadState *r= s); typedef void (NetAnnounce)(NetClientState *); typedef bool (SetSteeringEBPF)(NetClientState *, int); typedef bool (NetCheckPeerType)(NetClientState *, ObjectClass *, Error **); +typedef bool (IsWaitIncoming)(NetClientState *); typedef struct vhost_net *(GetVHostNet)(NetClientState *nc); =20 typedef struct NetClientInfo { @@ -110,6 +111,7 @@ typedef struct NetClientInfo { NetAnnounce *announce; SetSteeringEBPF *set_steering_ebpf; NetCheckPeerType *check_peer_type; + IsWaitIncoming *is_wait_incoming; GetVHostNet *get_vhost_net; } NetClientInfo; =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 814b99a43d..274fbcb0d6 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -40,6 +40,7 @@ #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" #include "system/system.h" +#include "system/runstate.h" #include "system/replay.h" #include "trace.h" #include "monitor/qdev.h" @@ -3079,7 +3080,17 @@ static void virtio_net_set_multiqueue(VirtIONet *n, = int multiqueue) n->multiqueue =3D multiqueue; virtio_net_change_num_queues(n, max * 2 + 1); =20 - virtio_net_set_queue_pairs(n); + /* + * virtio_net_set_multiqueue() called from set_features(0) on early + * reset, when peer may wait for incoming (and is not initialized + * yet). + * Don't worry about it: virtio_net_set_queue_pairs() will be called + * later from virtio_net_post_load_device(), and anyway will be + * no-op for local incoming migration with live backend passing. + */ + if (!n->peers_wait_incoming) { + virtio_net_set_queue_pairs(n); + } } =20 static int virtio_net_pre_load_queues(VirtIODevice *vdev, uint32_t n) @@ -3108,6 +3119,17 @@ static void virtio_net_get_features(VirtIODevice *vd= ev, uint64_t *features, =20 virtio_add_feature_ex(features, VIRTIO_NET_F_MAC); =20 + if (n->peers_wait_incoming) { + /* + * Excessive feature set is OK for early initialization when + * we wait for local incoming migration: actual guest-negotiated + * features will come with migration stream anyway. And we are sure + * that we support same host-features as source, because the backe= nd + * is the same (the same TAP device, for example). + */ + return; + } + if (!peer_has_vnet_hdr(n)) { virtio_clear_feature_ex(features, VIRTIO_NET_F_CSUM); virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO4); @@ -3204,6 +3226,7 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) VirtIODevice *vdev =3D VIRTIO_DEVICE(n); int i, link_down; bool has_tunnel_hdr =3D virtio_has_tunnel_hdr(vdev->guest_features_ex); + Error *local_err =3D NULL; =20 trace_virtio_net_post_load_device(); virtio_net_set_mrg_rx_bufs(n, n->mergeable_rx_bufs, @@ -3261,6 +3284,20 @@ static int virtio_net_post_load_device(void *opaque,= int version_id) } =20 virtio_net_commit_rss_config(n); + + /* + * If live-migration is enabled for some backend, than backend + * has already been migrated at higher priority (MIG_PRI_BACKEND) + * and virtio_net_vnet_post_load() has already called + * peer_test_vnet_hdr(). Recompute host_features so that virtio-net + * reflects the capabilities of the restored backend. + */ + virtio_net_get_features(vdev, &vdev->host_features, &local_err); + if (local_err) { + error_report_err(local_err); + return -EINVAL; + } + return 0; } =20 @@ -3411,6 +3448,14 @@ static int virtio_net_vnet_post_load(void *opaque, i= nt version_id) { struct VirtIONetMigTmp *tmp =3D opaque; =20 + /* + * If live-migration is enabled for some backend, than backend + * has already been migrated at higher priority (MIG_PRI_BACKEND), + * so n->has_vnet_hdr can be refreshed from the live backend right + * here. + */ + peer_test_vnet_hdr(tmp->parent); + if (tmp->has_vnet_hdr && !peer_has_vnet_hdr(tmp->parent)) { error_report("virtio-net: saved image requires vnet_hdr=3Don"); return -EINVAL; @@ -3890,6 +3935,42 @@ static bool failover_hide_primary_device(DeviceListe= ner *listener, return qatomic_read(&n->failover_primary_hidden); } =20 +static bool virtio_net_check_peers_wait_incoming(VirtIONet *n, bool *waiti= ng, + Error **errp) +{ + bool has_waiting =3D false; + bool has_not_waiting =3D false; + + for (int i =3D 0; i < n->max_queue_pairs; i++) { + NetClientState *peer =3D n->nic->ncs[i].peer; + if (!peer) { + continue; + } + + if (peer->info->is_wait_incoming && + peer->info->is_wait_incoming(peer)) { + has_waiting =3D true; + } else { + has_not_waiting =3D true; + } + + if (has_waiting && has_not_waiting) { + error_setg(errp, "Mixed peer states: some peers wait for incom= ing " + "migration while others don't"); + return false; + } + } + + if (has_waiting && !runstate_check(RUN_STATE_INMIGRATE)) { + error_setg(errp, "Peers wait for incoming, but it's not an incomin= g " + "migration."); + return false; + } + + *waiting =3D has_waiting; + return true; +} + static void virtio_net_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -4027,6 +4108,12 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) n->nic->ncs[i].do_not_pad =3D true; } =20 + if (!virtio_net_check_peers_wait_incoming(n, &n->peers_wait_incoming, + errp)) { + virtio_cleanup(vdev); + return; + } + peer_test_vnet_hdr(n); if (peer_has_vnet_hdr(n)) { n->host_hdr_len =3D sizeof(struct virtio_net_hdr); --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117993; cv=none; d=zohomail.com; s=zohoarc; b=jPc13BFNtoGsKHqr/rKuCXE7p0ua8nJc90FUkWZ3Voguz4hxirO3SGHiCKGeiuU5DrSaD5/ZyC45269cpMWEVwcO4VVa0zRw3/L+2O6CD/gAvRbp4lU6t8v2N1DhkMfPIjgbboWDXZFrCLWnAHIWzQTa8MaJprdCXgBxODTebqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117993; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e6oAhYiiIn3xpeHIgSvH0lgBJsq4uFVnZ7OcjCH2hOg=; b=Q+5Tvnc+9R0Cj8ZGIYkrhsMPR3ScK7CvxWjiDTP7B9EgOE8iPiJ3wCLfM95eQt0ODif21SVDRD+ZeQFADCErpwmMsBe+aSqcUsGnn5doZzailxxCxePuacug5yZEDbwhFL/H1Rl1lEvGDKbRREISpbEdhb4bC01u8ra3uoSSsgs= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117993897406.5183150096799; Fri, 11 Sep 2026 02:13:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9U-0002wr-Fr; Fri, 11 Sep 2026 05:02:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9F-0002Oz-MH for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9D-00088q-Sf for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:17 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-139-dnktDI60MTmIy3aUTcnwFQ-1; Fri, 11 Sep 2026 05:02:14 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-485afdd5079so544505f8f.1 for ; Fri, 11 Sep 2026 02:02:13 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb34fdd2sm4477488f8f.28.2026.09.11.02.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117335; 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=e6oAhYiiIn3xpeHIgSvH0lgBJsq4uFVnZ7OcjCH2hOg=; b=dLeDFAreUQeS9tRWb7wVgw5SasjSH4HwC9T+7fNMJwMdd1g19feuBPqmqk9i4VWDqFmjY3 qVO4pv0YT9yGzxZhI17tP2zRpUJ8oKD2iwFoOSq6j4m0zfBx2c5ZciMYxa9i12E5DT13TI xKGXsnysfeWhUD31DOdgLH5RrUgQvlg= X-MC-Unique: dnktDI60MTmIy3aUTcnwFQ-1 X-Mimecast-MFC-AGG-ID: dnktDI60MTmIy3aUTcnwFQ_1789117333 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117333; x=1789722133; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=e6oAhYiiIn3xpeHIgSvH0lgBJsq4uFVnZ7OcjCH2hOg=; b=b8QjTJBXicdBasexbnMNUCFNwRF1j0h83D87ezk7nOuF7Z2hrHiWU6pi6/YCX+zGkO ct600bQjvFrP6xUdWjq4fPbp/FLhne5mzvDJRdE5FjM9rhCNO4zD9aMLccEwMV/vQpyl K919bEf4UOxcjg4IPGeo4bqHVXU9yEZZ2RzpX3+s2vx8vCzIuh1mCHRy6ouflzDsPdCt 0fYqlgh+bea5jH31xcoO15WKqU+e6NrGYkDbirCch3HKqRAzKXN5vFIxQmrg5NSOW0xv lQXZP9fDUOuGVm3oechf0qtDrQPug7wfkTlpp+MqoYBY94t3ZPYnBfTyDKXmxNU3OYq6 wv5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117333; x=1789722133; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=e6oAhYiiIn3xpeHIgSvH0lgBJsq4uFVnZ7OcjCH2hOg=; b=mT6EwaiRxGXbXwG3E9UJhxe8xmNcoaWjmkPI3RdmB1M6Z6aojDlgvWLQFPOzF5mMxr L04G2O+yyQ380iHCLNFA205T2vuOjAvmQmQemhp6jGoBkFQOETXsrDAi1jVAGdgr6X0M v0FeLx7ElbGNpzexhSDagyFVLnpLHivRPyI+rpufdE8+qH2vkm/TGj9Ln370yLEjoA+x yvJVD/cRE7b78ptTL+0jD6osr8GTfPNk6x4G0sete14W9u/imySnkNyWhiCNcE93KvQU xbBMG0xKsmuEVWITorUtfC5UHr3muTnuuA6TteROY60/UdojeT6ObNlJG0keeRFWXwLW xQLw== X-Gm-Message-State: AFuF++kQJOfoGzzfvUQjH8EOFxc1/nGcxPZ5YmDEow0rsOnfpi/As/Bs f9tgX/IHAC9dmxsXLRqN4vLsbLUTeF+zAqNwsc+pZc8XNzKJ1rY9Jgi/cai/vbQDfBZpEBg/ud5 Og7/sMR/sdlF+Lp28Y+wycVmaIXp5eaURcfnb1xmln/AB+HHCwaovv1reXvRN1lDnnu+jUAtjF+ Q4HWLRvHPc/b6t4zmr2aUGxouMJwllLaLzjQ== X-Gm-Gg: AYBFou3Sg2j5KKq/BLjvIdnHqWsFV0SdOoc6YxmnDfqPhgA30X4v0I8pN+Vfu/iVBhZ RNhplmNuib6Al4bayemFOmdnpDGPI5aNIkY0KiIDoyqvudSRAoNvWCjQvQcFqIZ76Q+tic1KOYg Cw/bcFNWIHkhGonjOjjVYNiWmrFnYdC/ky7eLxwANd7YUULvfwyMQB3PHsNBFkMBMzaxPlnkOQ0 A+0lLGilEGIJuP+ji6FtKfs4ugHja2GYOX6sV1yXl9Yac9Bfdmtc1qZUQL5gxXIJ88VXn9GSp2W xwY8gN8SqFTf6H0Uud+/ePpit2ZFaSxMBvcws4krR2NwfG03MZx6/FOp1HQcKlfYzylYgdmPCxo Ppfhxsd5NJuihJdrZfFNPOF4= X-Received: by 2002:a05:6000:70c:b0:486:ed36:ba6 with SMTP id ffacd0b85a97d-486ed360cc2mr3114357f8f.56.1789117332442; Fri, 11 Sep 2026 02:02:12 -0700 (PDT) X-Received: by 2002:a05:6000:70c:b0:486:ed36:ba6 with SMTP id ffacd0b85a97d-486ed360cc2mr3114294f8f.56.1789117331791; Fri, 11 Sep 2026 02:02:11 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Jason Wang Subject: [PULL v2 22/75] net/tap: disable read polling for stopped VM Message-ID: <98a0c21270709cbd1c8624618a4fd72e5e2fed99.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117996276158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Polling when VM is stopped doesn't make real sense, as stopped VM can't handle incoming traffic anyway. And it's critical for introduction of local TAP migration feature in the next commit: the TAP device will be transferred to the target (open fd will be passed through migration channel), and if we continue polling on source, we may get a package, which we'll never handle on source (already stopped), it will be lost. Better is save this package for target VM to handle. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-15-vsementsov@yandex-team.ru> --- net/tap.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/net/tap.c b/net/tap.c index dd0d134875..51d028d956 100644 --- a/net/tap.c +++ b/net/tap.c @@ -36,6 +36,7 @@ #include "net/net.h" #include "clients.h" #include "monitor/monitor.h" +#include "system/runstate.h" #include "system/system.h" #include "qapi/error.h" #include "qemu/cutils.h" @@ -92,6 +93,8 @@ struct TAPState { Notifier exit; =20 int queue_index; + bool enable_poll_on_resume; + VMChangeStateEntry *vmstate; }; =20 static void launch_script(const char *setup_script, const char *ifname, @@ -145,10 +148,31 @@ static void tap_update_fd_handler(TAPState *s) =20 static void tap_read_poll(TAPState *s, bool enable) { + if (enable && runstate_check(RUN_STATE_FINISH_MIGRATE)) { + s->enable_poll_on_resume =3D true; + return; + } s->read_poll =3D enable; tap_update_fd_handler(s); } =20 +static void tap_vm_state_change(void *opaque, bool running, RunState state) +{ + TAPState *s =3D opaque; + + if (running) { + if (s->enable_poll_on_resume) { + tap_read_poll(s, true); + s->enable_poll_on_resume =3D false; + } + } else if (state =3D=3D RUN_STATE_FINISH_MIGRATE) { + if (s->read_poll) { + s->enable_poll_on_resume =3D true; + tap_read_poll(s, false); + } + } +} + static void tap_write_poll(TAPState *s, bool enable) { s->write_poll =3D enable; @@ -379,6 +403,11 @@ static void tap_cleanup(NetClientState *nc) s->exit.notify =3D NULL; } =20 + if (s->vmstate) { + qemu_del_vm_change_state_handler(s->vmstate); + s->vmstate =3D NULL; + } + tap_read_poll(s, false); tap_write_poll(s, false); close(s->fd); @@ -818,6 +847,9 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, int sndbuf =3D (tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT= _MAX; =20 + s->enable_poll_on_resume =3D false; + s->vmstate =3D qemu_add_vm_change_state_handler(tap_vm_state_change, s= ); + if (!tap_set_sndbuf(fd, sndbuf, sndbuf_required ? errp : NULL) && sndbuf_required) { goto failed; --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117978; cv=none; d=zohomail.com; s=zohoarc; b=NkxOgmglyS1rLkbxXr0/4l/Wq37prXVb4wzcnHxKSTgq3BRk4/EG/EiKvSo9JzjDlqhizG/sQ23cWfIb23eNYOXc+azzmId8zK41/jHngvkuW7zPNofWTlJVBNDdeQFOiMwk0iuF0QLllYEO6CIepjYZcHP3XOCBOBquc+7BoxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117978; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=U+LQxEq+xa1ZMmsDwLunNgJiMF+B5iHrSKttb1+MsNY=; b=Du+/8/xwp9gb7CsS5zdG0hRC8dpQoOlG0XzOWE81+NDSd3iTq01n/C7cMxi4v1LKoXMpfNljJja5ejig+kMsZgtR3whnFNub6BZBXCVvp0QAIb1uRxoG1J5IoCc6iewRO4AxwOXAXDdDyyWPUbxQvI+kyL/p0j2/0jOcMQWe+/I= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117978252306.3967973815488; Fri, 11 Sep 2026 02:12:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9U-0002wl-Fh; Fri, 11 Sep 2026 05:02:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9J-0002RJ-C0 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9G-00089L-IJ for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:20 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-22-ohiOhQRFNJeLSV8vHD_RwA-1; Fri, 11 Sep 2026 05:02:16 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4858f06e142so499405f8f.0 for ; Fri, 11 Sep 2026 02:02:16 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33e020sm4654433f8f.18.2026.09.11.02.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117337; 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=U+LQxEq+xa1ZMmsDwLunNgJiMF+B5iHrSKttb1+MsNY=; b=GiKiqeHxzr1si6+WjYsCA+8Ef/7ItCfW4mPb+CXqPLvqW2UU6OiqpwWSX7hmacNMtWG+9U rpCqiZjcsZoLPvJiob86HT6pqtmRrFZaP7i+0j+shzgLAqYhv++1TDatMry/1GuNwE/czi HVAHGuhtdHbfl0HvCxNvj17GqQoRTvM= X-MC-Unique: ohiOhQRFNJeLSV8vHD_RwA-1 X-Mimecast-MFC-AGG-ID: ohiOhQRFNJeLSV8vHD_RwA_1789117335 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117335; x=1789722135; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=U+LQxEq+xa1ZMmsDwLunNgJiMF+B5iHrSKttb1+MsNY=; b=Hu1tf8/8yVMRlHFSFCT6yUm9M0P1gPhtLCiFdW1rrvexfWDfGa7UxNgJ+T0mGkVkmI ckN0KuoMNmgc6UliOxTUN5BLD+ZoqnEtHSGFzU4y06YA0AYLrF1qEfXQIyDoPU4j8coG 2/x/xh0Op8ojXohFzrGr7Uzq6ozWt2xtoESznuidJokQJ+8LDpqz4lgF3lgJa8faAW1U BBNCk/z6dufWZGnRm4d2nurNZ+4dsAcHKR6fSItaR5G33a8qlAMgOepV2Qql33HpmcxW 3dwba9eKeQLV07GfHNx43xeZwk1d7buffx08VzXXq0PEaWD3SPJfd35gnbI+G+1f/4Km 18Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117335; x=1789722135; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=U+LQxEq+xa1ZMmsDwLunNgJiMF+B5iHrSKttb1+MsNY=; b=IZdJsVJtVsE/6hrABGQKzncDvArc1tf8j78ogaNspO9OedQmwz6u5+JuJfo/TEbN9E RT7DPb/L4Jy4NmGT7W8JOJ1DVNUGRIW+9qNgrF8LagPqxsQYhv0zah4eXb+RdFNBfmHz B+5u10sO/S4hkdeFWdEYvEMJVuctFSqEjguahGQVwt8IkBtaMahjTW1YZtduVl8U5bh7 feQOpNWZDN8SVXCvWER4PXOFxgCk7WjcFuFUhLU6Sixvo50UXroQNPQygulfnNwu8Aqd ddfKP+6W3inkuEMc9qSsTFuNe0qZBtsXMb2xzaD0pDCCghu3Bxl935dFLtxEOcpKp8u9 gsyg== X-Gm-Message-State: AFuF++ll++3G/BG+tEHJZRHM4JnLJbgt3BtMpxte9Qvo8U8wA34YiME4 M0GGN6J68wvg91BBqnjqzCTTB4ebAW620/KAm9G2ihp/iEWpdA20JX4bzBZmhnOnywozjhc6rlm Oi4q2a5ngNzJ63xb2QfUD+B5tJXmeNISpo6C7qr18ktPBIRUw+FNDXJGmCwWvdtiNRRcSiLzcdd jrt7nZi5B0cVC3fmULpaUZEX6l6CKu2PaTtg== X-Gm-Gg: AYBFou2pXGUa55WbRx/uWkGR1wQlyXLDTze46h1R16w8CRgu6I3zfoX+qmtLgUqmlhi A0uk1w987gwJcl23S35u7VYLQGVo3WwoWYsaGDEmWU2VkN4eGoEiRUVOyxvf3s+hWVK90dYQM07 gzsdmZT9LtpXZl5T8AofaVR1gj7UCXVDVkAubhgtKFF34teLMFju71aJjlrYMkonSG26HRV0rFd 9xAzmiY75HxigDqBiv34lZwF5FwGFEmaqoJ2+jaoL6QDzkpmgbf5R59rwd2fY3kU4cT2+0XaAvH bFdpfqjTYpmapP0ZNCFM67IDYhyNAbEH/us6zBmrzP2/vqH8t3u9ZDKw554/zat8jf+MnSmVLvp 2/z8QqwXilJ9QJyt2pAArS/Q= X-Received: by 2002:a5d:640f:0:b0:486:e5c6:cab with SMTP id ffacd0b85a97d-486eb31e8d9mr2672932f8f.32.1789117334763; Fri, 11 Sep 2026 02:02:14 -0700 (PDT) X-Received: by 2002:a5d:640f:0:b0:486:e5c6:cab with SMTP id ffacd0b85a97d-486eb31e8d9mr2672866f8f.32.1789117334065; Fri, 11 Sep 2026 02:02:14 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Markus Armbruster , Jason Wang , Eric Blake Subject: [PULL v2 23/75] net/tap: support local migration with virtio-net Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117980119158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Support transferring of TAP state (including open fd). Add new property "x-permit-local-migration", which defines whether local migration is actually permitted for this TAP device. Note that local-migration is enabled by global "local" migration parameter, but individual devices may have additional options to enable/disable it per device. The tricky thing is that we need to know whether to call open/connect in TAP initialization code, i.e. we need to know the value of migration parameter "local" when creating the TAP device. For incoming migration, we can know only for TAP devices created with QMP after setting the migration parameter with QMP. So the full picture is: On source, to start outgoing "local" migration you need: - migration parameter "local" set to true - "x-permit-local-migration" TAP option set to true If at least one of these options is not set, TAP backend doesn't participate in migration. On target, things are more difficult: Same, you need both "local" and "x-permit-local-migration" be set. And same, if one of them is not set, TAP backend is initialized as usual, and doesn't accept any incoming state. Additionally, if you are going to set "local", it must be set before creating the TAP device. If TAP device created with "local" unset, it initializes as usual. If you enable "local" after it and start incoming migration, it will fail in .pre_load handler of TAP backend. Moreover, there are interface restrictions: if you create TAP device when QEMU is in INCOMING state, and both "local" and "x-permit-local-migration" set, most of TAP options are not allowed, and script/downscript are required to be explicitly disabled. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Acked-by: Markus Armbruster Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-16-vsementsov@yandex-team.ru> --- qapi/net.json | 29 ++++++++- net/tap.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 189 insertions(+), 7 deletions(-) diff --git a/qapi/net.json b/qapi/net.json index dccf95bbbc..64c0ef1f6d 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -437,6 +437,31 @@ # @poll-us: maximum number of microseconds that could be spent on busy # polling for tap (since 2.7) # +# @x-permit-local-migration: permit local migration for this TAP +# backend. When set, local migration is enabled/disabled by +# migration parameter @local for this TAP backend. When unset, +# migration parameter @local is ignored for this TAP backend. +# +# To be able to do incoming local migration of a TAP backend, +# migration parameter @local must be set _before_ creating the +# TAP backend. Otherwise, TAP backend is initialized as usual, +# opening/creating TAP devices in kernel. In this case further +# local incoming migration (with migration parameter @local set +# after creating TAP backend with @x-permit-local-migration +# parameter set) will simply fail. +# +# Moreover, when QEMU is in incoming migration state, migration +# parameter @local is set and @x-permit-local-migration is set, +# the following options are not supported and must not be set: +# @fd, @fds, @helper, @br, @ifname, @sndbuf, @vnet_hdr. +# Additionally, @script and @downscript must be explicitly +# disabled then. +# (default: false, since 11.2) +# +# Features: +# +# @unstable: Member @x-permit-local-migration is experimental. +# # Since: 1.2 ## { 'struct': 'NetdevTapOptions', @@ -455,7 +480,9 @@ '*vhostfds': 'str', '*vhostforce': 'bool', '*queues': 'uint32', - '*poll-us': 'uint32'} } + '*poll-us': 'uint32', + '*x-permit-local-migration': { + 'type': 'bool', 'features' : [ 'unstable'] } } } =20 ## # @NetdevSocketOptions: diff --git a/net/tap.c b/net/tap.c index 51d028d956..d71e3dd117 100644 --- a/net/tap.c +++ b/net/tap.c @@ -38,12 +38,17 @@ #include "monitor/monitor.h" #include "system/runstate.h" #include "system/system.h" +#include "migration/misc.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/sockets.h" #include "hw/virtio/vhost.h" +#include "hw/core/vmstate-if.h" +#include "migration/vmstate.h" +#include "qom/object.h" +#include "qom/compat-properties.h" =20 #include "net/tap.h" #include "net/util.h" @@ -71,6 +76,8 @@ static const int kernel_feature_bits[] =3D { =20 OBJECT_DECLARE_SIMPLE_TYPE(TAPState, TAP_NETDEV) =20 +static const VMStateDescription vmstate_tap; + struct TAPState { Object parent_obj; =20 @@ -95,6 +102,7 @@ struct TAPState { int queue_index; bool enable_poll_on_resume; VMChangeStateEntry *vmstate; + bool permit_local_migration; }; =20 static void launch_script(const char *setup_script, const char *ifname, @@ -412,6 +420,8 @@ static void tap_cleanup(NetClientState *nc) tap_write_poll(s, false); close(s->fd); s->fd =3D -1; + + vmstate_unregister(VMSTATE_IF(s), &vmstate_tap, s); } =20 static void tap_poll(NetClientState *nc, bool enable) @@ -448,6 +458,78 @@ static VHostNetState *tap_get_vhost_net(NetClientState= *nc) return s->vhost_net; } =20 +static bool tap_is_wait_incoming(NetClientState *nc) +{ + TAPState *s =3D container_of(nc, TAPState, nc); + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); + return s->fd =3D=3D -1; +} + +static bool tap_pre_load(void *opaque, Error **errp) +{ + ERRP_GUARD(); + TAPState *s =3D opaque; + + if (s->fd !=3D -1) { + error_setg(errp, + "TAP is already initialized and cannot receive " + "incoming fd"); + error_append_hint(errp, + "Migration parameter 'local' must be set" + " before creating the TAP device."); + return false; + } + + return true; +} + +static bool tap_setup_vhost(TAPState *s, Error **errp); + +static bool tap_post_load(void *opaque, int version_id, Error **errp) +{ + ERRP_GUARD(); + TAPState *s =3D opaque; + + tap_read_poll(s, true); + + if (s->fd < 0) { + error_setg(errp, "FD was not loaded during incoming migration"); + return false; + } + + if (!tap_setup_vhost(s, errp)) { + error_prepend(errp, + "Failed to setup vhost during TAP post-load: "); + return false; + } + + return true; +} + +static bool tap_needed(void *opaque) +{ + TAPState *s =3D opaque; + + return s->permit_local_migration && migrate_local(); +} + +static const VMStateDescription vmstate_tap =3D { + .name =3D "net-tap", + .priority =3D MIG_PRI_BACKEND, + .pre_load_errp =3D tap_pre_load, + .post_load_errp =3D tap_post_load, + .needed =3D tap_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_FD(fd, TAPState), + VMSTATE_BOOL(using_vnet_hdr, TAPState), + VMSTATE_BOOL(has_ufo, TAPState), + VMSTATE_BOOL(has_uso, TAPState), + VMSTATE_BOOL(has_tunnel, TAPState), + VMSTATE_BOOL(enabled, TAPState), + VMSTATE_UINT32(host_vnet_hdr_len, TAPState), + VMSTATE_END_OF_LIST() + } +}; =20 static char *tap_vmstate_if_get_id(VMStateIf *obj) { @@ -456,17 +538,42 @@ static char *tap_vmstate_if_get_id(VMStateIf *obj) return res; } =20 +static bool tap_get_permit_local_migration_prop(Object *obj, Error **errp) +{ + TAPState *s =3D TAP_NETDEV(obj); + return s->permit_local_migration; +} + +static void tap_set_permit_local_migration_prop(Object *obj, bool value, + Error **errp) +{ + TAPState *s =3D TAP_NETDEV(obj); + s->permit_local_migration =3D value; +} + +static void tap_instance_init(Object *obj) +{ + TAPState *s =3D TAP_NETDEV(obj); + s->permit_local_migration =3D false; +} + static void tap_class_init(ObjectClass *klass, const void *data) { VMStateIfClass *vc =3D VMSTATE_IF_CLASS(klass); =20 vc->get_id =3D tap_vmstate_if_get_id; + + object_class_property_add_bool(klass, "x-permit-local-migration", + tap_get_permit_local_migration_prop, + tap_set_permit_local_migration_prop); } =20 static const TypeInfo tap_netdev_info =3D { .name =3D TYPE_TAP_NETDEV, .parent =3D TYPE_OBJECT, .instance_size =3D sizeof(TAPState), + .instance_init =3D tap_instance_init, + .instance_post_init =3D object_apply_compat_props, .class_init =3D tap_class_init, .interfaces =3D (const InterfaceInfo[]) { { TYPE_VMSTATE_IF }, @@ -499,13 +606,16 @@ static NetClientInfo net_tap_info =3D { .set_vnet_le =3D tap_set_vnet_le, .set_vnet_be =3D tap_set_vnet_be, .set_steering_ebpf =3D tap_set_steering_ebpf, + .is_wait_incoming =3D tap_is_wait_incoming, .get_vhost_net =3D tap_get_vhost_net, }; =20 static TAPState *new_tap(NetClientState *peer, const char *model, const char *name, - int queue_index) + int queue_index, + bool has_permit_local_migration, + bool permit_local_migration) { TAPState *s =3D TAP_NETDEV(object_new(TYPE_TAP_NETDEV)); =20 @@ -514,6 +624,12 @@ static TAPState *new_tap(NetClientState *peer, =20 s->queue_index =3D queue_index; =20 + if (has_permit_local_migration) { + s->permit_local_migration =3D permit_local_migration; + } + + vmstate_register(VMSTATE_IF(s), VMSTATE_INSTANCE_ID_ANY, &vmstate_tap,= s); + return s; } =20 @@ -522,10 +638,14 @@ static TAPState *net_tap_fd_init(NetClientState *peer, const char *name, int fd, int vnet_hdr, - int queue_index) + int queue_index, + bool has_permit_local_migration, + bool permit_local_migration) { NetOffloads ol =3D {}; - TAPState *s =3D new_tap(peer, model, name, queue_index); + TAPState *s =3D new_tap(peer, model, name, queue_index, + has_permit_local_migration, + permit_local_migration); =20 s->fd =3D fd; s->host_vnet_hdr_len =3D vnet_hdr ? sizeof(struct virtio_net_hdr) : 0; @@ -762,7 +882,7 @@ int net_init_bridge(const Netdev *netdev, const char *n= ame, close(fd); return -1; } - s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr, 0); + s =3D net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr, 0, true, fal= se); =20 qemu_set_info_str(&s->nc, "helper=3D%s,br=3D%s", helper, br); =20 @@ -842,7 +962,9 @@ static bool net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, Error **errp) { TAPState *s =3D net_tap_fd_init(peer, tap->helper ? "bridge" : "tap", - name, fd, vnet_hdr, queue_index); + name, fd, vnet_hdr, queue_index, + tap->has_x_permit_local_migration, + tap->x_permit_local_migration); bool sndbuf_required =3D tap->has_sndbuf; int sndbuf =3D (tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT= _MAX; @@ -990,6 +1112,7 @@ int net_init_tap(const Netdev *netdev, const char *nam= e, /* for the no-fd, no-helper case */ char ifname[128]; int *fds =3D NULL, *vhost_fds =3D NULL; + bool incoming_fds; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_TAP); tap =3D &netdev->u.tap; @@ -1012,6 +1135,23 @@ int net_init_tap(const Netdev *netdev, const char *n= ame, return -1; } =20 + incoming_fds =3D tap->x_permit_local_migration && migrate_local() && + runstate_check(RUN_STATE_INMIGRATE); + + if (incoming_fds && + (tap->fd || tap->fds || tap->helper || tap->br || tap->ifname || + tap->has_sndbuf || tap->has_vnet_hdr || + !tap_is_explicit_no_script("script", tap->script) || + !tap_is_explicit_no_script("downscript", tap->downscript))) { + error_setg(errp, "Local incoming migration of TAP device (-incomin= g, " + "migration parameter @local is set, " + "TAP parameter @x-permit-local-migration is set) " + "is incompatible with " + "fd=3D, fds=3D, helper=3D, br=3D, ifname=3D, sndbuf=3D = and vnet_hdr=3D, " + "and requires explicit empty script=3D and downscript= =3D"); + return -1; + } + queues =3D tap_parse_fds_and_queues(tap, &fds, errp); if (queues < 0) { return -1; @@ -1030,7 +1170,22 @@ int net_init_tap(const Netdev *netdev, const char *n= ame, goto fail; } =20 - if (fds) { + if (incoming_fds) { + for (i =3D 0; i < queues; i++) { + TAPState *s =3D new_tap(peer, "tap", name, i, + tap->has_x_permit_local_migration, + tap->x_permit_local_migration); + qemu_set_info_str(&s->nc, "incoming"); + + s->fd =3D -1; + if (vhost_fds) { + s->vhostfd =3D vhost_fds[i]; + s->vhost_busyloop_timeout =3D tap->has_poll_us ? tap->poll= _us : 0; + } else { + s->vhostfd =3D -1; + } + } + } else if (fds) { for (i =3D 0; i < queues; i++) { if (i =3D=3D 0) { vnet_hdr =3D tap_probe_vnet_hdr(fds[i], errp); --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117454; cv=none; d=zohomail.com; s=zohoarc; b=mwiB8obZqhh2BUJxuMRPusLXy4/6nl3j/ZxvRKZF0WnxOq0S9+sg/Fn9Y0RIR1mruWkB5Ipw3DGjhiVPgnYbVswEXHJR4dst3Z+hZvaa6yb9J3H6evf40fP74HQPO2kyzFjqlE8YMH7C0J+65eWiJsmvNGphGyYli9//dHKoRtc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117454; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5biUd1hrE7MZBRCxmWFH37KE+WRWPVMF0xAnNQXGG3o=; b=I0TLGHFFZhu0g1EOnD69f9aXj0VAnJ1CEbBrwvaN8G96/fhQZ31gCMziAsIUQf/sw6yCvNiE4EzIKzl2IS62lvNTgqTb7sqjy/JDaoQ1FjfAGhNpCYPsdGEpc1FAXeFwDHbXNadAff/ve232TPUtVc6zaXtKffFRwoJnCmmvGHg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117454800992.5244493814016; Fri, 11 Sep 2026 02:04:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9Y-00036L-I5; Fri, 11 Sep 2026 05:02:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9Q-0002fP-NB for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9M-00089z-JK for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:28 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-178-4MZi78jfO7WnGV6DWMQ_Vw-1; Fri, 11 Sep 2026 05:02:19 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-495689bfcc8so4976935e9.1 for ; Fri, 11 Sep 2026 02:02:19 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c300e2sm152070125e9.8.2026.09.11.02.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117342; 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=5biUd1hrE7MZBRCxmWFH37KE+WRWPVMF0xAnNQXGG3o=; b=Ebc6AlzKgwxfvy4iapxZ+8bYdLwawEPjk25oBC0ueK8Jcpj1z/tzs/grnbB5GzLDhwasH/ AgKSDZTo9KMTnkC4fv8fPkx4UfzpB9SMYJjyXfDL/Ik5fd2zXY97lSlQ9d01IDo2qxlGdI 3blls3ueNpnRtWF12+O7T0zQpD6DYbk= X-MC-Unique: 4MZi78jfO7WnGV6DWMQ_Vw-1 X-Mimecast-MFC-AGG-ID: 4MZi78jfO7WnGV6DWMQ_Vw_1789117338 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117338; x=1789722138; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=5biUd1hrE7MZBRCxmWFH37KE+WRWPVMF0xAnNQXGG3o=; b=HJ4IbE8jJmknF68BAGSwEhOnvsa/78EwceNCke6AlwJWKvz3C2+P9MK40IWROxF8cX U6ImqwJyZcyT1HOQ17N+Lrm5cSM79srPG+Mzt2FFtzEQK45WoDmmzpakxEyXYYL7P2bg sDX6X+6KFxXufDTIJCwEILQ5qdoiU1T7ZHec44M/evfLmxE7OtfgcrnnzwPY/REPAkFK 1mXl0eDiycNX17gxOJZYFcnmoDvm9LNr7mtBSFTk9MSDlEa/P8LKveKBhTGS3xSNmK5x 0w4muBrUNuwzb/BcvTJDE4eH15b002+7fpCx7H9fAv/swFBuui5M51y7hMTkLRj6bmwu 2PTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117338; x=1789722138; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5biUd1hrE7MZBRCxmWFH37KE+WRWPVMF0xAnNQXGG3o=; b=BDxMEqSf3u1PT0h3e+IqCaJiIlykU3l04hFAdEfpzwSxwoW+kYQo/Pw9IDHkR1OnRd dumsxE5UkrID+BvZtl8V5EL36gGgTL6UCvPVe/fZsbgK4fkSwGyo72C6sU3COYoYNvGf uz8XYxiw8Y1NzzbiUGx4oF3jetVknsxPJc67qFrXVlXwA6GulcJnqpuSoBngH3J0VWcD B7F6qw4uc9y9KSUXdx2ae2bs35tRPjmEaumBVMVO1K6VKXgyc8fyRCoOvp51IolQfdZM icYimyPm0wyweBKY3VaHtqN27OknTeW24dOr8bGmzgLM9axSLdHQGi9Cn6tLkIDVT9jQ g9GQ== X-Gm-Message-State: AFuF++llVa47gmRObMp2NHe4QEuOzaDmX+CTADPGtphM1GaMxq1FHRlK S16RAs8HVXnys6YiDe+S2J0MJnyuijfDFpaShJFpXvCXpmRx3Q7k9eeGylgLsFCCRR0/nAHikw6 lIdlqRo4sQs05OoTe4/8/gXZR+J/hfP0C8RyVN4UUJw55qz0zQTiPzg4eJW4GlOAhet0yV0K1P2 4YZ6zhGEjDhyMxs91PkzKbw9EbBC9yxq7DfQ== X-Gm-Gg: AYBFou0eJ9N65CwP/grLyvXvqmSHGvXz3drm2pGUoZGzfQvJMw8TMSyx/8KzkGO7ZBI L+vLBVWmm09kfkjWfz/S6xHqNd4FrDzLLlXIWopFwuyvSQaopq78B3hANLftXtp/SkyCFBZjHMn NYs/ePNYTYLlI8ctG2dlRcUia5CTUqPxyXOppwXfZD0npTSvWCqQeVBY1+NNGuWXfKjErnUqXqy n3poreBkFmG9SXlkihmlinNPPoUstl4EFRndp4QUwdALWPQJcV75JN5/p22wtgN9d0+6A0HVjJh CTQpGxoCA8DUvzGwv8Yepw+SD/qBewBTGn21B1Tz8tgiyFk92jhqce6L6L48j/9HtrEr87yhFuQ ea+mBtJiuDsc32iqadEzQE+U= X-Received: by 2002:a05:600c:4f88:b0:49c:fa21:e742 with SMTP id 5b1f17b1804b1-49e619ce757mr32581485e9.24.1789117337695; Fri, 11 Sep 2026 02:02:17 -0700 (PDT) X-Received: by 2002:a05:600c:4f88:b0:49c:fa21:e742 with SMTP id 5b1f17b1804b1-49e619ce757mr32580375e9.24.1789117336652; Fri, 11 Sep 2026 02:02:16 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:14 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Ben Chaney , Paolo Bonzini , Zhao Liu , Peter Xu , Fabiano Rosas Subject: [PULL v2 24/75] tests/functional: add test_tap_migration Message-ID: <88bba62b067f52e6c42f5a2a48e304c5e481ea85.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117456526158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Add test for a new local-migration migration of virtio-net/tap, with fd passing through UNIX socket. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Ben Chaney Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260819180201.1970193-17-vsementsov@yandex-team.ru> --- tests/functional/x86_64/meson.build | 1 + tests/functional/x86_64/test_tap_migration.py | 461 ++++++++++++++++++ 2 files changed, 462 insertions(+) create mode 100755 tests/functional/x86_64/test_tap_migration.py diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/= meson.build index 0353b2af8e..6254149239 100644 --- a/tests/functional/x86_64/meson.build +++ b/tests/functional/x86_64/meson.build @@ -51,4 +51,5 @@ tests_x86_64_system_thorough =3D [ 'virtio_balloon', 'virtio_gpu', 'rebuild_vmfd', + 'tap_migration', ] diff --git a/tests/functional/x86_64/test_tap_migration.py b/tests/function= al/x86_64/test_tap_migration.py new file mode 100755 index 0000000000..1e0d602518 --- /dev/null +++ b/tests/functional/x86_64/test_tap_migration.py @@ -0,0 +1,461 @@ +#!/usr/bin/env python3 +# +# Functional test that tests TAP local migration +# with fd passing +# +# Copyright (c) Yandex Technologies LLC, 2026 +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import time +import subprocess +from subprocess import run +import signal +import ctypes +import ctypes.util +import unittest +from contextlib import contextmanager, ExitStack +from typing import Tuple + +from qemu_test import ( + LinuxKernelTest, + Asset, + exec_command_and_wait_for_pattern, +) +from qemu_test.decorators import skipWithoutSudo + + +GUEST_IP =3D "192.168.100.2" +GUEST_IP_MASK =3D f"{GUEST_IP}/24" +GUEST_MAC =3D "d6:0d:75:f8:0f:b7" +HOST_IP =3D "192.168.100.1" +HOST_IP_MASK =3D f"{HOST_IP}/24" +TAP_ID =3D "tap0" +TAP_ID2 =3D "tap1" +TAP_MAC =3D "e6:1d:44:b5:03:5d" +NETNS =3D f"qemu_test_ns_{os.getpid()}" + + +def ip(args, check=3DTrue) -> None: + """Run ip command with sudo""" + run(["sudo", "ip"] + args, check=3Dcheck) + + +@contextmanager +def switch_netns(netns_name): + libc =3D ctypes.CDLL(ctypes.util.find_library("c")) + netns_path =3D f"/var/run/netns/{netns_name}" + + def switch_to_fd(fd, check: bool =3D False): + """Switch to netns by file descriptor""" + SYS_setns =3D 308 + CLONE_NEWNET =3D 0x40000000 + ret =3D libc.syscall(SYS_setns, fd, CLONE_NEWNET) + if check and ret !=3D 0: + raise RuntimeError("syscall SETNS failed") + + with ExitStack() as stack: + original_netns_fd =3D os.open("/proc/self/ns/net", os.O_RDONLY) + stack.callback(os.close, original_netns_fd) + + ip(["netns", "add", netns_name]) + stack.callback(ip, ["netns", "del", netns_name], check=3DFalse) + + new_netns_fd =3D os.open(netns_path, os.O_RDONLY) + stack.callback(os.close, new_netns_fd) + + switch_to_fd(new_netns_fd) + stack.callback(switch_to_fd, original_netns_fd, check=3DFalse) + + yield + + +def del_tap(tap_name: str =3D TAP_ID) -> None: + ip(["tuntap", "del", tap_name, "mode", "tap", "multi_queue"], check=3D= False) + + +def init_tap(tap_name: str =3D TAP_ID, with_ip: bool =3D True) -> None: + ip(["tuntap", "add", "dev", tap_name, "mode", "tap", "multi_queue"]) + if with_ip: + ip(["link", "set", "dev", tap_name, "address", TAP_MAC]) + ip(["addr", "add", HOST_IP_MASK, "dev", tap_name]) + ip(["link", "set", tap_name, "up"]) + + +def switch_network_to_tap2() -> None: + ip(["link", "set", TAP_ID2, "down"]) + ip(["link", "set", TAP_ID, "down"]) + ip(["addr", "delete", HOST_IP_MASK, "dev", TAP_ID]) + ip(["link", "set", "dev", TAP_ID2, "address", TAP_MAC]) + ip(["addr", "add", HOST_IP_MASK, "dev", TAP_ID2]) + ip(["link", "set", TAP_ID2, "up"]) + + +def parse_ping_line(line: str) -> float: + # suspect lines like + # [1748524876.590509] 64 bytes from 94.245.155.3 \ + # (94.245.155.3): icmp_seq=3D1 ttl=3D250 time=3D101 ms + spl =3D line.split() + return float(spl[0][1:-1]) + + +def parse_ping_output(out) -> Tuple[bool, float, float]: + lines =3D [x for x in out.split("\n") if x.startswith("[")] + + try: + first_no_ans =3D next( + (ind for ind in range(len(lines)) if lines[ind][20:26] =3D=3D = "no ans") + ) + except StopIteration: + return False, parse_ping_line(lines[0]), parse_ping_line(lines[-1]) + + last_no_ans =3D next( + ind + for ind in range(len(lines) - 1, -1, -1) + if lines[ind][20:26] =3D=3D "no ans" + ) + + return ( + True, + parse_ping_line(lines[first_no_ans]), + parse_ping_line(lines[last_no_ans]), + ) + + +def wait_migration_finish(source_vm, target_vm): + migr_events =3D ( + ("MIGRATION", {"data": {"status": "completed"}}), + ("MIGRATION", {"data": {"status": "failed"}}), + ) + + source_e =3D source_vm.events_wait(migr_events)["data"] + target_e =3D target_vm.events_wait(migr_events)["data"] + + source_s =3D source_vm.cmd("query-status")["status"] + target_s =3D target_vm.cmd("query-status")["status"] + + assert ( + source_e["status"] =3D=3D "completed" + and target_e["status"] =3D=3D "completed" + and source_s =3D=3D "postmigrate" + and target_s =3D=3D "paused" + ), f"""Migration failed: + SRC status: {source_s} + SRC event: {source_e} + TGT status: {target_s} + TGT event:{target_e}""" + + +@skipWithoutSudo() +class TAPFdMigration(LinuxKernelTest): + + ASSET_KERNEL =3D Asset( + ( + "https://archives.fedoraproject.org/pub/archive/fedora/linux/r= eleases" + "/31/Server/x86_64/os/images/pxeboot/vmlinuz" + ), + "d4738d03dbbe083ca610d0821d0a8f1488bebbdccef54ce33e3adb35fda00129", + ) + + ASSET_INITRD =3D Asset( + ( + "https://archives.fedoraproject.org/pub/archive/fedora/linux/r= eleases" + "/31/Server/x86_64/os/images/pxeboot/initrd.img" + ), + "277cd6c7adf77c7e63d73bbb2cded8ef9e2d3a2f100000e92ff1f8396513cd8b", + ) + + ASSET_ALPINE_ISO =3D Asset( + ( + "https://dl-cdn.alpinelinux.org/" + "alpine/v3.22/releases/x86_64/alpine-standard-3.22.1-x86_64.is= o" + ), + "96d1b44ea1b8a5a884f193526d92edb4676054e9fa903ad2f016441a0fe13089", + ) + + @classmethod + def setUpClass(cls): + super().setUpClass() + + try: + cls.netns_context =3D switch_netns(NETNS) + cls.netns_context.__enter__() + except (OSError, subprocess.CalledProcessError) as e: + raise unittest.SkipTest(f"can't switch network namespace: {e}") + + @classmethod + def tearDownClass(cls): + if hasattr(cls, "netns_context"): + cls.netns_context.__exit__(None, None, None) + super().tearDownClass() + + def setUp(self): + super().setUp() + + self.require_accelerator("kvm") + self.set_machine("q35") + + self.setup_shared_memory() + + init_tap() + + self.outer_ping_proc =3D None + self.shm_path =3D None + + def tearDown(self): + with ExitStack() as stack: + stack.callback(super().tearDown) + + if self.shm_path: + stack.callback(lambda p: (os.unlink(p) if os.path.exists(p) + else None), + self.shm_path) + self.shm_path =3D None + + stack.callback(del_tap, TAP_ID2) + stack.callback(del_tap, TAP_ID) + + if self.outer_ping_proc: + self.stop_outer_ping() + + def start_outer_ping(self) -> None: + assert self.outer_ping_proc is None + self.outer_ping_log =3D self.scratch_file("ping.log") + with open(self.outer_ping_log, "w") as f: + self.outer_ping_proc =3D subprocess.Popen( + ["ping", "-i", "0", "-O", "-D", GUEST_IP], + text=3DTrue, + stdout=3Df, + ) + + def stop_outer_ping(self) -> str: + assert self.outer_ping_proc + self.outer_ping_proc.send_signal(signal.SIGINT) + + self.outer_ping_proc.communicate(timeout=3D5) + self.outer_ping_proc =3D None + + with open(self.outer_ping_log) as f: + return f.read() + + def stop_ping_and_check(self, stop_time, resume_time): + ping_res =3D self.stop_outer_ping() + + discon, a, b =3D parse_ping_output(ping_res) + + if not discon: + text =3D ( + f"STOP: {stop_time}, RESUME: {resume_time}," f"PING: {a} -= {b}" + ) + if a > stop_time or b < resume_time: + self.fail(f"PING failed: {text}") + self.log.info(f"PING: no packets lost: {text}") + return + + text =3D ( + f"STOP: {stop_time}, RESUME: {resume_time}," + f"PING: disconnect: {a} - {b}" + ) + self.log.info(text) + eps =3D 0.05 + if a < stop_time - eps or b > resume_time + eps: + self.fail(text) + + def one_ping_from_guest(self, vm) -> None: + exec_command_and_wait_for_pattern( + self, + f"ping -c 1 -W 1 {HOST_IP}", + "1 packets transmitted, 1 packets received", + "1 packets transmitted, 0 packets received", + vm=3Dvm, + ) + self.wait_for_console_pattern("# ", vm=3Dvm) + + def one_ping_from_host(self) -> None: + run( + ["ping", "-c", "1", "-W", "1", GUEST_IP], + stdout=3Dsubprocess.DEVNULL, + check=3DTrue, + ) + + def setup_shared_memory(self): + self.shm_path =3D f"/dev/shm/qemu_test_{os.getpid()}" + + try: + with open(self.shm_path, "wb") as f: + f.write(b"\0" * (1024 * 1024 * 1024)) # 1GB + except Exception as e: + self.fail(f"Failed to create shared memory file: {e}") + + def prepare_vm( + self, shm_path, vhost, incoming=3DFalse, vm=3DNone, local=3DTrue + ): + if not vm: + vm =3D self.vm + + vm.set_console() + vm.add_args("-accel", "kvm") + vm.add_args("-device", "pcie-pci-bridge,id=3Dpci.1,bus=3Dpcie.0") + vm.add_args("-m", "1G") + vm.add_args("-net", "none") + + vm.add_args( + "-object", + f"memory-backend-file,id=3Dram0,size=3D1G,mem-path=3D{shm_path= },share=3Don", + ) + vm.add_args("-machine", "memory-backend=3Dram0") + + vm.add_args( + "-drive", + f"file=3D{self.ASSET_ALPINE_ISO.fetch()},media=3Dcdrom,format= =3Draw", + ) + + vm.add_args("-S") + + if incoming: + vm.add_args("-incoming", "defer") + + def add_virtio_net( + self, vm, vhost: bool, tap_name: str, local: bool, incoming: bool + ): + netdev_params =3D { + "id": "netdev.1", + "vhost": vhost, + "type": "tap", + "queues": 4, + "script": "no", + "downscript": "no", + "x-permit-local-migration": local, + } + + if not (local and incoming): + netdev_params["vnet_hdr"] =3D True + netdev_params["ifname"] =3D tap_name + + vm.cmd("netdev_add", netdev_params) + + vm.cmd( + "device_add", + driver=3D"virtio-net-pci", + romfile=3D"", + id=3D"vnet.1", + netdev=3D"netdev.1", + mq=3DTrue, + vectors=3D18, + bus=3D"pci.1", + mac=3DGUEST_MAC, + disable_legacy=3D"off", + ) + + def set_migration_capabilities(self, vm, local): + vm.cmd( + "migrate-set-capabilities", + { + "capabilities": [ + {"capability": "events", "state": True}, + {"capability": "x-ignore-shared", "state": True}, + ] + }, + ) + vm.cmd("migrate-set-parameters", {"local": local}) + + def setup_guest_network(self) -> None: + exec_command_and_wait_for_pattern(self, "ip addr", "# ") + exec_command_and_wait_for_pattern( + self, + f"ip addr add {GUEST_IP_MASK} dev eth0 && " + "ip link set eth0 up && echo OK", + "OK", + ) + self.wait_for_console_pattern("# ") + + def migrate(self, vm, mig_sock): + vm.cmd("migrate", uri=3Df"unix:{mig_sock}") + def do_test_tap_fd_migration(self, vhost, local=3DTrue): + socket_dir =3D self.socket_dir() + mig_sock =3D os.path.join(socket_dir.name, "mig.sock") + + # Setup second TAP if needed + if not local: + del_tap(TAP_ID2) + init_tap(TAP_ID2, with_ip=3DFalse) + + self.prepare_vm(self.shm_path, vhost, local=3Dlocal) + self.vm.launch() + self.set_migration_capabilities(self.vm, local=3Dlocal) + self.add_virtio_net(self.vm, vhost, TAP_ID, local, incoming=3DFals= e) + + self.vm.cmd("cont") + self.wait_for_console_pattern("login:") + exec_command_and_wait_for_pattern(self, "root", "# ") + + self.setup_guest_network() + + self.one_ping_from_guest(self.vm) + self.one_ping_from_host() + self.start_outer_ping() + + # Get some successful pings before migration + time.sleep(0.5) + + target_vm =3D self.get_vm(name=3D"target") + self.prepare_vm( + self.shm_path, + vhost, + incoming=3DTrue, + vm=3Dtarget_vm, + local=3Dlocal, + ) + + target_vm.launch() + if not local: + tap_name =3D TAP_ID2 + else: + tap_name =3D TAP_ID + self.set_migration_capabilities(target_vm, local=3Dlocal) + self.add_virtio_net(target_vm, vhost, tap_name, local, incoming=3D= True) + + target_vm.cmd("migrate-incoming", {"uri": f"unix:{mig_sock}"}) + + self.log.info("Starting migration") + freeze_start =3D time.time() + self.migrate(self.vm, mig_sock) + + self.log.info("Waiting for migration completion") + wait_migration_finish(self.vm, target_vm) + + # Switch network to tap1 if not using local-migration + if not local: + switch_network_to_tap2() + + target_vm.cmd("cont") + freeze_end =3D time.time() + + self.vm.shutdown() + + self.log.info("Verifying PING on target VM after migration") + self.one_ping_from_guest(target_vm) + self.one_ping_from_host() + + # And a bit more pings after source shutdown + time.sleep(0.3) + self.stop_ping_and_check(freeze_start, freeze_end) + + target_vm.shutdown() + + def test_tap_fd_migration(self): + self.do_test_tap_fd_migration(False) + + def test_tap_fd_migration_vhost(self): + self.do_test_tap_fd_migration(True) + + def test_tap_new_tap_migration(self): + self.do_test_tap_fd_migration(False, local=3DFalse) + + def test_tap_new_tap_migration_vhost(self): + self.do_test_tap_fd_migration(True, local=3DFalse) + + +if __name__ =3D=3D "__main__": + LinuxKernelTest.main() --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117441; cv=none; d=zohomail.com; s=zohoarc; b=ScyXInUuvyCwLygw5DZJZsKekLvWJYsrxGMDSn7N3UtTpyJg3xNbqGmbLQY/g4UQUx9zAXSooLej1IzC1muofMw0lvdmjhkyjXOcQjsO9EXxD/4vHE6Aq4u+evhHMxALA3Ny5toMJ6gpHYudSEcokeCCYQipkcR8Hgbh01UT6SE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117441; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GnRjJ65SGrC9am8hi9r7ANKDtkiUG6pnQWAw9MHk3fY=; b=Lky4IiimmRg1xy50hZadWuMXmjGw31G/Bc0duUDm7U80gaWzDzdnmRKBPNLYq7dDOCuAjrBKNLeIV6tGtp56EM/ilrsWGC19LlgGAOQBYKkVm2zK5ZiYZFJyHfPFo3mRVcD5v7lkmZtMkvDYbWxRXxyuRpVtHihhFhQimiBJkEI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117441026628.9384523463765; Fri, 11 Sep 2026 02:04:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9Y-00036U-IX; Fri, 11 Sep 2026 05:02:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9M-0002WP-PR for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9K-00089i-Hd for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:23 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-59-0g2nlY88MG-qocOJfnLFnA-1; Fri, 11 Sep 2026 05:02:20 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4957287363bso4185735e9.0 for ; Fri, 11 Sep 2026 02:02:20 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26d4e3f3sm154070505e9.15.2026.09.11.02.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117341; 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=GnRjJ65SGrC9am8hi9r7ANKDtkiUG6pnQWAw9MHk3fY=; b=ec4Mk1AndS7a5oAos/ZiElPkyOt0ebRFwdDfvI204CPX3xvNICJord3+CLog8hhIMCGLcc xWV4DRAv1kn2bKN1ikjOIWg1yGg4E8mbQ7fLP6HHC4pgZ9I8suGFhOqchamOSxlCNBEHLo S7intH/UOAHgH+3kQo6+S5fIYUYHIeM= X-MC-Unique: 0g2nlY88MG-qocOJfnLFnA-1 X-Mimecast-MFC-AGG-ID: 0g2nlY88MG-qocOJfnLFnA_1789117339 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117339; x=1789722139; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=GnRjJ65SGrC9am8hi9r7ANKDtkiUG6pnQWAw9MHk3fY=; b=rLsmQsUfOMFvqlrGT74AC7tkLZ5UH/x/AyyiDONnMu8vLZvX6Ftc0onM2wTHmxtnoF oXyJOl0N4EK+UnvvzNsxQT+pbIbjr3ADRGdXJ2EJMCCcLrxF62zIyvapalePwdtgIRT4 f/NHhFK7GdaSVDSzGVnAOkgn7sdyL/li+mA68dFLSh0vPCl+pcDNog30j/FRU+7sOPqn s01UtmQF6+AmTxhJ8o2M/e3IFICjjxgPcAap9fDcYBU/ltuK9NI1T1MZqUTX0vaCFQ1i mkKwwTk1OTOiuLLDTZvkqheICwUF2Rot9ZPg0EzaeQ7me8ipf/uZxuJ5MvAVcfRWomFg nr7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117339; x=1789722139; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=GnRjJ65SGrC9am8hi9r7ANKDtkiUG6pnQWAw9MHk3fY=; b=YEx1GXeMTr9MaQ9zsVYTRKEdzIkN94iIb6gYKRUDJz0EPzW3JAqWyrO3q6S32VtYjU z+aFjU/WLQZs9bf5fplMWikSHOpX8Ft37/SJEikVyqDC25N2eB9Ay4Ui03yWDwPY7DFT LWCkmEdNljzkRNDia8A70zirsd7Be5Dw/YLeqvorEXWaRaOfrXo3S2/rpnM+3Z85Epvy YbRgSIdTI/0hATWGxaUaxFl5/3h8oJhj2WioW288D78BgcJJ8AtZGmNgEoBHNR39i2ss grJJEJPHm372jJylMKFvtCDXiuLRRkUCpoOoTUw9ZyeYFiBHEyWUgXEOL2/njKI8JCO8 ogRw== X-Gm-Message-State: AFuF++krIqQyCPNCUxo747bT7YShyXQgIhGGyxac9rvPaMrPog5PALu1 lAhawyjPRMpRPVGAf6pQvB4fVfXLANntANOkEmWU/A+JHeHZ7ddo0vUI5Ufk5t65kvo5CjPBvGv zlVEREgF2+rLoSD4j3eGm6uxSWIGcSebtxi/mgYm9SIXHBDX5UYI/v6k1rrv5YFJ9AH3YEFGikQ M2I0RgssJbGgUqxf19/ZNhAvOPua7xpE9nqg== X-Gm-Gg: AYBFou3gcHB9fJnHGaIc91zuq8AJL2UwCW2V8W/QHDqAHGVdOCJYJgHx6JeBYL19xdI VkyYbumKTnajhRV2D4dCCT5RoA4DO65E/J2FYk30rIuWgWjYomVcy/bkggh7bOBCeFd2xDObfnY GRK2eTl2Fhz6Nn/MiDcQ5Buu3kTpx/ka8DSnqa9bW9az+jzlINxHwEcoiggMuP3EwGUSCmy8e2c vUNtVJHRHbG1+AfDXhXWJHHx+EqArRhdGh4YhxESeisGWoJ2vse0fsGmDSksxRvx8zLR5KkLUld JhrcXANu+soojOc2/dCpddBVT6xUj+UN1TOfZURiWSGYq2KKVerquRUBnL0MWn7IgFlsn9gMGpY 24yLpeFsCPS4HxNZ+TimkDHE= X-Received: by 2002:a05:600c:1386:b0:493:f5bf:4dc6 with SMTP id 5b1f17b1804b1-49e61887f7emr37195945e9.7.1789117339357; Fri, 11 Sep 2026 02:02:19 -0700 (PDT) X-Received: by 2002:a05:600c:1386:b0:493:f5bf:4dc6 with SMTP id 5b1f17b1804b1-49e61887f7emr37195245e9.7.1789117338841; Fri, 11 Sep 2026 02:02:18 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Igor Mammedov , Ani Sinha Subject: [PULL v2 25/75] tests/bios-tables-test: Exclude CEDT.cxl for the CFMW restriction change Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117442298158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso The next patch changes the default CXL Fixed Memory Window restrictions, dropping Back-Invalidate. Add CEDT.cxl to the allowed-diff list so the comparison passes until the expected blob is regenerated. Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-2-dave@stgolabs.net> --- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..b4646b5b31 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/x86/q35/CEDT.cxl", --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117381; cv=none; d=zohomail.com; s=zohoarc; b=CmnZNehtUxN+IXwZE4PK1lXrVxRuDUYasdCv+PIrtap993Eez9ENxzfo3Pq2ehIz6UWkgLQebmZHxeL1GGRv4LC6FGsHjVu8FYjaicryzb1/YijbKzV/sNk4ysL0+6I62eyz5AxonkFMS1HgpkktAT2xYtANe341wNjrLK3Bblw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117381; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YYj6Zo8VlXl2zP5B4qr6Yw7Ml5uWH4dbodIZUAM6V0A=; b=LdU7L4vmRUMUf+xfeD3nluziDDcPb8aDcCcZXmjHBRuEgIAKPvGEmQxCyyz7eT82NjXGjG0oBshvL7PKFaqMGISoZq4VJajH6IlwExrxiOfce/5Y2Eko8IjxxJ9jgdTbD6hruTNxgXJsgKWXvkBrDOSJz1x92fUS/x/ZQcTdOwA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117381841784.574924388026; Fri, 11 Sep 2026 02:03:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9c-0003Fk-6L; Fri, 11 Sep 2026 05:02:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9P-0002bx-GU for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9O-0008AG-0N for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:27 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-UkC8hZPiMGuZY7TYjOTGCg-1; Fri, 11 Sep 2026 05:02:23 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-486f187f2cbso145764f8f.3 for ; Fri, 11 Sep 2026 02:02:23 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60a8a89esm59268305e9.1.2026.09.11.02.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117345; 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=YYj6Zo8VlXl2zP5B4qr6Yw7Ml5uWH4dbodIZUAM6V0A=; b=SZ4JfrZQww8moqa80aLGy4HTyZHdLssmSZ6nvYO52PKn0uTmpLvBlOIDXTBBOYFIQCnzBd B7FJVNkBl2e++SIC55rx+7crHoH6B6dB18HEM48YK5oYMcVv/d0ALNZRNz1Nl5UHXam7/p ivEe4dOSVBX1wupbwSQ0KcYm/jQnPj8= X-MC-Unique: UkC8hZPiMGuZY7TYjOTGCg-1 X-Mimecast-MFC-AGG-ID: UkC8hZPiMGuZY7TYjOTGCg_1789117342 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117342; x=1789722142; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=YYj6Zo8VlXl2zP5B4qr6Yw7Ml5uWH4dbodIZUAM6V0A=; b=QFqyLMDsT56Xle17Fjfz5oJ1JIFDrw+O8V02JXk3jIlWB5paHSaS1mcuYCvLOjGOCg NVwLVSiFPWdhw9+ZhGrTqxHJZkrkXrf8hPzzu0cfyLOvrqsbEhW+/dDqV5kODGdOhqQ9 olgX5fDjxd6Bv+dUlD0c1ZQQ5QfvNqjIqRO6/pHRJ06F1nKEiR8sIPo+QUfSsCfrly1O WINIoiMVp1Vtza7b2iip88g5bm+L2MmpJP+9auFEq51qs3pqMCsocOLQpfUWTpaGNgy9 8f9H8KQ1J5MpHHLkcY/ic0P8iZDMTF/XTHkiWsm3UDepK8RoXSvBfGc/0iLfMAsRfskz lbBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117342; x=1789722142; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YYj6Zo8VlXl2zP5B4qr6Yw7Ml5uWH4dbodIZUAM6V0A=; b=VQnQhyCDOX15cjxKh+sztDtCvrYib8RoGRaI1im/WzF8dM5Z1626PJUqt2uoVTidnz /gar+MDGoifOVsdHTNgrVkoju5Ilryu4AgRTXzbEfQ7dDV4oDJKZM+mU+OYgAC54L/Dt 41FnXzhNoxjKfSkiaNK3T7EqW6sAIdIukCtb5jMXFf4MosgFa4nRU46z0UiSfI0TXyUC 0+h3s9ePSZbff5bxXoaFEF1I55RjYGlDsFDPzPmPwM9YSfjJ0RmBdUiOA1ycD1yFE0S7 H9V+5e1A1svb5GrodHvqSOIbVeg3SeWxI6lWnJgaJUhpwALYLXUzkDQSBGtbZzca6oxI kOdA== X-Gm-Message-State: AFuF++mVegbgvoE8TlRUh/kAnNT3zHLTkNhgJErJmmpf399i1KJmDIML S/pv2qcXTzXhkVGFhj1YAgL5ABz+5oOU61Ann2ZufbkqzcJmzIVngOY7VdS5Zh0bQJWtltumjmf J1HXdfj6oqqxiMUcLKIWhpLOkWPBnoMe06qyl9EbIGxdwSLmY8dkSUBjMlFZSdIgdoWaBYdUs+w AV9zL8+RgQWu6Us98wx0TGMN3eJKt1BEo27Q== X-Gm-Gg: AYBFou1coXQYH0fzjR8860ymw4TCdmSSdlnmVftS8wywrANlHx3wn8tqeAcVTEW2UGm FLlU0/YnCnh7Y59ou9KsLqDAI+wmxYrt2ik7rvzigNLFhiQ8d6zg3u46IsanDgKS+nA51lxKjEd uSRGwGOnsVpU2WtLe6VvR6a8lZwCa/KC4wKcZkjUK+Opvy6QQYGc+M2c1bIKeil4C01d7m7M3h0 +JFewXDJfzVD+7QGL0LLUjScTbIWs49X3IIRtk++29BlKt1jwCXA5zzEo/weuYY8RIjwgmpP2cR CLdfLCfnLwEwHAhHFHRBT10N17q0DQJUICa/xAp8zH+ZrcnegU7drH3dQnQFeYNBcMyJQKOqz+u OpJwZzNX2iEWAZ0+DSME8ZzU= X-Received: by 2002:a05:600c:548f:b0:499:8174:9f39 with SMTP id 5b1f17b1804b1-49e61639fdbmr70631845e9.0.1789117341578; Fri, 11 Sep 2026 02:02:21 -0700 (PDT) X-Received: by 2002:a05:600c:548f:b0:499:8174:9f39 with SMTP id 5b1f17b1804b1-49e61639fdbmr70630755e9.0.1789117340995; Fri, 11 Sep 2026 02:02:20 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Igor Mammedov , Ani Sinha Subject: [PULL v2 26/75] hw/cxl: Drop Back-Invalidate from default CFMW window restrictions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117384053158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso The default CXL Fixed Memory Window restrictions advertised host-only coherent together with Back-Invalidate. A window advertising both simultaneously is undefined behavior per CXL r4.0 9.18.1.3. Drop Back-Invalidate from the default, leaving device-coherent + host-only + volatile + persistent. Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-3-dave@stgolabs.net> --- hw/acpi/cxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c index f92f7fa3d5..75edb2c0a6 100644 --- a/hw/acpi/cxl.c +++ b/hw/acpi/cxl.c @@ -172,7 +172,7 @@ static void cedt_build_cfmws(CXLFixedWindow *fw, Aml *c= edt) build_append_int_noprefix(table_data, fw->enc_int_gran, 4); =20 /* Window Restrictions */ - build_append_int_noprefix(table_data, 0x2f, 2); + build_append_int_noprefix(table_data, 0x0f, 2); =20 /* QTG ID */ build_append_int_noprefix(table_data, 0, 2); --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117427; cv=none; d=zohomail.com; s=zohoarc; b=hygj7IjVH+fpfCQGUXR1euZDp4MNVbXjmV+0Zyw5sO/RwhFuRGh0hbd8Cj9DUAeor2f760+wiyt37IzETcrUWsbuj8xibfOrIC6RoFhXsDWVp8eTHzyciomUP3ahZ803y8kq0fHsbtKZZIHTM6aUODynCQHWBGWpHhuUoJZ72Ck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117427; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mkq+2WPt2mey0qAVGmB0E6fFgehzww9kQ8e4JC/K6q4=; b=k0CJyEoDNjI74i8QfSEPHRGrEZPuAiNMU/GX5pdH3KyeuZPOxiItoVYbZ6FK3PuOevjM/vggAwAwAOohF3e+Mla/kH24GcVCdKdUbLVT/pffZBfMe58ngjwITSA23LM6qcYD6/jNIibgIgghpwFFVFnIDdSBPnmltMBeYEPb8oE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117427522564.9012761009674; Fri, 11 Sep 2026 02:03:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9Y-00037U-SF; Fri, 11 Sep 2026 05:02:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9S-0002nG-3j for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9Q-0008Ak-9P for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:29 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-w2HWd2HkM7SFQsFAQ18d7A-1; Fri, 11 Sep 2026 05:02:25 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49b0e6638e3so4914675e9.2 for ; Fri, 11 Sep 2026 02:02:25 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62232cb7sm35577375e9.4.2026.09.11.02.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117347; 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=mkq+2WPt2mey0qAVGmB0E6fFgehzww9kQ8e4JC/K6q4=; b=GKdMwjToQZKc2+6/0TDt09yNChbVdWBna57EAWiPsUNLxxJfKwmuCK1J+5t71lsMp4Lt7h TrMWNpoUWI/GPu1vjgj6Jcyv9TgPgWKq4/FNxf7RJ4CNfC1zhw03rm3QcfqhaFmuJFhVyn 8IT4yx/8W55kGQRJyz37vykr+iFD16o= X-MC-Unique: w2HWd2HkM7SFQsFAQ18d7A-1 X-Mimecast-MFC-AGG-ID: w2HWd2HkM7SFQsFAQ18d7A_1789117345 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117344; x=1789722144; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=mkq+2WPt2mey0qAVGmB0E6fFgehzww9kQ8e4JC/K6q4=; b=TlcU14J83Gyb2l2It3vgMIrnCp/PzgqAIgmup3MpYCkD54wM1Vo2Bk7RMjnCVd/F3i WV9qjGgnRtxyYP01qQ9QKhO2Mm5QjDA6GcXn9aQTz7Mg8eNDjocz0TVCuch8MqptFJcn A2t1PtuixMbLARr4K+qmQTUZCCYChFbhiZB9uAen0ODtjtC7BHKK/EDzmuVlWNhxn4EQ gphCLP1Mo1i/8PG1+zA+tX4g6zTNEJytx+0qrcwX/s5/jUdU2/heudLfrqC6o0LhLyxP C1U3m+N0VXfXb2jk2+5YGjhtvFiPESGIf+lgxSFdL1YnxyuOtGlbzPAJo9/a4DtZMopz OXLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117344; x=1789722144; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mkq+2WPt2mey0qAVGmB0E6fFgehzww9kQ8e4JC/K6q4=; b=PJUUUz7y/IeFZtT9pjOAN261TIMw7V1w8Q/wtEHqlRMZhqlYMhGdqDDIvpa6AjHaBM mszBUUQgv8MH1Mp2WqLxqg6ZyegFy6bKlk4Y/B+6M+rilTAluyULUzueQDKqlZwl6+qc uhTIlW20005BNDcMKZsvvwKbt901NlixqHfxTMq7HW13sFvq3oTURtSQsFCoBpKGI1hH 2Nn800r3tBuwtPvY03BiQ9Wwu0Wa4LrM6pC+MaQ30UBnziC6pPMF+PZ6eqCOwy/teUVC YG3xPBsS/k7gqML/6j+JSwkAtJX5Fep1gGADgtohqxi1e5S5hLGS/muChc6UZUMbArvk rUfA== X-Gm-Message-State: AFuF++k8u2SJTSKesW8upZP0/E1P6+D6xM9Y5ZQmmDXCRyqVTTLvubfA RWL1T2dkSUkH8jnaVy7tnwqfL8YswjjrIdDBYRKooNHlOZontDm4SLwItvlgJwbR+9yw4oJZxIF r5RHc+aIcomEYZjCgVf8JLdKzQCuChFDZPf4VKNF+rBC2e+oaG3IobrcygwuW64KxXTHDVHgQYt sOC8HMFWvmq5BgQAQ5jIyVoTPY4HVkpykoQw== X-Gm-Gg: AYBFou3X5zJ6HlM9EuZieexdGrf00R33qoMfb+9gjdeCNhtz/zmfu9I66XZVv1gq8ni x9op0GnltA+VMIBFV/lZxOta0TeOS/ZpdZpgWpRgTRrP4lsIWpDV7PmYhRtn+uTUWEEy67EHW/E GI4Vg/h/hV68B0oI0nBF2aH+Cl/pY26IZ8NbW2nyl0UgK/0YuhSyGkNinnNNOES8gOsv/VGNY32 bdN4/gCndPjJBuJKa+0v2C35+uj8CJpCatSSPK3/cOYUGhb/a2568ef2Pjzaqq2X7wHS0dZD9uU KNNTnarFCWLa1tSn+MYSXR0EufHT27cGgS5Ce1iD0Y2JdBUmGKzSXRzXXkvGrxYX7qNIbJ8WE8S b8Q9PbD3JZyy6JYf8vF/IUd4= X-Received: by 2002:a05:600c:3e12:b0:49d:260c:a422 with SMTP id 5b1f17b1804b1-49e619ce817mr32326705e9.25.1789117344232; Fri, 11 Sep 2026 02:02:24 -0700 (PDT) X-Received: by 2002:a05:600c:3e12:b0:49d:260c:a422 with SMTP id 5b1f17b1804b1-49e619ce817mr32325775e9.25.1789117343605; Fri, 11 Sep 2026 02:02:23 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Igor Mammedov , Ani Sinha Subject: [PULL v2 27/75] tests/acpi/cxl: Update CEDT.cxl for the default CFMW restrictions Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117428325158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso With the default CXL Fixed Memory Window restrictions changed to drop Back-Invalidate (keeping device-coherent and host-only), update the expected CEDT to advertise 0x0f instead of 0x2f. [064h 0100 001h] Subtable Type : 01 [CXL Fixed Memory Window = Structure] [065h 0101 001h] Reserved : 00 [066h 0102 002h] Length : 0028 [068h 0104 004h] Reserved : 00000000 [06Ch 0108 008h] Window base address : 0000000110000000 [074h 0116 008h] Window size : 0000000100000000 [07Ch 0124 001h] Interleave Members : 00 [07Dh 0125 001h] Interleave Arithmetic : 00 [07Eh 0126 002h] Reserved : 0000 [080h 0128 004h] Granularity : 00000005 [084h 0132 002h] Restrictions : 000F [086h 0134 002h] QtgId : 0000 [088h 0136 004h] First Target : 0000000C Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-4-dave@stgolabs.net> --- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/x86/q35/CEDT.cxl | Bin 184 -> 184 bytes 2 files changed, 1 deletion(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index b4646b5b31..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,2 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/x86/q35/CEDT.cxl", diff --git a/tests/data/acpi/x86/q35/CEDT.cxl b/tests/data/acpi/x86/q35/CED= T.cxl index c35f3882eee67aa5613af427234d1ccd196aa249..ff8203af070241bd23dd0eb8a51= 460692bb7d229 100644 GIT binary patch delta 36 scmdnNxPy_)+0`Xv2Ll5G (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117411796211.78200958896116; Fri, 11 Sep 2026 02:03:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9b-0003Fd-Gr; Fri, 11 Sep 2026 05:02:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9V-0002z7-2O for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9S-0008BE-UV for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:32 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-117-Gz9qCm8UN9afZN-NpybAOQ-1; Fri, 11 Sep 2026 05:02:29 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49b0e6638e3so4915085e9.2 for ; Fri, 11 Sep 2026 02:02:28 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60adaee4sm85633975e9.14.2026.09.11.02.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117350; 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=bX21n48672hBN8Zfk6zuZxrqxEgRNXLThdAmJPdhE1E=; b=AVLsuTIMfPU08YABYFyGGaOxUS0JB1aq5tnaQAB4o5EepH12bnZmLpvehsJS9S8MqyjM/v uBh9e5AxBXfi9N3FlEX6+vxdkCN7kyy3FEDhHA3MPQ78Gu/qCQ8U87wkIpcLs5uubLV0R2 xTC3y+IvJrr6YpQ5bnj1UyoMGTp/kr0= X-MC-Unique: Gz9qCm8UN9afZN-NpybAOQ-1 X-Mimecast-MFC-AGG-ID: Gz9qCm8UN9afZN-NpybAOQ_1789117348 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117348; x=1789722148; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=bX21n48672hBN8Zfk6zuZxrqxEgRNXLThdAmJPdhE1E=; b=ZrqGo/wPjI0Am1b++rrqGyfozuK8laJ0//NY4CG8q8eEsSll8RnkovjVI257XAykvQ zHODxHJJj73sjNDntMAMeA6+DK+9fBlHY4xpIKu0rWjIWPdhDTDQJ/ItcpzESUFEIdj2 QzbGEddGigrDVoIyP3SEOZEmosZPcPb0FsBdBCVlLoRh9MNfvu1O4d5OV38wVXh2R40s ikbWg4offU9frhQNxIXBa72dVxJdKK2CIvuWyRHLD4bXRMSxp9tYI9vW5eLvGvAyMDF+ J0HfHX5SxRzr5TDKB2+FX1XhfLYgzYOyjIZBBj3GlfMPEQt2ZjgEEkTHLtAEoXle14OK fPqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117348; x=1789722148; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=bX21n48672hBN8Zfk6zuZxrqxEgRNXLThdAmJPdhE1E=; b=Pphy8VDcWIyEw48rn2zYHvesFyVxWJ5YewgpFiTegGEICp2DNJ3yvas6kSnHVdx3Pa 3333CnSGcToL6yusyfcBMk5FX81UdcYdP8/Wo7ueb45GI94pftRxvZQ8lQRrhYY/8kd6 ygNJIR7VVDo3o3IRyfETcXszbsZ0jMqqI7Ef75zeaw3oLvEmgyiDxnDTUnXCZhRmnaoj GVYQ//XxMuCLcVNBBAVb7vQicumEXXW5BCDl74I7wMpMInvDeMe8C4Wm17otpOFQcvED xVJakGKO/fHblV5NPVKRNRBsINI/fSIg7LQzR0DiMpra0jhGDd8tTCpvCXOFJg/Vwf/Z 8/9Q== X-Gm-Message-State: AFuF++loAP/k8Kii4obFE9+oFmBNRqBuI476pFhwtfFVF7D0C/2lLNga 5LVtzgHe+IVPDLjI7/7exdcb2bozepwT3s33WzHecxRRYAc2I7GdVIlOC8OB8P9lWTwBV2RcPhO 7Qhgc5xDkAIVbzgfUnhhYodt6/+YZ2dm7EuIqDuRno4GApZZLsVTsMnKXQSxkH4GHT7NhsKE3qR Lp4637I07vxBAhfvYt6HhSP2TpFgpO7+ji9g== X-Gm-Gg: AYBFou2rHbMlEmlCd+9glCPjqqSF75zh8lpBgB1UB1nsq4/CiR0wHBnRiRLTa4IU5fl xIwMhJ++FLjR6TyJ9pG/Hmb103zavMHW1OCCDCh0tNVpPW6tAMk+GWjVYvauj2mMTvFcHsGCzPG MhqWkEK8SAldaHgGjpljlYq0vVd37yvzFX1kbvvaTXPQZ6g9atC4uUe28184QNWlEllQpYCmyCJ Sep7lSNDgkmQ+Hh/ctkpKT7yU8wgkEuqHBxGV7F3VZ1eG4bXB4Rv6c7YVgWflQfckpxLf3wGYHZ LVG6qXy3dF2VqIqNdLTOeXTJ81PKXXuBOOSPLgdusR64FsXcG1eEgqwR46k+uEMAb6WkDPQDp95 epxSLpE0Dfu/Kc4AxviotTgg= X-Received: by 2002:a05:600c:34ca:b0:499:9240:9a1c with SMTP id 5b1f17b1804b1-49e619a09d3mr34869095e9.15.1789117347484; Fri, 11 Sep 2026 02:02:27 -0700 (PDT) X-Received: by 2002:a05:600c:34ca:b0:499:9240:9a1c with SMTP id 5b1f17b1804b1-49e619a09d3mr34868105e9.15.1789117346439; Fri, 11 Sep 2026 02:02:26 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Pierrick Bouvier , Igor Mammedov , Ani Sinha , Jonathan Cameron , Junjie Cao , Eric Blake , Markus Armbruster , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Zhao Liu , linux-cxl@vger.kernel.org Subject: [PULL v2 28/75] hw/cxl: Add configurable CXL Fixed Memory Window restriction flags Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117414336158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso Expose the CFMWS "Window Restrictions" (CXL r4.0 9.18.1.3) as named per-window machine properties -- device-coherent, host-only, volatile, persistent, fixed-config and back-invalidate -- so the advertised restrictions can be configured per window rather than left at the default. No changes in default options. HDM-D and HDM-H are advertised by default; disabling one (device-coherent=3Doff or host-only=3Doff) narrows the window= to the other. back-invalidate implies device-coherent (HDM-DB) and suppresses the host-only default. host-only coherent combined with back-invalidate is rejected as undefined behavior per the spec. Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-5-dave@stgolabs.net> --- docs/system/devices/cxl.rst | 25 ++++++++++++-------- qapi/machine.json | 28 ++++++++++++++++++++++ include/hw/cxl/cxl.h | 12 ++++++++++ hw/acpi/cxl.c | 2 +- hw/cxl/cxl-host.c | 46 +++++++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 11 deletions(-) diff --git a/docs/system/devices/cxl.rst b/docs/system/devices/cxl.rst index 9d0771cdfd..6bee339cea 100644 --- a/docs/system/devices/cxl.rst +++ b/docs/system/devices/cxl.rst @@ -384,8 +384,13 @@ An example of 4 devices below a switch suitable for 1,= 2 or 4 way interleave:: -device cxl-type3,bus=3Dswport3,persistent-memdev=3Dcxl-mem3,lsa=3Dcxl-l= sa3,id=3Dcxl-pmem3,sn=3D0x4 \ -M cxl-fmw.0.targets.0=3Dcxl.1,cxl-fmw.0.size=3D4G,cxl-fmw.0.interleave-= granularity=3D4k =20 -An example of 4 type3 devices with volatile memory below a switch. Two of = the devices -use HDM-DB for coherence, which requires operating in Flit mode:: +An example of a mixed configuration across two host bridges, each with its +own CXL window. Below cxl.1, two type3 volatile devices behind a switch use +HDM-DB for coherence, which requires operating in Flit mode and a window +that permits the device-coherent Back-Invalidate model. Below cxl.2, two +plain host-only devices are directly attached and use the default window. +Because a window targets a host bridge, giving each coherency model its own +bridge keeps the window-to-device mapping explicit:: =20 qemu-system-x86_64 -M q35,cxl=3Don -m 4G,maxmem=3D8G,slots=3D8 -smp 4 \ ... @@ -395,17 +400,17 @@ use HDM-DB for coherence, which requires operating in= Flit mode:: -object memory-backend-ram,id=3Dcxl-mem3,share=3Don,size=3D256M \ -device pxb-cxl,bus_nr=3D12,bus=3Dpcie.0,id=3Dcxl.1 \ -device cxl-rp,port=3D0,bus=3Dcxl.1,id=3Droot_port0,chassis=3D0,slot=3D0= \ - -device cxl-rp,port=3D1,bus=3Dcxl.1,id=3Droot_port1,chassis=3D0,slot=3D1= \ -device cxl-upstream,bus=3Droot_port0,id=3Dus0,x-256b-flit=3Don \ -device cxl-downstream,port=3D0,bus=3Dus0,id=3Dswport0,chassis=3D0,slot= =3D4 \ - -device cxl-type3,bus=3Dswport0,volatile-memdev=3Dcxl-mem0,id=3Dcxl-mem0= ,sn=3D0x1,x-256b-flit=3Don,hdm-db=3Don \ + -device cxl-type3,bus=3Dswport0,volatile-memdev=3Dcxl-mem0,id=3Dcxl-vmem= 0,sn=3D0x1,x-256b-flit=3Don,hdm-db=3Don \ -device cxl-downstream,port=3D1,bus=3Dus0,id=3Dswport1,chassis=3D0,slot= =3D5 \ - -device cxl-type3,bus=3Dswport1,volatile-memdev=3Dcxl-mem1,id=3Dcxl-mem1= ,sn=3D0x2,x-256b-flit=3Don,hdm-db=3Don \ - -device cxl-downstream,port=3D2,bus=3Dus0,id=3Dswport2,chassis=3D0,slot= =3D6 \ - -device cxl-type3,bus=3Dswport2,volatile-memdev=3Dcxl-mem2,id=3Dcxl-mem2= ,sn=3D0x3 \ - -device cxl-downstream,port=3D3,bus=3Dus0,id=3Dswport3,chassis=3D0,slot= =3D7 \ - -device cxl-type3,bus=3Dswport3,volatile-memdev=3Dcxl-mem3,id=3Dcxl-mem3= ,sn=3D0x4 \ - -M cxl-fmw.0.targets.0=3Dcxl.1,cxl-fmw.0.size=3D4G,cxl-fmw.0.interleave-= granularity=3D4k + -device cxl-type3,bus=3Dswport1,volatile-memdev=3Dcxl-mem1,id=3Dcxl-vmem= 1,sn=3D0x2,x-256b-flit=3Don,hdm-db=3Don \ + -device pxb-cxl,bus_nr=3D222,bus=3Dpcie.0,id=3Dcxl.2 \ + -device cxl-rp,port=3D0,bus=3Dcxl.2,id=3Droot_port1,chassis=3D0,slot=3D6= \ + -device cxl-type3,bus=3Droot_port1,volatile-memdev=3Dcxl-mem2,id=3Dcxl-v= mem2,sn=3D0x3 \ + -device cxl-rp,port=3D1,bus=3Dcxl.2,id=3Droot_port2,chassis=3D0,slot=3D7= \ + -device cxl-type3,bus=3Droot_port2,volatile-memdev=3Dcxl-mem3,id=3Dcxl-v= mem3,sn=3D0x4 \ + -M cxl-fmw.0.targets.0=3Dcxl.1,cxl-fmw.0.size=3D4G,cxl-fmw.0.interleave-= granularity=3D4k,cxl-fmw.0.back-invalidate=3Don,cxl-fmw.1.targets.0=3Dcxl.2= ,cxl-fmw.1.size=3D4G,cxl-fmw.1.interleave-granularity=3D4k =20 A simple arm/virt example featuring a single direct connected CXL Type 3 Volatile Memory device:: diff --git a/qapi/machine.json b/qapi/machine.json index 2d63c1bac3..de6460f091 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -552,15 +552,43 @@ # accesses will go to a given interleave target. Accepted values # [256, 512, 1k, 2k, 4k, 8k, 16k] # +# @device-coherent: Window permits device-coherent (minimally HDM-D) +# accesses. (since 11.1) +# +# @host-only: Window permits host-only coherent (HDM-H) accesses. +# (since 11.1) +# +# @volatile: Window permits volatile memory. (since 11.1) +# +# @persistent: Window permits persistent memory. (since 11.1) +# +# @fixed-config: Window has a fixed device configuration. Advertised +# in the CEDT only; not otherwise emulated. (since 11.1) +# +# @back-invalidate: Window permits Back-Invalidate (HDM-DB). Implies +# @device-coherent. (since 11.1) +# # @targets: Target root bridge IDs from -device ...,id=3D for each # root bridge. # +# Coherency defaults to both device-coherent and host-only; disabling +# one (host-only=3Doff or device-coherent=3Doff) narrows to the other. +# @back-invalidate implies device-coherent and is not host-only. +# @volatile and @persistent default on. host-only coherent combined +# with @back-invalidate is rejected as undefined behavior. +# # Since: 7.1 ## { 'struct': 'CXLFixedMemoryWindowOptions', 'data': { 'size': 'size', '*interleave-granularity': 'size', + '*device-coherent': 'bool', + '*host-only': 'bool', + '*volatile': 'bool', + '*persistent': 'bool', + '*fixed-config': 'bool', + '*back-invalidate': 'bool', 'targets': ['str'] }} =20 ## diff --git a/include/hw/cxl/cxl.h b/include/hw/cxl/cxl.h index d8cd8359d2..7cf3dc622c 100644 --- a/include/hw/cxl/cxl.h +++ b/include/hw/cxl/cxl.h @@ -27,6 +27,17 @@ =20 typedef struct PXBCXLDev PXBCXLDev; =20 +/* + * CEDT CFMWS "Window Restrictions" bits (CXL r4.0 9.18.1.3), advertising + * which capabilities the host bridges below this window support. + */ +#define CXL_FMW_DEVICE_COHERENT (1 << 0) /* HDM-D */ +#define CXL_FMW_HOST_ONLY (1 << 1) /* HDM-H */ +#define CXL_FMW_VOLATILE (1 << 2) +#define CXL_FMW_PERSISTENT (1 << 3) +#define CXL_FMW_FIXED_CONFIG (1 << 4) +#define CXL_FMW_BI (1 << 5) /* HDM-DB, Back-Invalidate */ + typedef struct CXLFixedWindow { SysBusDevice parent_obj; int index; @@ -36,6 +47,7 @@ typedef struct CXLFixedWindow { uint8_t num_targets; uint8_t enc_int_ways; uint8_t enc_int_gran; + uint16_t restrictions; /* Todo: XOR based interleaving */ MemoryRegion mr; hwaddr base; diff --git a/hw/acpi/cxl.c b/hw/acpi/cxl.c index 75edb2c0a6..77c1db6561 100644 --- a/hw/acpi/cxl.c +++ b/hw/acpi/cxl.c @@ -172,7 +172,7 @@ static void cedt_build_cfmws(CXLFixedWindow *fw, Aml *c= edt) build_append_int_noprefix(table_data, fw->enc_int_gran, 4); =20 /* Window Restrictions */ - build_append_int_noprefix(table_data, 0x0f, 2); + build_append_int_noprefix(table_data, fw->restrictions, 2); =20 /* QTG ID */ build_append_int_noprefix(table_data, 0, 2); diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index 369a985f9b..e279ce5fe3 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -61,6 +61,52 @@ static void cxl_fixed_memory_window_config(CXLFixedMemor= yWindowOptions *object, fw->enc_int_gran =3D 0; } =20 + /* + * HDM-D and HDM-H are advertised by default; disabling one + * (host-only=3Doff or device-coherent=3Doff) narrows the window to the + * other. + */ + if (!object->has_device_coherent || object->device_coherent) { + fw->restrictions |=3D CXL_FMW_DEVICE_COHERENT; + } + if (object->has_host_only ? object->host_only : !object->back_invalida= te) { + fw->restrictions |=3D CXL_FMW_HOST_ONLY; + } + if (object->back_invalidate) { + fw->restrictions |=3D CXL_FMW_DEVICE_COHERENT | CXL_FMW_BI; + } + + if (!(fw->restrictions & (CXL_FMW_DEVICE_COHERENT | CXL_FMW_HOST_ONLY)= )) { + error_setg(errp, "CFMW coherency model required"); + return; + } + + if (object->fixed_config) { + fw->restrictions |=3D CXL_FMW_FIXED_CONFIG; /* no-op */ + } + + /* Volatile and persistent are permitted unless explicitly disabled. */ + if (!object->has_q_volatile || object->q_volatile) { + fw->restrictions |=3D CXL_FMW_VOLATILE; + } + if (!object->has_persistent || object->persistent) { + fw->restrictions |=3D CXL_FMW_PERSISTENT; + } + if (!(fw->restrictions & (CXL_FMW_VOLATILE | CXL_FMW_PERSISTENT))) { + error_setg(errp, "CFMW volatile and/or persistent memory required"= ); + return; + } + + /* + * Reject the undefined and conflicting coherency combinations, + * per CXL r4.0 9.18.1.3. + */ + if ((fw->restrictions & CXL_FMW_HOST_ONLY) && + (fw->restrictions & CXL_FMW_BI)) { + error_setg(errp, "CFMW host-only coherency + BI is undefined behav= ior"); + return; + } + fw->targets =3D g_malloc0_n(fw->num_targets, sizeof(*fw->targets)); for (i =3D 0, target =3D object->targets; target; i++, target =3D targ= et->next) { /* This link cannot be resolved yet, so stash the name for now */ --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117452; cv=none; d=zohomail.com; s=zohoarc; b=d3pntclaHKcaClSB+kaApbMMc3kt0/+kyYcrZvQuVfTZYmUwGoz/q/W6XOf5q9N/snafSBgPX5b//K4LleghTCMGL3nSr07JJqOjjwS59l2vXcIgnGFp+tTmMWy83lZVwJPWG+XZno0Sgftoz8LRVP2qseZGfMHuA5Kj6eZOtFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117452; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SMrXl840QxHcg/H4ML9GgiuvmC8Z3gLSM3n2uW6G38c=; b=fDX7dV1IOGCJd0MZBhAB4jBju4fw1bEZWtxNPJbui2q0QhuKc5szIqu12lJRLN5z4P6uIvQOlY2KuQTqJVqee4KqjD9gvdUPe9XKq4e+F1VFoF1qQxlvScxzYoqg8+Pss/dC1qjcE8IATMkvpMV+V6vm8Y8wn+XhkY3CYNQnuQM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117452269759.9168155040171; Fri, 11 Sep 2026 02:04:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9x-0003g5-4c; Fri, 11 Sep 2026 05:03:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9W-00032O-Na for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9U-0008BK-W3 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:34 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-I6gXuegCNemilfOyE-VivA-1; Fri, 11 Sep 2026 05:02:30 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49cf5bd2f12so7325265e9.1 for ; Fri, 11 Sep 2026 02:02:30 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60946249sm69455245e9.0.2026.09.11.02.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117352; 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=SMrXl840QxHcg/H4ML9GgiuvmC8Z3gLSM3n2uW6G38c=; b=cdKpWQ4t49pVDzRKldLqlvbd2anSCn7bBBVjFogT0arrlwCB4BdQWKE8y0D8/MPhWiIYr7 b+hCejr6HnlfCrv8CbW5XdhuNoeUUNkpFlVTzV0/3tNei3MCU45QMxxyMzFfhPw1MP77in PWWI/SFYjetp7IQfJDMBzWU3gC6HR9I= X-MC-Unique: I6gXuegCNemilfOyE-VivA-1 X-Mimecast-MFC-AGG-ID: I6gXuegCNemilfOyE-VivA_1789117350 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117349; x=1789722149; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=SMrXl840QxHcg/H4ML9GgiuvmC8Z3gLSM3n2uW6G38c=; b=Ezrs0JxcOxUWEvyAJs8AuQcU1Gklw1O4Qn30HhITrxL9XKLkptLcAn0Q2Ikm4IrW72 RGGpjLAkEEWs+DS9WWxRYMh2n8/hCkqXUqgx9j7UumCmDJpMxv1RV0mdyjsbmfAspEe5 VejRplCi9vXCs2CKfbq7LrkaWywMtkdiI1M9vXYxtU4vuQbLx9oAL97XaT0dtLXPIFyl KLDqh3jl8seg2/rRdH/De1vvYV7xBzYOY03d+vxOm0SdviT8LqlLTZImMd7zViB9IZ2O kvZXh3d7FsQ++AHfXx1D4XxgfRQMOOCq/xdYP1eZjuO0IWjQJDyfqipLH6AJO5JDxAMg Ay3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117349; x=1789722149; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=SMrXl840QxHcg/H4ML9GgiuvmC8Z3gLSM3n2uW6G38c=; b=ag5hPuKKOZxU9XdBI59O2b2YgweAV0pbkuATnIUq0ZRpQhbbpEK++mLvCY9aRDBMFx 9SwEQqVCAzKbs/hGJe3TKI2Vw9fzlwn6vB3c2dc3ZH2e8bkQ9FQ0wV38mkP+UMV2zuZI wspOdA9C1lbFKXz8+2VaqpTH0584FYF5CKC7zEVNHFYcENEswGMem07QeQySkRFvWFP5 IZf4sfT3ToFuhvr08NVBkbMDQnUVwqNxTIPJlx6Q/6RqcJPA56yVAKt8jwpWvQvG4BeO 35gD7aYhfJwcC/U7BPBut77y/biJSicnlRFM6UHSr9I+Y2BVFdCYKX836ZVPAqj7+suj u16w== X-Gm-Message-State: AFuF++m0Mn0oxqaJSJW3JNSV/QpNgiY5WI6Td0Y6Ey8ZKYymVrUAWz95 1Pg1hpdQEgWfyvT+bapL9lxc0DNc2/QjtUuIv2zvsEnbNtaUOP3HZW6KLDI1AV6p/qpUwMeFu6Y 1zGg5WGPeGFDrjqbkYjO8nfVRVDxe0lQGTff3tgkpYl+uMENbLup7V/aOsGL8azmPuJGs6qiGDS ahAf3vSay5T6mmGYt0UGKr0b6zBIolVTNzqQ== X-Gm-Gg: AYBFou3Dzxq81rFAEMdzhskRnubGaefCAEu/OpTdriunFDv3VR4S9d6fwWBicBB0d65 U6sHw2KyjqHFLZFmJ/UDzDUoVblVeOdpTRi6oMLUzMG7b4Y0grQk0lH4A1SEf1JCpopJgwAVufu jH9tVdxUHCTQVCsS4OUj2eH/I1DFIBpz1QuvAPgP1vKlbrjnrlJlEancmPFd/waMIROInvwmijx hIqSio+P4wrbJr2k1dF2w+Z+YnKXelpJqseRg7RJO6Jw/Y8vElnto0qeq+wOOjXl/lwzdhAP1ZK QqfwsrhB8RAZytZ6N3fx/zc9u8TGc8EUmnpuY9YoIRk1vOvDZQjuG2i6Khl84xPZOO9llzIIDs3 0gLDvc0Ox8lG3XMduN8bb1ZU= X-Received: by 2002:a05:600c:3b1f:b0:49d:25b0:cc60 with SMTP id 5b1f17b1804b1-49e619d1d24mr37106075e9.29.1789117349288; Fri, 11 Sep 2026 02:02:29 -0700 (PDT) X-Received: by 2002:a05:600c:3b1f:b0:49d:25b0:cc60 with SMTP id 5b1f17b1804b1-49e619d1d24mr37105265e9.29.1789117348635; Fri, 11 Sep 2026 02:02:28 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL v2 29/75] tests/qtest/cxl: Add CXL Fixed Memory Window restriction flag tests Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117454545158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso Add a /pci/cxl/cfmw group exercising the configurable CFMWS Window Restrictions. Signed-off-by: Davidlohr Bueso Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260720233242.901544-6-dave@stgolabs.net> --- tests/qtest/cxl-test.c | 95 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/tests/qtest/cxl-test.c b/tests/qtest/cxl-test.c index 8fb7e58d4f..49d820cde1 100644 --- a/tests/qtest/cxl-test.c +++ b/tests/qtest/cxl-test.c @@ -81,6 +81,13 @@ "-object memory-backend-file,id=3Dlsa3,mem-path=3D%s,size=3D256M " \ "-device cxl-type3,bus=3Drp3,persistent-memdev=3Dcxl-mem3,lsa=3Dlsa3,i= d=3Dpmem3 " =20 +/* Single pxb + volatile type3 + one window; base for the CFMW tests. */ +#define QEMU_CFMW \ + "-machine q35,cxl=3Don " \ + "-device pxb-cxl,id=3Dcxl.0,bus=3Dpcie.0,bus_nr=3D52 " \ + QEMU_RP QEMU_T3D_VMEM \ + "-M cxl-fmw.0.targets.0=3Dcxl.0,cxl-fmw.0.size=3D4G" + static void cxl_basic_hb(void) { qtest_start("-machine q35,cxl=3Don"); @@ -117,6 +124,81 @@ static void cxl_2root_port(void) qtest_end(); } =20 +/* + * CFMWS "Window Restrictions" (CXL r4.0 9.18.1.3) are configurable per + * window; check that valid restriction sets are accepted. + */ +static void cxl_cfmw_default(void) +{ + /* No coherency flag advertises both HDM-D and HDM-H. */ + qtest_start(QEMU_CFMW); + qtest_end(); +} + +static void cxl_cfmw_host_only_off(void) +{ + /* Disabling host-only leaves device-coherent (HDM-D). */ + qtest_start(QEMU_CFMW ",cxl-fmw.0.host-only=3Doff"); + qtest_end(); +} + +static void cxl_cfmw_device_coherent_off(void) +{ + /* Disabling device-coherent leaves host-only (HDM-H). */ + qtest_start(QEMU_CFMW ",cxl-fmw.0.device-coherent=3Doff"); + qtest_end(); +} + +static void cxl_cfmw_back_invalidate(void) +{ + /* Back-Invalidate implies device-coherent (HDM-DB). */ + qtest_start(QEMU_CFMW ",cxl-fmw.0.back-invalidate=3Don"); + qtest_end(); +} + +static void cxl_cfmw_fixed_config(void) +{ + qtest_start(QEMU_CFMW ",cxl-fmw.0.fixed-config=3Don"); + qtest_end(); +} + +static void cxl_cfmw_device_and_host(void) +{ + /* + * device-coherent and host-only may both be advertised (the spec + * permits multiple bits set); this must be accepted -- a regression + * guard against reinstating a device/host-only mutual exclusion. + */ + qtest_start(QEMU_CFMW + ",cxl-fmw.0.device-coherent=3Don,cxl-fmw.0.host-only=3Don"= ); + qtest_end(); +} + +static void cxl_cfmw_volatile_only(void) +{ + qtest_start(QEMU_CFMW ",cxl-fmw.0.persistent=3Doff"); + qtest_end(); +} + +static void cxl_cfmw_persistent_only(void) +{ + qtest_start(QEMU_CFMW ",cxl-fmw.0.volatile=3Doff"); + qtest_end(); +} + +/* Two windows in one VM: a Back-Invalidate window and a host-only window.= */ +static void cxl_cfmw_two_windows(void) +{ + qtest_start("-machine q35,cxl=3Don " + "-device pxb-cxl,id=3Dcxl.0,bus=3Dpcie.0,bus_nr=3D52 " + "-device pxb-cxl,id=3Dcxl.1,bus=3Dpcie.0,bus_nr=3D53 " + QEMU_RP QEMU_T3D_VMEM + "-M cxl-fmw.0.targets.0=3Dcxl.0,cxl-fmw.0.size=3D4G," + "cxl-fmw.0.back-invalidate=3Don," + "cxl-fmw.1.targets.0=3Dcxl.1,cxl-fmw.1.size=3D4G"); + qtest_end(); +} + #ifdef CONFIG_POSIX static void cxl_t3d_deprecated(void) { @@ -233,6 +315,19 @@ int main(int argc, char **argv) qtest_add_func("/pci/cxl/pxb_x2_with_window", cxl_2pxb_with_window= ); qtest_add_func("/pci/cxl/rp", cxl_root_port); qtest_add_func("/pci/cxl/rp_x2", cxl_2root_port); + qtest_add_func("/pci/cxl/cfmw/default", cxl_cfmw_default); + qtest_add_func("/pci/cxl/cfmw/host_only_off", cxl_cfmw_host_only_o= ff); + qtest_add_func("/pci/cxl/cfmw/device_coherent_off", + cxl_cfmw_device_coherent_off); + qtest_add_func("/pci/cxl/cfmw/back_invalidate", + cxl_cfmw_back_invalidate); + qtest_add_func("/pci/cxl/cfmw/fixed_config", cxl_cfmw_fixed_config= ); + qtest_add_func("/pci/cxl/cfmw/device_and_host", + cxl_cfmw_device_and_host); + qtest_add_func("/pci/cxl/cfmw/volatile_only", cxl_cfmw_volatile_on= ly); + qtest_add_func("/pci/cxl/cfmw/persistent_only", + cxl_cfmw_persistent_only); + qtest_add_func("/pci/cxl/cfmw/two_windows", cxl_cfmw_two_windows); #ifdef CONFIG_POSIX qtest_add_func("/pci/cxl/type3_device", cxl_t3d_deprecated); qtest_add_func("/pci/cxl/type3_device_pmem", cxl_t3d_persistent); --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117765; cv=none; d=zohomail.com; s=zohoarc; b=nEuN/TQcV+zqJ3l+If5I1i3CDg13fn8rbfYXHPvBl3K+8djgB1SNk0c0U2U4ULrYJTAb+4Hr8QoQ1xxHltloj1km/KZwXVy5CyD/bYhfSlWEMU09xLbrA/KuSSnIK/NqFCZ0QBDTyBamTf9jI9zw35bdHbq4BN8pd5wB2dpfeOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117765; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QEbTpBGXkapN3DVQGc/Z0YGHeJnV/+deXbNBxtlR344=; b=WzcUDL0y/7vF1sVguxLw3KtuxhiWJTRumRIwQr9enV/uYCY7mozHdQCHC7YjOqo8ptXY8H3r0dCLTeXMkVwEIsQHcgJTCZrsRWTJaS3tsVOuTU4XPR/fnv3VtzgARJp73h0qFby+q/lpx5/StYNuHtiYJP2VNO6DBQ0LKq0vc78= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117765636143.1060494825847; Fri, 11 Sep 2026 02:09:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9i-0003Wc-GY; Fri, 11 Sep 2026 05:02:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9a-0003Fw-93 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9Y-0008Bn-M5 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:38 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-fhzmbPuoPR-khXnIeHgMlg-1; Fri, 11 Sep 2026 05:02:32 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49554715277so6426345e9.1 for ; Fri, 11 Sep 2026 02:02:32 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a7a686sm40699275e9.1.2026.09.11.02.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117356; 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=QEbTpBGXkapN3DVQGc/Z0YGHeJnV/+deXbNBxtlR344=; b=DhZrPSz6Ivy5gdpPtGgHnC18+FdDPMAQ0MAiUzwX66xnfoEaSxmaBWHRH/srGTkg1xCyHi JBIiql/UFtkE9Wlno4yXBBoZAfu1IxF+Auf0AJsRnGLq49GMAHZ9Grl/ROFEr1EOwepVaH nuf4TZ7q8eZLMoWGnMEuvC+FIwNsax0= X-MC-Unique: fhzmbPuoPR-khXnIeHgMlg-1 X-Mimecast-MFC-AGG-ID: fhzmbPuoPR-khXnIeHgMlg_1789117352 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117351; x=1789722151; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=QEbTpBGXkapN3DVQGc/Z0YGHeJnV/+deXbNBxtlR344=; b=DcPVKCkEiQw57Z/L/oflYPrcrk7ZqwSb/OElZqB2Usu4p0ie0f0zS4yeUtf/FEmXlV vSh4CAh9Q3ffXzNqGGYc0QHsTupW6DpEsdTYdXtM8Ae4gsrePRP64EksSHQC/YaNVQTe kHFZsP5eekgNvTG9tPLpOKOChsyVtgfox+00TwMvTILC9fmZafA7xWCtoA8XmkZGvjqb wS1ZsaB54CY1iEAcZdM7YbkXi0Bf1J5WJAqyjmQDgNe8Vz9ZEQgngfSXMd+9oyDGc8g6 rOV/A6ZMVOoGRuL7f6QPdJqLdTnvHJgK8mmLe0Zr9zL3t02p33MxvrP3VMkhjhMSc414 Smpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117351; x=1789722151; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=QEbTpBGXkapN3DVQGc/Z0YGHeJnV/+deXbNBxtlR344=; b=jctRhng6tVMTbnecyfw/MazSmeyCIT2oZbmBtd1QFqju0JmYDmmSbA9r4QaQXLYvVn np+Wot/i6xK9NsW+3fDHIwUQIELBVPsRj2U/qdzI4y/E9imYofZdstrkrlA/eZbea2Cc Uu9ZfE8MZlXdwJ2BB44Gd5jlAL61ssT+1Tkqn9xBX8inlR42UZBgafxet2AuIceKdl2P +eAbVYS52TLrbBh3Ox4BUtIksD0yZqRhfNHXpVYSFilmfa2lxZobxiHleQrKJ/O9yajN 037ZQUw/fQiyRqBUm6zCprYuL6CNcvUQ5+90968Dg0w8FCMGnVaOsNz2chQvMYTa02pm Z4wA== X-Gm-Message-State: AFuF++m3NkBkTYidSYgD7pPUjRLW/ctPrZY7y+z06f87knRwagdWqAkB 0tN55gLhNK9XfMlNI4PS2jnEIbBIofO6H16efysMNsh6iIW+dkujh91/VFtsW9mg5AL/5aNM7ut oy9HB6XpsExYtRzftpX7tErY+WheSwzgNvFCDSegH6njjxCyE6xg/X6mrAhH0V7H/VpukKgo8ob NqN6g3JIXm5dCJlVOnaB+A6It0qloH9ZpgwA== X-Gm-Gg: AYBFou00g1YWc6tmtwL+mhVu5Ng5UyweWsvAJITIhYxLudbIoLNoYBFaS4yC3LYCaU5 glVt1mXIw3f8CIRLXf47o/BBMFuCGRMPki6Iiz75Kbk0V8s8IUD/lLet7n2QmSIJMgonHnAdoZ0 cOj2q4MdU7hQtd89W2BNcCzW/78860+QIabUpFfi1kYUoHH3FRBSYp1eUy4S9kefe0/jC3Yn6LZ PinK1vIpUzrkBkWmH+mhxwXwsGzB5wVw9b/X0DWtK3ClVEtwLxLK4W5VhpNl1zq7Tddt70fO1Iz 1Vriye0GCDeh0WKrHCfgUpmXWP7jb8o19vpgs0lf8Tkk7VZApNOXOTsE9moUPlMSZbKe/4BOQhA rNWKPMhk5qeVyOs7NbBspvd4= X-Received: by 2002:a05:600c:8411:b0:49d:1e09:694a with SMTP id 5b1f17b1804b1-49e619f5049mr74971815e9.11.1789117351575; Fri, 11 Sep 2026 02:02:31 -0700 (PDT) X-Received: by 2002:a05:600c:8411:b0:49d:1e09:694a with SMTP id 5b1f17b1804b1-49e619f5049mr74970365e9.11.1789117350824; Fri, 11 Sep 2026 02:02:30 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Laurent Vivier , qemu-stable@nongnu.org, Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL v2 30/75] hw/net/virtio-net: check packet size before VLAN tag access in receive_filter() Message-ID: <1d2dc18b298da9d1b615e7399b87a0619ac1a323.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117766991158500 From: Laurent Vivier receive_filter() reads ptr[14..15] to extract the VLAN ID without checking the packet is large enough. A short frame with VLAN TPID at bytes 12-13 but no VLAN TCI causes a 2-byte out-of-bounds read. Add size checks before accessing the Ethernet header and the VLAN tag fields. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3788 Fixes: f21c0ed97c97 ("qemu:virtio-net: Add VLAN filtering (Alex Williamson)= ") Signed-off-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260722115008.1570510-1-lvivier@redhat.com> --- hw/net/virtio-net.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 274fbcb0d6..f3f375e1b2 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1751,12 +1751,16 @@ static int receive_filter(VirtIONet *n, const uint8= _t *buf, int size) } =20 ptr +=3D n->host_hdr_len; + size -=3D n->host_hdr_len; + + if (size < sizeof(struct eth_header)) { + return 0; + } =20 if (!memcmp(&ptr[12], vlan, sizeof(vlan))) { int vid; =20 - /* Truncated vlan packet */ - if (size < n->host_hdr_len + 16) { + if (size < 16) { return 0; } vid =3D lduw_be_p(ptr + 14) & 0xfff; --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117431; cv=none; d=zohomail.com; s=zohoarc; b=JMZd3YyckbHk8sv9N9MOs48hxCXT58HSPWPkklPoBGBoIGZS6ydtijD5bsgolPZMjeVfPvjC8yAymBDXYWOQq1ddbDVBL7RdsydIXxW3mywTEQchXoReKLW77S4snc2aMne4AGzQufJFCRuWIh9u984MG9kR1ywchKVWlRvKO7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117431; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YVWgcLlJ6W5VVT8H262UfAJpSjM0Zse4ulGjykHY0SY=; b=ZkQtuuNUaLFI/BP6gqWWJzm6ngsT16dXHbKcAeLl/uECTTlMXOHLNU4x/rLPRUFRGichooMNKsMfuNaRJvwzO6Sb6yVkpiP1ySgqa4/uCksPGPatfcW9s7bGe5YXIhS9Y3s1jnxQgjUYubLJijA3NO+1pXR09dVfSFsO5PU6ptU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117431822989.1230650022524; Fri, 11 Sep 2026 02:03:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAF-00049w-O4; Fri, 11 Sep 2026 05:03:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9b-0003Kf-Pr for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9Z-0008Bz-F2 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:39 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-QHM21EYcN12msoCCvjcrBg-1; Fri, 11 Sep 2026 05:02:35 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49cdc4080ddso3439675e9.1 for ; Fri, 11 Sep 2026 02:02:35 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e0asm147534515e9.1.2026.09.11.02.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117356; 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=YVWgcLlJ6W5VVT8H262UfAJpSjM0Zse4ulGjykHY0SY=; b=fCT7073teAyPe6FIZiFhudKTQ8argIN7Pbm8UWRIQP+ZcbMHsPmdPgzn9UZvFrItH9KwIK eKGhbXpvLbBpgln3Kpj7qocHXg6d849VxZI9AjFVC/aJTAFAD3zJ6v4ZpX2oU0TXEYf7Oe cZ2slyHrWwFg0sHjTUAdtHJwhrptjDs= X-MC-Unique: QHM21EYcN12msoCCvjcrBg-1 X-Mimecast-MFC-AGG-ID: QHM21EYcN12msoCCvjcrBg_1789117354 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117354; x=1789722154; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=YVWgcLlJ6W5VVT8H262UfAJpSjM0Zse4ulGjykHY0SY=; b=EycpQigLoyPocedAodlmw+O2JMBcRNgrJsWffHPFCRP/HmGhRl/Ks9I6TLhyT1fF8C UTPjIrr7zl/S0zybi5YbP563iDCkZ6NB8OiBhul0BZ9FtVi/gh2zVzNwLDHcL8rnQ3s8 Mb9I7730g8ePxSw/scAft3sITNgumm4Co0Rv4WlDIR3Hn01+I/EaYFCklYcliwdRa1Oe kRIELh257/DaFVwNxFvsYjLDHxKX2kSHGnX2iWv9QqSXk0CVbTXCZtTUo4uXKjsmMgS1 JYlRFCqb/jOeCTX9DeWxbHJzZiaYg6a4RyH54+lN03jXe3ocfp+FnOjbku7EP6XVtOBD Ex2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117354; x=1789722154; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YVWgcLlJ6W5VVT8H262UfAJpSjM0Zse4ulGjykHY0SY=; b=qDrm5oX1DhLOaVmUtif7oN3inRba9RmRkLWBOvjT36IezFGNm6zcEsQV+7wnRY8xW5 YIqT247K/uQv+9eRBYofZtufn/4hO5Wn+KcDkzuKuRWN0viAu645+Icp/EdvdLVGj2WA zXEYUl5ym/Z5G1xoyjjlYulBLN9RPiUC0LMsU1OhI1+damXABo2y0nEJtvEbXOdZS6BO kTQwlr5sbHySEvJKT4XywY9FJaMMIIRdQW7bbaha5czuiYFZ0Wq+Gahp+rIggpjRj8nr Us8y2tZuY6TLLv4kjO8idrjRiTGuTlF4yVUPf9RS5lgSeQ87/eS/bo/Z73IOILKxMRG6 3FXw== X-Gm-Message-State: AFuF++mkvfERbCdcumCx+PKoXCuoFxJhRbmmFz8U5nXGGQ9A67v8d2wQ MZtb7gvQnBiGRxwpeT/PWLPsBhfE4CY5TPAFaclpx6aizthq7OFZ8WZ7kvlnbQd4B+fljY/AqRi YAHJPYxH4ke1NI5ydPuvyLnJ2EtkmThxgh3xUu3rzbni7diqTR8XfUC8ec/erARpgf73xIJLOfX lvwU6Mw/tzYpGUuDzwTIIl12rR5jN7OjQh4w== X-Gm-Gg: AYBFou1qO0sRXpWx1roD/PS8OYpvSKWq3BX1PVgNykuvQLlifMuud+/At3vI4StUGXu X9S9rem2xSrBekodLpcCDuOmbrlyeqmRD6jla6+Saqu2Odnk/jd12sQlhIWq2a3yrDEI1ScS17w QG13r40tlcG1n0BUPbihk80uM51VgNyUaT8G8/t1tEhX3vg+ha69Vb9PJ3I59hYMP73E1DvKxr5 lu55uGJHPwRVf7rLmpk4TU3MJ/09/r+o3r0CCePGAZI8/6p5tAtcffvnuamfakD3HLh2ShKcw/+ Cr15Sk0fx0onf/LlDC3Sod2XKULLZRnIc4VYkplXvBou8uzEF6lF1YeNfTaCJ5pY9OKDpv4jgde eTE9msr5jxVvlcIS2vGBnOks= X-Received: by 2002:a05:600c:628f:b0:49d:2705:7030 with SMTP id 5b1f17b1804b1-49e60f71698mr40227875e9.7.1789117353893; Fri, 11 Sep 2026 02:02:33 -0700 (PDT) X-Received: by 2002:a05:600c:628f:b0:49d:2705:7030 with SMTP id 5b1f17b1804b1-49e60f71698mr40227065e9.7.1789117353210; Fri, 11 Sep 2026 02:02:33 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , Kevin Wolf , qemu-block@nongnu.org Subject: [PULL v2 31/75] hw/virtio-blk: Account discard operations Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117432285158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek The acct_failed argument to virtio_blk_handle_rw_error() tells whether there is accounting for this operation or not. The only operation for which there is none is discarding, which seems to be because at the time of the introducing commit 37b06f8d46f ("virtio-blk: add DISCARD and WRITE_ZEROES features"), BlockAcctType did not yet have a BLOCK_ACCT_UNMAP variant. It does have that now, though, so we may as well track those discard operations with it, and can thus remove the acct_failed parameter. Signed-off-by: Hanna Czenczek Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-2-hreitz@redhat.com> --- hw/block/virtio-blk.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index cb6a276a82..4110380392 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -69,7 +69,7 @@ void virtio_blk_req_complete(VirtIOBlockReq *req, unsigne= d char status) } =20 static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, - bool is_read, bool acct_failed) + bool is_read) { VirtIOBlock *s =3D req->dev; BlockErrorAction action =3D blk_get_error_action(s->blk, is_read, erro= r); @@ -85,9 +85,7 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req= , int error, } } else if (action =3D=3D BLOCK_ERROR_ACTION_REPORT) { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); - if (acct_failed) { - block_acct_failed(blk_get_stats(s->blk), &req->acct); - } + block_acct_failed(blk_get_stats(s->blk), &req->acct); g_free(req); } =20 @@ -124,7 +122,7 @@ static void virtio_blk_rw_complete(void *opaque, int re= t) * the memory until the request is completed (which will * happen on the other side of the migration). */ - if (virtio_blk_handle_rw_error(req, -ret, is_read, true)) { + if (virtio_blk_handle_rw_error(req, -ret, is_read)) { continue; } } @@ -140,7 +138,7 @@ static void virtio_blk_flush_complete(void *opaque, int= ret) VirtIOBlockReq *req =3D opaque; VirtIOBlock *s =3D req->dev; =20 - if (ret && virtio_blk_handle_rw_error(req, -ret, 0, true)) { + if (ret && virtio_blk_handle_rw_error(req, -ret, 0)) { return; } =20 @@ -153,17 +151,13 @@ static void virtio_blk_discard_write_zeroes_complete(= void *opaque, int ret) { VirtIOBlockReq *req =3D opaque; VirtIOBlock *s =3D req->dev; - bool is_write_zeroes =3D (virtio_ldl_p(VIRTIO_DEVICE(s), &req->out.typ= e) & - ~VIRTIO_BLK_T_BARRIER) =3D=3D VIRTIO_BLK_T_WRI= TE_ZEROES; =20 - if (ret && virtio_blk_handle_rw_error(req, -ret, false, is_write_zeroe= s)) { + if (ret && virtio_blk_handle_rw_error(req, -ret, false)) { return; } =20 virtio_blk_req_complete(req, VIRTIO_BLK_S_OK); - if (is_write_zeroes) { - block_acct_done(blk_get_stats(s->blk), &req->acct); - } + block_acct_done(blk_get_stats(s->blk), &req->acct); g_free(req); } =20 @@ -443,6 +437,9 @@ static uint8_t virtio_blk_handle_discard_write_zeroes(V= irtIOBlockReq *req, goto err; } =20 + block_acct_start(blk_get_stats(s->blk), &req->acct, bytes, + BLOCK_ACCT_UNMAP); + blk_aio_pdiscard(s->blk, sector << BDRV_SECTOR_BITS, bytes, virtio_blk_discard_write_zeroes_complete, req); } @@ -450,9 +447,8 @@ static uint8_t virtio_blk_handle_discard_write_zeroes(V= irtIOBlockReq *req, return VIRTIO_BLK_S_OK; =20 err: - if (is_write_zeroes) { - block_acct_invalid(blk_get_stats(s->blk), BLOCK_ACCT_WRITE); - } + block_acct_invalid(blk_get_stats(s->blk), + is_write_zeroes ? BLOCK_ACCT_WRITE : BLOCK_ACCT_UNM= AP); return err_status; } =20 --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117398; cv=none; d=zohomail.com; s=zohoarc; b=KStfQkrzjV+E1r45og29TVDnFdBc7W7jRSrb5lGfSTSyE1CqMelgsLOOHzRZpEo1+GxxI4A8QXuHO5N3RNRLttSEAuaxRRd/kO/4xgqPvwDi82DQi2MImzSkuIVukDN0+zJFu8F98bJe5GPv+b5vENxAjSaqv2pQLPGdhJtKWn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117398; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3G43obeGkrZrvaSbMOJK2K6rTqOeLtl6zfRvJGCm6co=; b=iiMewGnHZDzry2BPztRswPZdXYiAmadIS2VG3t5O81NMB073G+WDvt25LlxcAqPIMa2AfKKmOcZKpSvDafiefNaVgzT5iYKpXdiYX9+5VWZYA+50ra/mTAu8F76E5J+ye0OJ8c8deAMur5yWsbo5IMiLxy4ne9KZ0LptDKLdSd8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117398409787.2943830763888; Fri, 11 Sep 2026 02:03:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4x9x-0003i2-8m; Fri, 11 Sep 2026 05:03:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9e-0003SP-VZ for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9c-0008Cb-Pn for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:42 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-AJngWoTdO1uy5ENCssypNw-1; Fri, 11 Sep 2026 05:02:38 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-482e05af072so558522f8f.3 for ; Fri, 11 Sep 2026 02:02:38 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35bed0sm4412415f8f.32.2026.09.11.02.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117360; 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=3G43obeGkrZrvaSbMOJK2K6rTqOeLtl6zfRvJGCm6co=; b=YL5/kR0fhljGVBNkPiiDfsdYRU0rNam0Y6OEiyacVPsM2ThKNLVZ0NAyxriPge6STmv4yz iFxy9ZyFUZxn7P2KD5qlSJ/XvTaHby/CTK+C2kn0T8CsHtrAuPyDfIFbBRzvby9Agd+JT1 4IDgrnpnCN5Qj7m6e03LvHhZ7J+Yppw= X-MC-Unique: AJngWoTdO1uy5ENCssypNw-1 X-Mimecast-MFC-AGG-ID: AJngWoTdO1uy5ENCssypNw_1789117358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117358; x=1789722158; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=3G43obeGkrZrvaSbMOJK2K6rTqOeLtl6zfRvJGCm6co=; b=Gpa9t7DK4ARUMwovIqLnoPZQoiR+3H3LCJvvVSYR58vXWmWBelhzdYdrbEsvTrnRGu Xpahq/4djeMWQWLc1VdPXsBpmb9nsLtFovllCpacCLNj1J5aJ/3uF4mHhYeUd+kQtavp cemRW9SzEZqFAvKoqoyDYuX0nEklVH9yX1gY4bLhrH6kB0oAo8rnqcILi3LbynO1NXnk DTtoukEO6aJhdlHUqLaC5bGkY+tv21H0c5K4NjBdG/mO8D9a1ExnVUdUyIdevUbqZMNj zCBYV6uunRmvZ/ACLfmdCY/DXnEgMt9HPB7W4V6ADJ/LGebypEvi3RbtldS4CeDcLTcI PsqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117358; x=1789722158; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3G43obeGkrZrvaSbMOJK2K6rTqOeLtl6zfRvJGCm6co=; b=VHCWAWF3BOTB/IIHdkin/idUZNqSWaRNdky6TG/LbRS2HjTV2hw36PKaKkzc2WtOCC svLbIY3PhG/+olg0PB4SU3cKCoy86XydXey2kdf8a2P+rOVtXEU81ULm/9nc1L8q9EZR RqDzAIk/1KO5a2wrip68pNqds2DaAPaxoitOQTaaTAuBsP+XVSLocHqs5AAionLkMYtE Vqykn9S7yNwTx8J01BGBnhwldsR2p71uT/pMcbtFcCs6OE+FE6Rfah7ZcHaOhhRIjvRr HACu3RRbIaC7EZS6PHDSp3Lc5AYpvWgf3h+sit1v/qWvg1BtW3XoJSUkBbiPmhxFn7NE UIkQ== X-Gm-Message-State: AFuF++nXjIiRTIiF8fyElLrOqkr0Xi8U+dVKON7OnW5FDstsgF3cCNjT e4fJSAvoIhI66+Q9b6jHtNaRLW4DlSa67dVMmnz1QG/xZqPUUYE6yc8cUVBrdUz20G3MXUz7+N2 sgbLIMrdbzCJY3YmpX0xLFTJqzS1N3VjviYIohQ/G2OfeLVLSdhSjBQc5QVx70TBwBnO6WketD1 FSN2oqoDdd9UJ7WrbdHTofthq2+5GbYxG92Q== X-Gm-Gg: AYBFou0TNV4Xugw5uuaTfI58uJ1aBjL/z8n2H/kYEXlYxJjv2o/attDugW9F0uREbAR PNusYt4LCQCxcVQt54sqlkl1mB/wjCdF8fR9SUUmI2Fm0qv6pMgpZZwYmLidGOw6TB4xcIIE2Fz z8uPRPuvcv2naRbmHCxrRvJQtblUjdpJpg0T5mMaiYoy3AUyN2cMEC1fEw5LGaOqaBkUsl0AJWV sdEPtX5u6O2EZ1782bJSQK6ZnfDSrDtSKgB1EDStkHOqTBLZeduMeXrmz6BZK/kDofvKb2+oclQ a9kBY7sQOTqyZPpx2k6H3mTET3Rw4gy/Nr7thJryGnYY1iOto/4dKTI5lkznoZqAgTRAJKYU03H EGzCOh73ReLA01ua/Z67qrm0= X-Received: by 2002:a05:6000:400d:b0:486:e1a0:4451 with SMTP id ffacd0b85a97d-486eb1d9caamr3521144f8f.24.1789117357522; Fri, 11 Sep 2026 02:02:37 -0700 (PDT) X-Received: by 2002:a05:6000:400d:b0:486:e1a0:4451 with SMTP id ffacd0b85a97d-486eb1d9caamr3521083f8f.24.1789117356899; Fri, 11 Sep 2026 02:02:36 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , Kevin Wolf , qemu-block@nongnu.org Subject: [PULL v2 32/75] hw/virtio-blk: Complete zone-append cookies Message-ID: <0e9e4f715aee501c7f87bf821a73a020c24c8640.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117400063158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek virtio_blk_handle_zone_append() starts accounting via block_acct_start(), but this is actually never completed. Do so. Signed-off-by: Hanna Czenczek Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-3-hreitz@redhat.com> --- hw/block/virtio-blk.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 4110380392..61c341ce2c 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -755,7 +755,8 @@ static void virtio_blk_zone_append_complete(void *opaqu= e, int ret) { ZoneCmdData *data =3D opaque; VirtIOBlockReq *req =3D data->req; - VirtIODevice *vdev =3D VIRTIO_DEVICE(req->dev); + VirtIOBlock *s =3D req->dev; + VirtIODevice *vdev =3D VIRTIO_DEVICE(s); int64_t append_sector, n; uint8_t err_status =3D VIRTIO_BLK_S_OK; =20 @@ -778,6 +779,11 @@ static void virtio_blk_zone_append_complete(void *opaq= ue, int ret) =20 out: virtio_blk_req_complete(req, err_status); + if (err_status =3D=3D VIRTIO_BLK_S_OK) { + block_acct_done(blk_get_stats(s->blk), &req->acct); + } else { + block_acct_failed(blk_get_stats(s->blk), &req->acct); + } g_free(req); g_free(data); } --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117944; cv=none; d=zohomail.com; s=zohoarc; b=ATPd/xquZZTz8bZIn0qom4EuGVJTrr16okoQPET+lcu7/WnzJ95qKTNaQ3Nz9X0ZATib9QM+poWR98WKw2g8ums9kA5/6TioEcqSpKIojAMy8O2y+q+FjuaYAZ8I49RkyHzvSREnCSeoU7VivQeWFxKSnhr6wdTRrnTkzuZqQlU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117944; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=S24e5KZkbgytsFsTZMikkKLncaEvmAfRYA/x9bDr/iM=; b=F/envC2PfzkUfxj7XNXOGi8aUkmCRTURzKpBSH0NJq4iWRummee02kKnDDPCgtVwjFaIuT2ctl12p/WdycQJZbeGFUveIS1WGYDQnOZMrLWC3L4MwbTrarddRj+SuCse5XZMUc3/9UxSTalqkPOB4nvrILA0WoBGbe2Dtyn15j4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117944115697.2374870871666; Fri, 11 Sep 2026 02:12:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAm-0004qA-64; Fri, 11 Sep 2026 05:03:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9h-0003Wa-Hr for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9f-0008DA-NL for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:45 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-Fc9RUdY8P-ewipH1xCP2TQ-1; Fri, 11 Sep 2026 05:02:41 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-482f763db88so272612f8f.2 for ; Fri, 11 Sep 2026 02:02:41 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e5765152asm91366705e9.11.2026.09.11.02.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117363; 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=S24e5KZkbgytsFsTZMikkKLncaEvmAfRYA/x9bDr/iM=; b=CR21iuEiBLHc92ZQ7phIUvJQQUiRWYg7OHDyp/ogDmi0bb46V9Vcq/9xrRThHDNuXZYMwh eo3f6x74bEwXnni+5SWma8h9Ewe8jgdB3bXPG8Z5gNx+A5ab5VTsQ9Ey0Auk9PAsCF6ESz zdpQPLIvbsulrN1p0kMwVbSn1t3VPvU= X-MC-Unique: Fc9RUdY8P-ewipH1xCP2TQ-1 X-Mimecast-MFC-AGG-ID: Fc9RUdY8P-ewipH1xCP2TQ_1789117361 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117360; x=1789722160; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=S24e5KZkbgytsFsTZMikkKLncaEvmAfRYA/x9bDr/iM=; b=XIkahLd1booqJa2tdCy8z/SfmVYep6lfaPk3ZwaV/IFuSDveJS6EZopZsQbDXFiVxG Ox/6bZe/SH7/WSjRJsJjUwkVVZXI9RKwlZSeGl1WpwNUAm92K10owQMV7ZD56p8z8KOO sdzKLfEOFenHna+S7brPVUNh8GYZhtj/cqDj6Xsg9uj2EWrfuLumVSWFGPYFl6RJADkS sLf1HsM23Q9liRyyZln/p+1KkQA5WgPLed0ECOZFfCT9zxfDoY75moh2KZg4D15Rw4IJ Y5bpuT+NLYwt7feBNNIgxEGZpzm7wsvgZ8a1Z6kz6//YaBqdenxOS6awIb12pGKjs9uZ 4hfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117360; x=1789722160; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=S24e5KZkbgytsFsTZMikkKLncaEvmAfRYA/x9bDr/iM=; b=rK2UAwXELRqqUWbvmVXqCZra5MBqOumu06vcm63FxBdNbfMOHeXGt+4fmg9CAN5SDg jIr1RPUkFAYhHNanA96Mk/EH1OAtalLtNoAX9wBX7xWgwCTXwKVT5PNuBDpN63WDr87X G2jedOwolqc8/kRS5i/1JAb8x5s9ydiY6AN1lU3RlaXx98J+yaUGCAUuOzR7Ia0+yi0j ducL60u2Agd2Hs6Mro/p8NsVoTp4zp3g5GqxfB5PkrNyJ4J4tocQHXnhilbPDwz5+eQy m5UhH/CV0tCS0J0rYBIdcCzAeX7He1L3ScR4ZT+PP5F+Jol+U4y3ktB4lOr86T5zT1Js kN8A== X-Gm-Message-State: AFuF++nowg5/jikk1GwyzP9Vixs/5eUSim144D/2BD+ETBjqz6CNJINv d0pfGKew4cmUgHUIJuODgrlw5GHUlvMtNsUzvjijcGtB/yCVnFgph8Fu0runYDJxwdnQK6jC66+ HKFUz2jX8o7lH/niYxoihz19ugdcU3RF88rq7I3leb4ydUzDs4H45CuR6cX95moOriZt8jSbgGm lI10MLIsVZKgJ1/bx5o1yfah3LqxAZtVCmiA== X-Gm-Gg: AYBFou0+5XV2ZzOudCWYuXyWNqyeskmwVYV6U9kjnT4ind+N8eAETl0A4lFBo0AvB28 Q+2YUhAKqT2kidygIm1nv3yKzjoK6e3fTYrjisJmgjqpNfZ/l64ThgjDdUA1OCBlsa/+62sDWcB +cTsMUCS+6eywCAHx1YJexoRRgbGixLCcErnaksL5kl9bNbQ7gJBlKh3hYC4/kGbTjmGtnL8+4n gWBbDjmK8tML0m1ENIm6h3Krb9lxwzQCg36NX9W1VAH9EAFGZGMIInCAfHSUEDSl+/lfbNeZUR/ IgrUSOWeu9Mwwp20HhjQq0q8amK/Wm31xchi02/XRrui/9uXhllxN0wZ84VXsu1TlpSEx0lRKzc 0WYPWU1/lUuJc1vmMFF6v3tc= X-Received: by 2002:a05:600c:3b02:b0:49d:1f32:c911 with SMTP id 5b1f17b1804b1-49e61982fb0mr35298925e9.3.1789117360070; Fri, 11 Sep 2026 02:02:40 -0700 (PDT) X-Received: by 2002:a05:600c:3b02:b0:49d:1f32:c911 with SMTP id 5b1f17b1804b1-49e61982fb0mr35298145e9.3.1789117359437; Fri, 11 Sep 2026 02:02:39 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Klaus Jensen , Stefan Hajnoczi , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org Subject: [PULL v2 33/75] hw/nvme: Fix block accounting in nvme_copy() Message-ID: <426450da58d0130e1500ea85d78899a872e96be9.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117946134158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek In nvme_copy(), we start accounting for each of the copied ranges, but only end it once (in nvme_copy_done()). We should end it after each read/write operation is done instead, so they are properly accounted for. We should also actually pass the number of bytes we are reading/writing (instead of 0), and probably account for the metadata operations also, as they are block operations we execute. Signed-off-by: Hanna Czenczek Reviewed-by: Klaus Jensen Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-4-hreitz@redhat.com> --- hw/nvme/ctrl.c | 53 +++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index c662d968db..c56725947a 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -2802,8 +2802,6 @@ static const AIOCBInfo nvme_copy_aiocb_info =3D { static void nvme_copy_done(NvmeCopyAIOCB *iocb) { NvmeRequest *req =3D iocb->req; - NvmeNamespace *ns =3D req->ns; - BlockAcctStats *stats =3D blk_get_stats(ns->blkconf.blk); =20 if (iocb->idx !=3D iocb->nr) { req->cqe.result =3D cpu_to_le32(iocb->idx); @@ -2813,14 +2811,6 @@ static void nvme_copy_done(NvmeCopyAIOCB *iocb) g_free(iocb->bounce); g_free(iocb->ranges); =20 - if (iocb->ret < 0) { - block_acct_failed(stats, &iocb->acct.read); - block_acct_failed(stats, &iocb->acct.write); - } else { - block_acct_done(stats, &iocb->acct.read); - block_acct_done(stats, &iocb->acct.write); - } - iocb->common.cb(iocb->common.opaque, iocb->ret); qemu_aio_unref(iocb); } @@ -2951,6 +2941,7 @@ static void nvme_copy_out_completed_cb(void *opaque, = int ret) NvmeCopyAIOCB *iocb =3D opaque; NvmeRequest *req =3D iocb->req; NvmeNamespace *dns =3D req->ns; + BlockAcctStats *stats =3D blk_get_stats(dns->blkconf.blk); uint32_t nlb; =20 nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, NU= LL, @@ -2959,10 +2950,12 @@ static void nvme_copy_out_completed_cb(void *opaque= , int ret) if (ret < 0) { iocb->ret =3D ret; req->status =3D NVME_WRITE_FAULT; - goto out; - } else if (iocb->ret < 0) { + } + if (iocb->ret < 0) { + block_acct_failed(stats, &iocb->acct.write); goto out; } + block_acct_done(stats, &iocb->acct.write); =20 if (dns->params.zoned) { nvme_advance_zone_wp(dns, iocb->zone, nlb); @@ -2979,11 +2972,18 @@ static void nvme_copy_out_cb(void *opaque, int ret) NvmeCopyAIOCB *iocb =3D opaque; NvmeRequest *req =3D iocb->req; NvmeNamespace *dns =3D req->ns; + BlockAcctStats *stats =3D blk_get_stats(dns->blkconf.blk); uint32_t nlb; size_t mlen; uint8_t *mbounce; =20 - if (ret < 0 || iocb->ret < 0 || !dns->lbaf.ms) { + if (ret < 0 || iocb->ret < 0) { + block_acct_failed(stats, &iocb->acct.write); + goto out; + } + block_acct_done(stats, &iocb->acct.write); + + if (!dns->lbaf.ms) { goto out; } =20 @@ -2996,6 +2996,7 @@ static void nvme_copy_out_cb(void *opaque, int ret) qemu_iovec_reset(&iocb->iov); qemu_iovec_add(&iocb->iov, mbounce, mlen); =20 + block_acct_start(stats, &iocb->acct.write, mlen, BLOCK_ACCT_WRITE); iocb->aiocb =3D blk_aio_pwritev(dns->blkconf.blk, nvme_moff(dns, iocb-= >slba), &iocb->iov, 0, nvme_copy_out_completed_c= b, iocb); @@ -3012,6 +3013,7 @@ static void nvme_copy_in_completed_cb(void *opaque, i= nt ret) NvmeRequest *req =3D iocb->req; NvmeNamespace *sns =3D iocb->sns; NvmeNamespace *dns =3D req->ns; + BlockAcctStats *sstats =3D blk_get_stats(sns->blkconf.blk); NvmeCopyCmd *copy =3D NULL; uint8_t *mbounce =3D NULL; uint32_t nlb; @@ -3024,10 +3026,12 @@ static void nvme_copy_in_completed_cb(void *opaque,= int ret) if (ret < 0) { iocb->ret =3D ret; req->status =3D NVME_UNRECOVERED_READ; - goto out; - } else if (iocb->ret < 0) { + } + if (iocb->ret < 0) { + block_acct_failed(sstats, &iocb->acct.read); goto out; } + block_acct_done(sstats, &iocb->acct.read); =20 nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, &s= lba, &nlb, NULL, &apptag, &appmask, &reftag); @@ -3102,7 +3106,7 @@ static void nvme_copy_in_completed_cb(void *opaque, i= nt ret) qemu_iovec_reset(&iocb->iov); qemu_iovec_add(&iocb->iov, iocb->bounce, len); =20 - block_acct_start(blk_get_stats(dns->blkconf.blk), &iocb->acct.write, 0, + block_acct_start(blk_get_stats(dns->blkconf.blk), &iocb->acct.write, l= en, BLOCK_ACCT_WRITE); =20 iocb->aiocb =3D blk_aio_pwritev(dns->blkconf.blk, nvme_l2b(dns, iocb->= slba), @@ -3121,20 +3125,29 @@ static void nvme_copy_in_cb(void *opaque, int ret) { NvmeCopyAIOCB *iocb =3D opaque; NvmeNamespace *sns =3D iocb->sns; + BlockAcctStats *stats =3D blk_get_stats(sns->blkconf.blk); uint64_t slba; uint32_t nlb; + size_t mlen; =20 - if (ret < 0 || iocb->ret < 0 || !sns->lbaf.ms) { + if (ret < 0 || iocb->ret < 0) { + block_acct_failed(stats, &iocb->acct.read); + goto out; + } + block_acct_done(stats, &iocb->acct.read); + + if (!sns->lbaf.ms) { goto out; } =20 nvme_copy_source_range_parse(iocb->ranges, iocb->idx, iocb->format, &s= lba, &nlb, NULL, NULL, NULL, NULL); =20 + mlen =3D nvme_m2b(sns, nlb); qemu_iovec_reset(&iocb->iov); - qemu_iovec_add(&iocb->iov, iocb->bounce + nvme_l2b(sns, nlb), - nvme_m2b(sns, nlb)); + qemu_iovec_add(&iocb->iov, iocb->bounce + nvme_l2b(sns, nlb), mlen); =20 + block_acct_start(stats, &iocb->acct.read, mlen, BLOCK_ACCT_READ); iocb->aiocb =3D blk_aio_preadv(sns->blkconf.blk, nvme_moff(sns, slba), &iocb->iov, 0, nvme_copy_in_completed_cb, iocb); @@ -3342,7 +3355,7 @@ static void nvme_do_copy(NvmeCopyAIOCB *iocb) assert(len <=3D blen); qemu_iovec_add(&iocb->iov, iocb->bounce, len); =20 - block_acct_start(blk_get_stats(sns->blkconf.blk), &iocb->acct.read, 0, + block_acct_start(blk_get_stats(sns->blkconf.blk), &iocb->acct.read, le= n, BLOCK_ACCT_READ); =20 iocb->aiocb =3D blk_aio_preadv(sns->blkconf.blk, nvme_l2b(sns, slba), --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117703; cv=none; d=zohomail.com; s=zohoarc; b=QPafTq6x8l9ph9X6fEGpLZXzA5QTxJHgDvLrCipTH9NfvlYy40MikHJSTkcsLZ7RXwx2zWnJAB9LUp2RghwlSFr/1PrsSx9CIcsadMr/YC5VK6ser3lYE/TIMP9uZR35m+dBQoIqSp8sqOkyznKN7SfLrkIxynslu89+sIs36j4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117703; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JyVf7JBB2VSLc3TqglYtvlBBQTxI0eqQCJH5aubruxE=; b=h60Vvk5ThkAQ7viCUQLO2f77np2WW3E8oTxZeol8ZcCUURsu/dPsbAS+rQP6CB1YqUc9tmPQM0GXsZ/kkrM3PLAY3FSVY02jbEZCTIjIiw+XhljfP8M2edtBbs+MaqsUDZupZxz7PID3nawhdpOct3rUEFm2We5sAKqDgEug4GA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117703631606.5673350824742; Fri, 11 Sep 2026 02:08:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAY-0004Kg-2a; Fri, 11 Sep 2026 05:03:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9j-0003Yk-Nr for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9i-0008Dx-5e for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:47 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-241-3qbwktSHP_aaAa2Y9ZzaTQ-1; Fri, 11 Sep 2026 05:02:44 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4839f9edb08so340091f8f.0 for ; Fri, 11 Sep 2026 02:02:44 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e8d1sm4440197f8f.11.2026.09.11.02.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117365; 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=JyVf7JBB2VSLc3TqglYtvlBBQTxI0eqQCJH5aubruxE=; b=PzgUFEL1osVdJ/MH3VY56Qxyw1qXQmE95NKR5n2BUbQ91JT3ncfU3n8zxjZ5yf2UPFaDg7 sCPfVJaGlcTgvLf/B4bXRDvQoyW4qWAsbehOeJ9TW3asVxcuLqGsuEwV/gCEI8lDW/SGRx FZay7hJxEcU5AhNVmG2Q13oH5/9HLzM= X-MC-Unique: 3qbwktSHP_aaAa2Y9ZzaTQ-1 X-Mimecast-MFC-AGG-ID: 3qbwktSHP_aaAa2Y9ZzaTQ_1789117363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117363; x=1789722163; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=JyVf7JBB2VSLc3TqglYtvlBBQTxI0eqQCJH5aubruxE=; b=qqk9MlebkAR6TRyG4GCibRxVOJha/Ei1KdS1+NVQLVbaVGKB7JYWUXo6ivP4LNyyxa 90BscyMrKhMrSL5kWuZTg/M4TFTVX+li1DKK0k0g4X/8vzBhnvz1ozyLAVkFjF8hhNNx hH0LRTR9jhSMobmzhylu3b2RHn4nsTqM08vuYB/x6KVQBRfqGDbmaDryQxCIzzqLstvF US4HB4okePSALM6ielXT3ttjc8rk4TjuVH8EUAOcYeuJs1mIeDW4IAH5gEwAQ1/9wCkp IWKgWIP2xLG7x/zcu3JPuRaXCCRnLIslCmbpfURdASrPnVg5GaNiqrzRUfUXYQMef8Nv rwUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117363; x=1789722163; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=JyVf7JBB2VSLc3TqglYtvlBBQTxI0eqQCJH5aubruxE=; b=De4sYECyG4Qq72ToItmgrkN1Yc9PDiuejlsjDskoqMCWILPQHa4h4v3suK6jOqK8fL RHK6jkF3deYIkaf0bOM6rLt1dvLDGfwuQF9zqzNebgR8sg7U10sdYkZtwZihJ81eM3HN S0+kiLbc8BpMfTrBhhLyuSkL/JYNh4fp6zZRDLz1vXoW2/ogy+/c5ROoOGBLg2fT4iN/ 9wKWJYqi1LIiiBqfzv6ttBOKHmjEU7PC+1TaiWNll0/laYWZVVY2JPfNTogKAI3V2+FS xWXMKZExYlg3dGRgUShENkgdEV4EkccgMVf2w/X2BRE9mtcQMFafVD6s00mf1Ko3tNoP Dxsg== X-Gm-Message-State: AFuF++lTHaG+tc46DCjJe82BhIRqBrWR6ESmqHh7WMvXawoBYvCULmrq MShqtoVTO85hPEgv7Fc/3E+qsyaHPKWGusuWcApvwtfeCAZgtNFZy5Q4w6bOzxyAbQzqHs5/HMr NdxBp2FUPUe/M4NK1QiLaKJkO2WJzqRXdbkPsIsObinBuqyqao8HdDHmysqUAiqRLvE+2k/9aGu 6htvpzth6lFY+z/1NMl1sMjjb388U8XG5ZBQ== X-Gm-Gg: AYBFou3RBfF3gp3RWHXz+8wt89rCG6KeFwY4ObaJCrEpc+fyykkJajOCAs5CjcDgdoj 6hMPkJGGtaQiIPV4jcRcqRZB5zeOJEVx902y/v6lx7BGJBgsQ8HX+AmhX2xDfSWD8UZCYDik3XG uCYIYduTekRFZm5Gr5pJkyEAW0Vc0pFY/NoCxeo3iqjPSYUTfW0j0fI0VOUq6wX9T96y/YGj1fx K9l9l2iZPDVFz/2Uk4BA2uPMVjebm5bG2RayNgwHFnwsx6IAntzbyrXhW4fknTW0kRIIZDhU929 XFPpGzQW7nuaVJZ1VpVQochCFU+SkkySKE5rTDz91nTeeRlshz9hVbljuYuteIk5g/V4ajUtFe7 ztvyJ/25CJ0PUwKn9sJsfoUY= X-Received: by 2002:a05:6000:2912:b0:486:e708:2e5d with SMTP id ffacd0b85a97d-486eb1d5c5fmr3799934f8f.18.1789117362790; Fri, 11 Sep 2026 02:02:42 -0700 (PDT) X-Received: by 2002:a05:6000:2912:b0:486:e708:2e5d with SMTP id ffacd0b85a97d-486eb1d5c5fmr3799847f8f.18.1789117362090; Fri, 11 Sep 2026 02:02:42 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Klaus Jensen , Stefan Hajnoczi , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org Subject: [PULL v2 34/75] hw/nvme: Fix block accounting for compare Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117706101158500 From: Hanna Czenczek nvme_compare() starts block accounting for the operation, but nvme_compare_data_cb() (and nvme_compare_mdata_cb()) do not always finalize the cookie. Specifically, there are a lot of error paths that do not call block_acct_failed(). Fix this by putting block_acct_done()/block_acct_failed() under the `out` labels of nvme_compare_data_cb() and nvme_compare_mdata_cb(). Signed-off-by: Hanna Czenczek Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Klaus Jensen Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-5-hreitz@redhat.com> --- hw/nvme/ctrl.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index c56725947a..7478f0b33a 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -2389,7 +2389,6 @@ static void nvme_compare_mdata_cb(void *opaque, int r= et) trace_pci_nvme_compare_mdata_cb(nvme_cid(req)); =20 if (ret) { - block_acct_failed(stats, acct); req->status =3D NVME_UNRECOVERED_READ; =20 trace_pci_nvme_err_aio(nvme_cid(req), strerror(-ret), req->status); @@ -2444,9 +2443,14 @@ static void nvme_compare_mdata_cb(void *opaque, int = ret) goto out; } =20 - block_acct_done(stats, acct); =20 out: + if (req->status =3D=3D NVME_SUCCESS) { + block_acct_done(stats, acct); + } else { + block_acct_failed(stats, acct); + } + qemu_iovec_destroy(&ctx->data.iov); g_free(ctx->data.bounce); =20 @@ -2474,7 +2478,6 @@ static void nvme_compare_data_cb(void *opaque, int re= t) trace_pci_nvme_compare_data_cb(nvme_cid(req)); =20 if (ret) { - block_acct_failed(stats, acct); req->status =3D NVME_UNRECOVERED_READ; =20 trace_pci_nvme_err_aio(nvme_cid(req), strerror(-ret), req->status); @@ -2513,9 +2516,13 @@ static void nvme_compare_data_cb(void *opaque, int r= et) return; } =20 - block_acct_done(stats, acct); - out: + if (req->status =3D=3D NVME_SUCCESS) { + block_acct_done(stats, acct); + } else { + block_acct_failed(stats, acct); + } + qemu_iovec_destroy(&ctx->data.iov); g_free(ctx->data.bounce); g_free(ctx); --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117910; cv=none; d=zohomail.com; s=zohoarc; b=RhV2oF0DINTvhvnNKt/Er1ycdrO0D09ApfysOfbIvmyi67qQ8PRfV9L9Dm4RRJlO9p7jTOyYRpHaIXbNv7gKsuBtT6aL34IjOemNFH+5Hdb0AJEgSW/8dftaYZjrmSAGx/4ClpRwgMZndwawtQ9KjXjUGFzTEpM8RAyD7WUzouE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117910; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wqIBh6wrg3/cCLBO/xish158SNEF5YQcKd9WgGS4UWY=; b=cwig0LmGQLO8Itc93JRi/GFFk6AQvPaoILjzl09Xmpgx0uKOunmec9Ec+JWrTGNS8MMRT13ae3ajlyyHNXrYZUnqsxLYGvaSg1EqLlzkVfyqXU4stlaSTVaEaaXEl+WOS57uKIfCOVkrHBHKmBoUAeN1UV63D3RsjF5hS1rDxH4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117910255159.7624501809421; Fri, 11 Sep 2026 02:11:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAD-00041d-4g; Fri, 11 Sep 2026 05:03:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9n-0003ci-7U for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9k-0008EW-EY for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:50 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-GfNpdgjuOFCRF-QXy_UYbQ-1; Fri, 11 Sep 2026 05:02:46 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49cd83ca361so6753705e9.1 for ; Fri, 11 Sep 2026 02:02:46 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60946249sm69473825e9.0.2026.09.11.02.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117367; 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=wqIBh6wrg3/cCLBO/xish158SNEF5YQcKd9WgGS4UWY=; b=Y/w+J2SC8+1Za3bbARTXczzHINxDUxoLTKFoXes9rXHpj+AQ2o342PQp3tLlr36Txu8kkt E505uyOU1xsBbQQpA0KoJgK35byuuYZr6GS/jxnJbAXRv8tButYWHjYdc4WrySKe3//f/a 0Rpi/iIDGfQeqHzt/EPFr4g2eygXNxs= X-MC-Unique: GfNpdgjuOFCRF-QXy_UYbQ-1 X-Mimecast-MFC-AGG-ID: GfNpdgjuOFCRF-QXy_UYbQ_1789117365 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117365; x=1789722165; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=wqIBh6wrg3/cCLBO/xish158SNEF5YQcKd9WgGS4UWY=; b=ZrTN0zAb/BYQX1KNzJ5jMkdZ4n4qiySEgqBuuSs+JGDSe835aqum8Ewq0kGY3FTQSL i7pkmSsMhjpeu4CTeaL6dWEiE2FbM09PIDvo6DUuS2105+229/eBGYgnypTy1aJ336Hy g8TRHVO0OqlEpm+wEkdSQTpgA943R2ZJxjZhMJRVs1+TTEAil68MWP4gCvLwdr+UWP5P 0MDnRRyBKqhpFhY87uANXNLe4j05338rUXmrZJfgO71kgwiqx+s3yicvAhJ+84jyqQny 4D6k7JmCHETVtGzkn5EypPWtvH+AWNUR/eibm04wM/KrcDUqUKMd4AFgIvMoZiwTHlIV /LNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117365; x=1789722165; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=wqIBh6wrg3/cCLBO/xish158SNEF5YQcKd9WgGS4UWY=; b=mwMod0EvYKXM3VISVLoqVoLsSvA4+8I4lje2LHPiFzs2seCjiLqtuJ6RVewxeZxqyB Mmj3cYFmy4BJp57V8xjzMAXoWJ0bqSf849HolaLgoxMwHSBDowrN1odxIafbP8s8a+KM U4B9RwRv2WkxbZc3zhZL4hTnUCcI5xA+Q3UHvVZllVNsb+XrxhUozPiGEbTJiF1T7u+3 nf3G28a7J/BHEvkDIEu6hdQ4gAYSb3cHoGgtoIn2S/Iz5PGr2+KMzt44TM5FL9tfXcuw fRZwkVb+xnkZHwRxh3qSAfxVH5+sZyQm+bW1gMWA1jlZKYcD9e+UKBFMuFKLtn/MKbUG ceCw== X-Gm-Message-State: AFuF++l1LEgsl+/IcREoai1Z7qE+WBu6fGkIkIZaDzyoh6lb7ZQjTzT5 FNQ7qddXjgrOOjPZnZthcgiTqAOGr5Gv5MHkL5q54jx53MlCm6UBirZL4xEvszB70oQwlN7hVn6 18Ge002D0Ef0+VGJnmWfumNvbR5W2RzFHZGOwk9ua4pGO/Z7tU+RooybdpNJF7trdSWhe3nRD7N 58W646MQk7WQgjxNJiTzG6PmQ5r4Dl0vLhpQ== X-Gm-Gg: AYBFou0SSz+hx978kE+mMzz/ArOmJeMPnVp2QBdoJLmSjGhzjxGclDxcM2OrPVbN8My H0/LEtd9YZoFdbUWlaD9XKqcEvZEKJN8OeBpnkRgrG21o4H5aJdH8fyUr40Ec/rjprPmWJRbfiD 4bxY9NLrP1VcddzzQJp8tjt5wf3lbuVetXLJI+k/TwDlKAGom1Gozu/MG7Q69+7puMhQBgSdaIx ZrB6nB4cQMq1sx2vIv+JpfPsHhefdt+h9gP9Ul5wrSZj5qr4PckOsobfMkNKVrsF/Se/UUw5SgP p+YbWtSucJRpSiov4u3wK1Gxr7dmVxK+gcnvC8OSShKNFk2yibnvLmnXg+vqEgRU5y8V+KkyZbd d81wIKD+hx1WKx0wz6NQU/v8= X-Received: by 2002:a05:600c:4f43:b0:49c:fc6c:be0b with SMTP id 5b1f17b1804b1-49e619bd068mr40685275e9.17.1789117365085; Fri, 11 Sep 2026 02:02:45 -0700 (PDT) X-Received: by 2002:a05:600c:4f43:b0:49c:fc6c:be0b with SMTP id 5b1f17b1804b1-49e619bd068mr40684385e9.17.1789117364446; Fri, 11 Sep 2026 02:02:44 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , John Snow , "Denis V. Lunev" , qemu-block@nongnu.org Subject: [PULL v2 35/75] hw/ide: Have ide_dma_cb() complete accounting Message-ID: <578d59de7220df86e87a43fb1a435b3927aa27b4.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117911684158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek ide_sector_start_dma() starts accounting for reading and writing, and ide_dma_cb() is supposed to complete it, but currently does not always: In one case, it just forgets it altogether, in the other, it uses block_acct_invalid(), which should not be used after a cookie has already been created. Signed-off-by: Hanna Czenczek Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-6-hreitz@redhat.com> --- hw/ide/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index ef573798d9..06e6bb6067 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -898,6 +898,7 @@ static void ide_dma_cb(void *opaque, int ret) =20 if (ret =3D=3D -EINVAL) { ide_dma_error(s); + block_acct_failed(blk_get_stats(s->blk), &s->acct); return; } =20 @@ -968,7 +969,7 @@ static void ide_dma_cb(void *opaque, int ret) if ((s->dma_cmd =3D=3D IDE_DMA_READ || s->dma_cmd =3D=3D IDE_DMA_WRITE= ) && !ide_sect_range_ok(s, sector_num, n)) { ide_dma_error(s); - block_acct_invalid(blk_get_stats(s->blk), s->acct.type); + block_acct_failed(blk_get_stats(s->blk), &s->acct); return; } =20 --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117900; cv=none; d=zohomail.com; s=zohoarc; b=iI6nHlweLPS1enpk+W2hqfTJz3b7t/mLUGx+2B3fvBmsGCqSxLsN9XSBqoFNFTcKG26SR3nL3hfCjfj/JAkkOERPKT73E330jF+/YkYKBy5NrrH154NM/Lw0airsEneYi7PETMRMz9RFxtAxUtcGLRVWnKHNDT7pbfuKXsxAnqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117900; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wnxtJwJv6yUaxvWZxIjniMMKZkL70PYqB4D9wt2Y1j8=; b=aZ8xR5Funow5LL4LN87YIrtrHE2jRs/KS1il+omanXMNrkl1IBW7MqiOsCkXDnGL/8MzGGFg4S3RztN/0NKBDKPmLQr5zGSueAwv46GlYP4zMXSCyyrtOrCg1HKc0R8K0ni/rJg2TbYHTmkRX4WccCDua3DoByiXWG4xoVfOFgY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117900347670.5933245282138; Fri, 11 Sep 2026 02:11:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAm-0004oU-18; Fri, 11 Sep 2026 05:03:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9o-0003eM-NL for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9m-0008Eq-W4 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:52 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-223-UZgfuDZEOLG8YFFlOMyXUw-1; Fri, 11 Sep 2026 05:02:48 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49d1a778b9dso6297995e9.0 for ; Fri, 11 Sep 2026 02:02:48 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a33e34sm39031965e9.0.2026.09.11.02.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117370; 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=wnxtJwJv6yUaxvWZxIjniMMKZkL70PYqB4D9wt2Y1j8=; b=B22r16bNl0+50JfjkXbc1zZ+xz0z9CW22uxaYOG8XPMxOTubBvSVlZfdBuq9BU0GExGgZI oJ9ss7+Lr/Pkk4bu1f5xFtxV0LZz0I91iVmFFbpUs5CRMQJnVmGhX4f0C0WEiydb5GcwDR cSbrrq4WyYBhMdejKbcxKJ5nBflnkZ0= X-MC-Unique: UZgfuDZEOLG8YFFlOMyXUw-1 X-Mimecast-MFC-AGG-ID: UZgfuDZEOLG8YFFlOMyXUw_1789117367 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117367; x=1789722167; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=wnxtJwJv6yUaxvWZxIjniMMKZkL70PYqB4D9wt2Y1j8=; b=ouGKhrHOGQd1bu/dLOH3i+3OypbGd6zdXMVBtDk2FmvKE8CjNEgrXGSE0Mp60oraMJ VhIrT+cKrYkVPU9LOiM4KRKiL8Uuxcw0QEv/7Wgvw8ihC8i5ZUaLQqXjjiyMNg7i3wSD Vmk6hBJ5tuCUumPo++ksQjxKWNqW/bBsy4jsAZdlKqD3ihjk5l4mTgoUIy/QTzvOqwFp 8S6QDSiVxXAwA9Cj37JZcnhBPW6F6gNdIUkaGg0T8jRpzi2dl4jIYqG301mqBe5sd20I yqYagj7aA96Qeqed2XsGVUdblPfeeKpNNa2wsZdUVmVr/sXM7xUoIjkx/YGjZEcTnNCy nkRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117367; x=1789722167; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=wnxtJwJv6yUaxvWZxIjniMMKZkL70PYqB4D9wt2Y1j8=; b=nMXlbtQ5yZs5CtGn1RbNJ4LC5q1+jryBULnrTxGejcgZ2YV1KHlof5U2OPGQWidNRF jufysi7U8cO7osiVR8N2fzxs0T9mKr2OFvIwkGVw/L4tgxFQARMbNpTJ10aYAMXXMFBJ U81RiCC3NizJxkq7ep4FV7ruXTBbQpNCqX+ifFJ6SiRGeaSUkviWcu/2UwIpITmdnQfi GEj2v7g8Uc6Qo9lLT+vLHy7Z7VVwl/AMMuU90WENoIfQws2Gq7V/iFYLkAcBMFdr3Wq+ rNKJ51vixyG8ZjEHFR/3/dagwrQBD6I1PKQw7dUcEUsdP/2YZ/jSuKQRX00ITk4EtUZa aLfw== X-Gm-Message-State: AFuF++lgvzxGE3xbVKGYgdjC5KYs6D0MGEsvTEe7NlyIggvTfttT/I4Z S3nlyNfmi9ua2vFSUzyuelfDVhmaxAsHiayb7RlHVBTcPuPmaCFXksUDiIUP3LgL2MTcCYgPWBB MiNpLaF4IH5/4eHej1A1WOe8CGNlSs2ppy4QtaqWLEGvguQD9FsExAiJNEEpQ2KuI99fE1egupT 19auYv5MGVlfb+0eQQo2i0bu2bEu2lOrWcDQ== X-Gm-Gg: AYBFou3oDegBgHmoQzsO/NlmN/7OTEBzYoYuG/uWzYPuue9VM+xEuXcbEyyB5jgy+fJ VsE/RykC+K9c0nZFta9mBKTsb3c6VOHT60kANp9IzC5GDarCFk1r06U/zyXgbPEQJwN1vbl+eIT QQjIaP02kw1rRHPOHjgFFkNaKmar+1eRYIGHW0aSKxO0QgE+5P3sUy5u7cB+Mx3wRdXCFLcfoQX UGwzzwgrZbSn24pE+i62hlXxdnN8Hq0qYLmgOUA8gVIb6q9akRImBnzohPECRHF7/GW+pmc4a7S f6GrzPefOAsY7VAfhjh/85BdWLvvYFvhICy71KlM589SUaTssLIc/S6XfnEYe2pBMt1FV6Ggg5L kGWfGpgENXMoYVCSIqHapWM8= X-Received: by 2002:a05:600c:3513:b0:493:f140:c3fb with SMTP id 5b1f17b1804b1-49e619c0357mr55971385e9.7.1789117367319; Fri, 11 Sep 2026 02:02:47 -0700 (PDT) X-Received: by 2002:a05:600c:3513:b0:493:f140:c3fb with SMTP id 5b1f17b1804b1-49e619c0357mr55970485e9.7.1789117366727; Fri, 11 Sep 2026 02:02:46 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:44 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , Paolo Bonzini , Fam Zheng Subject: [PULL v2 36/75] hw/scsi-disk: Fix accounting for IGNORE, ret > 0 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117901626158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek When encountering SCSI error status (ret > 0), accounting is left to scsi_handle_rw_error(), but the BLOCK_ERROR_ACTION_IGNORE path in turn leaves accounting (block_acct_done()) to the caller, so neither side does it. Fix this by unconditionally calling block_acct_done() in the IGNORE path. Yes, this will often result in it being called twice, but that is a no-op, as block_acct_done() resets the cookie type to BLOCK_ACCT_NONE, and will only do accounting if the type is not BLOCK_ACCT_NONE. (And given that the conditions on who does what accounting are quite confusing in scsi-disk, for me at least, I prefer this unconditional call rather than guard it with a condition that has no obvious reason.) Signed-off-by: Hanna Czenczek Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: Michael S. Tsirkin Message-ID: <20260724152315.234183-7-hreitz@redhat.com> --- hw/scsi/scsi-disk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index a42f7d8e77..deb33ac1dd 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -318,6 +318,13 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int r= et, bool acct_failed) return true; =20 case BLOCK_ERROR_ACTION_IGNORE: + /* + * The caller may have already finalized the accounting cookie + * (e.g. scsi_dma_complete() for ret < 0), but calling + * block_acct_done() afterwards is fine (just a no-op). Just + * make sure all cookies are indeed accounted at some point. + */ + block_acct_done(blk_get_stats(s->qdev.conf.blk), &r->acct); return false; =20 case BLOCK_ERROR_ACTION_STOP: --=20 MST From nobody Sat Sep 26 20:50:15 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117434; cv=none; d=zohomail.com; s=zohoarc; b=bqZzXUAcshOCbw830Zd3BoWeS6UIsbFJjl1+j4Gf6K8Ik0GL/VnQPfAl7G7Xe9vp16N8PIMHdw5He7zv8+45qI7bOYRwYLDBYCNcu+DnqwkGh1U63y5W28OwG5xqrSLH6icosCexwNE+uvJmZG/APu7Y+P9sMIilNPTNjSwGGhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117434; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5re7lxkrkt8+upQzc9fNBwoUOfPVSS5sXD8pGJHek6w=; b=oJFVIruHH3uMK2OWa3blxgj+YWc/rE2PSpMHKhWx2tkZ2at5p0wClUvbfxlB20Q5BPSI4dEeTKqO9kAjH6I4MVcTo/iWUHxjEID2BqmX+T9jOEczXnFEH0qxZc1t9y/IRoHEf57XBJyzfrgjwdAYMbMU8CPkeMzz8sMHLWbIwW8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117434458568.1297495112469; Fri, 11 Sep 2026 02:03:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAQ-0004KD-Sl; Fri, 11 Sep 2026 05:03:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9u-0003hV-B1 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9r-0008FL-V8 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:58 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-78-XGv7e90QPK-KaV-lr6NmzQ-1; Fri, 11 Sep 2026 05:02:51 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49e6683d48fso1171415e9.0 for ; Fri, 11 Sep 2026 02:02:51 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e81asm4602336f8f.7.2026.09.11.02.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117375; 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=5re7lxkrkt8+upQzc9fNBwoUOfPVSS5sXD8pGJHek6w=; b=J4s+3IFjL2wstmi3cCYONxuPPqJrpkRwU4MNEfLXJQ5SaPXrmzpCDss+l0W+XO4mHX/8o4 5Qk/GeTiFjuNECdRbaCY6UsfS9lkgMNDbIQRM53BntLY+VJ/yIGUkDJBCwdw4OWrS2/FsW n8OfvncTkJu7Z9uSw7Y2KGZWd6JEEXI= X-MC-Unique: XGv7e90QPK-KaV-lr6NmzQ-1 X-Mimecast-MFC-AGG-ID: XGv7e90QPK-KaV-lr6NmzQ_1789117370 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117370; x=1789722170; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=5re7lxkrkt8+upQzc9fNBwoUOfPVSS5sXD8pGJHek6w=; b=pFKBjkcqLvpuB71Fp50wVnBrCy1oTohX+AQc80Bfuf8ey9SIhQx5Er+tEq5XWbA3Xn iAk+p5P1SOl2r0tGxtC2xOwQ0gPI0tvtLI2TzOqtM9pkje0qlbFqGPmX16kvBx3APmrr oiUn1HYSdnblPr2HmuAnd7XcH+NxjszINa6CxMMNhM/sdgpIWgngYwkqYzmEKthDX6Pk CickmPUM51hv2QeG69WVMOJlnRGXkl1P7Icl9DT6qtIQd1e3edRCOFOxUgp5gupDYaLU nUahsCCcMAP0B9ER0w6rTd9EasqcT3eT3XBf7zFcJYByX7TKMOdFsbPJY73BbflYw3fs xoNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117370; x=1789722170; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=5re7lxkrkt8+upQzc9fNBwoUOfPVSS5sXD8pGJHek6w=; b=E462e/xKV1P/LrKT+HPyNG1qyeUeC99xAWFV6oWGNwtsLzaSsHnpanM+7T6r3UB/Bm bnfazBGnqdHut8N0mUCn9VoGsMUzWWEUo7RdGpz/BMbB7AlPAJcY/uPDzusjnsXIqYEc zmFWGtiAbs/637VKlAHnqsNSFdtcJjEG/VTVi36WFgBd8nyBdkaYWvCeMsPIiO46qIVh bK51puGQloEPK4kPCWUwJ+XMOXP37zhHBvGUmhjSuPo808irwoiGNEJBNdmdprC8C1e1 GIvWZxX4KC2y4yRJh0EQ8eizYREwIBzGIo5+0++de1JwWwHhSr8jwlu4ueqwekP4NG7z J3oA== X-Gm-Message-State: AFuF++lIxYQoE39DmRnPCbuoI49bNCEBw9ek/B5h+6GvS3jKYw0amp0q +2LeKSg2wah75ng838/aOATko7DWx/e4+W9WR4vwbtxufloModEx6MKA2IdVTy0GsD7a9VugJ6D j8MWxHkVuBnAQv1BNGfwHXjRZV2cDpvVv3Sw64wCo9ZmQTLS5gQONvlf04VnvWj0WnMBfpYFLu+ N51T7OzR0pLl8yP5nsO+vCi2z6kd+D2EmEhw== X-Gm-Gg: AYBFou29gyljazSe7nLp3w0INGVsMG7MFkrlngSEP3nN8oqsS+IVediNVvW6Wc/3t+D ixvQ8CtaPW+QP0ghyPATuD021XOIw3BevQgGhcOlXg6064JNUbrYtUMLNAfAWzntezaS9fO028N 0sNvqpg/5qCBed6Hg/CUUtPND1Pn8EIU3uz6BLMfbSTA+8anSLtckAovGqhcXGq/8O7Ogd+L7D4 Zsvghg06Qpn3nEJ4/0W94oIFbMNMmhDHmJmBda83/1CAgTa9lKt55UVEQ2ZpzVviqHNqHS2weuZ 4Ab4cwsCs0cmpC2LDeXmnRRmePoAkRQv5Zh/8B9Tucx9kpKG7rWFmt+lBpRih/BWGGMkKpuSEpv esZdj43iz4H2eTxPAU885x7s= X-Received: by 2002:a05:600c:3b90:b0:49d:16df:8521 with SMTP id 5b1f17b1804b1-49e619805f1mr34590815e9.4.1789117369747; Fri, 11 Sep 2026 02:02:49 -0700 (PDT) X-Received: by 2002:a05:600c:3b90:b0:49d:16df:8521 with SMTP id 5b1f17b1804b1-49e619805f1mr34590175e9.4.1789117369073; Fri, 11 Sep 2026 02:02:49 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Paolo Bonzini , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Pierrick Bouvier Subject: [PULL v2 37/75] meson: disable "maybe uninitilized" errors with -Og Message-ID: <9eb79bc1aa06d89b19273562dec8206d1e38b70d.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117436254158500 GCC's "maybe uninitilized" warnings depend on optimizations for code flow analysis, and produce false positive errors with -Og. Default build gives us coverage with that, so let's just disable with -Og. Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index ec9b05414a..e2da31880b 100644 --- a/meson.build +++ b/meson.build @@ -746,6 +746,10 @@ warn_flags =3D [ '-Wno-typedef-redefinition', ] =20 +if get_option('optimization') =3D=3D 'g' + warn_flags +=3D ['-Wno-error=3Dmaybe-uninitialized'] +endif + if host_os !=3D 'darwin' tsa_has_cleanup =3D cc.compiles(''' struct __attribute__((capability("mutex"))) mutex {}; --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117461; cv=none; d=zohomail.com; s=zohoarc; b=UwNg2zmE5eblXU2yrFAofPgiI/5eLL4dBRVTcQ/z0H2fn3aGNMFKRXqjyFAJP807cNwLrRGUYkQ2BuAkt11wzgqgH5XJ+/WKhj48wSPicXvS3qigjW52dUoyGVlpXgxjpGg4CWpq5F7DjRnx8aFN9WGbOvaL46pysSthk8E4boY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117461; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sbPme7j4pWLTyo9RI68qo6cFhFds/zr08zUNXOqMtd4=; b=ROMGCD/6js5VBLWZp8Zk6wM/wvQFjj8fSpEQPAOkdmeiXIRM50fNtyFd58AYKGGSJnWFHde1Lrpbukq1ZkltzNCT7VaqW/UlPy6IguZMuhDh4EYfx8LvBPPW4vOuAUYfdqb4mJUvbkM3fVxy6m9PnA9ZvuVL6ifNedml0qAvc0A= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17891174615281008.4338829271235; Fri, 11 Sep 2026 02:04:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAo-00053t-4G; Fri, 11 Sep 2026 05:03:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9t-0003hU-B8 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9r-0008FG-O3 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:57 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-57-flFIr1MxOv-COMjpBoyNbA-1; Fri, 11 Sep 2026 05:02:53 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49cdc4080ddso3441185e9.1 for ; Fri, 11 Sep 2026 02:02:53 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c1bfc1sm162330005e9.4.2026.09.11.02.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117375; 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=sbPme7j4pWLTyo9RI68qo6cFhFds/zr08zUNXOqMtd4=; b=QTut/jPiGbSDplD84UoanbfMgQtnCZI2FnButRK3KFcyoyPCFi4b+TjGknecnc7VkrjH/I liQL6Mj8miG6D4YtDbGHQ/UhJ+qK6UPrmHSHVNa+DYmptE/yuWjUf90iV6eJkixwsiRZHj 5+IAWmeGrd3MdiFfx3k//O9zry3CdSk= X-MC-Unique: flFIr1MxOv-COMjpBoyNbA-1 X-Mimecast-MFC-AGG-ID: flFIr1MxOv-COMjpBoyNbA_1789117372 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117372; x=1789722172; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=sbPme7j4pWLTyo9RI68qo6cFhFds/zr08zUNXOqMtd4=; b=WWMt+RJC8t+zqzLmVo9Aw4nzVgefrvljkLRQZqEkBbzG8TzXAjV+46oQs8MngrUrWN 5JY38eUKJJmyl4BZKW+TlgvvMvjVZifdkaIToPpulg9VT14HptI0wpx6Mtx6TAKW6rWS FqaF2MXLpkL/E3bZ8rEOZPZCvYlyAc5mClFITlhxWEdj8IuAqiBGHmwRSJOcLgap8HbL dPiqBxEYbEWTO4IDuarlZo3Mvw170+/1vM5Xzj6NXUMEzdOBykJNAFBY4s/JvnFGe0Xk abmGYurJVtEtL5aDo7uTlLGj/0AYqiquKrDD1mtzUabmEaqM70K6RApOKkLRQ+LomvFf 0gVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117372; x=1789722172; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=sbPme7j4pWLTyo9RI68qo6cFhFds/zr08zUNXOqMtd4=; b=ZyEsFvDwagxOqcIPdhbNvE/oX682Gwd0cEOCMLlGgFrpKkdztPGsFSqeSUSEUEokqS rMeefoRMTtkj7a6+3bgu9GfmGiXpBySw9B5xQ3/0gTIW7uCTRwBXsvkIWRzxqnGkzMVC XA5JtPjXG6OO/P1C+5C4mfeXtEDOlH8Z7a8yBmz3wUlpGsNTCmiNfso+LpusXwg7058r zMjc++z9q+DlCjBHM0m89HA3QIioFXcoFhFFVZCNFF1bf8elOX3mt4UUkdPMARpSC2sI L140SfnN9eZQvc9EOnshuOFNIUV+RJA0lnQtHXvNe7vPpRi4FjNl8B28bmJ5oK6upOWa qVYQ== X-Gm-Message-State: AFuF++nOIS4+RevXzfEAPsZI54D8wWLjoultduFGoqCiSCSlkwDiQU0z BNfBJ/Cr+bD60AAvvyZHz4gVBww2yemFWpcu9EmhQCN/o5w5TRZ9ykrcJW7hsnRP61LNWX9BCJL fIIojAOVsFxs0gSLhz3CcO5GSQYAiGFuV9dmc8/WKYHGWlzWbKEVfn+Xnh04hW+7d+MBzdC9ZKU 8RHeHpRoeiK91BtgizML+4opzYLCkf8avYuQ== X-Gm-Gg: AYBFou1cJsioMHIG/sTDybA29n3gxN/eXP0yBip6t2CwGKaeYSuUGYkx8QwQUnpHIHw LMpYbuVWddGRG3lu78n4Yx2JzI4llxm9DpfnU2UnDgDjXIvG68vog9fr0pxn5VSKsnbSXFAnUrq F064ZkJtHCU8kIS6xKgYKEIqtPJg3JBmsojzQgfSXgL6zTvaCaw+WSzSmkvwqVfXffMFoTrTLD5 1PxFoqJeQMwEtulinjyfns2R45D1ALP4nFOM1mVlqJbpxhzglBAPMvrjnF2a0bb6PzOUeyF5/IB rULCDDETRyrWQn3FMW/ZoclHgYfpoOQOnp5F6lsJO8nk+eHnk4FsxDFImTTWBK+5ndXg6LXlNTH PpkEdPkI8QvAxk1TeKSrl1Io= X-Received: by 2002:a05:600c:4584:b0:49b:8f5e:51fb with SMTP id 5b1f17b1804b1-49e60f5afbcmr39265245e9.3.1789117372222; Fri, 11 Sep 2026 02:02:52 -0700 (PDT) X-Received: by 2002:a05:600c:4584:b0:49b:8f5e:51fb with SMTP id 5b1f17b1804b1-49e60f5afbcmr39264755e9.3.1789117371609; Fri, 11 Sep 2026 02:02:51 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Laurent Vivier , qemu-stable@nongnu.org, Yuri Benditovich , Sven , Jason Wang Subject: [PULL v2 38/75] hw/net/virtio-net: strip trailing padding when caching RSC segment Message-ID: <9ca7b8261eee82551674614ca09ef2cc0b8faf72.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117462541158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier When an RSC candidate packet has trailing padding bytes beyond the declared IP payload, virtio_net_rsc_cache_buf() copies the full wire size into the coalescing buffer and sets seg->size to that value. The bounds check in virtio_net_rsc_coalesce_data() uses the IP length field (o_ip_len) which does not include the padding, so the check can pass while the subsequent memmove() overflows the buffer. Fix this by computing the actual IP packet size from the IP header and using it for both the memcpy and seg->size, so that seg->size stays in sync with the IP length field. virtio_net_rsc_sanity_check4/6() guarantees that ip_size <=3D size. Fixes: CVE-2026-66900 Fixes: 2974e916df87 ("virtio-net: support RSC v4/v6 tcp traffic for Windows= HCK") Cc: qemu-stable@nongnu.org Cc: Yuri Benditovich Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3879 Reported-by: Sven Signed-off-by: Laurent Vivier Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260728082311.4179910-1-lvivier@redhat.com> --- hw/net/virtio-net.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f3f375e1b2..23c26aa08c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2200,13 +2200,31 @@ static void virtio_net_rsc_cache_buf(VirtioNetRscCh= ain *chain, { uint16_t hdr_len; VirtioNetRscSeg *seg; + size_t ip_size; =20 hdr_len =3D chain->n->guest_hdr_len; + + /* + * Strip any trailing padding beyond the IP payload so that seg->size + * stays in sync with the IP length field used by the bounds check in + * virtio_net_rsc_coalesce_data(). virtio_net_rsc_sanity_check4/6() + * guarantees that ip_size <=3D size. + */ + ip_size =3D hdr_len + sizeof(struct eth_header); + if (chain->proto =3D=3D ETH_P_IP) { + struct ip_header *ip =3D (struct ip_header *)(buf + ip_size); + ip_size +=3D htons(ip->ip_len); + } else { + struct ip6_header *ip6 =3D (struct ip6_header *)(buf + ip_size); + ip_size +=3D sizeof(struct ip6_header) + + htons(ip6->ip6_ctlun.ip6_un1.ip6_un1_plen); + } + seg =3D g_new(VirtioNetRscSeg, 1); seg->buf =3D g_malloc(hdr_len + sizeof(struct eth_header) + sizeof(struct ip6_header) + VIRTIO_NET_MAX_TCP_PAYLOAD); - memcpy(seg->buf, buf, size); - seg->size =3D size; + memcpy(seg->buf, buf, ip_size); + seg->size =3D ip_size; seg->packets =3D 1; seg->dup_ack =3D 0; seg->is_coalesced =3D 0; --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117729; cv=none; d=zohomail.com; s=zohoarc; b=XQI+fPz2sIfJ9l/0An+Mccee7g4XE5abgfiiHo7Ai1D1+ul0+YTsy7ZYxtQmAVjsVfV4/RwVVu4Nj9lDXFNo8eBnye/0l9obAxAWKLROADoC0BHCw+Dlr1HGEwZRgGxTLgba7mCxcWMKKkqQjq/4NoXGWgrS0XE95kmDHQMoJPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117729; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6dS2LV10xW58XQBK2n8n0ndzTRRlQmRu7LpDRVGCeMs=; b=SUdZRS5nCkiKZF5KyrEBaNRDrF+TLBpwfua3JsnaaaoKwYuU9Ur4IOpZUqxXq8KnwlikoItKIRpVEo3NA21vanUHmWH4Kk0TClDw9N6F9sR7sjrqY/vgovi9d69Hc2tHE+uVn0fNccl8PVcjY89Mi/3kz0NGWvGQTdWq2kch/xM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117729327477.6028212465459; Fri, 11 Sep 2026 02:08:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAm-0004pw-6o; Fri, 11 Sep 2026 05:03:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9v-0003iE-3T for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9t-0008Fd-Lf for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:02:58 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-10-8g2x9CxTO0GjkVq5xWcNcg-1; Fri, 11 Sep 2026 05:02:55 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49e6683d48fso1172785e9.0 for ; Fri, 11 Sep 2026 02:02:55 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c2985dsm239121435e9.6.2026.09.11.02.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117377; 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=6dS2LV10xW58XQBK2n8n0ndzTRRlQmRu7LpDRVGCeMs=; b=JQLi8KVrBeNHgtBfiZHLN4CQPHIODFFDKuCnxIYevlCMrLyz/DH/bGGaRMgDsLWnwqPK1O sP6jm19ksWU9eJfMRefTp5KtHPaOlqiYZQ0UP/f6IKAJxNgGUWtBAh9r4Ce/uZoSu/cXhB 890xu1wp7YCZgoZoEIoTIVWCZM44vRM= X-MC-Unique: 8g2x9CxTO0GjkVq5xWcNcg-1 X-Mimecast-MFC-AGG-ID: 8g2x9CxTO0GjkVq5xWcNcg_1789117375 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117374; x=1789722174; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=6dS2LV10xW58XQBK2n8n0ndzTRRlQmRu7LpDRVGCeMs=; b=p+kbw6yt5db1fEbuIkLr8ExXpBnhXKfmeJr2QmHmmJNXbZ+y0k7ffrMY7Nalm2iCrY NnasXi/NBr1rWIJWMdyv7+qOWeWjXPxq8qQtZgvZ6IBOaovEgfN04kPpnFv0FuZmhjt7 44AbttfFVCEg5xEhsSvu1Mm+AR0Fr8Hpv+hE38vsLY4skeuQ/myAZkDvc7oFWry+oxZf 8uYRyzpE9K0NfWuxAEaOQRrQmZFe1kK880ZmzsgIdDnn/ERspQlLL3oPkkho2VvB252D o6Y76ITgwfQCdpNTkDwsSneURHo4uIbi8LVs2U2pWHDMH5w2S8xDsV8pFLLBBHmh6CCl 7NmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117374; x=1789722174; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=6dS2LV10xW58XQBK2n8n0ndzTRRlQmRu7LpDRVGCeMs=; b=KuE64pypipL+lSGe/GOvH2LPtDV9SkA9cQrv40zBoTf/MxCMeIJlN6TWkp0TX7BmCh VDZRZniIgSQ/dloDm5YSuXCKFqGmOtwpkFkrG0b8QK6D+kBk0CaoKjKs5bbAHgdyHhN9 b2MT+PO0KaMZVPrAUC+/djBbsjmQ1vw3HtaGy1g6CpARc2nrymrKyIujM/JxbsDsqLh3 VMqEKEaGI66YL6JGwG7AolIZA++dh+HibTrnb2rP3joE7CSpWb0QYEDZOWlvVNg2Lj6K DwuDMh0UaucqYsVbbXnJlN6tUJJkao1kTZwqN7U4NLdRxc+X+oSeiOwe4xkOAtf3qx2p W1uA== X-Gm-Message-State: AFuF++l8iWFZnDDZBDKtRaMKZA1eLMjr/1eD5u0tSLjETR1y7/7Bo/2x +UlctWTbFknLZw11SAYAOm8PX4x3WKyEtvoJEI/UJ9jZXZBTGA10NJD+TB/j6Im6id/cQ3XCm9t 3t0jCp/vKImMfQfTClanpGCWWdHw6Je5kbU3fNdxn/dMcLw1fIJ8P6NYUWozOSZ6mArMYG3gVlw GyVE4yXtrKMZ/OfQedI5xivOUWFSSiBxX4Xg== X-Gm-Gg: AYBFou28TjPZsxOq0PPLwTCrKnXrmlDzW1jzsPA/7KDXQV+L+ZP+ucudw8cKjn1W5SS L6VWn+S76po1GTZ8VYMrr3eKz0sulmgHq62ZOMIu8+5v9Fe0fmFSzqRZCt7Gi+vxOqY2it6ijA/ /rkWXysAocM3hJ1CWuJd9B9R+p9ymT/W2FP6yUsaDjS9VFOvhOBc90I70V22umNy08Yp09XCdE+ XSa9dGYRgK5RkK2DrNuG+qPx9CGNpBUF/Nk6cQ3iXPdafhPAAk5xjIKpDQsi2uxEw/M3eDF+LAQ zMTF6Hj8FYvbtQ10XXtyecLgA5SwgUIhvhNzvLOR0wAzIMIF4Uy3y602+bhzVs2K1cYB7oMlzio kKWmMu/lseZZX61O9WGuKlLQ= X-Received: by 2002:a05:600c:46d3:b0:49c:cfbe:5a76 with SMTP id 5b1f17b1804b1-49e6197fd2bmr34460945e9.2.1789117374332; Fri, 11 Sep 2026 02:02:54 -0700 (PDT) X-Received: by 2002:a05:600c:46d3:b0:49c:cfbe:5a76 with SMTP id 5b1f17b1804b1-49e6197fd2bmr34460175e9.2.1789117373731; Fri, 11 Sep 2026 02:02:53 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , GuoHan Zhao , "Gonglei (Arei)" Subject: [PULL v2 39/75] virtio-crypto: clean up every data queue Message-ID: <6bc7c19eca673e99feb01d431e4c5c4959d4ebc2.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117730906158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: GuoHan Zhao realize() creates max_queues data queues and one BH for each of them. unrealize() decides how many to tear down from multiqueue, but nothing ever sets that field, so it only deletes the first queue and BH. It does not matter how many queues the guest used here. unrealize() must undo all the allocations made by realize(), so loop over max_queues. Fixes: 20cb2ffd5ff3 ("virtio-crypto: using bh to handle dataq's requests") Signed-off-by: GuoHan Zhao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260728111217.573046-1-zhaoguohan@kylinos.cn> --- hw/virtio/virtio-crypto.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 79e2acb56c..85c7279aae 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1114,10 +1114,9 @@ static void virtio_crypto_device_unrealize(DeviceSta= te *dev) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOCrypto *vcrypto =3D VIRTIO_CRYPTO(dev); VirtIOCryptoQueue *q; - int i, max_queues; + int i; =20 - max_queues =3D vcrypto->multiqueue ? vcrypto->max_queues : 1; - for (i =3D 0; i < max_queues; i++) { + for (i =3D 0; i < vcrypto->max_queues; i++) { virtio_delete_queue(vcrypto->vqs[i].dataq); q =3D &vcrypto->vqs[i]; qemu_bh_delete(q->dataq_bh); --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117781; cv=none; d=zohomail.com; s=zohoarc; b=U0aVCXISx2yqlj6/lG2XKG+herEe1xINFoKujLgAlKNY2513Rv+CaLHvCB5Pzpb4KiF0cOe/QJ8yXbiHqehKIL7+8I0jSvhWGVEen6qmNIjA4adYxHP7IsQMWKDnbFTK1LaKSo150X3TMZKBwpcaymByu+XEV6V975Mq5gjddxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117781; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tjmu0XflcFt7hcajhQyvOAGpQgP0KwuZU8Bcnz844UE=; b=ZSFZ3RkkUEzEg+xnYLW78Gcu3va6JJFhn037gOZ0WzH4bfVm8W4UplcGCizMepk7HlCBHNVcKGkFJ4uxJDZewxrpCXh9uE1h0KDsHev0RHQRH+XKDDKqxoXqowdaxeea4PNn8S0hMo7kQUckgRqjEyTCG+ca7AUOd3Ue+UKoubM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178911778156732.678127952949694; Fri, 11 Sep 2026 02:09:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAq-0005N8-Vr; Fri, 11 Sep 2026 05:03:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9x-0003lo-E9 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9v-0008Fu-Ku for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:01 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-9l-LcIr0OYa7FSundF2HdQ-1; Fri, 11 Sep 2026 05:02:57 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49ccfbe060aso4208695e9.0 for ; Fri, 11 Sep 2026 02:02:57 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60946249sm69486125e9.0.2026.09.11.02.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117379; 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=tjmu0XflcFt7hcajhQyvOAGpQgP0KwuZU8Bcnz844UE=; b=N2o2fFHcGcuV4pFi/eUilu7W1JW0MEZ5IqxtBVOzVauFTer9X6dsXaqtP20s24avlVQ4M8 WjztPiRZ1Fu9w98khoJf//x080VF1cGyX2VnZcELYvxnRmLwUiz+VlFs7GupRBX51Oz6D6 85X3fEjQMLinzSQf3VL6exRq+lHAQmE= X-MC-Unique: 9l-LcIr0OYa7FSundF2HdQ-1 X-Mimecast-MFC-AGG-ID: 9l-LcIr0OYa7FSundF2HdQ_1789117376 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117376; x=1789722176; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=tjmu0XflcFt7hcajhQyvOAGpQgP0KwuZU8Bcnz844UE=; b=WyjzAvfgaOVjAwEbPcHJDLBZ1OqFGr72d4+p8tWvMwsGXo4JlM+aqmxNSQLuOSaMTE hCnFUJNdHbKg1WyUfajchboAJhIeFvfkcnUfRvQhe4XwiYDq8C4VbMCNXFWVYWqEsXok drEo6/ur7hKTxhaeiWceeH0p7MqZ627F+Afz54UdmsYlwDh2f0a8bnFL92eZUNRUqI2t NglW20+aodLetRAmYZw2oIsINuFWWKzYz8O2mSndHBAgmeggJGcpm2yf8pq2AZ7oaQQJ 9TBGAErSMGY6oMoqYbLO59KiWwnQhHrfV8LG/xgSkOgpooXI24mOo0AyeL7/185KViKY xDdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117376; x=1789722176; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=tjmu0XflcFt7hcajhQyvOAGpQgP0KwuZU8Bcnz844UE=; b=ZK9trvOoq4co8rtcxN+vsxTu8dAhdYkpvbzPFaKYMZHENFpW53/dAvMAzJ//KR1lDN iONqCQFQFz8yd591xp1J4frIYGleecO/3JDJBipKDWdvSk9jI4HYxVQWTBuEL1Dj8NcA FH7nB1+PKFVNU6idKi0oYRVrFDXfw3g0/bXlEDmAuwr1kYTOjCsF93iS2aLNchFPZfQp fnqIIPFFdla3a+Tae6dgnII2SpUBx516rtcF+8gjruaatkWfhZb0u+izNOpAWJEvlJU/ e+VadjQTroyQXU0q0WER2KgKz9OEetXfczj/DLZ61lKjQNKRhjqva5H3OQ4m0jabSFP2 0A8A== X-Gm-Message-State: AFuF++lMH//WtFyYAhSKYzcWOK5220ZwayKsmW+P4bzPWirgkTN6UwEc c0FS+uzh8o+/iNNEEzUi1ZRk0NwfkNxd/OF+vzMhApnRfKROPFUq8N9yVA9LqDaShfXRYsPKWkT 6UkLwGxsaLVR4ddRvQ/+DKtmuEpAzexjzUxPQbzGQxvTDRzpiDVVgmnZ2+7Fj5m8zpYCC1J0IkF aQwCTEllL4i6V9MvZq/j5OxGbTrbR23AiD7Q== X-Gm-Gg: AYBFou1bDa+rMfP27PQNVDlFXl7svjxgEdyb3VB2xuYPZ/PSvCgQSrVYl7DbhdghC1q YtlbdFRvjtVC7VzUHWZlo5VAcF2lE0bLDPAfpESKU981HPjDzK7zUNjEkmwFYypcqGpWL13rT/M zZ59F5f+IgHspDoPvBVY3q2304z3dzr3bxezZJBq29xrthcx1CZYeW397SjPkm2OPP26LLVQWQ3 T4NJjxcUABNU5P9OJdH4xdwr8deJX+NZpggjwPrOY3tEucq3vvi+NM+pEFzMWGjfCsu613c9HWo zKbZNxdfE/swi4Zfbic656hPdaEE7qSzRqXV2Pu5o5QdTOZXNtEXQ1UikNszN5am7KaYUnwGOZu O2Be96EpF7PQjgqEdIsgIUKo= X-Received: by 2002:a05:600c:3515:b0:497:fecd:5b00 with SMTP id 5b1f17b1804b1-49e61a7425cmr32653305e9.9.1789117376424; Fri, 11 Sep 2026 02:02:56 -0700 (PDT) X-Received: by 2002:a05:600c:3515:b0:497:fecd:5b00 with SMTP id 5b1f17b1804b1-49e61a7425cmr32652605e9.9.1789117375824; Fri, 11 Sep 2026 02:02:55 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jia Jia , Eric Auger Subject: [PULL v2 40/75] hw/virtio: reject inverted virtio-iommu IOVA ranges Message-ID: <0c3d950c27cb052b1bf14ec084d723d92ab1726a.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117782991158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jia Jia Guest MAP and UNMAP requests can set virt_end below virt_start. Since virt_end is inclusive, this is not a valid interval. MAP nevertheless stores it in domain->mappings, but interval_cmp() assumes low <=3D high. For an inverted key, interval_cmp(key, key) returns -1. A covering UNMAP can therefore find the key but fail to remove it and repeat forever while holding s->mutex. Reject inverted request ranges with VIRTIO_IOMMU_S_INVAL and make the notifier range decomposition skip invalid ranges. Keep the existing notifier-before-remove ordering, but return VIRTIO_IOMMU_S_DEVERR if g_tree_remove() fails. Fixes: fe2cacae2438 ("virtio-iommu: Implement map/unmap") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4104 Signed-off-by: Jia Jia Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260729131953.1720567-1-physicalmtea@gmail.com> --- hw/virtio/virtio-iommu.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 533bd5073f..208815096f 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -212,6 +212,10 @@ static void virtio_iommu_notify_map_unmap(IOMMUMemoryR= egion *mr, { uint64_t delta =3D virt_end - virt_start; =20 + if (virt_end < virt_start) { + return; + } + event->entry.iova =3D virt_start; event->entry.addr_mask =3D delta; =20 @@ -807,6 +811,10 @@ static int virtio_iommu_map(VirtIOIOMMU *s, return VIRTIO_IOMMU_S_INVAL; } =20 + if (virt_end < virt_start) { + return VIRTIO_IOMMU_S_INVAL; + } + domain =3D g_tree_lookup(s->domains, GUINT_TO_POINTER(domain_id)); if (!domain) { return VIRTIO_IOMMU_S_NOENT; @@ -857,6 +865,10 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, =20 trace_virtio_iommu_unmap(domain_id, virt_start, virt_end); =20 + if (virt_end < virt_start) { + return VIRTIO_IOMMU_S_INVAL; + } + domain =3D g_tree_lookup(s->domains, GUINT_TO_POINTER(domain_id)); if (!domain) { return VIRTIO_IOMMU_S_NOENT; @@ -879,7 +891,10 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, virtio_iommu_notify_unmap(ep->iommu_mr, current_low, current_high); } - g_tree_remove(domain->mappings, iter_key); + if (!g_tree_remove(domain->mappings, iter_key)) { + ret =3D VIRTIO_IOMMU_S_DEVERR; + break; + } trace_virtio_iommu_unmap_done(domain_id, current_low, current_= high); } else { ret =3D VIRTIO_IOMMU_S_RANGE; --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117576; cv=none; d=zohomail.com; s=zohoarc; b=iJE47JT3Je6reEmEz1aWO4gkemTzk7IhHvd7qwMP7grUk7AV87zy+YCQ3b7Bj1XPC/mmOJBe9j4NGPoSULv08vJICv7o6eaSBSTzTdR6awdUHzu//VwAnoid63KDyVdMIs9++f8cZu6oqlTCius+s7EmfktOjP7YlxhFVFPQUXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117576; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DrlxSV2VF2oztmcd8kqn2wrqEBAsS1OzZaHE6hsiVqg=; b=ZRaQWV23g0lG7bzhTJBNBD0wyBjJqhidQIj4/t10pouNbWerCeXQh3fZ3pEC0GkrUgEiJsn0JIEI9bgT9t2jRbZ1GNonC2ls9zFEaAuagci51a3ZzmH3MWLq/d9VmERuSHuG/qseJ6+X2mjPX/038KjWgwMMz4P+s93kt+p9V34= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117576491149.3573015322279; Fri, 11 Sep 2026 02:06:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAj-0004dQ-Ma; Fri, 11 Sep 2026 05:03:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xA0-0003mP-1M for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4x9y-0008GE-Bp for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:03 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-219-MrITJfMVOc-YS5ajGiUTFw-1; Fri, 11 Sep 2026 05:03:00 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49ccfbe060aso4208935e9.0 for ; Fri, 11 Sep 2026 02:02:59 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60adaeefsm58754815e9.12.2026.09.11.02.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117381; 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=DrlxSV2VF2oztmcd8kqn2wrqEBAsS1OzZaHE6hsiVqg=; b=aoTEZbCEia59GpqH5Vrz5e/i9mVUBSb+ULGgKyb3Y37chl6wH3cLAVYTretsxv+cdT52AB Fm1ym6w5AMu8SMw/i0fjQZofwanMnptDbiQjtt+Rt7PSFM84v/nLevXST8jWSH5n+TZhXo f7EEmMx2SnEiPSw+TqZTXmLmybcCX/0= X-MC-Unique: MrITJfMVOc-YS5ajGiUTFw-1 X-Mimecast-MFC-AGG-ID: MrITJfMVOc-YS5ajGiUTFw_1789117379 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117379; x=1789722179; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=DrlxSV2VF2oztmcd8kqn2wrqEBAsS1OzZaHE6hsiVqg=; b=kE2ixUsZOKjG9CaYWa7IopTqjZCGnvHvMV1nwU+iMOLSyLo3JxUgeUw8v4QInBBOLg 5nLrFaIAx3iBfejg0cUyLyHmqbhepj3UBFunOZO7Zcyg5cpejOKOfprKmSI6cE6ewm4Z obz3EcLBX2A+uIcIzMleFYc+jc9f2dSx0uE5yk+2jB+uDlg827lT7+9O/ZIF8lsiNqSd 7vEknaPRrp/DnWZWC3n75FsKZlwLVt7GCynC/CJC83nnlXZ07HmHBVCAJpd5fNa8KO0L oOG6oVjwVFaJBqv/2NumrCLsvPeefpklP4qNC/Q4j9zF4f0IRuXXV2U1PaUR+eE00tqz wjCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117379; x=1789722179; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DrlxSV2VF2oztmcd8kqn2wrqEBAsS1OzZaHE6hsiVqg=; b=dVbUFtLKwAb/SfAQ4i5XqI32nhxBwMjmlG6Y7Jo6cyIl9UIenW0rtkJc/e3LrBBSyw ji07ukdnhPPL6Cc2ZFeBTeukF+BlYtzBMJjFKYweWowou57YMqb+b3e+7q0pjv8Mmb6v lUEFsBNDlh37w5AyjnyfQJdOaEvQUVrgMSjnUczaYGX3zWWkatTFI6UHdL3yD09ZDOyS aE8nN1Zab2+WS4rDNOq+J+lrgMlf6wg9xpYPFs/FV2URWkb3CFR+7h3ZcBYL5xSeDxGw W8Iu58TfFilFg1eRxt3gRQ/+cDp1L/wRxDV5vx6/dROAC6hUZQRofdNHK2tIsvWwnYo1 P+8g== X-Gm-Message-State: AFuF++nyY0yy6z5c8atwmlRABNUyey++NBko9JQW0MLLrgCYBobSwuXT zLSL6r8Zvc2b7/jZT9H5ySnm5E+dTVPIzWdUV+QRSN5g8mAbgYW3pcoGIHKvJMDD9LJwEaQB+za eX2Tt+rk3jslIW8OLdbK86ey6AN3oew4fUkwEL3gYVBOa0gQEu6vrsT5V5zDIvxv44RG7hX11xT Qy+LsXTYhyj7c/ZpjQKNvnHDi6GRzg8dq/Jg== X-Gm-Gg: AYBFou0cNovtl8xtv3Bd13RFuLF69FbjUB7tahq1glGTU4pu1IQOlpC/kpBX+5qfwrG dVzE1/cKObwWEmB0xyaB9rmopowFAmDPyo/dTUaZ9ZvZBmPs3sxn21yhZY8SeV+zOqUDz6qbZgf ZOJQafWcoppakLHJfalOnrnA04OHdRpc7WeRwf69DRP4GZxtBLcqIjNE2rEq35UCXhNIQ4wR6TP oUd3RAN93E7jsvuzzwKwt3KaNQLFHJlPN5DgFi3Cr6r+Gc+D777v1U777EoCm9/Mxoec48799qr bYQuMfJr/FHnFcgkFQtRHR1wxJ55ZahzXWXFXzdEkYvEENliQakZgvPbtmKlmvp+52EwYWr66wI avybQpf33MPCuj1Ehi/XghCk= X-Received: by 2002:a05:600c:b96:b0:49d:1916:59c7 with SMTP id 5b1f17b1804b1-49e619831a9mr34888475e9.7.1789117378642; Fri, 11 Sep 2026 02:02:58 -0700 (PDT) X-Received: by 2002:a05:600c:b96:b0:49d:1916:59c7 with SMTP id 5b1f17b1804b1-49e619831a9mr34887615e9.7.1789117377872; Fri, 11 Sep 2026 02:02:57 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , David Hildenbrand , mhun512 Subject: [PULL v2 41/75] virtio-balloon: fix free-page BH teardown on unrealize Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117577211158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a guest triggers PCIe hot-unplug while the free-page-hint BH is running on an IOThread, the BH will keep accessing vq->used_elems array when running it. Note that qemu_bh_delete merely prevents new BHs from running, it does not wait for already running ones to finish. We need to wait for it to finish - do it like virtio scsi and run a dummy oneshot AIO in the same context, and wait for it. But there's a twist: BH could be blocked in qemu_cond_wait, then AIO won't run. Add a special reporting state FREE_PAGE_HINT_S_UNREALIZE to make BH exit immediately. Cc: David Hildenbrand Fixes: CVE-2026-66899 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4079 Reported-by: mhun512 Reviewed-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <0967d574d9ffe469edf5fc16da86237e54a69c34.1785327742.git.mst@re= dhat.com> --- include/hw/virtio/virtio-balloon.h | 1 + hw/virtio/virtio-balloon.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-= balloon.h index abbf339718..53bbaa4c9a 100644 --- a/include/hw/virtio/virtio-balloon.h +++ b/include/hw/virtio/virtio-balloon.h @@ -39,6 +39,7 @@ enum virtio_balloon_free_page_hint_status { FREE_PAGE_HINT_S_REQUESTED =3D 1, FREE_PAGE_HINT_S_START =3D 2, FREE_PAGE_HINT_S_DONE =3D 3, + FREE_PAGE_HINT_S_UNREALIZE =3D 4, }; =20 struct VirtIOBalloon { diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 4c5f486ba2..07d519cf6d 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -35,6 +35,7 @@ #include "system/reset.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" +#include "qemu/aio-wait.h" =20 #define BALLOON_PAGE_SIZE (1 << VIRTIO_BALLOON_PFN_SHIFT) =20 @@ -519,6 +520,9 @@ static bool get_free_page_hints(VirtIOBalloon *dev) int i; =20 while (dev->block_iothread) { + if (dev->free_page_hint_status =3D=3D FREE_PAGE_HINT_S_UNREALIZE) { + return false; + } qemu_cond_wait(&dev->free_page_cond, &dev->free_page_lock); } =20 @@ -912,6 +916,11 @@ static void virtio_balloon_device_realize(DeviceState = *dev, Error **errp) qemu_register_resettable(OBJECT(dev)); } =20 +static void dummy_bh(void *opaque) +{ + /* Do nothing */ +} + static void virtio_balloon_device_unrealize(DeviceState *dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -919,9 +928,17 @@ static void virtio_balloon_device_unrealize(DeviceStat= e *dev) =20 qemu_unregister_resettable(OBJECT(dev)); if (s->free_page_bh) { + AioContext *ctx =3D iothread_get_aio_context(s->iothread); + qemu_bh_delete(s->free_page_bh); + + qemu_mutex_lock(&s->free_page_lock); + s->free_page_hint_status =3D FREE_PAGE_HINT_S_UNREALIZE; + qemu_cond_signal(&s->free_page_cond); + qemu_mutex_unlock(&s->free_page_lock); + aio_wait_bh_oneshot(ctx, dummy_bh, NULL); + object_unref(OBJECT(s->iothread)); - virtio_balloon_free_page_stop(s); precopy_remove_notifier(&s->free_page_hint_notify); } balloon_stats_destroy_timer(s); --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117489; cv=none; d=zohomail.com; s=zohoarc; b=M3b4rOlg0svs6bCTnnIDsb9YIeULEyKtvdn+L56xru8CbMD49HsMKm8zcsOcGo0Zr4Suia3zkww6hSInJHtai1TdnqFtih6kTbvAbgQNfCoHrLca2USeaiwJvLX5cpbsD7JwGHCuEOdcf0N/nX82gQmJyXtKdxMZd/pCHWNugb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117489; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XBW41WApnawDSx9a8mqXcCXFaaQqc3qyywi8ob8BaOU=; b=ELPSCUS+hXNnJA3HpU6KuyefmmpeRuM6Cw4tO8YBXwsMHuDOwMj+96bvqTPccoSFR0uIfhrU89KNXuFRyj3ffVnPVgi+NH6DATfYSfPPoaB+VjNlYoAtl6NzfArFDS+sHA+RNW+qLo7GYDmreQgQW6rwWonbVmxGJHr8CuYfEF8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117489446287.5741756089285; Fri, 11 Sep 2026 02:04:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAo-00055L-OZ; Fri, 11 Sep 2026 05:03:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xA1-0003nB-I8 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xA0-0008GO-4p for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:05 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-qCfWmE33NN-iZfBPu0Vchw-1; Fri, 11 Sep 2026 05:03:02 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49d0ae342b9so5183735e9.1 for ; Fri, 11 Sep 2026 02:03:01 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e636f7fa2sm38792325e9.15.2026.09.11.02.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117383; 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=XBW41WApnawDSx9a8mqXcCXFaaQqc3qyywi8ob8BaOU=; b=N7lUkNnra/ZTSZenYg36zh7m1qE8dl/sgxz37nTSXkm1PkRb9z/MIck4KNIwJtoTpCB+mg WAmRFFL52vnV7BFhZ/eL1xPQPchG52+Xsy/bQhknci7u2jdOsm8Exre+IpOupa1PHH4Ozj wqCJaFNSqPmJJ94rSGmL4sKWh2SpqMo= X-MC-Unique: qCfWmE33NN-iZfBPu0Vchw-1 X-Mimecast-MFC-AGG-ID: qCfWmE33NN-iZfBPu0Vchw_1789117381 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117381; x=1789722181; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=XBW41WApnawDSx9a8mqXcCXFaaQqc3qyywi8ob8BaOU=; b=B5JDkwdHBoAWGEPlc6hITbIDsFgXR+oyIguuELk77Lb8VjFLz9vT51xIPk4A3Me6px J+la4FyyAh/udLm3rdaDhNfS41vBbk/yfP8ZY5/6DpZXX2xgWhNUtnEmC4zlzFE5if6X WLqTVeUyWfIvIf3koEwaM6I3BU0Epzvozw27km0S/dBBVjU9SA0KO+Zd7slRw/KvsTPd EwLs8bfdU3YSzMqS+Z/6N8DFcPoSJK81WIHu6GELdB4PYjLOtaD/MMPoxCXchnMYwCMo IWj5o6D92nAAlff+bekSVoaRHatL/v1pfkuAekz65+lVAziPcqOVVp6cx1G6iBi/kFxk gk6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117381; x=1789722181; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=XBW41WApnawDSx9a8mqXcCXFaaQqc3qyywi8ob8BaOU=; b=BI1/rKIEbyf0YgMEpoLsyHc9AzeXJEXp0Xx2aYaECq0yPjTTuY0KRCPdEvWLEFudir fdFIknqHE4CMw7AB6uKfarh3zaQq0Fu/zy2JpL/NysEWDQbnUZcg+/TAc2GRv1OwtAAf z1u7CfOkqUiv6o+u9ONpd1jhq36MoNDe62zArOGTNFxLWaesFGv0prRkHkzhsXd/DNyk PprF27c1MqKoqfVA85JL+1fmsOktrnQklF6pR1mDsdc0oZdxm7lMlAcCftJ26VBBy9PI 8PBgAf+Ru5OW5lQ9LmoTtI+sEvtGfiKf41VKgo/SDiAmBy7uZJJYtoMGn+exdlUvygtc Ny4A== X-Gm-Message-State: AFuF++kwu9Ql2+tYJuFSS/q4RTZMx9MS7rGhaR4pS8lAmAeLNr2YDID3 biH/lh9WplYphFDS60WBaLX4GQGfYa3tBEPea3XOkISbwOoUGJgvpyvUtTXhlCSHvB/j22KQvB/ NQqK1wd+9C2CdyLdzlgA0Z4F/Ga52fGYBTY4o3b2cZ7vVf7JcE7JjHPp/BzKCEkUZk6VTkI37Di LOedi/VeHcFNPwMYGbe7keN2+BiGSntXkkIQ== X-Gm-Gg: AYBFou3yWf9ZyAwmRZ5aenfJ32JJ9DfBDzSvH98IGvoKq0HapGrm/CEYoG/Oueu9Vo0 8zM5DwkF0pON7Pw26a3krSy311FdPOdYwXpR4ceQWBGPLU/e42e5jOPCl3IxDOEeWV+smbKIDEQ BJNo7NLyZmxqIjecxqg2m6gW1UdgwtxY83jx80wL4dUTuvKWscMbgb4LWZAMK0e+S8quFl/794/ PVMrseh4rbi6v9wK5ur1u+GL9hJRK5dAi7ebupxBFb76ZMc4WDeW+oeNQGUb08gK+PPXcsuvOxZ qhJatcOd3qQiMregzYK4O6EsKAE//lsYKE+MMg6BTm7gcntx0rrtJCdl3Tnd51KmyFs3HAtVJCi IMdn/1fyRe0m7CgW9cHO2ux8= X-Received: by 2002:a05:600c:4703:b0:49c:fc6e:a3d7 with SMTP id 5b1f17b1804b1-49e619bfdd3mr31900385e9.22.1789117380724; Fri, 11 Sep 2026 02:03:00 -0700 (PDT) X-Received: by 2002:a05:600c:4703:b0:49c:fc6e:a3d7 with SMTP id 5b1f17b1804b1-49e619bfdd3mr31899625e9.22.1789117380148; Fri, 11 Sep 2026 02:03:00 -0700 (PDT) Date: Fri, 11 Sep 2026 05:02:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alyssa Ross , Manos Pitsidianakis , Stefan Hajnoczi , Stefano Garzarella , Pierrick Bouvier Subject: [PULL v2 42/75] vhost-user.rst: fix typo Message-ID: <1a166f44eef46b9ca46f5950526c2ee79f1e019d.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117490850158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alyssa Ross The protocol feature is named SHMEM. SHMEM_MAP is one of the requests. Fixes: 588acb45c2 ("vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec") Signed-off-by: Alyssa Ross Reviewed-by: Manos Pitsidianakis Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260804121000.444745-3-hi@alyssa.is> --- docs/interop/vhost-user.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index ae8c7ed995..fbfb9d01c6 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -1158,7 +1158,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_DEVICE_STATE 19 #define VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT 20 #define VHOST_USER_PROTOCOL_F_GPA_ADDRESSES 21 - #define VHOST_USER_PROTOCOL_F_SHMEM_MAP 22 + #define VHOST_USER_PROTOCOL_F_SHMEM 22 =20 Front-end message types ----------------------- --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117781; cv=none; d=zohomail.com; s=zohoarc; b=ea7cRFhILbAhSNyUeN97GQTI5U0XbhPnBNs0fbA9j0FENVYsvcRq7Bd0eZUiMPtJYNE+fPlFWDvXMgb6ab0Yc47YXL3atTa/y2gRFAE8NwgPXwbYNCsLpsprqKT9yWie1D3vUabxN5Q1lt3/1rbMejpeGdXGTxYglHbKDahOo00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117781; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DD7zxYroH7IaX3wIfwdVw0uNvZf16+MQiMTQFIYE/+w=; b=OiLNXdX9iUlj88KrPHY2ceZ/aSiSsPS8yxpcPp918sBY1LuPaZvSlR7DLpxd37kwFQMKZu44rPxEvlWXet28ILAxHL+8jSb+lMof0izMLMccrWpxweZ5KFA+1+fqW2gJOx/IAh4KtUyj80rkchVGZRsWm2EI1W9iUaoAjOHXrps= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117781494544.646739710313; Fri, 11 Sep 2026 02:09:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAs-0005XP-5Z; Fri, 11 Sep 2026 05:03:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xA7-0003v8-I9 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xA4-0008Go-IY for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:11 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-e35dekjcPl-CPvn32NUsdA-1; Fri, 11 Sep 2026 05:03:04 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49e6683d48fso1174505e9.0 for ; Fri, 11 Sep 2026 02:03:04 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60946249sm69492385e9.0.2026.09.11.02.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117387; 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=DD7zxYroH7IaX3wIfwdVw0uNvZf16+MQiMTQFIYE/+w=; b=T0lvbqzZlj7AZFYWl/iiXS9sOU5PbhZm1W98Bjl74vV/yYZ6srWLYvZDefgDYmIOZ0Wwg4 qA6U9hsmM+4HVvmgzQqbzn/iL4H5ZH6OAWYYgD5uSgIjZ0gosvt7wVOCIbkDxGB66q2XVc Tz8OQMY8/t2wZzpNpsbVO56+4jEt2Ck= X-MC-Unique: e35dekjcPl-CPvn32NUsdA-1 X-Mimecast-MFC-AGG-ID: e35dekjcPl-CPvn32NUsdA_1789117383 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117383; x=1789722183; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=DD7zxYroH7IaX3wIfwdVw0uNvZf16+MQiMTQFIYE/+w=; b=dKOnENMJeikD1qTfJSLdsri/bhh9ryEW6hA+4vbQ7M0EbbW+Vh54dCqjv6EbaMvqZ2 br55h//PXELY0V42+sTgzkeNGVMxEUgYv8TmLsc+qx1nRTiB9+q8Awr/g7pfudxeatvw apuYjE0KGy7Pbyj6uzZRpIMnqVHt1UO6cCQEHbLHxk3gM5053FfcASZp+RLxHRMdpm3w Iliov40Tn+qKvDaXHPKZ6GiqR7Zn/GoekbchVvqT8Vvu/JqC7Vidb4s9X2kETWIDW7G0 rjh3hFpq/l+88xr/D93pwfzXVjfEOR6MKAixAn/LixJliGdTqnCS3oiRT4e/4PeVCE0H vUxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117383; x=1789722183; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DD7zxYroH7IaX3wIfwdVw0uNvZf16+MQiMTQFIYE/+w=; b=k7wPo0dNcsj31GJs7OoIgTTKx/pdGY37QvI2SAtDkEITgarRbyol+/S16OObtlhh/U dbnMi31jDB+Piw1ximMMmiICvOp7ofP9l9vp5ZOSY0JVjkG1ZO54bU3WXpt6aWQ72yvo ccgwZ+3mJcnruGuQONeJCZcCuVU6MvVSDz5H0m5UYJrdCh9SBRlJyHfcd4N2gk4M874v 7mVzXPJvz8CF7E+4sqEGPo+g7DEg5Jpwf+vwBRwP1QglXP8j8cdX5XqUzuGZh/zp73L8 4Oddn/y7VygQY59A+QoT3olTQhHg1VGlX4CL+Gmh38xdyaBwWYuCqmxIhGsvAN8iB4Nc TPcg== X-Gm-Message-State: AFuF++m42z0DYXuI2w+I4PWkGBIcBBmUnyED02m1Qch7mf+wwXDPRG5p FjKXbFKYeGHtGOjp2sWzS9CwM3ulmz9ipiRO7kmfBzsm0/yuxjP6tw0zkoZbiLfYDnge8h7hZ4W HUhhnxhIv/9M02Ut1cT3zBqjihmEiT0qoB0K9TNOd2Tdgb8k75eBbPNrqYkwawK+jI4KaXFOOge tyLvWYTpNJ3qjd+tLgOhXLaMFFMTfTivTpZQ== X-Gm-Gg: AYBFou3JUdndLhb6KZC1JLK3FT5OxX4t8OwVQbgKLpog/Nb7O9ONLnxT4y8IA6w/Abx ygaaNzupq2cI4g5H8QEblyseTI+gOKybUHoN5uFDT092Y5riiroJCDo+Ijc+xs+dCdXGZfKvAig D0fa8ICYzU+inUwNGGmeCkVus/6BWdzNUMitZ4SlyRyUoy8594LolT01KQJWv+pyN7fApy8IYod 2KMZbMkB/y/PEiZIQq8GaCVKLl9L2B6oeJRlW1WPTkDXOKe/42vA9Z5erEx2FLV8HrERaMnGAo/ uTnlj+caiRRb6jYhJfj6O6+4z+iD04+zQCJkLnZTi5BqsS/ZgVYoaBWN8o8kbuFwuP+lY+6rxza UmKGoTGfNShSgSW6fQEHSc5Y= X-Received: by 2002:a05:600c:3b90:b0:49d:16df:8521 with SMTP id 5b1f17b1804b1-49e619805f1mr34603305e9.4.1789117383072; Fri, 11 Sep 2026 02:03:03 -0700 (PDT) X-Received: by 2002:a05:600c:3b90:b0:49d:16df:8521 with SMTP id 5b1f17b1804b1-49e619805f1mr34602545e9.4.1789117382371; Fri, 11 Sep 2026 02:03:02 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Xiong Weimin , Stefano Garzarella Subject: [PULL v2 43/75] hw/virtio: Propagate vhost_virtqueue_mask errors Message-ID: <4692630d1859603ad16ba46c9994d85f259adc12.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117783221158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xiong Weimin vhost_virtqueue_mask() currently reports failures from vhost_set_vring_call() but always returns void, so callers cannot react. In particular, vhost_virtqueue_start() has a TODO next to the unmask call when !use_guest_notifier_mask. Make vhost_virtqueue_mask() return the underlying errno, and on failure in vhost_virtqueue_start() jump to the existing fail path which unmaps the vring and propagates the error to the device start caller. Other call sites keep today's behavior by ignoring the return value. Signed-off-by: Xiong Weimin Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807024359.2157914-1-xiongweimin@kylinos.cn> --- include/hw/virtio/vhost.h | 9 ++++++--- hw/virtio/vhost.c | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 684bafcaad..3db56433b6 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -310,10 +310,13 @@ void vhost_dev_set_config_notifier(struct vhost_dev *= dev, */ bool vhost_virtqueue_pending(struct vhost_dev *hdev, int n); =20 -/* Mask/unmask events from this vq. +/** + * vhost_virtqueue_mask(): mask/unmask events from this vq. + * + * Returns: 0 on success, a negative errno on failure. */ -void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int = n, - bool mask); +int vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, + bool mask); =20 /** * vhost_get_features_ex() - sanitize the extended features set diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 371dca17dd..52ea142bd4 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1471,8 +1471,10 @@ int vhost_virtqueue_start(struct vhost_dev *dev, * will do it later. */ if (!vdev->use_guest_notifier_mask) { - /* TODO: check and handle errors. */ - vhost_virtqueue_mask(dev, vdev, idx, false); + r =3D vhost_virtqueue_mask(dev, vdev, idx, false); + if (r < 0) { + goto fail; + } } =20 if (k->query_guest_notifiers && @@ -1919,7 +1921,7 @@ bool vhost_virtqueue_pending(struct vhost_dev *hdev, = int n) } =20 /* Mask/unmask events from this vq. */ -void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int = n, +int vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n, bool mask) { struct VirtQueue *vvq =3D virtio_get_queue(vdev, n); @@ -1940,7 +1942,9 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Vir= tIODevice *vdev, int n, r =3D hdev->vhost_ops->vhost_set_vring_call(hdev, &file); if (r < 0) { error_report("vhost_set_vring_call failed %d", -r); + return r; } + return 0; } =20 bool vhost_config_pending(struct vhost_dev *hdev) --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117737; cv=none; d=zohomail.com; s=zohoarc; b=Iz8pg94DZRwU6t5z+MykWbU/6hygPgNyI0r2WlOffIF1tKLtbut2UyT79dmP6jdBKgYy8SMQcrCdlaRs+jt8y3xHV8CoSYdwwetDKB63tHkE/GL9Xk1ienit0aJ0Lm7mJWIVUC2aUsQ5INWglSL/weUrsg6SuoSjETjxn9cpyxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117737; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+sod/F5ZJD19JAbUugoGre+d4N7kWAhYD4EQjfTMC7Q=; b=dhT4ViZXo6ycz2XyhxUeIKQE9d/cLN13vdfCvYT+3oBUQdZPFqPD80lbfVHQ8ACwIgPAKmZENugux7ZRHR7DOSwddd1k4YO0EmyTOUp1XDEUcxovJpdTswqoWBbvsAHbJbqYYZX4OpiVCeZEfwZS38WlYn1ijJa9Z9C4FAaezQ8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117737491705.3789442695559; Fri, 11 Sep 2026 02:08:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAj-0004aP-Cy; Fri, 11 Sep 2026 05:03:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xA8-0003yi-Q5 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xA5-0008Gr-Sl for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:12 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-82-Vp6hFUcZPH-H2O-C5fmDDQ-1; Fri, 11 Sep 2026 05:03:07 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-486f1eee015so121917f8f.1 for ; Fri, 11 Sep 2026 02:03:06 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35c071sm4601237f8f.33.2026.09.11.02.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117388; 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=+sod/F5ZJD19JAbUugoGre+d4N7kWAhYD4EQjfTMC7Q=; b=Nv2eG2cRH5KsuS/WWn8Whuih/nBW9yKQaE86LegCGImnitsLzRovB7kh4Yplmiow2LUN3a oenSaDLSrRunelg88Kl2nSI9BW3dABC0etFlDq9Z1W4Z6guwLAPJyAt1sajlRc0doQT93O EVcYU3gZsUILMUcBsf/jAvTUhm5jj4A= X-MC-Unique: Vp6hFUcZPH-H2O-C5fmDDQ-1 X-Mimecast-MFC-AGG-ID: Vp6hFUcZPH-H2O-C5fmDDQ_1789117386 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117386; x=1789722186; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=+sod/F5ZJD19JAbUugoGre+d4N7kWAhYD4EQjfTMC7Q=; b=L2YI4hzdTgM8OrxejdgvPpmSyyh0ZI7sAOCKPdDwwvDy4rOQQA2PeO4LqUGuRz0fGx sEcYCe+6yKAtQF3c4coR59HDCUIYoNT9cDESEthd5cNApg2oZR5BOUt5AIof4fErlOqQ u41PDw5pNFK4wHdIU+1pumd49S4dkg41ZZUSillf7xE7Zy1U5ohOk1Bohl0R2HQBAiZU CY8t5PJTnJ1KhtmTyp6XWKAwFiMmi1Y/nBeoVkurcA8U9jLBNh/Dawo5GOeCYQyxQ42Q p1u4K+auO1KJO5Hn6rkYZtEO4MtLXTtL7mXYCbf1u5w/a8ZidyFRhQ3FzY1a7rwdXyJ6 lg1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117386; x=1789722186; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+sod/F5ZJD19JAbUugoGre+d4N7kWAhYD4EQjfTMC7Q=; b=cjw0sbGd+wPLvg+hoU9LgnwCdtZiC3xMWyaBsTv7g+7P2hAk+WKiWWxhvun1DmLsXi jfD7hW5lnQEIZ088ajmfnP0D5jTpJSOQJ9wX27ZBMqTTDwOPZVapl4PjKHa6nMnxEyb5 XegIkd0adjWG87j9gBBNeKI8BGpYC2Y+pY3rcyv69QyhRHLV8pXfjp+GQLQq9/GGPjzz PEKKtYNT7DBk/FjcFde3RLqVOUjzEbBCSalReorrXmVu7Tyl1GFjHVwlDIdp1nF6756T ti97n6sjDsXQq9TVhDD9mZjQQWqrw3Notj+EgZpb5NexZoNkNAccG29JMn4omKFdATfJ 5bNw== X-Gm-Message-State: AFuF++mUFupViEApZaR0kXcvIjqcYZmy/mXHa9QxwSur2KX0KFQTMpa4 MZLoSMV1xe47IlVVvy62cVQMH6DnWq/0M8rtfNllpBqaRBzySfCW5tapOkP/OEJuBTsfK/Xcbek 9VdYWGY5Ptx1OL8FbQAahtO8NuuHF8Ky9qA4VpvHMSkzw/A65uNPt3p8w9dOd09I2D4VBmXvYBc N5QkKzqk/eIB3xSQ2Rcf35TWrlHFppXM0ylg== X-Gm-Gg: AYBFou2KOWOnAREwSkqu3EnvNh7vP39OaSJ6BY5mC4p2UE+dHvQjNjEZufDniK0HYf+ 3j6F70YyuPSgv1T1ilpdCxOk9KUUmKGDZ0h5anYEmKia/BtTClrd074+pxImTivcWjEAaYMi1WV ykfKwtN2L6NfDj8v+hq/FrqtJ52XNkzsN23QW5LU05j4C6J1vUTlyUtTxCjSL1qBPe2RRPy4pku IobDWDwM3/xeUqczAASW3pKDzk9l4sod6ISMzMyagsfpIb8p1hD0KvrNrvTIIPaBrUdne62Aa0F XOlgxS5BG0h7Gm/LXXKdNquNuuUh+2mTwNya1GXi5Y6im/C67DGcJuH/eIIrqCCYaJV0VjfH61n 0o1tSC/Mzmb3BgGrVDNtwzZ8= X-Received: by 2002:a5d:5e82:0:b0:485:8101:dc40 with SMTP id ffacd0b85a97d-486eb2d8278mr8393074f8f.9.1789117385592; Fri, 11 Sep 2026 02:03:05 -0700 (PDT) X-Received: by 2002:a5d:5e82:0:b0:485:8101:dc40 with SMTP id ffacd0b85a97d-486eb2d8278mr8392907f8f.9.1789117384948; Fri, 11 Sep 2026 02:03:04 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:02 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Alejandro Jimenez , Paolo Bonzini , Richard Henderson Subject: [PULL v2 44/75] amd_iommu: Return empty efr for stub call Message-ID: <85e4587c2b3000c1dd2626664741f1f27e297773.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117738859158501 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar The stub call should not return normal EFR as it is used as place holder when actual AMD IOMMU calls are not available. Hence return 0. Signed-off-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-2-sarunkod@amd.com> --- hw/i386/amd_iommu-stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/amd_iommu-stub.c b/hw/i386/amd_iommu-stub.c index d62a3732e6..fb36dee903 100644 --- a/hw/i386/amd_iommu-stub.c +++ b/hw/i386/amd_iommu-stub.c @@ -22,5 +22,5 @@ =20 uint64_t amdvi_extended_feature_register(AMDVIState *s) { - return AMDVI_DEFAULT_EXT_FEATURES; + return 0; } --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789118059; cv=none; d=zohomail.com; s=zohoarc; b=id5w15hpvloz4VaVWMUvlRqXXaUXWEUJSJZzaSE2F5H4ycE4eyknYAU8PKaS7Qxy1RUHXBPOmFS2HHRV9Abv+PVIz9vKyZ0gvGWRG5nRQab5sWOmslsUdkB9qxLDjFc3E51yzTMZVd/IQk13Aq2B7biTGnKPLp4NJdQj3z7PoQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789118059; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mBiB/jOHXjADUICu4zFhNVY6emnuWrVA0Kv/cK2oUiY=; b=AzxXeS/IN3eqvmVMuPQ1b9EeHpKlMkb39qdk2WrdaFVR7E81U/JRNXKnMN06todcGJ9e5M44bxKPp33N8JgvnTMGSQXiwQrwlPmZHW3FvzzsclDb3uhSfYmEK5GeXJvHwVYrqCo4+WloOo+T7Zea9IZbJb3ieEMOA5/B3+ZUl6w= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789118059653703.4939738549492; Fri, 11 Sep 2026 02:14:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAr-0005NT-6a; Fri, 11 Sep 2026 05:03:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xA9-0003yk-32 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xA7-0008H7-Kq for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:12 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-lu2vwWRsOBa2_FtQQQMWlg-1; Fri, 11 Sep 2026 05:03:09 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49e6683d48fso1175345e9.0 for ; Fri, 11 Sep 2026 02:03:09 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33fd3bsm4589243f8f.19.2026.09.11.02.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117390; 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=mBiB/jOHXjADUICu4zFhNVY6emnuWrVA0Kv/cK2oUiY=; b=VAI9wnxvEjP2DqmIBCS4EOC6BXJHfs3AZeszW0YvEUFq/3/lj5X9ArKqZPUWo3cocZHQWP hNczlOe1lBIZCJIZC8xvKEERPaJyEdwcHyi6L8ztxFMh2Wi++ri2vOJ2hIu+qhfCA3EH2E YACPUyiiwyGrBlTFJvtN/RPc2IIgyQY= X-MC-Unique: lu2vwWRsOBa2_FtQQQMWlg-1 X-Mimecast-MFC-AGG-ID: lu2vwWRsOBa2_FtQQQMWlg_1789117388 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117388; x=1789722188; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=mBiB/jOHXjADUICu4zFhNVY6emnuWrVA0Kv/cK2oUiY=; b=WbetaV+U3BEjHvAo6llIpU9R1OSf1pRpiXzkuzDgnkn/2juV4HUI1rL+EKuxtTNeLN Fc9IecOaWIeg5wBanjxOBJwt5pjWPfTPxQxI3CNpFYL1U981fpfKQwJ23kCAsMAcSA3K t4MtI8y087lpJHn/dSSQiXlO1rXNU+ZRyKIglNjAwVhj6BEdZfy2pyNn0VnkFd7usj9Q xFd7koLKh/rDm1Kh+oNbgIvnSReRQGbWVhpmJmgZj1OR6QE2Px9WZBUK2TncqIUbzn1T yq24Pq2/qb8hfASF4sme6Y5LfzLdWjhEBrkq9nXvsl8d0Kd4Q+mQFdPCgeLaPE/eYswW VV0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117388; x=1789722188; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mBiB/jOHXjADUICu4zFhNVY6emnuWrVA0Kv/cK2oUiY=; b=D5VNsEIGD6Lo57Q8YyRimFXtufZaDZhAemBoEpC6jgBNK+Pv3rToIF24woGjpiUddO 7b1xQRYB4JKVE7mbflXZI0kQsydA4qNGe+9/1WXwSwmhsEORoGsnKTGowM3s99IGQTpO C1x8hf8by98X5YB4Slkzz+jupzwvlMgDeCPzM0qhmhx4CdhReH2PGiidhyBZxujmGPC1 DcjkZ/ItkuWOjW9dmsFpINNpwLMTe51jrVV/VZ6LJ19cALaZxqL3WJt3U8u/w4h7NtBn 4dSzEOaQqfipnwgRTKHe+25kG6uKWUbo5qTmDCKoFTbb1Sw2gOFxh6Znio8BmP8NQdn+ 5IWA== X-Gm-Message-State: AFuF++k9Wf53YRcbiiZhRV3cTc3KdbYVFTOEB3mWdmZSrC++ehpJ5xMg coUmg5VyVggJUpH+W2cbOiyblUU93hTeQh0D6NNJTiIxB/aEtch4V0iQlwzHfyZZiX/vbE8Pe0q iqHH9ES4frr7cXEpYH7j4BAk6WGa3AIZ5zl0OXmmxeiBKFZlZEOHeGdYR1SWVCuIhJh43MVFlPI P5h4q9Uzew1Os/vowNOVx9TdieRmeChF5JyQ== X-Gm-Gg: AYBFou2s66E/OvoJJtNp1u+sIHE5RqdmNpFRBfBsyotta/uC1FJbXApmAUxH8r4ltcN MNctmV27fe0+LU4oaT+jXLWrSUyd66TuJ1wvUeSn4aGp5R/VHT8IZPmn9B8YToxVo1VY8U3fkF1 gHHc6/zvQwK1P78EJcQKlWxXWpkLoKACod16rY2ND1IONFz+AIIdkBt7F5HKnscTT0TlEV03Cco wW9RcogMCKBv35GbN0NXsoPEQapP4Y4augpHWpXUyj2FaizRW4zDj4SMFH8KSpjZ6kEdX9o49p3 7IREU9I1pFwpYn5+IVNqIAAw9FMa6AE02zM3C7OJqj4E1MxBwFNfVJDRGzQrQHTyLWVufLxh08g 8YM2swC21pwkiXNX2VlzA59Y= X-Received: by 2002:a05:600c:3484:b0:49d:433:c3b6 with SMTP id 5b1f17b1804b1-49e619d1eb8mr34384855e9.27.1789117388147; Fri, 11 Sep 2026 02:03:08 -0700 (PDT) X-Received: by 2002:a05:600c:3484:b0:49d:433:c3b6 with SMTP id 5b1f17b1804b1-49e619d1eb8mr34383725e9.27.1789117387249; Fri, 11 Sep 2026 02:03:07 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Igor Mammedov , Ani Sinha Subject: [PULL v2 45/75] tests/acpi: x86: Allow IVRS acpi table changes Message-ID: <324c0a70b9a3763d8b0df63929251e1e25264d39.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789118060518158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Signed-off-by: Sairaj Kodilkar Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-3-sarunkod@amd.com> --- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..33e9981655 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +tests/data/acpi/x86/q35/IVRS.ivrs --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117664; cv=none; d=zohomail.com; s=zohoarc; b=hZxOkVrqFQGvkPfTCwsgbqM596WjX+Nh2VWro2EJdlSQKYfxTHdCGbXvMM227B8OPjy2J24dZNmZH12qv9BFmHpjS2JPP9/g4JwxykmOEbp54lbjWzK9YoyHSiQucglv7kHsBa4JhrLohjQwtwRfBww2koAUb0tAp0r8+lQgNGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117664; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EbHgYTTTglQemO80px4rrB2L4uzTAs06wcqbum2Jp9A=; b=L5i5UCr9+BWehrUw3R5O2X4peo85xCBI/ID4O5rnZYqyKEkp06o3dGxgpLHI2HHgIYAppJG84+c4xaQ5qBzkhVA2le1JXr8j+69ld8fCGffIGQ5B0j6QKMVxmVF3+O7SlXaPFEiE+l6TEflE0bsPVsULZJ4m3UGIr3KMrSIBwxA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117664537211.57016583932625; Fri, 11 Sep 2026 02:07:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAw-00060h-RO; Fri, 11 Sep 2026 05:04:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAE-00049y-PV for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAC-0008Hi-Sh for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:18 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-655-ZJ6A67S3PmexFqgembDmDA-1; Fri, 11 Sep 2026 05:03:12 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-47d81cf0c4cso327102f8f.2 for ; Fri, 11 Sep 2026 02:03:11 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb34e4b5sm4622931f8f.22.2026.09.11.02.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117395; 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=EbHgYTTTglQemO80px4rrB2L4uzTAs06wcqbum2Jp9A=; b=YqYIGAdw3gmHkLEUUBUnUuBwLH6Nzpy60xc76rfrnxJf0Qc3sZtNpgLpA8oMhAv/4/hTOq Ic6Psr3QeMujq+IyslzuAiXkYRUzC5QnToUodW3Fh8iHoTXts3gq5tNl+oRtHznt56V8Rq DLyqoUa93rPGu5jSv1S5mH/upqWd+F8= X-MC-Unique: ZJ6A67S3PmexFqgembDmDA-1 X-Mimecast-MFC-AGG-ID: ZJ6A67S3PmexFqgembDmDA_1789117391 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117391; x=1789722191; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=EbHgYTTTglQemO80px4rrB2L4uzTAs06wcqbum2Jp9A=; b=BRP7bK6ruSppgclE5TnFkXMEh2Bzz3ckQLzouclkPhaFd8+zxMwP+071nBqxI19UlD khktFHaoVrnDwY/ZrMNAuLRCVcM3TjJOHbErBarqpeUozv+x1A0rGruPIWLx6BgJ8uIY k3XOgiHLEdolJceifxFaaXWdJjfRWiyjzhAdWcUAqPSDdY6oB0qQcvbr2RCTh99GdbVp sMVB8s7e7ajUAk7bL23tbr8lTbKJ+eaOLGjr5tdSiGuY5BQ6QhnNxz/6pBtvKBFDAg77 WZKliW/k9gC1Qof1Jls7CZd2QMbQDGR+U4GuUYUJIllz3XACKPgWYYkweiF73Mh5DGs3 FBtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117391; x=1789722191; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=EbHgYTTTglQemO80px4rrB2L4uzTAs06wcqbum2Jp9A=; b=KXo0fWnpao1H56uYXz34Gxsn9wzQVxUvBLXKijld647EtCRXsV/CdZRQCEQxYB7tFq AgwX9p4N2kAKfnTDX+SlmrFo+TcBMAmF37RqiTkc+3ufJzrnxL4XKJZGL1Pg1WsNJceU 9PupaABSmB2K7U7i6DvpE6Xh7UzrtoQQGeltLt+PWSGnExjrhyw//odwMHMJf+FnrQhk RYSUvCv8I59TX4rPuD0R3XSeB3cod5h4qLEDoT2g2cxQsxbixT0/lxE1fHVrlqTspEdv a1d1WWeQmebHED4J5g/xqd8Zz0q38Mx8ncw8UTqi7+zw0Lbph9d/gfKlM5v9FiEMvI9d 4y/w== X-Gm-Message-State: AFuF++mgoGDJ6BYX7DLngVbRAWjLqPi1glOu3rlVYEoaJ3oOhN3qnwOn 8aM0qEw6negwLdU6l3wXIFBGZLd7WYMsHI9+MC2J0dNfgav/PHCTATYyv1efrmnvptuA/ZntANP 1mySEr8Uni5zTKQjRqtGlB0IH3+IkAxmC7PpUNTmcm71fOTHR9Rt8Js9DWdvo9ll2nwLXT6TEiG FWGlPaO0DTI1F23GZWMzTWpGQds8x5ANXK+Q== X-Gm-Gg: AYBFou2HpQ7dwZpfx9XeBLj6SbgpGRI2iku9x7YJMpWIFXXCUzaWbU1/s69B0Yn24BR MqHQp4pLKY3Cc97hLgj14CIffRW9/RTES/jz7R7B5BD1VbhlyiqwWm7ET2P8O17/nCUMcnvZX9o 0vfO2stpykpUqX06vCDK6ThlNNeZrsu+SqDns+CxT1DeWQl1yD/4+RpVetE21cJDwQRZhIUrJ6d IqNdwcU9PLDezkqxe5oJRMOyWniGJbc8KqgD1ejWBBiwik/Ik7ZWmWsc5xpvOGVdFRbdqz0Tm40 ewcNgVDxCPj0ARF0cle/pqoHh/9czAYc5aC38EoMKGiYlMMt8u0hgK5wU+N1Jripk6UvtR2syxf Loi5clYtVssFHbLCggGXDIuc= X-Received: by 2002:a5d:64ea:0:b0:486:e91d:9f99 with SMTP id ffacd0b85a97d-486eb2e40c3mr7014909f8f.10.1789117390544; Fri, 11 Sep 2026 02:03:10 -0700 (PDT) X-Received: by 2002:a5d:64ea:0:b0:486:e91d:9f99 with SMTP id ffacd0b85a97d-486eb2e40c3mr7014734f8f.10.1789117389778; Fri, 11 Sep 2026 02:03:09 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:07 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Alejandro Jimenez , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson Subject: [PULL v2 46/75] amd_iommu: acpi-build: update PA, GVA and VA size macros Message-ID: <12e1b767b60a77da1c55749d72330ef733fd3e80.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117665889158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Current implementation supports up to 64 bit IOVA and up to 52 bit PA. Modify related macros so that guest can see right size. Also, use these macros to build the IVINFO field in the IVRS. Signed-off-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-4-sarunkod@amd.com> --- hw/i386/amd_iommu.h | 11 ++++++++--- hw/i386/acpi-build.c | 4 +++- hw/i386/amd_iommu.c | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 687691ec1c..d01f9b41df 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -243,9 +243,14 @@ #define AMDVI_PAGE_SHIFT_4K 12 #define AMDVI_PAGE_MASK_4K GENMASK64(63, 12) =20 -#define AMDVI_MAX_GVA_ADDR (2UL << 5) -#define AMDVI_MAX_PH_ADDR (40UL << 8) -#define AMDVI_MAX_VA_ADDR (48UL << 15) +/* + * IOMMU Capability Offset 10h: Miscellaneous Information Register 0. + * VAsize[21:15], PAsize[14:8], and GVAsize[7:5]. + * These fields use the same layout in the IVRS IVinfo Field. + */ +#define AMDVI_VA_SIZE_64 (64UL << 15) +#define AMDVI_PA_SIZE_52 (52UL << 8) +#define AMDVI_GVA_SIZE_48 (2UL << 5) =20 /* Completion Wait data size */ #define AMDVI_COMPLETION_DATA_SIZE 8 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1696821048..05b68d05a8 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1858,7 +1858,9 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, */ build_append_int_noprefix(table_data, (1UL << 0) | /* EFRSup */ - (40UL << 8), /* PASize */ + AMDVI_GVA_SIZE_48 | /* GVASize: 010b =3D = 48 bits */ + AMDVI_PA_SIZE_52 | /* PASize: 011_0100b =3D = 52 bits */ + AMDVI_VA_SIZE_64, /* VASize: 100_0000b =3D = 64 bits */ 4); /* reserved */ build_append_int_noprefix(table_data, 0, 8); diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 578c27ccbe..56e7815412 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -2595,7 +2595,7 @@ static void amdvi_pci_realize(PCIDevice *pdev, Error = **errp) 0xff000000); pci_set_long(pdev->config + s->capab_offset + AMDVI_CAPAB_MISC, 0); pci_set_long(pdev->config + s->capab_offset + AMDVI_CAPAB_MISC, - AMDVI_MAX_PH_ADDR | AMDVI_MAX_GVA_ADDR | AMDVI_MAX_VA_ADDR); + AMDVI_PA_SIZE_52 | AMDVI_GVA_SIZE_48 | AMDVI_VA_SIZE_64); } =20 static void amdvi_sysbus_reset(DeviceState *dev) --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117715; cv=none; d=zohomail.com; s=zohoarc; b=UuOzpOjRcRUsQCBjCxsQNo8AcAsk61CL5Scza9FIMX++5vPv5Vx4hnc9fPS3HJJ0mSvNHAg6b6cVOVa+3YrWCKf7yO7/r9LMgQkjjPlXoOdBANVd8z24jYcHOx8FpX2gVykHD4a37v+QTPDKh9RTJp/w2cOVaNjY2kie36WzWqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117715; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Moug1WmXO2CB2DYm8PmKZYdWRJM7GGO9/h6JXojQGEQ=; b=Wv/4qTQWOyxefE7wiBgAfGHCRIsZnIAbcEG7V041sKJ6NDIAJIAPSaJ1McBF53jpt30GWgBwmMI1oPjQFssO1vaT8iyQ6h73tDJKzJBQDdWeewaYHv3l7JLv+NRQXnFGc+56+7hxk4WeJc4nzcrt9b5Q7xMkQUe0xk6hWTTzaC8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17891177155141.734382261015412; Fri, 11 Sep 2026 02:08:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAt-0005hP-M2; Fri, 11 Sep 2026 05:03:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAE-00049x-IJ for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAC-0008Hg-SF for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:18 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-KlY7Ve_JMpa1YDEI3BxlVA-1; Fri, 11 Sep 2026 05:03:14 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49e635a6002so4482475e9.0 for ; Fri, 11 Sep 2026 02:03:14 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c2a419sm152277935e9.7.2026.09.11.02.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117395; 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=Moug1WmXO2CB2DYm8PmKZYdWRJM7GGO9/h6JXojQGEQ=; b=C7Ug589ABENeDLY602ihwO8CCG2bjtl/9tFleuVCPSx+HaivoYBYUxYnlYRuy5JVC9vz/U 14hQR0XRg/0waAAH5ZGswfy7d/eDO2r34qBoQxT6VPDzbd3+kahnpJ3dl+ib7fbzy7bhGL EmGZnZ1HA3YTH2WJjndnuYkEEibZM2M= X-MC-Unique: KlY7Ve_JMpa1YDEI3BxlVA-1 X-Mimecast-MFC-AGG-ID: KlY7Ve_JMpa1YDEI3BxlVA_1789117393 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117393; x=1789722193; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Moug1WmXO2CB2DYm8PmKZYdWRJM7GGO9/h6JXojQGEQ=; b=YT5L48t+DXawpf/tzLLA/Cx+1hl6rLxEaJ8xLYSNTOgR7NK8f1N6Rrybn3OxPk8aTX 34hFlqFQnVItwczMnGHz8D758vNliGz6uUbdI2CltAkvSFLDPiu+zBKejxeWFQaAWWlG ICKDv7bhS9SyYyI6PNyyqffubJNagrOlIbvKvYAx4P3voEI34iVbMUaDGndqNNHhYnTq OvPuP6bmH7WkTfx+37XZr4pPljSEEmB9bRpMsiuLbsjb2hoav0enbBrMAhxyE0hDPX8p AT51PAhqXQNSrTYJrIXS+jRTNzxEnz+DiQtqbQ+iuJhWqfkLfj6mECcxoBfp1k21tNtt FyAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117393; x=1789722193; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Moug1WmXO2CB2DYm8PmKZYdWRJM7GGO9/h6JXojQGEQ=; b=LfzZ86wJkbs0NJIn76WYBGvP16xkuSohXo3rjsrFZulCfz4pOWFVvsMe5iIi8D84/i ho5zlj09dD1PqRzuqi7FWx4voc8a3IM/gY+vzeJnDuhZzeTr2X+U+kmCj6SAR0VQFtmG XwTPLG66lnlkrZDmRoY9v+Y2vGKC8FqFhWUKa838TL2eaYiy6X7YjCq7a7WuSQzl6cuR 2WiNe4qsNHEomO8QCjRamjgekuUFhUmWhDtDb/C3J7z0GTf0B2xgiyzXhCJDFGBllrdb 9o44EMuOYhbKiLvvMP32eCBuqPFSXi09gi7BRlhvX9ooXGomhI3fcJIXkzocMqaeeOt/ Hhqw== X-Gm-Message-State: AFuF++leZc2YE0G6Bs8Mi7fLQ7agvc4oBsz/8HeculIOyimCAyTbdIIi Ve37dJCysR2RwtylNzHNp057IiERGeuVhOCtHcDMrtPmkriiWOGUyS5d6fsLdphLUSnpNaDsBCG a+SfC1rWHfEu5cS4Xe4aCEyOP72FmLF4xllYqUWFdKfDnHq/Pqm6mu91TSG2+5jlHRQmLjBKeD9 7z7bU1ewfZrI5eEz1MjhX5GTVvRvqmuRynOw== X-Gm-Gg: AYBFou2gsAMI2+y9rypJWwiBksVVZCbNO62Gf2oQ0rARuLgpXB+52Nyand2BGDobd81 l6l0h1DJ/aZckrKjusH5adM5vsVA/UpPjWQbTYZRDIlkV1OruWNHBPAKrLret3M+M5ILR2NbuFD SGSm9ySO0RJ+MtLNdaeN2dGEaon057Ly9n+MKRH9Dy+IzKxi2bhJ05UjuBOMqV4b8EZ9X1TdUcW G5KoofbcViTonB8xRtGTNy1SPretzrGscDU63eH89Uhw6zmGLAs52q0kzN8Y7L7z/LwmH/c+wQI IOv0RRk/8td0cD2Z5viEpho4KMQahkMv+UxARCb1zbmmYWWtSgC6Xc9R0QBTW5KWwd37LYK6g+a PGJC6djEuqTBjTj6Z3BbaW8c= X-Received: by 2002:a05:600d:6501:20b0:495:48d7:f178 with SMTP id 5b1f17b1804b1-49e61988e73mr24438595e9.11.1789117392817; Fri, 11 Sep 2026 02:03:12 -0700 (PDT) X-Received: by 2002:a05:600d:6501:20b0:495:48d7:f178 with SMTP id 5b1f17b1804b1-49e61988e73mr24437855e9.11.1789117392136; Fri, 11 Sep 2026 02:03:12 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Alejandro Jimenez , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson Subject: [PULL v2 47/75] acpi_build: Use IOMMU pci device to build IOMMU DeviceID Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117716025158501 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Currently, build_amd_iommu() uses "addr" property to build the DeviceID for IOMMU device and advertise it through IVRS. But this property does not enco= de IOMMU bus number, only the device and function number. This creates an incorrect DeviceID when the IOMMU is attached to a bus other than the default one with bus number 0. Signed-off-by: Sairaj Kodilkar Reviewed-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-5-sarunkod@amd.com> --- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 05b68d05a8..a28bb2ec63 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1851,6 +1851,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, AcpiTable table =3D { .sig =3D "IVRS", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id }; uint64_t feature_report; + uint16_t iommu_devid =3D pci_get_bdf(&s->pci->dev); =20 acpi_table_begin(&table, table_data); /* IVinfo - IO virtualization information common to all @@ -1913,9 +1914,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, /* IVHD length */ build_append_int_noprefix(table_data, ivhd_blob->len + 24, 2); /* DeviceID */ - build_append_int_noprefix(table_data, - object_property_get_int(OBJECT(s->pci), "add= r", - &error_abort), 2); + build_append_int_noprefix(table_data, iommu_devid, 2); /* Capability offset */ build_append_int_noprefix(table_data, s->pci->capab_offset, 2); /* IOMMU base address */ @@ -1947,10 +1946,9 @@ build_amd_iommu(GArray *table_data, BIOSLinker *link= er, const char *oem_id, =20 /* IVHD length */ build_append_int_noprefix(table_data, ivhd_blob->len + 40, 2); + /* DeviceID */ - build_append_int_noprefix(table_data, - object_property_get_int(OBJECT(s->pci), "add= r", - &error_abort), 2); + build_append_int_noprefix(table_data, iommu_devid, 2); /* Capability offset */ build_append_int_noprefix(table_data, s->pci->capab_offset, 2); /* IOMMU base address */ --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117784; cv=none; d=zohomail.com; s=zohoarc; b=MRxN0dgjmg+kYyuU85XD8MGxhNSbqLA48FIH/BOwqdh4CwzDE3UXCVRsF3O2JspLSPGUkroEYQRID4JqsNtbUngSQe7k11LFzFiNX1L+LDCn0FzjWPQk3g/oURmRMi8bmJVTGgjjBFLgpGA3ngl/2QNWB9QKu7Aly2C1NQmu4rA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117784; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PWQxLCtaF9Z/qhP7GNgCPFbg0LbmSSJO7NpN+DpDut8=; b=mt9xVJzERd5BwN86SX+sCGhy7qY9K7j4Oav++gzE1oBGqon3yjMAhNh9lABlh2vC3JqDiKLLZuazL202JSd3AFzP5XyxfAY1j+WEx2hIwVGCdy0+kC4g9qCVlsBO5W2z15eYYZNE4MbFzx1EVlds6+9EYsalvDygyI6Mo57R6jY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178911778424287.49336180240755; Fri, 11 Sep 2026 02:09:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAv-0005qj-9K; Fri, 11 Sep 2026 05:04:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAI-0004I3-NV for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAG-0008IH-K6 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:22 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-227-k2vySDC3OZulp23l022kQw-1; Fri, 11 Sep 2026 05:03:18 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490a767b782so5965195e9.2 for ; Fri, 11 Sep 2026 02:03:18 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e35sm134873165e9.2.2026.09.11.02.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117399; 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=PWQxLCtaF9Z/qhP7GNgCPFbg0LbmSSJO7NpN+DpDut8=; b=S7rYXnPBvvGsMLWdGNRhKO/Dr2nZ5AWVfi5nbUhw6f1LM8hkAw0cg17P7lALybX5akWmSd 3DQH4D/khEEAsucGHIBlRCZEETGC+g/uXbHlq8n0TGVsF3JNYYWahD7QHiZQazV/sJMJPn oxeK1d6EBP5p4YSSswa8QzSX8+HA6hY= X-MC-Unique: k2vySDC3OZulp23l022kQw-1 X-Mimecast-MFC-AGG-ID: k2vySDC3OZulp23l022kQw_1789117397 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117397; x=1789722197; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=PWQxLCtaF9Z/qhP7GNgCPFbg0LbmSSJO7NpN+DpDut8=; b=h9AWcvLVnEJHKJitR2dVAZlSwliADp89SH0FFYmhpSny5q8aLv2M2jDaiuFyJkIhJJ BQEUck7lTys3tg9CieQ5jA+bi7jGTrEqufzl5ZSJxUuCMOoY8kFjv7j2swcEPbUKZS6Z Zrn9fu+fcrODilQ+t8PGDOq0Iqj1daJMyKGNxepC7nyrByn3oBfm1oKiGIs6uo9QIZJU Nk19/dqq7nDa+OIwWt6N/kP/nypUZhnxZQ0adlaPqvezS2hdR54QHLoJzd23XmlW7aP2 ljaKyFvabWd0ayD741DyCoceEhmU2nCvMeBs/CYc7nWlcKQnMbX/2Yz8U3Ki2jjcPFUm 7qZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117397; x=1789722197; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PWQxLCtaF9Z/qhP7GNgCPFbg0LbmSSJO7NpN+DpDut8=; b=MSGxohPWsPn9DQJbzp2r3rVFnumtkwynIl+kRg56EBtAZzaeDTWoODth7aCTm+YAPE ba5SPvuq+Hq0KjgTioPvzbDLPd12DvNVkCj31E2+qHaLpfJk1NiLLEkjmMngLnzXf0hk r+RUipr+RHFVmpgsj86NGAfeszObb5uCBGNRDnD8BycF7lO7atmVpKG1r0cT/XwH2xcn wXDLlIccw+tOxVi3wVznF3NEsx37yC5iQT74wPVAhVVyer/eLKbCYaudINHb1xY9SXNg vYUqv49GLf4GCuK7ooJdHD50z3P2FuRgZM2neXhYsCIpKuPXJ/wTyuqL3U/tMdbLY+ve LvHg== X-Gm-Message-State: AFuF++k5Ozrzeej5A0N40r6g5vtAfopwTiZtS5ajjsk3VgB0WFREzQY9 +OE2mubYVUd6X9x/oFYrLsPzBMbCIgKHNqiv3lXuuXm+04gfPCVEJLYlto+Ce5CuTXGIk+QPWWs 9P4HiSDnshUMIFmQQemYQy+eMGrGjdEihe50sStkTPw0WqdGuH6pqIARbR87LddGt9+FiyNzSMM 438PE+d7mQG6DcweD2V1PsF2ls7w== X-Gm-Gg: AYBFou3+yjpZagDGD+QoisPe+QpuyFoNvF+/vP5aOIeodLebTZIf8lSHgGmMB6hRhnO NjYwn76adIv/kzDzv32tadAeW3Ho46E8UEP3KR3mMMnpo099hZMFLV3s+7cp3wh9M6vDp2P9ebq WjuZRnbpdiULmag2q0V5gR3RpJ2QZ22xCAFp/ZFWtMxVackKcAUvyhaVQhiFE4lWnnXWZBuIiID AXNirEU3LDRzo0/VNNrrO0Fpc2OnS9hbAr5ha7sH+zCGw8XbEpvjQUUxX+JcB1hvg23IVJMCowy H41FgKd5LZlQWyEPF239XX8Xr+u+pk7HeBGF3rbyIu5/aRhP257IlBRa2SEDPxNO X-Received: by 2002:a05:600c:6296:b0:49d:191b:88be with SMTP id 5b1f17b1804b1-49e6164a26dmr34354095e9.0.1789117395134; Fri, 11 Sep 2026 02:03:15 -0700 (PDT) X-Received: by 2002:a05:600c:6296:b0:49d:191b:88be with SMTP id 5b1f17b1804b1-49e6164a26dmr34353445e9.0.1789117394459; Fri, 11 Sep 2026 02:03:14 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Alejandro Jimenez Subject: [PULL v2 48/75] acpi_build: Build IVRS feature report using extended feature register Message-ID: <7dbb1e91e35020245c24e5d911e00cce2a7bac1c.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117785059158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Currently IVRS feature report values are hardcoded, this is difficult to maintain as any updates to extended feature must be synced. Along with it, current feature report does not have GATS and HATS set. Hence use the extended feature registers to build the IVRS feature report. Signed-off-by: Sairaj Kodilkar Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-6-sarunkod@amd.com> --- hw/i386/amd_iommu.h | 11 ++++++++++ hw/i386/acpi-build.c | 48 +++++++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index d01f9b41df..319db18618 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -174,7 +174,11 @@ #define AMDVI_DTE_QUAD3_RESERVED (GENMASK64(14, 0) | GENMASK64(53, = 48)) =20 /* AMDVI paging mode */ +#define AMDVI_GATS_MODE_SHIFT (12) +#define AMDVI_GATS_MODE_MASK (3ULL << 12) #define AMDVI_GATS_MODE (2ULL << 12) +#define AMDVI_HATS_MODE_SHIFT (10) +#define AMDVI_HATS_MODE_MASK (3ULL << 10) #define AMDVI_HATS_MODE (2ULL << 10) #define AMDVI_HATS_MODE_RESERVED (3ULL << 10) =20 @@ -296,6 +300,13 @@ #define AMDVI_DEV_LINT0_PASS_MASK (1ULL << 62) #define AMDVI_DEV_LINT1_PASS_MASK (1ULL << 63) =20 +#define AMDVI_IVHD_FEATURE_REPORT_HATS_SHIFT (30) +#define AMDVI_IVHD_FEATURE_REPORT_GATS_SHIFT (28) +#define AMDVI_IVHD_FEATURE_REPORT_GA_SUP_SHIFT (6) +#define AMDVI_IVHD_FEATURE_REPORT_IA_SUP_SHIFT (5) +#define AMDVI_IVHD_FEATURE_REPORT_GT_SUP_SHIFT (2) +#define AMDVI_IVHD_FEATURE_REPORT_XT_SUP_SHIFT (0) + #define TYPE_AMD_IOMMU_DEVICE "amd-iommu" OBJECT_DECLARE_SIMPLE_TYPE(AMDVIState, AMD_IOMMU_DEVICE) =20 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a28bb2ec63..7bf3858b63 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1842,6 +1842,37 @@ ivrs_host_bridges(Object *obj, void *opaque) return 0; } =20 +/* + * IVHD type 0x10 reports features using Feature Reporting field, which has + * different format than extended feature register (EFR) in the IOMMU MMIO + * space. + * + * Convert the EFR format to feature reporting format. + */ +static uint32_t +get_amd_ivhd_feature_report(uint64_t extended_feature) +{ + uint32_t feature_report; + uint64_t hats_mode =3D (extended_feature & AMDVI_HATS_MODE_MASK) >> + AMDVI_HATS_MODE_SHIFT; + uint64_t gats_mode =3D (extended_feature & AMDVI_GATS_MODE_MASK) >> + AMDVI_GATS_MODE_SHIFT; + uint32_t is_ia =3D !!(extended_feature & AMDVI_FEATURE_IA); + uint32_t is_ga =3D !!(extended_feature & AMDVI_FEATURE_GA); + uint32_t is_gt =3D !!(extended_feature & AMDVI_FEATURE_GT); + uint32_t is_xt =3D !!(extended_feature & AMDVI_FEATURE_XT); + + feature_report =3D + hats_mode << AMDVI_IVHD_FEATURE_REPORT_HATS_SHIFT | /* HATS[31:30= ] */ + gats_mode << AMDVI_IVHD_FEATURE_REPORT_GATS_SHIFT | /* GATS[29:28= ] */ + is_ia << AMDVI_IVHD_FEATURE_REPORT_IA_SUP_SHIFT | /* IASup[5] = */ + is_ga << AMDVI_IVHD_FEATURE_REPORT_GA_SUP_SHIFT | /* GASup[6] = */ + is_gt << AMDVI_IVHD_FEATURE_REPORT_GT_SUP_SHIFT | /* GTSup[2] = */ + is_xt << AMDVI_IVHD_FEATURE_REPORT_XT_SUP_SHIFT; /* XTSup[0] = */ + + return feature_report; +} + static void build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) @@ -1850,8 +1881,8 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, GArray *ivhd_blob =3D g_array_new(false, true, 1); AcpiTable table =3D { .sig =3D "IVRS", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id }; - uint64_t feature_report; uint16_t iommu_devid =3D pci_get_bdf(&s->pci->dev); + uint64_t extended_feature =3D amdvi_extended_feature_register(s); =20 acpi_table_begin(&table, table_data); /* IVinfo - IO virtualization information common to all @@ -1924,14 +1955,9 @@ build_amd_iommu(GArray *table_data, BIOSLinker *link= er, const char *oem_id, /* IOMMU info */ build_append_int_noprefix(table_data, 0, 2); /* IOMMU Feature Reporting */ - feature_report =3D (48UL << 30) | /* HATS */ - (48UL << 28) | /* GATS */ - (1UL << 2) | /* GTSup */ - (1UL << 6); /* GASup */ - if (s->xtsup) { - feature_report |=3D (1UL << 0); /* XTSup */ - } - build_append_int_noprefix(table_data, feature_report, 4); + build_append_int_noprefix(table_data, + get_amd_ivhd_feature_report(extended_feature= ), + 4); =20 /* IVHD entries as found above */ g_array_append_vals(table_data, ivhd_blob->data, ivhd_blob->len); @@ -1964,9 +1990,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, build_append_int_noprefix(table_data, 0, 4); } /* EFR Register Image */ - build_append_int_noprefix(table_data, - amdvi_extended_feature_register(s), - 8); + build_append_int_noprefix(table_data, extended_feature, 8); /* EFR Register Image 2 */ build_append_int_noprefix(table_data, 0, 8); =20 --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789118079; cv=none; d=zohomail.com; s=zohoarc; b=PI8gqvlUIf5zbnTrVp7QH1QjD8+FAxe7hp/fifVCQRkkbOWzPV3UwX0a9tGLOqlUUooul6hB5GDDSuKNYpGXWvK6ndny0OtkqXvOhyGfCk+h9mvoEOI0aoq74lkpVm3er/jeG7HWOtCgX3yXmTEx6nSnheeySL5jF92L5WClW4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789118079; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4xO9Jj7yHXJpXhsIddL9LHeTxBWYycN9Rwv/iB+IGEU=; b=O+phAzn4qkd9fxYrXNgsLtVTZV+c0/cea5GUgSWX9wPEm+mkM71ytQdOqxWQN5ngaAtA8FyKStUQHqRluB4Nc4MkjjWoZqEylcXVybvqAlKuVRmFPfukA8NzPuH05+IuKZGUbxTSxkPypM84WaH9wGxlBnQZSEShYH/TbCItP9k= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789118079578289.21292792857014; Fri, 11 Sep 2026 02:14:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAu-0005mq-LV; Fri, 11 Sep 2026 05:04:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAL-0004Jj-B2 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAH-0008IN-0R for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:23 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-248-ndqtfExFNKiVrNOKUf7uPA-1; Fri, 11 Sep 2026 05:03:19 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4957287363bso4192205e9.0 for ; Fri, 11 Sep 2026 02:03:18 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26c2985dsm239150075e9.6.2026.09.11.02.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117400; 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=4xO9Jj7yHXJpXhsIddL9LHeTxBWYycN9Rwv/iB+IGEU=; b=IsKiX4sQwz7hA0kVHtA5y07S4V/PFDhp3NSDxhp/BzvbpYu3j5T7bgv5GO3cIezLIN4S+Q W7SixhH2eBWDonwU7zm/VJfhN0Prr7ZMgCJr6jDDqC12mEUfuJBPfer0yi2Dh+jZSUZqLQ 6HqRqUyMElc5700viIHJUmjC+0uBMKk= X-MC-Unique: ndqtfExFNKiVrNOKUf7uPA-1 X-Mimecast-MFC-AGG-ID: ndqtfExFNKiVrNOKUf7uPA_1789117398 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117398; x=1789722198; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=4xO9Jj7yHXJpXhsIddL9LHeTxBWYycN9Rwv/iB+IGEU=; b=JE6Z4oBYed1n4UjeeLzWZKfq5rMuF3+SQ7Cj0bLjGfAjwo4VrTJGGc5jXCadWuWi9I TbKJ8uGM7DbRzr/n9twCVqB+F2xCh2/lDkQjTNl+5ef/c0rKchWyq/l6L+FNEet19ezb tOqWm16CZzH0IqXawDcZW8d4Lbr5p5nLbL6O4Xfyv6CQZSDNXCtnSJHUq7XKFnRkNXD2 UE2UhBNZwFDFJUJuw/Z0xid+iWN+TwAO2j+5lyRdGrry7ZZToR8MVJNyCzR+ZOm+68Wm Y5M7CjLFuVC/48VioorVe2QU0UkwuYK+e8PAk4cVc+AOUKMvAfncgCc5fFTz4dO60a3V PkiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117398; x=1789722198; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4xO9Jj7yHXJpXhsIddL9LHeTxBWYycN9Rwv/iB+IGEU=; b=sDuSAhDvxoItlJxk4m2Gw8NeThAhCxPe6HeUOdK/M+PRus+lj4h4pcKDoTeapb2N3G u1xUDXUAvT8aVWzqq8fAfv2GAFmOr8RYWmBW814Fvc4dIzcWdEXcFmAiW342ZUwmJdTD o60p3g5DLYSE4PVNY9popfmA4tmcSm+2EXawgC8ezRSX32EX3JBPgMj/j9Lj9gtzdxaP sZXi37pnrk4qkyObc9QzLbNtNy4qEhP8/42kIRr/BwubLIhRSsekDQamC+T7WnQXa/yn 98ipg6JmDadX5E5IRxCt2kY5FZXFWa89Me81JiroJT05XwsIWv1b1Ql9a2H38ZVHVLMf r9wg== X-Gm-Message-State: AFuF++m4gki1lPQgxlPExc8WnazyyImicpu04RFsh9J15D/DYqExQwqW Y/FJCHRqN9+iUDa3j9yvaAFPsr+b9VoRVVgokaekbYj8E+/JrJDCutTDfJmJQ0zfN29Qc+NTWfo BVIKJHRwi3n/HUzYItMssTJ5Xpo3d+bHY4UFqz9mUcrdgfzY3z+qBntGeFUVQJ1bzuK3GLLrx0w jkPYH4I2B16Hvk1Z8hsoGGx+A50y0qIWGZuw== X-Gm-Gg: AYBFou0dzr+pK6wY5ooHWUtXIsAQGLH6VY0z4bM3/SAs+/Dzt8nrxzxVZTGj2ZN+NbT sQoWUuel3BuHX94yIIstq9mxN11cemOJ6ul/i8nRplb4QPjRNHBvcnerjJBsaGT+ptLJuF9ngPX blrdwss/3XogSdOyN6r13PPAuKzSWeFAAqAW7k6bD12hsr+KRnwk0iv82u/a6hajB8nEUYiI0BL dP35MDkfYlN/b1GKId7NPwQ+CdiLyZ5INqy7YP3yZg1eZPKoNrrxVmrNLWOYkbPjbFKjoecSPQA a5D7QAKcsdGJCF4oC4Br38ey3GBzvb65hoRw3KDREXv1nr21w5P1jEyHihzhFErqL/zpQBDAXEV gwfsN4GlibJhyEfff4hpIlSY= X-Received: by 2002:a05:600d:8496:20b0:499:8aff:59b6 with SMTP id 5b1f17b1804b1-49e6199234amr23189565e9.14.1789117397583; Fri, 11 Sep 2026 02:03:17 -0700 (PDT) X-Received: by 2002:a05:600d:8496:20b0:499:8aff:59b6 with SMTP id 5b1f17b1804b1-49e6199234amr23188735e9.14.1789117396753; Fri, 11 Sep 2026 02:03:16 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:14 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Alejandro Jimenez Subject: [PULL v2 49/75] amd_iommu: acpi-build: Remove unsupported PPR and HE feature Message-ID: <95d03f5268980e31042d8d0b7e595c66e286f1d8.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789118080523158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar AMD IOMMU does not support ppr and hardware error registers. Hence do not publish these features to guest through extended feature MMIO register and IVHD 10h flags field. Signed-off-by: Sairaj Kodilkar Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-7-sarunkod@amd.com> --- hw/i386/amd_iommu.h | 5 ++--- hw/i386/acpi-build.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 319db18618..c5b346cc35 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -227,9 +227,8 @@ =20 /* default extended feature */ #define AMDVI_DEFAULT_EXT_FEATURES \ - (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_PPR | \ - AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | AMDVI_FEATURE_HE | \ - AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA) + (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | \ + AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA) =20 /* capabilities header */ #define AMDVI_CAPAB_FEATURES (AMDVI_CAPAB_FLAT_EXT | \ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 7bf3858b63..6d7308b4e4 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1938,8 +1938,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, build_append_int_noprefix(table_data, (1UL << 0) | /* HtTunEn */ (1UL << 4) | /* iotblSup */ - (1UL << 6) | /* PrefSup */ - (1UL << 7), /* PPRSup */ + (1UL << 6), /* PrefSup */ 1); =20 /* IVHD length */ --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117445; cv=none; d=zohomail.com; s=zohoarc; b=K8KTHSFLfs9E05mee336yrcYwR/xFopM6cqhTJKAW0aWITegiv3al4P96T658D+6kjQTztBg9p6QdgBsmUbWg8wfXXmwW/YbXBqEesfxF2loNIfA7tdaoASQW+GmfoN5jzz+9D5Eht7xFxoInSj/aKaHWcAzlz2KklXjE5fQj8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117445; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=s25v9MuORRs6iYLVe6PGLtMBi7BEybbRfKrSYsEB5hA=; b=CWBapJmAinIO0+XTc1+pflILkdZadOc/Ls/yO2pzJUx0EibEb4Efs5GQ+zipEOV+Lway7oIXSZp0yTuX/5WjmaoqPjw4Sr0GoB7TqjenvI6W7h8yA01ZlMAbUnKU8fIgyAW4haH+BLwlHomD47HXWRDiArU37PJ1fYD43XD7qvI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117445088659.1902570778485; Fri, 11 Sep 2026 02:04:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAo-000558-GN; Fri, 11 Sep 2026 05:03:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAS-0004PI-5o for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAL-0008Io-Ex for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:29 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-5s_-HDuDMqCSPDhhzWlGTw-1; Fri, 11 Sep 2026 05:03:23 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49e65f2f1baso1787065e9.3 for ; Fri, 11 Sep 2026 02:03:23 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e35sm134877635e9.2.2026.09.11.02.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117404; 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=s25v9MuORRs6iYLVe6PGLtMBi7BEybbRfKrSYsEB5hA=; b=aZEJ3ZblGs7K6WWM0SfwMONlR9StFkFnsty0S9pKmzreMkvwYpJXeg4H3XiH4DJjsAsXd3 7aii3Wzy/N7vod+VMzIadbj0vd0WwL2KL6wcrzJKV1TipcZM3rphgsyzMY7NujgEKCmbg7 +IqYbZhbQWcyxNAi9XXb/mHhrysGBng= X-MC-Unique: 5s_-HDuDMqCSPDhhzWlGTw-1 X-Mimecast-MFC-AGG-ID: 5s_-HDuDMqCSPDhhzWlGTw_1789117402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117402; x=1789722202; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=s25v9MuORRs6iYLVe6PGLtMBi7BEybbRfKrSYsEB5hA=; b=ctWSu0mj/bHOnvVUPPUp3g8HZAvQnps/o+D8a2qS6y6DJryBund4+NCkIrAV8m/BsB W7PV1fZ1DQQVaM4yo+3nUpycUcDPm/luwKQjEQ9GX98x/UDwcjy+zEH6bC2O1zizZsu3 Y8RFGJmBNlCviCUikxdnrTxXY9Tcve+wQeHK3On6cKeN4b5+2qwCzOJ7PSEm0FRc7CtI uQhHR5FbtPpUDvlG6En406C45SFHAb/9TJLbEN1ENVAFkroGVAesj8BLQlysFD0Y7ga/ WubLgmZrxe94jiPiJdJ/98liH2EroVx99NNgxo6fTtbc01V/dbLUN2zBD+c5Jdz35snl DKCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117402; x=1789722202; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=s25v9MuORRs6iYLVe6PGLtMBi7BEybbRfKrSYsEB5hA=; b=IB2Dp71z5XQBOoXEgf/YXVbj+u/CZz33fE3aF4uCDTzD9H3kLEk6b0FXRBnr9jj02P qhM7XowUNVE4edNcKRjv7Aipf8SYm2sjj4xr/t/Xtj2fkKlqJqPELs03Dt1aiXF/Axks Rq9x9MLooBHwO2cHB8px4j+i+lSMRWkOIqdbCVhsbXr4znJWxQplVPhzFdNs5pDL19qp rR75wEd/6yBBlek3pSRCHLJB4PyRUE1ipvJzQSqb+tWx28XbwpneEf/NCiSiqaZtAN5A JFyfugWs0okY3jVQ119EjzXj7IcOqn18xn+baGDEWUTZasMbExVmVFWvlqfR0/SIFvr2 dFbQ== X-Gm-Message-State: AFuF++kgETkUFlggUn83rbb5WRV+32i6v9WRcvwTI6DwY8uWGzdMlZq7 Xc7Hr0Dq9bzs+yjAuV+mLlMwCyWdQBvPSUSoLi/89r98AFVPlCKIUnIPcL3F6fZ02VAi2PJ3SCQ TfD5sysNirFkbTDN8I159MdG4NmU1z0AcJec9rKtIv2+i7vvc0lDux+C3R0n/C5iMJZX5qgU3oE n0vNhlkE+dinIMeUuEp2gWzuD/9eCDrC9/sQ== X-Gm-Gg: AYBFou2IDuWaqCjyOwpx4WNkET6cO2S50UpmbNXAK6unuTyLf/3EkCXG4RGP9EZnNug GdgtPLlihf7A4rl8wuxKP8+0ipxBZR+OLE8MsCCd7ouTHWAY1hzFRh1FC3JdmYqb8xbs/JGkjfS PL8xH/vYv37rKjOEXy9UlW++0XO13vGnpfCB7BVuQB/7LRH0tDyDnKXnLAHrPvIM+ak+V2jRexi QWhTR6uDKq1KBmBCFZ66MUwgqAof5M51gZDkzA0Z6gvYDsbqCy4FLjGx4aH8YdF5uVmCjKlAogi P24Z7s779yERH5Xd17IxtUzLm3HSEA8oc2WSe4+vZ9ivtfwHXBpDmkwFQtRI7NXfDcyvjaWcz7l KNZoGYmCCO7Keg/t5FxrQens= X-Received: by 2002:a05:600c:3acb:b0:49c:dcec:bd27 with SMTP id 5b1f17b1804b1-49e61987ecfmr34418735e9.8.1789117400688; Fri, 11 Sep 2026 02:03:20 -0700 (PDT) X-Received: by 2002:a05:600c:3acb:b0:49c:dcec:bd27 with SMTP id 5b1f17b1804b1-49e61987ecfmr34416985e9.8.1789117398927; Fri, 11 Sep 2026 02:03:18 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sairaj Kodilkar , Igor Mammedov , Ani Sinha Subject: [PULL v2 50/75] tests/acpi: x86: update golden masters for IVRS Message-ID: <51bb6779c0d0b106ef1f283acacb6d9a4d8d0374.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117446390158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sairaj Kodilkar Differences between disassembled ASL files for IVRS: /* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20200925 (64-bit version) * Copyright (c) 2000 - 2020 Intel Corporation * - * Disassembly of tests/data/acpi/x86/q35/IVRS.ivrs, Mon May 11 11:21:47 2= 026 + * Disassembly of /tmp/aml-NGQ9O3, Mon May 11 11:21:47 2026 * * ACPI Data Table [IVRS] * * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue */ [000h 0000 4] Signature : "IVRS" [I/O Virtualizati= on Reporting Structure] [004h 0004 4] Table Length : 000000B0 [008h 0008 1] Revision : 01 -[009h 0009 1] Checksum : 74 +[009h 0009 1] Checksum : CB [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPC " [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001 -[024h 0036 4] Virtualization Info : 00002801 +[024h 0036 4] Virtualization Info : 00203441 [028h 0040 8] Reserved : 0000000000000000 [030h 0048 1] Subtable Type : 10 [Hardware Definition Blo= ck] -[031h 0049 1] Flags : D1 +[031h 0049 1] Flags : 51 [032h 0050 2] Length : 0038 [034h 0052 2] DeviceId : 0010 [036h 0054 2] Capability Offset : 0040 [038h 0056 8] Base Address : 00000000FED80000 [040h 0064 2] PCI Segment Group : 0000 [042h 0066 2] Virtualization Info : 0000 -[044h 0068 4] Feature Reporting : 00000044 +[044h 0068 4] Feature Reporting : A0000064 [048h 0072 1] Entry Type : 02 [049h 0073 2] Device ID : 0000 [04Bh 0075 1] Data Setting : 00 [04Ch 0076 1] Entry Type : 02 [04Dh 0077 2] Device ID : 0008 [04Fh 0079 1] Data Setting : 00 [050h 0080 1] Entry Type : 02 [051h 0081 2] Device ID : 0010 [053h 0083 1] Data Setting : 00 [054h 0084 1] Entry Type : 02 [055h 0085 2] Device ID : 00F8 [057h 0087 1] Data Setting : 00 @@ -62,33 +62,33 @@ [061h 0097 2] Device ID : 0000 [063h 0099 1] Data Setting : 00 [064h 0100 1] Handle : 00 [065h 0101 2] Source Used Device ID : 00A0 [067h 0103 1] Variety : 01 [068h 0104 1] Subtable Type : 11 [Hardware Definition Blo= ck] [069h 0105 1] Flags : 11 [06Ah 0106 2] Length : 0048 [06Ch 0108 2] DeviceId : 0010 [06Eh 0110 2] Capability Offset : 0040 [070h 0112 8] Base Address : 00000000FED80000 [078h 0120 2] PCI Segment Group : 0000 [07Ah 0122 2] Virtualization Info : 0000 [07Ch 0124 4] Attributes : 00000000 -[080h 0128 8] EFR Image : 00000000000029D3 +[080h 0128 8] EFR Image : 00000000000028D1 [088h 0136 8] Reserved : 0000000000000000 [090h 0144 1] Entry Type : 02 [091h 0145 2] Device ID : 0000 [093h 0147 1] Data Setting : 00 [094h 0148 1] Entry Type : 02 [095h 0149 2] Device ID : 0008 [097h 0151 1] Data Setting : 00 [098h 0152 1] Entry Type : 02 [099h 0153 2] Device ID : 0010 [09Bh 0155 1] Data Setting : 00 [09Ch 0156 1] Entry Type : 02 [09Dh 0157 2] Device ID : 00F8 @@ -98,27 +98,27 @@ [0A1h 0161 2] Device ID : 00FA [0A3h 0163 1] Data Setting : 00 [0A4h 0164 1] Entry Type : 02 [0A5h 0165 2] Device ID : 00FB [0A7h 0167 1] Data Setting : 00 [0A8h 0168 1] Entry Type : 48 [0A9h 0169 2] Device ID : 0000 [0ABh 0171 1] Data Setting : 00 [0ACh 0172 1] Handle : 00 [0ADh 0173 2] Source Used Device ID : 00A0 [0AFh 0175 1] Variety : 01 Signed-off-by: Sairaj Kodilkar Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260807061250.27739-8-sarunkod@amd.com> --- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/x86/q35/IVRS.ivrs | Bin 176 -> 176 bytes 2 files changed, 1 deletion(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 33e9981655..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,2 +1 @@ /* List of comma-separated changed AML files to ignore */ -tests/data/acpi/x86/q35/IVRS.ivrs diff --git a/tests/data/acpi/x86/q35/IVRS.ivrs b/tests/data/acpi/x86/q35/IV= RS.ivrs index 7f9e91aabc0b7777a7efc9f219587a4f91f0edb1..b3b809c65f026fde0a49a2243a3= 216e7b8c87502 100644 GIT binary patch delta 67 zcmdnMxPg(&Gb|{00|NsC (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117901487893.7650078081242; Fri, 11 Sep 2026 02:11:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xB0-0006K8-FC; Fri, 11 Sep 2026 05:04:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAU-0004Pf-Kw for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAN-0008J7-Ld for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:33 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-542-4R1MyDJVOoO_jBrScxhh3A-1; Fri, 11 Sep 2026 05:03:24 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49cdc4080ddso3444725e9.1 for ; Fri, 11 Sep 2026 02:03:24 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62121747sm37573605e9.2.2026.09.11.02.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117405; 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=n9ZmjCxLo+pq7wNUdqZBErRHKHAn5SxcOItc3qcLCnY=; b=BkXMnNattpH/aJNFGeOAJwX3rRanHZdqSKx/thb5c2Ghiw01l2B3x3WzN4njMVMjSD/mO/ ZQHsTvRDzu5jQBKT9bDUNswUmtpBaiKrhHLsQ4t9lICyIokkanFxAQCWoBzN3UlrHBZ7Qg 8NUuMZNGKKbo8B+A7xMidQkPhvL2Anc= X-MC-Unique: 4R1MyDJVOoO_jBrScxhh3A-1 X-Mimecast-MFC-AGG-ID: 4R1MyDJVOoO_jBrScxhh3A_1789117403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117403; x=1789722203; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=n9ZmjCxLo+pq7wNUdqZBErRHKHAn5SxcOItc3qcLCnY=; b=Ko9NYH5yBAJutCEu6BIf31HysYXEFTqOvVujYpc2sowm+YZIb/m+kldQyPgj+4rsve 44cmn50EI41UjTLjTPup9bg3ILhLanoEwZCoEP5Qhg44oalS+LS6f3sgXJur+VHLNVXD jxZJV4vCN2DCBn9hcy9eVE8BG0Ceaj5DNGG0jFWQWAS/O/mjXlAQ4c0UuTjTIK0pQfG9 ZyknrzcOD75CwyHS5+GBMrc2jyP4OH7AcmKBH70oZQYvYVlYuM1CkQFcYWT9521sAjNT q5315gWeTn3PadaM2Y2s2cK1NmoYe/KL+/lNwFrQpsVVxeZMIemGTrCIiA6rOviDAIe1 cLaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117403; x=1789722203; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=n9ZmjCxLo+pq7wNUdqZBErRHKHAn5SxcOItc3qcLCnY=; b=M0adsCn1R65BTY6mXPYDcwkHJko6NIzYc39a7GexdxNQnRouzM2TjP4gh5KL8QtX8u d9QRkKQjNtPyaSQQABqin3eaCl4LGurQwLAE1nemBhTAVI5ZR56kdUvxTNnFLFNET0wd VkipAUbJo2wrtJYT6jt2I7AliNPDhX7HgwF7ytxF8S08BtyPUe4ID8TPS6oWjahEGGbq 7gUmeHqoGoyRpUe1LVU+FAJd3tSpOYTxlESwaNNnUK78fzjEqrTs0OmUWLakfpBviCCx bbFhYOBZ7eabuERHUlJ4ukwvRGVvLK6X1YjYcWjdzYu2LkWauhFZAx4hnOl6y8BCA+F0 Tcpw== X-Gm-Message-State: AFuF++kFVUzZAe+lhTSLt5j1f1JGSOJHYLkcJdIczvVyrF8X8fE0U1fl Dto6FuCElhysHoYrEpSp6D6rsjwcNVItWm4B5BzLZNfoFYU+GP8TvdTDe1Sn/4W7TGTPT4cQzNR cMsFLvynIsP4OrjHSKOg6DQnRlUhbb1bK7gqGfySGwaohsbXe4SNBkZ79LzejAeTV0T6sk7m36M BlRRHcclP2la1VOVqNtzM9FN05N26k+rC+qw== X-Gm-Gg: AYBFou05w/LQN8Vmtd18auHYvACLTeumUgZ0bIbOxEhh+gxA1SlvXU+Vq17A42G9JB5 2mo4SukOzVJ/zNjk2G0PcdBONRo9reBb9kMA+ws7jXmV8AuzBJ2pE1tpFmhfZRFKI2/Xomh3nrq KvJrLaH+jgXY979Vvov8wfpJyqlWlnIn4kSUCACJo2T8MjtbV9xONC3ZYwpEOlEvjZkstYqJk39 d4/Xbgu1lEcaAWl7vGFARPkYE9Uakg5a68bHSGB5u/I/TgOEChnI+jlxEd7roPqgDuOU7kH32df ghLo8O8ZYMTItxjbX8T5IODiO96t2G4dXmY+OG8bufON7eZZkci9pqd6QFSOOPvvXU3kANsa4XD S4zdoOoc++UG0SLJu8O5pWb8= X-Received: by 2002:a05:600d:849b:20b0:49d:257c:a735 with SMTP id 5b1f17b1804b1-49e61082867mr29086925e9.11.1789117401939; Fri, 11 Sep 2026 02:03:21 -0700 (PDT) X-Received: by 2002:a05:600d:849b:20b0:49d:257c:a735 with SMTP id 5b1f17b1804b1-49e61082867mr29086285e9.11.1789117401209; Fri, 11 Sep 2026 02:03:21 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bin Guo , Stefano Garzarella Subject: [PULL v2 51/75] libvhost-user: accept the postcopy client base ack in vu_add_mem_reg() Message-ID: <1504232c523264cb49f54fda1171dd34f71528a6.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117903785158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bin Guo In postcopy mode QEMU signals that it has collected all the postcopy client bases by sending a VHOST_USER_ADD_MEM_REG message with a u64 payload of 0 and no file descriptor (see vhost_user_add_remove_regions()). vu_add_mem_reg() has a case for that message, but only reaches it after validating the fd count of a regular region, so the ack is rejected first: VHOST_USER_ADD_MEM_REG received 0 fds - only 1 fd should be sent for this message type This kills the backend during memory table setup, making postcopy unusable for any libvhost-user backend that negotiates VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS. Recognise the ack before validating the fd count. Fixes: 9f4e63491b ("libvhost-user: Add vu_add_mem_reg input validation") Signed-off-by: Bin Guo Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260813095501.20282-2-guobin@linux.alibaba.com> --- subprojects/libvhost-user/libvhost-user.c | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index a74d814bb4..248550aae1 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -948,6 +948,20 @@ static bool vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { VhostUserMemoryRegion m =3D vmsg->payload.memreg.region, *msg_region = =3D &m; =20 + /* + * If we are in postcopy mode and we receive a u64 payload with a 0 va= lue + * we know all the postcopy client bases have been received, and we + * should start generating faults. This message carries no file + * descriptor, so it has to be recognised before the fd count of a real + * region is validated below. + */ + if (dev->postcopy_listening && + vmsg->size =3D=3D sizeof(vmsg->payload.u64) && + vmsg->payload.u64 =3D=3D 0) { + (void)generate_faults(dev); + return false; + } + if (vmsg->fd_num !=3D 1) { vmsg_close_fds(vmsg); vu_panic(dev, "VHOST_USER_ADD_MEM_REG received %d fds - only 1 fd " @@ -971,18 +985,6 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { return false; } =20 - /* - * If we are in postcopy mode and we receive a u64 payload with a 0 va= lue - * we know all the postcopy client bases have been received, and we - * should start generating faults. - */ - if (dev->postcopy_listening && - vmsg->size =3D=3D sizeof(vmsg->payload.u64) && - vmsg->payload.u64 =3D=3D 0) { - (void)generate_faults(dev); - return false; - } - _vu_add_mem_reg(dev, msg_region, vmsg->fds[0]); close(vmsg->fds[0]); =20 --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117957; cv=none; d=zohomail.com; s=zohoarc; b=bObTLkzsDtTU73YSh6TFfGWb/Rs0cboq0a6YZtSdU7qRj+jMOFcO4DXMsolsyJguFhXUbNMXwhPxjxzGfWy8EQ+CB0Uaa6IjYY1MMPizcu4zDd9GM1/NiuMjGKjYpRNqBePBYT+zDxsJIQOJJIlVCqD4M4q3TpObeQ8yvRx/U1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117957; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OCozH6Xs5QSeR+YEhmbXShw4rBZnSCVZ1vH0Ur9vXBU=; b=ASctqzGY9+1TjMkoFfBZ0vJs98WcDO8HUTHQqqvXx0lfyoD96jYhWCvzeZm1+QzPsHl9sojrF6U2gRJqHxnjXE+fXB3oQUwwhaS4LDneMGoGCEgHjX0GtOZsNszncgYCjz3Mzalr09FL8NeOjPGolLR/aRTOLrOFrWL4H3z/ay8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117957086374.14085474949263; Fri, 11 Sep 2026 02:12:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xB1-0006MZ-3w; Fri, 11 Sep 2026 05:04:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAU-0004Pg-W9 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAR-0008JK-VQ for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:34 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-7XImqNN6OZycb7GEpxKf3w-1; Fri, 11 Sep 2026 05:03:25 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49b8c651ac0so9063575e9.2 for ; Fri, 11 Sep 2026 02:03:25 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e6f1sm4465156f8f.6.2026.09.11.02.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117406; 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=OCozH6Xs5QSeR+YEhmbXShw4rBZnSCVZ1vH0Ur9vXBU=; b=TuI4wDzkL7BCW/Ocqlanw/EUlFmm8RBI2u767H1ZeoZ6k87tpIlcJoXDHTyao8o9LZzyXQ 1vY6TaaGD/hKSt5NFpLqvxVV9tBWev/HvKBBiYS5Bp/c1+aYIqmVaJGQn2LRX+yOgWj9gv Al3rukDlIyXBepnv4asP5X0yHIXh3/8= X-MC-Unique: 7XImqNN6OZycb7GEpxKf3w-1 X-Mimecast-MFC-AGG-ID: 7XImqNN6OZycb7GEpxKf3w_1789117404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117404; x=1789722204; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=OCozH6Xs5QSeR+YEhmbXShw4rBZnSCVZ1vH0Ur9vXBU=; b=Gnk6uy/FXjBxPnGNhmBChUQz4S6USiyxmP2f8mN+VVc5TashQV44GTSLXSbzBhR6M5 WfsrvxA3w0ImDi3V48tyfBaNdn1UeHAxMeHBzkn6hwBAuMXE4qyTyEJGRvT7JdT13mKH lk8wnQ53sn9UGCkI7A4JnsKPAP1NOF5hfx+C463dsTt+25kfpX48huqvTrRabCTVKBPk YgLmZU3I/o8vP7fq+rVMs1fghRFUG4Io9wxjGvWEiUnLJQ8Sky4Sv4/mkADYg+AYGEvG 9yNjq2SWkLe9qLwZGaxC92Es0fasUfKkKdHMpuHVJmmhxaeEO53aDSWSfgrSBz5HpxCT wV1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117404; x=1789722204; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OCozH6Xs5QSeR+YEhmbXShw4rBZnSCVZ1vH0Ur9vXBU=; b=jToAlMR/5Fj2dqh2IfW7gDOD1uZyIlAnzIADOvU1yQWlZK8g3P1LedhSLtC8VhgsGI 3NHx82FuggEleAiHMTfczuUCOFFJQjX+Pp0NBWmnj9GNaHgQ9luj+NUqG7Bnuqx415gG YhqxUUYU26GEsBjngPQ7AJhWM1p7/Wp7956V22O+n8vEPAZjjtEZELCBqmH0jsDDG4wL jRLUkR7iE6yEzyqMi/n73/Q2o3qwSvHlzH6JQoEM68i/eq8AVSQNxpHtBLk9f1ODSh0a VuxgVdGn9L6cfLH/le1zlKxCWf8cbJrp545hx5aqoe7NXNi9Y1lyEbuCIGGEApV9qwGs u9ew== X-Gm-Message-State: AFuF++kjzeHRI2QJRCLpJJVkYOD5IkMfwlwqF7jwKpXS9l7Rr/Fl+3R4 3SSmRKzYQ2uiCGFcpQIyVYGQ+x5Cc5TO/EpCpcVyuUpClkmSeEzgQWIYV+ZUn+rSLw9c0PmXtTm Xzr41qfJdJ24xDMfVwxx7OizqfhEc/E9aMZc31+qBbJN6p0wTDjXx4uSmVyhwTXtYzNbY3jcr2l uAtDMoMsjlSiOpjvxPRfcDYIswcU+NupUcGg== X-Gm-Gg: AYBFou2yums/y1fzSHSXGu4e7JCmTELaCYyKZlS7fM0MeeM6ksitqp8UCqsNQPsjKzv QdTHPvSCsdrxa3pD0asVonNfWsMcrv2m1kAHb7cSpVTm2D+ymd2fKmY46KRpOf4rN+pcjVFSvj2 dkDqgU0RPjh6BFnSNKc3i2ZoYuRQXeTjDyZVQpOSs7PBisFisTiT0vyAlQ03cItwQX/w0Zjx/3v Qir5k3b5n3xfG6vSrgcORvWjHhNwKiIoXFelKQvtgw4+8ZqU62CaAKx50gqLnqSfZ3Z/EKjnBkd ePtZRPgOdEZXxoLzYdthZ4hc1B9o4IcnyxeskcyKaR3q9hN0h6RsJ9d1/KkzzuKztoyG8pZ4W5X 73Scc3o8m9DV35D41OxygAuM= X-Received: by 2002:a05:600c:1c29:b0:49d:15f8:2bdb with SMTP id 5b1f17b1804b1-49e619806cemr34665305e9.7.1789117403943; Fri, 11 Sep 2026 02:03:23 -0700 (PDT) X-Received: by 2002:a05:600c:1c29:b0:49d:15f8:2bdb with SMTP id 5b1f17b1804b1-49e619806cemr34664575e9.7.1789117403366; Fri, 11 Sep 2026 02:03:23 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bin Guo , Stefano Garzarella Subject: [PULL v2 52/75] libvhost-user: return the backend mapping address for added regions Message-ID: <710889c97f919b2ef11cb3b837d7a33d2264148a.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117957955158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bin Guo In postcopy mode the backend must tell QEMU where it mapped a region, so that QEMU can translate the backend's fault addresses back into a RAMBlock and offset. vu_add_mem_reg() works on a copy of the region and lets _vu_add_mem_reg() fill the mapping address into that copy, but never writes it back into the reply payload. QEMU then stores its own address as the postcopy client base, so fault resolution fails: vhost_user_postcopy_fault_handler: Failed to find region for fault ... The VHOST_USER_SET_MEM_TABLE path is unaffected, it fills the payload directly. Put the updated region back into the payload before replying; a pointer into the payload cannot be used instead, as VhostUserMsg is packed. Fixes: ec94c8e621 ("Support adding individual regions in libvhost-user") Signed-off-by: Bin Guo Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260813095501.20282-3-guobin@linux.alibaba.com> --- subprojects/libvhost-user/libvhost-user.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 248550aae1..2fed792e85 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -989,7 +989,13 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { close(vmsg->fds[0]); =20 if (dev->postcopy_listening) { - /* Send the message back to qemu with the addresses filled in. */ + /* + * Send the message back to qemu with the addresses filled in. + * _vu_add_mem_reg() worked on our copy of the region, so it has t= o be + * put back into the message payload. A pointer into the payload + * cannot be handed out instead, VhostUserMsg is packed. + */ + vmsg->payload.memreg.region =3D m; vmsg->fd_num =3D 0; DPRINT("Successfully added new region in postcopy\n"); return true; --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117763; cv=none; d=zohomail.com; s=zohoarc; b=PUgV2e8xRwEKV8OkZE/RS9l04/B5tjtVC8G1ZLeNAYIrPXKWkgkSZU6MskE1fDnk08N1y7i1gue/zNSDjqQxRl1jxWe7k8M9/aIlOBx4mGUPS0IO/u9CFd+UypC/Tj8pTS7lKYNVuPSSGoBP2gLm5yBf5XmuF6SPqKs3WFLpM7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117763; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BDaUJ5n6w1ultc7lfv5pJdGM89J/WSuiZOQnoJO8Zqs=; b=LlzjQlWiOgt8NEcoJqRDfz9JCOfijXtQDBjAbLkVL9GSlopvJEbL4x4ww+niBMZ3YJ42dnZuanxXqIX8F61D8a0X2mFJBB4ghsZcBrjGeb+Ht24poAV6O7dvgc77vpUPY62+eMeZ2kcfKkr5cmIZu46X8tBUbUp/40WBCvOwPK0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178911776339926.679263077875703; Fri, 11 Sep 2026 02:09:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBD-0007I0-Ex; Fri, 11 Sep 2026 05:04:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAV-0004Ph-4I for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAR-0008Ja-Uo for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:34 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-nwV1CcEuNxGqThK_onToLg-1; Fri, 11 Sep 2026 05:03:28 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48439eea716so326660f8f.2 for ; Fri, 11 Sep 2026 02:03:28 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60abab54sm60624535e9.5.2026.09.11.02.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117410; 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=BDaUJ5n6w1ultc7lfv5pJdGM89J/WSuiZOQnoJO8Zqs=; b=Vkgf9iW2+iGxwEWXG7v/5Z/pTlc4JGpqctbYpHdExP+eC0uKq5Sr8+bjlZ+hhClMFZiFXw XT8w15RiK9Mz1a/xqJgccQWycp+TH3CHvDXw8ieseao9GTHn6aKVkJub1Fgf9DOs0FMi0x VkmVsg7roUtaErLrnmKcfav09ga2YhA= X-MC-Unique: nwV1CcEuNxGqThK_onToLg-1 X-Mimecast-MFC-AGG-ID: nwV1CcEuNxGqThK_onToLg_1789117407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117407; x=1789722207; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=BDaUJ5n6w1ultc7lfv5pJdGM89J/WSuiZOQnoJO8Zqs=; b=anjD7uhffufuEOSrcesWuDjF+/UYoIFx1FDbuYf3SBTpxleqlx0Go0iYFFVTCG5o16 V6ao6wmZXCsIwK4mRVaPt3KDlwLFzB7yJVbzeiQu0Q1G5YLD/h7F1oXvsTassK8Ib51B A2J1NVJjlrVx/MWGqrqlJTgK2E7JLaTx/tSHKVsJSc9XKrAgCEkgDrHa+bc4qv3GlWji hI19KB6nxi3KWcGhiutOx542BATkvPHRqcQBbDClMyoJe2oWtB1u2gJl0qi5X/p7jpBQ bWpdQjygjvgvceZX5R2gqWG3FAbfR/eBi9GQ73YwWeBSfV1KWcEdb/A8rk7IsfoywYva cVJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117407; x=1789722207; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BDaUJ5n6w1ultc7lfv5pJdGM89J/WSuiZOQnoJO8Zqs=; b=ToTIzewImB03xslEuPTD747CsyVPpr8bbGrpV3OkdnZMLQvCHTjqSCZ0G+jI+6BndU I0YD/l/YEFfnr6aYkrZt8+r2ZjtwgWxr6+aRyn6jLDpxuV1tGSCAbDGEB3kI/mPHoH4k 7Xi4t2vvB83fsNhH0nDdnfYcaqweI93KFEWiW3uG1tk4fy+nJmvFzQKzUXdGji+t/x6x ywcbXU5TIGSlzzmp+H3jTIE/+89QqfwVPUD9ahkehzeAgyZyyp+4atNoBJmgjkSAUrrf lqh/l70KNNELXzBz6/ulC1NuWTLDQMMWmS37iXsXSgAa87Gx2KFfW2reCvFDGVyQTJBk o25A== X-Gm-Message-State: AFuF++maxve+E2LtYuXcsE/awKF+6Meio/pzLvdo9w6z3gdDdCk7IQ/9 Qxw+gi7Nttq1bMWCNDprW+p3HwJfjb8ZXuPr5NETOOnoF1ri1KPrBIpThAkQGEO7e6j14ZFzd92 pofzFfn49PTxNYKczGXIsD/0bQRjxY5oiYippsN1g3MvvvWmntRMiQQ0qO9PoGxiZTclPpqqf+n nl74CkvZVd9840EELO2bCYRLxDtkjmZolohw== X-Gm-Gg: AYBFou0bR454DaI/cMfwfQMGgtcjMvIxSGH1NC3UuoMwa+2QteOQia3obv/abSSz67d XgQCSuA5G5RUejx03MFWnNbGZF7mldj/4VfaE1hTiSGKnDxLmyU9tP+FNRecVAKq9IoluueMnfF OcqTlSp/h/xNbEPFGX2K5/XmaKg20UoLCIKMll8QdQCqIkOB7wyI+Jt1bm5E6uTIqCKykErd/mR kGrqHhcDsCDdkX7ky6xhPhfnim0+kflveu1FuRixowZ1bWqHYlZWnWeLkVFCsus3T0zBhTVuToh 8o5nAxinjHu/EThPzgW+ViK5gZsq2aDEIRYNBL35CfYRURoeOAhHse0K3pESQ0KrOXN4D/WxBwo f/cwXbok2zHtxNouSt6LjWpw= X-Received: by 2002:a05:600c:a05:b0:49a:a101:4157 with SMTP id 5b1f17b1804b1-49e619a0499mr34312205e9.7.1789117406665; Fri, 11 Sep 2026 02:03:26 -0700 (PDT) X-Received: by 2002:a05:600c:a05:b0:49a:a101:4157 with SMTP id 5b1f17b1804b1-49e619a0499mr34310955e9.7.1789117405817; Fri, 11 Sep 2026 02:03:25 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Albert Esteve , Cornelia Huck , Paolo Bonzini Subject: [PULL v2 53/75] linux-headers: Update to Linux v7.3-rc1 Message-ID: <80661b84c384d4e40f3ccc8e9c8a2be35a624e7f.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117764895158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Albert Esteve VIRTIO_ID_MEDIA was added previously, synchronize the rest of the headers to the same version. Signed-off-by: Albert Esteve Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260821135038.2676679-1-aesteve@redhat.com> --- include/standard-headers/linux/ethtool.h | 6 +++ linux-headers/linux/iommufd.h | 45 ++++++++++++++++++-- linux-headers/linux/userfaultfd.h | 54 ++++++++++++++++++++++-- linux-headers/linux/vduse.h | 28 ++++++++++++ linux-headers/linux/vfio.h | 21 +++++++++ linux-headers/linux/vfio_zdev.h | 2 + 6 files changed, 149 insertions(+), 7 deletions(-) diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index 55f608c3a7..622d634d04 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -2015,7 +2015,13 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT =3D 39, ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT =3D 40, ETHTOOL_LINK_MODE_1000baseX_Full_BIT =3D 41, + + /* Despite the "baseCR" in 10000baseCR, this is not an IEEE 802.3 baseCR + * It represents SFF-8431 Appendix-E SFP+ Direct Attach (10G-SFI-DA). + * The name is kept as-is for uAPI backward compatibility. + */ ETHTOOL_LINK_MODE_10000baseCR_Full_BIT =3D 42, + ETHTOOL_LINK_MODE_10000baseSR_Full_BIT =3D 43, ETHTOOL_LINK_MODE_10000baseLR_Full_BIT =3D 44, ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT =3D 45, diff --git a/linux-headers/linux/iommufd.h b/linux-headers/linux/iommufd.h index 10c600d71e..3c61caadbf 100644 --- a/linux-headers/linux/iommufd.h +++ b/linux-headers/linux/iommufd.h @@ -57,6 +57,7 @@ enum { IOMMUFD_CMD_IOAS_CHANGE_PROCESS =3D 0x92, IOMMUFD_CMD_VEVENTQ_ALLOC =3D 0x93, IOMMUFD_CMD_HW_QUEUE_ALLOC =3D 0x94, + IOMMUFD_CMD_IOAS_NOIOMMU_GET_PA =3D 0x95, }; =20 /** @@ -219,6 +220,33 @@ struct iommu_ioas_map { }; #define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP) =20 +/** + * struct iommu_ioas_noiommu_get_pa - ioctl(IOMMU_IOAS_NOIOMMU_GET_PA) + * @size: sizeof(struct iommu_ioas_noiommu_get_pa) + * @flags: Reserved, must be 0 for now + * @ioas_id: IOAS ID to query IOVA to PA mapping from + * @__reserved: Must be 0 + * @iova: IOVA to query + * @length: On input, non-zero maximum number of bytes to query starting f= rom + * @iova. On output, number of physically contiguous bytes starti= ng + * from @out_phys, capped by the input length. + * @out_phys: Output physical address the IOVA maps to + * + * Query the physical address backing an IOVA range. The beginning of the + * range must be mapped already and length must be non-zero. For noiommu + * devices doing unsafe DMA only. + */ +struct iommu_ioas_noiommu_get_pa { + __u32 size; + __u32 flags; + __u32 ioas_id; + __u32 __reserved; + __aligned_u64 iova; + __aligned_u64 length; + __aligned_u64 out_phys; +}; +#define IOMMU_IOAS_NOIOMMU_GET_PA _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_NOIOM= MU_GET_PA) + /** * struct iommu_ioas_map_file - ioctl(IOMMU_IOAS_MAP_FILE) * @size: sizeof(struct iommu_ioas_map_file) @@ -574,11 +602,22 @@ struct iommu_hw_info_vtd { __aligned_u64 ecap_reg; }; =20 +/** + * enum iommu_hw_info_arm_smmuv3_flags - Flags for ARM SMMUv3 hw_info + * @IOMMU_HW_INFO_ARM_SMMUV3_ERRATA_REPEAT_TLBI_CFGI: + * If set, user space must issue TLBI/CFGI+SYNC commands twice due to + * hardware erratum T264-SMMU-3. See the description at + * arm_smmu_erratum_repeat_tlbi_cfgi_key. + */ +enum iommu_hw_info_arm_smmuv3_flags { + IOMMU_HW_INFO_ARM_SMMUV3_ERRATA_REPEAT_TLBI_CFGI =3D 1 << 0, +}; + /** * struct iommu_hw_info_arm_smmuv3 - ARM SMMUv3 hardware information * (IOMMU_HW_INFO_TYPE_ARM_SMMUV3) * - * @flags: Must be set to 0 + * @flags: Combination of enum iommu_hw_info_arm_smmuv3_flags * @__reserved: Must be 0 * @idr: Implemented features for ARM SMMU Non-secure programming interface * @iidr: Information about the implementation and implementer of ARM SMMU, @@ -594,7 +633,7 @@ struct iommu_hw_info_vtd { * idr[0]: ST_LEVEL, TERM_MODEL, STALL_MODEL, TTENDIAN , CD2L, ASID16, TTF * idr[1]: SIDSIZE, SSIDSIZE * idr[3]: BBML, RIL - * idr[5]: VAX, GRAN64K, GRAN16K, GRAN4K + * idr[5]: VAX, GRAN64K, GRAN16K, GRAN4K, DS * * - S1P should be assumed to be true if a NESTED HWPT can be created * - VFIO/iommufd only support platforms with COHACC, it should be assumed= to be @@ -602,7 +641,7 @@ struct iommu_hw_info_vtd { * - ATS is a per-device property. If the VMM describes any devices as ATS * capable in ACPI/DT it should set the corresponding idr. * - * This list may expand in future (eg E0PD, AIE, PBHA, D128, DS etc). It is + * This list may expand in future (eg E0PD, AIE, PBHA, D128 etc). It is * important that VMMs do not read bits outside the list to allow for * compatibility with future kernels. Several features in the SMMUv3 * architecture are not currently supported by the kernel for nesting: HTT= U, diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfa= ultfd.h index 4283de22d5..c8e99df952 100644 --- a/linux-headers/linux/userfaultfd.h +++ b/linux-headers/linux/userfaultfd.h @@ -25,7 +25,8 @@ #define UFFD_API ((__u64)0xAA) #define UFFD_API_REGISTER_MODES (UFFDIO_REGISTER_MODE_MISSING | \ UFFDIO_REGISTER_MODE_WP | \ - UFFDIO_REGISTER_MODE_MINOR) + UFFDIO_REGISTER_MODE_MINOR | \ + UFFDIO_REGISTER_MODE_RWP) #define UFFD_API_FEATURES (UFFD_FEATURE_PAGEFAULT_FLAG_WP | \ UFFD_FEATURE_EVENT_FORK | \ UFFD_FEATURE_EVENT_REMAP | \ @@ -42,10 +43,13 @@ UFFD_FEATURE_WP_UNPOPULATED | \ UFFD_FEATURE_POISON | \ UFFD_FEATURE_WP_ASYNC | \ - UFFD_FEATURE_MOVE) + UFFD_FEATURE_MOVE | \ + UFFD_FEATURE_RWP | \ + UFFD_FEATURE_RWP_ASYNC) #define UFFD_API_IOCTLS \ ((__u64)1 << _UFFDIO_REGISTER | \ (__u64)1 << _UFFDIO_UNREGISTER | \ + (__u64)1 << _UFFDIO_SET_MODE | \ (__u64)1 << _UFFDIO_API) #define UFFD_API_RANGE_IOCTLS \ ((__u64)1 << _UFFDIO_WAKE | \ @@ -54,13 +58,15 @@ (__u64)1 << _UFFDIO_MOVE | \ (__u64)1 << _UFFDIO_WRITEPROTECT | \ (__u64)1 << _UFFDIO_CONTINUE | \ - (__u64)1 << _UFFDIO_POISON) + (__u64)1 << _UFFDIO_POISON | \ + (__u64)1 << _UFFDIO_RWPROTECT) #define UFFD_API_RANGE_IOCTLS_BASIC \ ((__u64)1 << _UFFDIO_WAKE | \ (__u64)1 << _UFFDIO_COPY | \ (__u64)1 << _UFFDIO_WRITEPROTECT | \ (__u64)1 << _UFFDIO_CONTINUE | \ - (__u64)1 << _UFFDIO_POISON) + (__u64)1 << _UFFDIO_POISON | \ + (__u64)1 << _UFFDIO_RWPROTECT) =20 /* * Valid ioctl command number range with this API is from 0x00 to @@ -79,6 +85,8 @@ #define _UFFDIO_WRITEPROTECT (0x06) #define _UFFDIO_CONTINUE (0x07) #define _UFFDIO_POISON (0x08) +#define _UFFDIO_RWPROTECT (0x09) +#define _UFFDIO_SET_MODE (0x0A) #define _UFFDIO_API (0x3F) =20 /* userfaultfd ioctl ids */ @@ -103,6 +111,10 @@ struct uffdio_continue) #define UFFDIO_POISON _IOWR(UFFDIO, _UFFDIO_POISON, \ struct uffdio_poison) +#define UFFDIO_RWPROTECT _IOWR(UFFDIO, _UFFDIO_RWPROTECT, \ + struct uffdio_rwprotect) +#define UFFDIO_SET_MODE _IOW(UFFDIO, _UFFDIO_SET_MODE, \ + struct uffdio_set_mode) =20 /* read() structure */ struct uffd_msg { @@ -158,6 +170,7 @@ struct uffd_msg { #define UFFD_PAGEFAULT_FLAG_WRITE (1<<0) /* If this was a write fault */ #define UFFD_PAGEFAULT_FLAG_WP (1<<1) /* If reason is VM_UFFD_WP */ #define UFFD_PAGEFAULT_FLAG_MINOR (1<<2) /* If reason is VM_UFFD_MINOR */ +#define UFFD_PAGEFAULT_FLAG_RWP (1<<3) /* If reason is VM_UFFD_RWP */ =20 struct uffdio_api { /* userland asks for an API number and the features to enable */ @@ -230,6 +243,18 @@ struct uffdio_api { * * UFFD_FEATURE_MOVE indicates that the kernel supports moving an * existing page contents from userspace. + * + * UFFD_FEATURE_RWP indicates that the kernel supports + * UFFDIO_REGISTER_MODE_RWP for read-write protection tracking. + * Pages are made inaccessible via UFFDIO_RWPROTECT and faults + * are delivered when the pages are re-accessed. + * + * UFFD_FEATURE_RWP_ASYNC indicates asynchronous mode for + * UFFDIO_REGISTER_MODE_RWP. When set, faults on read-write + * protected pages are auto-resolved by the kernel (PTE + * permissions restored immediately) without delivering a message + * to the userfaultfd handler. Use PAGEMAP_SCAN with inverted + * PAGE_IS_ACCESSED to find pages that were not re-accessed. */ #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) #define UFFD_FEATURE_EVENT_FORK (1<<1) @@ -248,6 +273,8 @@ struct uffdio_api { #define UFFD_FEATURE_POISON (1<<14) #define UFFD_FEATURE_WP_ASYNC (1<<15) #define UFFD_FEATURE_MOVE (1<<16) +#define UFFD_FEATURE_RWP (1<<17) +#define UFFD_FEATURE_RWP_ASYNC (1<<18) __u64 features; =20 __u64 ioctls; @@ -263,6 +290,7 @@ struct uffdio_register { #define UFFDIO_REGISTER_MODE_MISSING ((__u64)1<<0) #define UFFDIO_REGISTER_MODE_WP ((__u64)1<<1) #define UFFDIO_REGISTER_MODE_MINOR ((__u64)1<<2) +#define UFFDIO_REGISTER_MODE_RWP ((__u64)1<<3) __u64 mode; =20 /* @@ -356,6 +384,14 @@ struct uffdio_poison { __s64 updated; }; =20 +struct uffdio_rwprotect { + struct uffdio_range range; + /* !RWP means undo RWP-protection */ +#define UFFDIO_RWPROTECT_MODE_RWP ((__u64)1<<0) +#define UFFDIO_RWPROTECT_MODE_DONTWAKE ((__u64)1<<1) + __u64 mode; +}; + struct uffdio_move { __u64 dst; __u64 src; @@ -374,6 +410,16 @@ struct uffdio_move { __s64 move; }; =20 +struct uffdio_set_mode { + /* + * Toggle async mode for features at runtime. + * Supported: UFFD_FEATURE_RWP_ASYNC. + * Setting a bit in both enable and disable is invalid. + */ + __u64 enable; + __u64 disable; +}; + /* * Flags for the userfaultfd(2) system call itself. */ diff --git a/linux-headers/linux/vduse.h b/linux-headers/linux/vduse.h index e19b3c0f51..bab47129db 100644 --- a/linux-headers/linux/vduse.h +++ b/linux-headers/linux/vduse.h @@ -14,6 +14,12 @@ =20 #define VDUSE_API_VERSION_1 1 =20 +/* The VDUSE instance expects a request for vq ready */ +#define VDUSE_F_QUEUE_READY 0 + +/* The VDUSE instance expects a request for suspend */ +#define VDUSE_F_SUSPEND 1 + /* * Get the version of VDUSE API that kernel supported (VDUSE_API_VERSION). * This is used for future extension. @@ -63,6 +69,12 @@ struct vduse_dev_config { */ #define VDUSE_DESTROY_DEV _IOW(VDUSE_BASE, 0x03, char[VDUSE_NAME_MAX]) =20 +/* Get the VDUSE supported features */ +#define VDUSE_GET_FEATURES _IOR(VDUSE_BASE, 0x04, __u64) + +/* Set the VDUSE features */ +#define VDUSE_SET_FEATURES _IOW(VDUSE_BASE, 0x05, __u64) + /* The ioctls for VDUSE device (/dev/vduse/$NAME) */ =20 /** @@ -325,6 +337,8 @@ enum vduse_req_type { VDUSE_SET_STATUS, VDUSE_UPDATE_IOTLB, VDUSE_SET_VQ_GROUP_ASID, + VDUSE_SET_VQ_READY, + VDUSE_SUSPEND, }; =20 /** @@ -372,6 +386,15 @@ struct vduse_iova_range_v2 { __u32 padding; }; =20 +/** + * struct vduse_vq_ready - Virtqueue ready request message + * @num: Virtqueue number + */ +struct vduse_vq_ready { + __u32 num; + __u32 ready; +}; + /** * struct vduse_dev_request - control request * @type: request type @@ -382,6 +405,7 @@ struct vduse_iova_range_v2 { * @iova: IOVA range for updating * @iova_v2: IOVA range for updating if API_VERSION >=3D 1 * @vq_group_asid: ASID of a virtqueue group + * @vq_ready: Virtqueue ready request * @padding: padding * * Structure used by read(2) on /dev/vduse/$NAME. @@ -399,6 +423,10 @@ struct vduse_dev_request { */ struct vduse_iova_range_v2 iova_v2; struct vduse_vq_group_asid vq_group_asid; + + /* Only if VDUSE_F_QUEUE_READY is negotiated */ + struct vduse_vq_ready vq_ready; + __u32 padding[32]; }; }; diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index f3282b8e86..c85dcbfe30 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -1534,6 +1534,27 @@ struct vfio_device_feature_dma_buf { */ #define VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2 12 =20 +/** + * VFIO_DEVICE_FEATURE_ZPCI_ERROR feature provides PCI error information to + * userspace for vfio-pci devices on s390. On s390, PCI error recovery + * involves platform firmware and notification to operating systems is done + * by architecture specific mechanism. Exposing this information to + * userspace allows it to take appropriate actions to handle an + * error on the device. + * + * Userspace provides an opaque buffer of fixed length, and the kernel + * fills it with the zpci_ccdf_err data structure. The length of + * zpci_ccdf_err is provided to userspace via the + * VFIO_DEVICE_INFO_CAP_ZPCI_BASE capability. + * + * The ioctl returns -ENOMSG if there are no pending PCI errors. + */ +struct vfio_device_feature_zpci_err { + __aligned_u64 data; +}; + +#define VFIO_DEVICE_FEATURE_ZPCI_ERROR 13 + /* -------- API for Type1 VFIO IOMMU -------- */ =20 /** diff --git a/linux-headers/linux/vfio_zdev.h b/linux-headers/linux/vfio_zde= v.h index 77f2aff1f2..d6c1175c88 100644 --- a/linux-headers/linux/vfio_zdev.h +++ b/linux-headers/linux/vfio_zdev.h @@ -32,6 +32,8 @@ struct vfio_device_info_cap_zpci_base { /* End of version 1 */ __u32 fh; /* PCI function handle */ /* End of version 2 */ + __u32 ccdf_err_length; /* PCI CCDF length */ + /* End of version 3 */ }; =20 /** --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117966; cv=none; d=zohomail.com; s=zohoarc; b=M28Y9Hppr2LCWXTklGsM3eSjAbTgoy6fCHRdT3zFdDnOK+kY3Q+9Lq3rHOlS1usVL8+18txbVvttB2IanS3W780O4NVP3HrdJY4S4byzVa4CpGbKhMGFfyo6wgQ3hPilyLkObYSeQqrA+OxVMG3aqmVaT/3nJ1i4kwzOw2mJz4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117966; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zlpYQy/1MbjiL1NkAZwSro3mr5gaZVYlMNIrEIu3Rs4=; b=F9S3C3fQbbLygDDgbx+FiRaa3DVeceL6xGa4+KHyCgdmLOwEFARp1ltC0iRUIOiB0andCQAfTDMr4+mML8Qp7uvQfETyNNE6Ke8M1Bw9SQHai5zAYBkSs1fMDrGN5mawKFVAO8so1LZByEUHiuGYmmP1rww9zmH+j8nA5LRxs/E= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117966755584.7922586560105; Fri, 11 Sep 2026 02:12:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xAr-0005Vw-Qr; Fri, 11 Sep 2026 05:03:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAW-0004QG-KF for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAS-0008Je-On for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:35 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-15-k7LnJeZzOG6kZzuZR24-zg-1; Fri, 11 Sep 2026 05:03:30 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48439eea716so326682f8f.2 for ; Fri, 11 Sep 2026 02:03:29 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e61a33e34sm39073565e9.0.2026.09.11.02.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117411; 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=zlpYQy/1MbjiL1NkAZwSro3mr5gaZVYlMNIrEIu3Rs4=; b=dI6LfGzIx+bu/0ELhR2bLdW4UA3MKYsG6FYDfSq03J9Yu6MFEMOmBIHCOWMhqJpc/IY9aN vwhXZndkYw0zGHkB4vQNbvf/MO/vNoYvrbFYy3q6qcIkp6lWWRzEXTfYdszJiL5RLg4ClN X90ROb/pgxIb5s14R4dPAGGXD0OaQ18= X-MC-Unique: k7LnJeZzOG6kZzuZR24-zg-1 X-Mimecast-MFC-AGG-ID: k7LnJeZzOG6kZzuZR24-zg_1789117409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117409; x=1789722209; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=zlpYQy/1MbjiL1NkAZwSro3mr5gaZVYlMNIrEIu3Rs4=; b=t2QVLxXLll7FDJze0O/4/wpCgEXlJGQcvqfJvzznEU512Jk1RJSZLy7dhRyORKGQVV 63HToyjDS9JrTRYYDpu/w5pC7qaajCKevvtv8Kk0nZVnJIm4CotRVWear8oD0wmoaL3N lz9wFNy6GsdKqf4iKIATJ1EQmqwO2d82Pj8NaKXEZSyINGxkaLPMvBL95ehq7nHysPgN Jx6hEbySBF9P+r+3c65j3KhOLHDjJNGNo+mnLMW0gi7/qMago9+yzc0XPiaEjmA77YID KwwKUdlDTE0Wi62vvUcAnUVj0UXPENnGElWpZh7vtM/pNYKOTv5CtBTuce6g+8I4J6Rn s5Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117409; x=1789722209; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=zlpYQy/1MbjiL1NkAZwSro3mr5gaZVYlMNIrEIu3Rs4=; b=MbXm4/WnlYNfzEpWZUJeNLEZoX+NtbFOJ164c3jFJcJn5a4sS1BnsY4HiX1KSZfR3g 2vogSkn5BNXJZX16JM8PEt5OnZtllwcBOwaRA5YZp+iT4O86AO37GkZGAGbvvZcrHYpf 2v0ggY13Xih5SgJDRfHgMMC+/yRzJrsUHfxVTi6gzfUSMtgB5ixygHr3noUhzXigbjIy 762JkrxXj7hn6G9rqmCnH20MppOrrkC2tUaVBOh7r3SR6swIZzmorqGxvLwLpSDDA2JM V/U+xDIGQuxc5FlG5NIZgOWL8oV7HCnnBqSw06ZFgj9NQlUq21iG6JlJndev8EBwGZOS I8dg== X-Gm-Message-State: AFuF++kHwuNlN1+2NHFPnJ4UrA/2pHAc8qoO8Mr7OI96j8+vyJFVhZL1 0//pnfg4YD/4Hv3jbGVefOoyd5HesYF76c1tI9CLrZXTdlnAPm1hhmNOBTlPuFPfeQTeMtFo5Ix MJ+rU5lxRQpvLZrb/p0v80SSDs5ZnoX21elek+nhv5j7/J1aaqrP4MHTiJf4sFtX1BtmfWMGhxI QxWzO6IwHAAdV2bMAXNsXInTU6Q8iocV9mWg== X-Gm-Gg: AYBFou23aBiZvCdWkL5WzyBwPJjjtiQktshuXFWLlVNZI1xoAr9OOaILx8WNzjcHtVj ol3vFgMOtfY8c/elbkFhHm8E1t1UvY111/unS90wE1A0D/oqCXQe6jPKuw1xjuIpus7YEWmGfPX 7uuEJUL3Z6M3A0WC373dQAovzOsRd4bXZ+ZEvRv87h9iMm1T9UknKSWjPgn4h2GflkyUY2Ndq6H s0y54A7X4vNet9AOMJoiTg+b+Vq0lrXzYsOrNoJw6v8ZvjHLDKNdNK5yX0nCeOZ8BmWtZsVqvYe XOEPF05llI0f1bEqSV5xbgLv9fhCy4uon9aldg3NzdYXVGUbJikGJMvZp4DE5lRcSI/KAI09wER RYAEXN8PDdoo15xQJ/aPnuLI= X-Received: by 2002:a05:600c:46cc:b0:49c:fc6c:be03 with SMTP id 5b1f17b1804b1-49e619f63a5mr30047615e9.26.1789117408640; Fri, 11 Sep 2026 02:03:28 -0700 (PDT) X-Received: by 2002:a05:600c:46cc:b0:49c:fc6c:be03 with SMTP id 5b1f17b1804b1-49e619f63a5mr30047005e9.26.1789117408083; Fri, 11 Sep 2026 02:03:28 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Fam Zheng Subject: [PULL v2 54/75] virtio-scsi: set dataplane_started to false upon failure Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117968072158500 From: Stefan Hajnoczi Commit e24a47c5b73e ("virtio-scsi: do not use vring in dataplane") set dataplane_started to true when virtio_scsi_dataplane_start() fails. This is likely a typo since dataplane is not functional after failure. The non-ioeventfd fallback is broken because dataplane_started is true after virtio_scsi_dataplane_start() failure. As a result, the following assertion failure occurs when a virtio-scsi device exceeds the open file descriptor ulimit when setting up notifiers (eventfds): $ ulimit -n 104 # exact number can vary based on QEMU version $ qemu-system-x86_64 -M q35,accel=3Dkvm -m 1G -cpu host -smp 14 \ --blockdev file,node-name=3Ddrive0,filename=3Dtest.img,cache.direc= t=3Don,aio=3Dnative \ --blockdev file,node-name=3Ddrive1,filename=3Ddata01.img,cache.dir= ect=3Don,aio=3Dnative \ --device virtio-scsi-pci,id=3Dvirtio-scsi-pci0 \ --device scsi-hd,drive=3Ddrive0,bus=3Dvirtio-scsi-pci0.0 \ --device virtio-scsi-pci,id=3Dvirtio-scsi-pci1 \ --device scsi-hd,drive=3Ddrive1,bus=3Dvirtio-scsi-pci1.0 qemu: virtio-scsi: Failed to set guest notifiers (-24), ensure -accel kvm= is set. qemu: virtio_bus_start_ioeventfd: failed. Fallback to userspace (slower). qemu-system-x86_64: ../hw/scsi/virtio-scsi.c:1017: virtio_scsi_reset: Ass= ertion `!s->dataplane_started' failed. Aborted (core dumped) Cc: Paolo Bonzini Fixes: e24a47c5b73e ("virtio-scsi: do not use vring in dataplane") Buglink: https://redhat.atlassian.net/browse/RHEL-193328 Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260825154854.263819-1-stefanha@redhat.com> --- hw/scsi/virtio-scsi-dataplane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplan= e.c index 95f13fb7c2..bcb6e44133 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -230,7 +230,7 @@ fail_host_notifiers: fail_guest_notifiers: s->dataplane_fenced =3D true; s->dataplane_starting =3D false; - s->dataplane_started =3D true; + s->dataplane_started =3D false; return -ENOSYS; } =20 --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117758; cv=none; d=zohomail.com; s=zohoarc; b=GNDfANrgSnql8zqOGmlsGG7otqO+xZnIDK+kksFmEz+8Czx20Yo/nm9qjKd2l4TfS4w8w8X7UBKH6cPcPQpyajhLTQ9DMO0SlKxijWmCOk7KjDyx00lE7VNuJ62mikQZ7KCYYTJMkLtbm0OKE3YZiFM3S84RvlGWeDDnvx6dQus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117758; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=swaVK7hHvfhctLSwvjj1/ywE8ntA6Euz0DduNvrigAM=; b=Lb1KHuo6w2F9E9w/fz+L5c6LGCyXVB4j5p+wWD6jUwkajoCjn5qu5KoJj8G/tPUMftMeLWFFtVAtOiU0QQJTqXe1hkgIJ7glIOA7owfihvPiuUjSbrw85QHhSit0hp1BFPl6xwAi9l/s7zxTwbHUWKQprn8Wi4MNBb1Rkyj3gH0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117758110567.1150880224851; Fri, 11 Sep 2026 02:09:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBA-00073p-1g; Fri, 11 Sep 2026 05:04:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAi-0004ZA-2z for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAf-0008Lt-S6 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:47 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-13-3aOm_GopNRuplp9koN5-yg-1; Fri, 11 Sep 2026 05:03:42 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49cdc4080ddso3447495e9.1 for ; Fri, 11 Sep 2026 02:03:41 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60946249sm69520125e9.0.2026.09.11.02.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117423; 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=swaVK7hHvfhctLSwvjj1/ywE8ntA6Euz0DduNvrigAM=; b=JsZShD0Om3sCc8vs2FC8EBZ5Q62Id2knBRV7rgEW8ICtWNti7jnZxDeLpdqONvzFyI6HOu EiLYaXOp6uOIi8weYGNJe+j51p6/N6tLRO5j0M66EBtpjMN42pqCuqSi3Jy2On86mW+8NH HlucYb0KVnkiQn9ag8YMUfxr4gExkII= X-MC-Unique: 3aOm_GopNRuplp9koN5-yg-1 X-Mimecast-MFC-AGG-ID: 3aOm_GopNRuplp9koN5-yg_1789117421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117421; x=1789722221; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=swaVK7hHvfhctLSwvjj1/ywE8ntA6Euz0DduNvrigAM=; b=F6BZt6hUHgbdJPshGE+U11pJW2vhWCWxpwsSHLOSgTu5zDJbWT/B8n5MedrygLxNSR syuGrtqL8hmUYByCvKdH/YK5lLfnoFMhVyIixMWfx+hN21C1+NIjD/GlkE3H4mTAll+s lNc2pj0/Cogfa2v0NW17k7NJgfhKxup4IwijXKNje03GeMHphfR1ggPn4lcRZUHHoQtg cQbop2Gj9VH+y7kzdagFHdVdOLEm86BnswKx2UgwTMOBZyikwpiXW7YnuLvZ3vRURYJi 1zxnLjuBwKtErIxOqglE7LLWniMPPqb0zdpg/3Wltfxgzi81IS1MVi277ozTGH5Yknz5 SrMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117421; x=1789722221; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=swaVK7hHvfhctLSwvjj1/ywE8ntA6Euz0DduNvrigAM=; b=X8kxEnYNiWwKckBcJMt2ApMxKgBSloDKP8vJu7cO6YHYl8pSoJw/5RbFjKRgbtb0Jq vrSmQ94xlPFrJQczYo91cI7rLFNBy2ghbxjx5CoGR1MdD9PSq131MgBbjN8dd/DwgXBB fehX0UhQ+MfWX/8ECKYmtL1rY3/AuLCPkrezmdCnvG3E1izUCklMB8yelhpCe9G3/QQl 6jUZx553y3I0Bff50B/WhIvDiLks0fBUpdnyPWeajzj/EyOAdNMN42v4kPqknnp9lXlA b6Iz6TSE/qwX6SjnOzQ5YW3Lhz+mIH0wzSQEtHE08d0JCJRwgLh3EWP1iEmcrb8rsBlk hm6w== X-Gm-Message-State: AFuF++kuVecI4J9ss7wsyZiz4+l4YI9mJtG+jQSViOiCPJagP5taxVGi retD2Jn2Ms2bUnK6X9z6AMmCrI9EA5R94WgpQ7K8nWViOA61UDg331a6VaDM6H+PamcLllWkVHL MotqBCIovTVAB4rCfZPfyBkSo/jV0/p+m6afu0Ybk3MmiuXYDF9hXaa+5CY9jrZmR8jwpC4y11T W7WAHE6VZrmxM4KsalBtKu86coSyIfADJ11g== X-Gm-Gg: AYBFou2NboyEDWWBu/oqXg2HtlpwWxjMizIjpwjiN9bJYitddb7495hDasRVNjzbn6v ZM+I52BWRALA98SN4PtKNVsK1O32ahtOjYPmapNV2MWjLGz/Eqe7cxcC9slLZgrqmak1yYA7NSo 8OssiEH8QJvpreA0nhp5kumGZaLvubaX9kqtXajlX9khlAjNZw5MtsxCAPXD77AMLs2j9zGgQLU AwMebisgwVGLw+Z6VQcKfT2jPCiUTY7wsswejr9rUbNwx+UzWYame9KW3rs+M46vJNLHPh+tGIr 4zHfy9Kh0HQa3DTpaWZbuQh/BFbZ5z8nO9q585ZG0vjpxWu03hdf1SMd9yaG45/OqMb9jJoP5DA NmbqazVuReLLbKGiUw8mMJoo= X-Received: by 2002:a05:600c:4ece:b0:49c:f13e:e4c with SMTP id 5b1f17b1804b1-49e610829b5mr37824945e9.9.1789117416886; Fri, 11 Sep 2026 02:03:36 -0700 (PDT) X-Received: by 2002:a05:600c:4ece:b0:49c:f13e:e4c with SMTP id 5b1f17b1804b1-49e610829b5mr37818395e9.9.1789117410371; Fri, 11 Sep 2026 02:03:30 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Junjie Cao , Jonathan Cameron , linux-cxl@vger.kernel.org Subject: [PULL v2 55/75] hw/cxl: fix the CDAT DOE overlapping the Flex Bus DVSEC when sn= is set Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117760896158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Junjie Cao ct3_realize() adds the CDAT DOE at a fixed 0x190. Since 8700ee15de the four DVSECs take 0x90 bytes, which from 0x100 ends exactly at 0x190. With sn=3D the Device Serial Number capability pushes the block to 0x10c..0x19c, and the DOE, added later, overwrites the last 12 bytes of the Flex Bus Port DVSEC: Capability2, Control2 and Status2. Nothing catches this -- pcie_add_capability() checks bounds, not overlap, and the chain still walks because the DVSEC's next pointer becomes 0x190, inside its own body. Most cxl-type3 examples in docs/system/devices/cxl.rst set sn=3D. Derive the offset from the DVSEC block instead, as cxl_upstream.c already does. Without sn=3D the layout is unchanged byte for byte; with sn=3D the DOE moves to 0x19c, below the AER capability at 0x200. The type 3 device has no VMStateDescription, so its config space never reaches the migration stream. Fixes: 8700ee15de ("hw/cxl: Standardize all references on CXL r3.1 and mino= r updates") Signed-off-by: Junjie Cao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260831022302.406740-1-junjie.cao@intel.com> --- hw/mem/cxl_type3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 6f44770db6..a04dc74ecc 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -936,8 +936,8 @@ static void ct3_realize(PCIDevice *pci_dev, Error **err= p) } =20 /* DOE Initialization */ - pcie_doe_init(pci_dev, &ct3d->doe_cdat, 0x190, doe_cdat_prot, true, - CXL_T3_MSIX_PCIE_DOE_TABLE_ACCESS); + pcie_doe_init(pci_dev, &ct3d->doe_cdat, cxl_cstate->dvsec_offset, + doe_cdat_prot, true, CXL_T3_MSIX_PCIE_DOE_TABLE_ACCESS); =20 cxl_cstate->cdat.build_cdat_table =3D ct3_build_cdat_table; cxl_cstate->cdat.free_cdat_table =3D ct3_free_cdat_table; --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117627; cv=none; d=zohomail.com; s=zohoarc; b=eg21TjZwZEE6R3y0ZMl6i5ExBcPDOU3i5usi7ed5uLtnPpzHKqBLXppwXVs+thLM1K29CFGo2SX8l4OYjEnjO7kXgZogTCXB5tEC2YRbKk2dDqpM5guORg+Qpb/MHS518Mn8/wbsr1b1sTJRv+DKGAm+RygU9DAmI5xG8yb1/Gk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117627; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=13Q36j0M5BaF1k6VkvQm4baQtJfJHEebKt7N8YZcxpU=; b=h5kmKDzbf5IFU+wKqS7KBqvC1t+jNk7DYOe3OqvCnEJmKvtRcFnup2tTH2I781boqDMS1CHK8e8uUyrxA65JjNOeJ4BlEn6xptzAoZqTiuRkFJ7aQ42kgLV+A1DwNGS3WugfzfghQWCYnZ/gCdo/agMIl7hfmHF2NSbhLl2wu5k= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117627655323.4930504832581; Fri, 11 Sep 2026 02:07:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBB-0007FI-Rg; Fri, 11 Sep 2026 05:04:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAa-0004Rv-OW for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAY-0008KM-0R for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:39 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-149-BR0E4Gc2McikE-FvPTbd-A-1; Fri, 11 Sep 2026 05:03:34 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4957287363bso4194705e9.0 for ; Fri, 11 Sep 2026 02:03:34 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb3602eesm4249179f8f.34.2026.09.11.02.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117415; 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=13Q36j0M5BaF1k6VkvQm4baQtJfJHEebKt7N8YZcxpU=; b=CFmUpsyaVPbxJ0X61Adj7Dhi1hmZKoK4q7AhqT9geuCZdZlQVYRV8cYR5/+fqkQdpMs4eq 9oCa0+yYpWze8jPFYs4RMwwgeLM+cgZPcN8nXrliHI/1KDQyQxXri5o1J0/hfmk80dYHGK UPOq0Og9ZaJKoru2LLBMk+ZoX9M9gFM= X-MC-Unique: BR0E4Gc2McikE-FvPTbd-A-1 X-Mimecast-MFC-AGG-ID: BR0E4Gc2McikE-FvPTbd-A_1789117413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117413; x=1789722213; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=13Q36j0M5BaF1k6VkvQm4baQtJfJHEebKt7N8YZcxpU=; b=Gd90zTjZeraaRfo142wnKLtDe9XWh9txkV1iAiQNNKXeRlaqcPjw7gVgX02cT7CUzr 9ahaX1t19ooAJpWT0KAx648bDEKXt0RL2A2S2ZFpq7BcxV3rQ8dUNyeeecEMaYFIrzZa 8IAX2NvKHLaYWvMU8V/vD3L3R/6BQ0fA02RMIaKTh1yasjx9764f/+CsLpGtb51Gplwq 5VFVEfOPRgjsf8ora1KrDkVSWtgzltrRA87nNr9+Enf9ipliN2pyr8Sy23vDu8alawol oMOwjWmM+WDObMHMqfdx6WO4SwA/vnnBp0wGgUuQgLy3BmT83S+SKxRgv57MEb23mrpB WYaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117413; x=1789722213; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=13Q36j0M5BaF1k6VkvQm4baQtJfJHEebKt7N8YZcxpU=; b=V3NofjEa9DccQ6wF/kKqbqFGTlv5+u0f7smawIOYH0zINZWXmkJGZE15FEhZWqdDTu WYuDrXfGofQ9GbaOdeJeoT5NvbLdxHD2QGL71Ic+rLNopP6HcWz2f9kFdp/okzcKFFS9 UGgx8Jw8R7oWjihsdy+Tm28bXTajnNqvC7CY36TS1zSGgCwiDPNTZwsWosubbL4Y+4gc pWWxCSPELDhIYWEW9AKBOrA4UolSbLix/1BDxAXGPfQQ0qiNC/5s1ec5faHXjAbzThpC RMYp/xPB4SExXS0XNxY3aT795KoTIpAyMQQ7PTjRmJcE8zXJGtwVd42NW8WG3HH2nnO7 1Y0w== X-Gm-Message-State: AFuF++nr+bZ/ZAvI6OsgW4lUJ5JaqiSlCyFt7JCx01Ozy6fy6+sXsnwd lFkptMgLodR5EP7V9uq1AUv9/2Mn0DkW5LaPkThm5p4OrQodZir4ErdAmct5wpbpy8w0KgM5hMX rfDhO9SwF/gf8sECjP8gECmnD13+iTQFbs36SN5dM5w9op5aBtiUjUuEfb3MODjJHPFRtRi03Ju 1HTjhonjsLXIsImtUZRqsGYTTOQlhQ6tOO2A== X-Gm-Gg: AYBFou0RlWmJccLcmzJvR/A7+DNt2tzH1Ui68i2qjeqlJlS/wGgDCHOPtsEsIS+hBFE TrGehlmsjYNlEV211s2Z24t7hzsNILAmM/3jjJAxe6JbKRAEMY0Y32HMvNr7KfN4mIN+NE+gQm+ ORsaR/Rn2i7C9s1bTlF3rrYoy83MoIFv+/MTUn6PO4YRAeK0QWcFdc4yunDrMiYGmBMwBJVtzPo oqdWr5dRbGwM+K8glfF+pkLCElD0dw2gV4qs7qHHrEyGzauUZibNXbX1qsRxctmLI+9XPhIYZ4h jVa3DJc/smUBBujbjODllkWPqyR4fo2HZ2DBR2hSHWsZvInK2xT8H63fuwG/YoFKf4oYDdQKNjv QPWwKZHUtTtZrUoDe83vJJLc= X-Received: by 2002:a05:600c:4e46:b0:49e:6683:d23c with SMTP id 5b1f17b1804b1-49e6683d4f6mr7158185e9.0.1789117413085; Fri, 11 Sep 2026 02:03:33 -0700 (PDT) X-Received: by 2002:a05:600c:4e46:b0:49e:6683:d23c with SMTP id 5b1f17b1804b1-49e6683d4f6mr7157155e9.0.1789117412431; Fri, 11 Sep 2026 02:03:32 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Kuan-Wei Chiu Subject: [PULL v2 56/75] virtio-rtc: Report smeared UTC clock type Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117629653158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kuan-Wei Chiu The Linux virtio_rtc driver only registers an RTC class device when the clock type is VIRTIO_RTC_CLOCK_UTC_SMEARED to avoid leap second steps on pure UTC clocks. Report VIRTIO_RTC_CLOCK_UTC_SMEARED in clock capabilities so the guest can expose the device as an RTC device. Signed-off-by: Kuan-Wei Chiu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260831190612.369235-1-visitorckw@gmail.com> --- hw/virtio/virtio-rtc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-rtc.c b/hw/virtio/virtio-rtc.c index 32de9c1650..0dcbe94758 100644 --- a/hw/virtio/virtio-rtc.c +++ b/hw/virtio/virtio-rtc.c @@ -62,7 +62,8 @@ static void virtio_rtc_handle_request(VirtIODevice *vdev,= VirtQueue *vq) resp.head.status =3D VIRTIO_RTC_S_ENODEV; } else { resp.head.status =3D VIRTIO_RTC_S_OK; - resp.type =3D VIRTIO_RTC_CLOCK_UTC; + resp.type =3D VIRTIO_RTC_CLOCK_UTC_SMEARED; + resp.leap_second_smearing =3D VIRTIO_RTC_SMEAR_UNSPECIFIED; } written =3D iov_from_buf(elem->in_sg, elem->in_num, 0, &resp, sizeof(resp)); --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117842; cv=none; d=zohomail.com; s=zohoarc; b=FA5lD0tamJAjHrRa/xDkIbApC9J674pyUHCfSpI7sTLZolCWesqdyZYmRRcZErGrOCPPVmihNYVoH8M4p5mk2Q0qQ6Njb/9YBpc1N3qt026WCzLY5sbBrGtWHflWrblBFzQtiSZWO4SfVaq6k3ByBMf0qlGtKN+lbxiGpNIJ150= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117842; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qEQqbP05s+OSlyzjNTsgrx4dobovQAA0LQxrJHMbWCc=; b=f+0wBL8hbIzJYTfZE5raBFbtPzm190ruKdQIBG6Lxv26g1KEs4igddIeDQC9WgatIbTfRGHYomGCQBJLyC+y9KIN4iAkzEvsdxKvd5XwOAGyn0994azEb+RFXztxexOY56Bu1a12votp97RJhMeCfCbMxm9pngg8dhXrtuCBtfU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117842331756.9060005296287; Fri, 11 Sep 2026 02:10:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBA-000742-21; Fri, 11 Sep 2026 05:04:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAc-0004SB-DP for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAa-0008L3-IA for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:42 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-77--r4YUZxUNiq-DeoDgvb2VA-1; Fri, 11 Sep 2026 05:03:37 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49b8c651ac0so9067165e9.2 for ; Fri, 11 Sep 2026 02:03:37 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb350686sm4714981f8f.27.2026.09.11.02.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117418; 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=qEQqbP05s+OSlyzjNTsgrx4dobovQAA0LQxrJHMbWCc=; b=i5npJEVJghjF09AWm7AHDypW+EVCze+Oemlse54K/hMW5Y5FzRI3pfT3HNpSsTyXl2FqNI 9HJJVbxVJtpEEmgS/PyX7SsNqYLwCEPggQhLT6Yj3VmCl6YkxocQNT2fEltm9StvPch/xz 3ipcy/gRTdLMziV5W3/3Mn8Sk/GdttU= X-MC-Unique: -r4YUZxUNiq-DeoDgvb2VA-1 X-Mimecast-MFC-AGG-ID: -r4YUZxUNiq-DeoDgvb2VA_1789117416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117416; x=1789722216; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=qEQqbP05s+OSlyzjNTsgrx4dobovQAA0LQxrJHMbWCc=; b=FbkGF9kqoCzRV8meIXHInXeoKbz5gRr56NJJ4kHMAAoySJ1vagpPafGFtcINdc5w4K voNp/GhpZADyklfCSO9+Bs0CsobRRdTyUQIQUB9PyjDoNdJX70JLDCy0g4J5Q1ZlqN38 J7MLmO8UyfIti1N3DF8JPVVqeYvqFXBYC6GOEqBmwPf3gcq4Le3eH1UMF5V0yXDUlMFy 06kJXnXJSOEEPpTsyOx8H9frplNefwMLYhcenYrWm9VQaUhHlPaH9DHYim7OatLmAYwv b3URyy16sYx3DNxSH0yD9bUfp++/QrJM8XIKN1SK44WZC5Yoz6fyP27EpbXV1Ua3O0Q2 mxWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117416; x=1789722216; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=qEQqbP05s+OSlyzjNTsgrx4dobovQAA0LQxrJHMbWCc=; b=CRU+QzC7jrrNQD8jlR3W2VjeUXw28ZYOlLwBRtwpJyWoundPgGlxjsYnN2mwYmd991 RbS7mjZMNfDIfiJQOFCaU64lfLkX9+W7qE5ytCQkNVzgIELxO7ULuoDpzAalakJiDw6V dsUxWDB4ik0sZGanYRb+wH1wC44TCjAYaY6V/AZ1oTS5iiS7vAkHCoGSgJf48N52tUVO AeYVV1xBnRuKp2aFvGgagCBW08i5twWRo4AGpFrDBe83cq7Umf2IxA94fyq3ozlxnbZB +bcI/WgS2/vd+9NkSghGNb4OLMQq4iE8+eGe0TqEwbMx+kvcV3l1Xyo92IESzKdt569u u/pw== X-Gm-Message-State: AFuF++lb1ua5zonjstvzOh8dAdEiZhkeMaXSjZ6BaCWvp4mw2BCyZYIT jXuWrc6Hh96oI7b1ukTDVaoXndn6Ub6p+UMKGeAs9KoywixZpDp1JplLoLxE7oP0mF3aNR0Y60+ HLDbDkQNWqX5t46WLobiNg68QyXw7ZfLth2dNTYTnENXidwrLDY9ptETT4IGlgHLgWVKca3tOa4 JwUaChOlfHrSKhTPr+l0jJ0P2+H9cgPD82tw== X-Gm-Gg: AYBFou09ug4tq72x8NwW8vB5+rYuUqZWO2LzIwpv9Z/+VRdincNyilfeN/kZzmmL7Ik NIdD26DKgK4S3vYDv/A4fPIdPmVdUwbgthY1HFs3OsOr8/1R9sklA+D5H0y8PS7iPYorkkdtMLh StEEE3klyXeTUTuUjBVYPXx559TQCs6RGxqDD4/Q/BU5/51+nPhb5v2oU+RhuYLWt2WMoKlaVMt eBHO4QmI60stvkMUpg6rgadxmUR7L4v4zxoCSHlvO/HHv6kKfQZNKScmjE21H2oZYu7t3ThWgVs ybxOBWpLQjybFLmTvtSxzqL2qtK0ioSRNkZEykxCOWxtAqxOtCx/jrRKUORpv5sMzg8CCgt+mww wZ8XTbCtlzLSddNkZlradx78= X-Received: by 2002:a05:600c:3b90:b0:49d:16df:8521 with SMTP id 5b1f17b1804b1-49e619805f1mr34637905e9.4.1789117415567; Fri, 11 Sep 2026 02:03:35 -0700 (PDT) X-Received: by 2002:a05:600c:3b90:b0:49d:16df:8521 with SMTP id 5b1f17b1804b1-49e619805f1mr34636975e9.4.1789117414728; Fri, 11 Sep 2026 02:03:34 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF , Jason Wang , Yi Liu , Paolo Bonzini , Richard Henderson Subject: [PULL v2 57/75] intel_iommu: Support concurrent page fault handling with PRI Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117843798158500 From: Cl=C3=A9ment MATHIEU--DRIF PRQ slot allocation must be thread safe to avoid posting multiple commands in the same slot so we take a lock in vtd_pri_request_page. This allows multiple devices to call the page request interface of the same iommu instance. Signed-off-by: Clement Mathieu--Drif Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903145044.2245609-1-clement.mathieu--drif@bull.com> --- hw/i386/intel_iommu.c | 103 ++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 40 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 82c3c3b2c3..7c442a86ca 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3627,15 +3627,26 @@ static void vtd_handle_iectl_write(IntelIOMMUState = *s) =20 static void vtd_handle_prs_write(IntelIOMMUState *s) { - uint32_t prs =3D vtd_get_long_raw(s, DMAR_PRS_REG); + uint32_t prs; + + vtd_iommu_lock(s); + + prs =3D vtd_get_long_raw(s, DMAR_PRS_REG); if (!(prs & VTD_PR_STATUS_PPR) && !(prs & VTD_PR_STATUS_PRO)) { vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); } + + vtd_iommu_unlock(s); } =20 static void vtd_handle_pectl_write(IntelIOMMUState *s) { - uint32_t pectl =3D vtd_get_long_raw(s, DMAR_PECTL_REG); + uint32_t pectl; + + vtd_iommu_lock(s); + + pectl =3D vtd_get_long_raw(s, DMAR_PECTL_REG); + if ((pectl & VTD_PR_PECTL_IP) && !(pectl & VTD_PR_PECTL_IM)) { /* * If IP field was 1 when software clears the IM field, @@ -3644,6 +3655,8 @@ static void vtd_handle_pectl_write(IntelIOMMUState *s) vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); vtd_generate_interrupt(s, DMAR_PEADDR_REG, DMAR_PEDATA_REG); } + + vtd_iommu_unlock(s); } =20 static uint64_t vtd_mem_read(void *opaque, hwaddr addr, unsigned size) @@ -5377,19 +5390,18 @@ static int vtd_pri_request_page(PCIBus *bus, void *= opaque, int devfn, { IntelIOMMUState *s =3D opaque; VTDAddressSpace *vtd_as; + uint64_t queue_addr_reg; + uint64_t queue_tail_offset_reg; + uint64_t new_queue_tail_offset; + uint64_t queue_head_offset_reg; + hwaddr queue_tail; + uint32_t old_pr_status; + uint16_t sid; + VTDPRDesc desc; + int ret =3D 0; =20 vtd_as =3D vtd_find_add_as(s, bus, devfn, pasid); - - uint64_t queue_addr_reg =3D vtd_get_quad(s, DMAR_PQA_REG); - uint64_t queue_tail_offset_reg =3D vtd_get_quad(s, DMAR_PQT_REG); - uint64_t new_queue_tail_offset =3D ( - (queue_tail_offset_reg + VTD_PQA_ENTRY_SIZ= E) % - (vtd_prq_size(s) * VTD_PQA_ENTRY_SIZE)); - uint64_t queue_head_offset_reg =3D vtd_get_quad(s, DMAR_PQH_REG); - hwaddr queue_tail =3D (queue_addr_reg & VTD_PQA_ADDR) + queue_tail_off= set_reg; - uint32_t old_pr_status =3D vtd_get_long(s, DMAR_PRS_REG); - uint16_t sid =3D PCI_BUILD_BDF(pci_bus_num(vtd_as->bus), vtd_as->devfn= ); - VTDPRDesc desc; + sid =3D PCI_BUILD_BDF(pci_bus_num(vtd_as->bus), vtd_as->devfn); =20 if (!(s->ecap & VTD_ECAP_PRS)) { return -EPERM; @@ -5413,25 +5425,7 @@ static int vtd_pri_request_page(PCIBus *bus, void *o= paque, int devfn, return -EPERM; } =20 - if (old_pr_status & VTD_PR_STATUS_PRO) { - /* - * No action is taken by hardware to report a fault - * or generate an event - */ - return -ENOSPC; - } - - /* Check for overflow */ - if (new_queue_tail_offset =3D=3D queue_head_offset_reg) { - vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PRO); - vtd_generate_page_request_event(s, old_pr_status); - return -ENOSPC; - } - - if (vtd_pri_perform_implicit_invalidation(vtd_as, addr)) { - return -EINVAL; - } - + /* Prepare the descriptor */ desc.lo =3D VTD_PRD_TYPE | VTD_PRD_PP(true) | VTD_PRD_RID(sid) | VTD_PRD_PASID(vtd_as->pasid) | VTD_PRD_PMR(priv_req); desc.hi =3D VTD_PRD_RDR(is_read) | VTD_PRD_WRR(is_write) | @@ -5439,26 +5433,55 @@ static int vtd_pri_request_page(PCIBus *bus, void *= opaque, int devfn, =20 desc.lo =3D cpu_to_le64(desc.lo); desc.hi =3D cpu_to_le64(desc.hi); + + if (vtd_pri_perform_implicit_invalidation(vtd_as, addr)) { + return -EINVAL; + } + + vtd_iommu_lock(s); + + queue_addr_reg =3D vtd_get_quad(s, DMAR_PQA_REG); + queue_tail_offset_reg =3D vtd_get_quad(s, DMAR_PQT_REG); + new_queue_tail_offset =3D ((queue_tail_offset_reg + VTD_PQA_ENTRY_SIZE= ) % + (vtd_prq_size(s) * VTD_PQA_ENTRY_SIZE)); + queue_head_offset_reg =3D vtd_get_quad(s, DMAR_PQH_REG); + queue_tail =3D (queue_addr_reg & VTD_PQA_ADDR) + queue_tail_offset_reg; + old_pr_status =3D vtd_get_long(s, DMAR_PRS_REG); + + if (old_pr_status & VTD_PR_STATUS_PRO) { + /* + * No action is taken by hardware to report a fault + * or generate an event + */ + ret =3D -ENOSPC; + goto out; + } + + /* Check for overflow */ + if (new_queue_tail_offset =3D=3D queue_head_offset_reg) { + vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PRO); + vtd_generate_page_request_event(s, old_pr_status); + ret =3D -ENOSPC; + goto out; + } + if (dma_memory_write(&address_space_memory, queue_tail, &desc, sizeof(= desc), MEMTXATTRS_UNSPECIFIED)) { error_report_once("IO error, the PQ tail cannot be updated"); - return -EIO; + ret =3D -EIO; + goto out; } =20 /* increment the tail register and set the pending request bit */ vtd_set_quad(s, DMAR_PQT_REG, new_queue_tail_offset); - /* - * read status again so that the kernel does not miss a request. - * in some cases, we can trigger an unecessary interrupt but this stra= tegy - * drastically improves performance as we don't need to take a lock. - */ - old_pr_status =3D vtd_get_long(s, DMAR_PRS_REG); if (!(old_pr_status & VTD_PR_STATUS_PPR)) { vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PPR); vtd_generate_page_request_event(s, old_pr_status); } =20 - return 0; +out: + vtd_iommu_unlock(s); + return ret; } =20 static void vtd_init_iotlb_notifier(PCIBus *bus, void *opaque, int devfn, --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117753; cv=none; d=zohomail.com; s=zohoarc; b=VC+xHdXwzWoSpAuNhlRUCKt09Tglog28vv72U+VENAzP3InOcqb1vlz+ptptDf5o/FzOPB3Vphhfdzrr5kjwfapsPW5C5bvZhMLFbsmX6D54i3/dfEGmBSLeCs/i177Itmd40zsYLsoOHogJQ6tT20UBrZ88eraT1k9ki2UEd8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117753; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mDN0pKO3NI28SBsIJ08S3mFqoBiJB+cbySC7sAon6z4=; b=l6LkfkDvi3Hg77urJDIjwcpw30TyF4QIlRTyGWkwIFs3PgpTAjjQ1Do7ZZDohbGmDN+ZGMT5AsfArl36DQ32/UPxbXvATHjTmTMLVUzEhq7FCbZ8XHasboArppjH0huMsbM4oZjIcnsRM5G3RQRX67CEr7jGBGuma2DhvaGAvvk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117753321658.6780541289803; Fri, 11 Sep 2026 02:09:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xB8-0006y4-Pc; Fri, 11 Sep 2026 05:04:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAd-0004SM-Fn for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAb-0008LE-1H for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:43 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-382-H4ZKI3e6N_CVIKBW0x-lsQ-1; Fri, 11 Sep 2026 05:03:39 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490a767b782so5968715e9.2 for ; Fri, 11 Sep 2026 02:03:38 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32e7f5sm4641204f8f.9.2026.09.11.02.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117420; 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=mDN0pKO3NI28SBsIJ08S3mFqoBiJB+cbySC7sAon6z4=; b=TVT2cqUXUcy2niCiGJ9qzO/ZgJh8xvmPegxlvQvtfyRtAT+Bnt21X9s943MV9tPRhhurxc 7yRgguLw23UMoXe5Lpekw0nAeWLyQg1gxp+Gg92/FCS3k/p1QW1T+QaHthIvpSqc1PcaLP 7SoHzSTummIpZFzr/doD62/7J43kN8Y= X-MC-Unique: H4ZKI3e6N_CVIKBW0x-lsQ-1 X-Mimecast-MFC-AGG-ID: H4ZKI3e6N_CVIKBW0x-lsQ_1789117418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117418; x=1789722218; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=mDN0pKO3NI28SBsIJ08S3mFqoBiJB+cbySC7sAon6z4=; b=Cg615xuICHM+PCQxPdYjvttLbnes2E7kOZ28k0s591zzFNKPGlpPfJS4V9MysZ81kF ZSqBCU4x9zceAdkY8z8e853l4RDKQFEV8azPznNLmksS02XXiO9uIJuYu4REacwE2Zbl Iyeav7xXigc9bhINlPZBQgNaqyyQbLewPxTbIqNxTjcTiQ82n229xszlOOOhKbEGpW+7 Jtfkt7C/VIO5UIzQoL/HIfSPIr0U2PoU0Agz6vk5DcKEwYTDrRN1TOn49/HFDkgiHLu1 4+W7gW/9YWBr8UB0lbGbuGd23Qrv6tPIYVxLMasgL9JW9Xf6ypo7HXnWoOR85pxXVG92 haIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117418; x=1789722218; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=mDN0pKO3NI28SBsIJ08S3mFqoBiJB+cbySC7sAon6z4=; b=YKOpRw6zJoytbkeIcaHhwt0tbDtRy6b3fJ9SCaLmbBbt6vH8E/scnCKP5V05iJEG4j 2AiMw080gg5pR3SFYnx494myw/EtB7ligoKtFtVpw82hcwTJqEtpTaJ3MTPHbOpb+ifu NUk0Tr1Mm0Lc+TuW7MimC5SIx/CRfeJcOUmrbzfDHW2b0UnmCEKLxGVy3Vc21N5MNiyI nSgFHTxyrkHEjyvQQ+IkMo6VPuuV0Oi0T0hZj/LPKzM3GA9rZB0CbdD+r6GBb4NhGLB+ 1x0VHJeWBetb94RAnnX5YwYjBX1H731U06izZohh8Un30G8w01yZNUmNuhHAzmxq72bt a0Ig== X-Gm-Message-State: AFuF++kjg8FwdmOOkNP6MDqW88V5w3tNwlBku+vkcjN/WwZ8TanVHamt 5kt/KCIZK7FMTMQW8M7Wrbo9DcPQ5ArlUADpjWhGhSTF/xm1i8AaWve77RTvSNb/VbsfEUNYWjw xtdn2lkWlvL4gLVaxuLHqUAiqEfeXue23TUaqiQDhjSPdF6+aPjrhnekMp0rKAfCiZ6/ciA4JcO tUORpS7n/tBwoNoDWXDteM2mvapuExvoIL9w== X-Gm-Gg: AYBFou1ytALWyVLqn2v9//u6LwwkMyAyxXR1vtfJr3dxkbcAzNyCvyuJhdwcQEJ7LWt lJY3i9IwIQvtDr5maUzJ7mg//QvQfAE+C2/3Kq0wSwdFhQhMRi58LbUBoOPMd3SlhP//3e99AS8 j0FzydHqt8iCk8dPEeMdYu7m5KicJeqYtT7RI6K9fIhs/Xoq8dMuc7KQusQkUqKnY2pgW7kDLWB D/aBn2AZpg+jaI9WK0sni0+jy9KRH8IHYBI/DJrXfURgZgzJiAlA1DxaRSxeuZB5zV1TFf7CO1M EWgX8mZDqmDNnht9Iw2w8k3X9SuDhqSI/nB6ca9z0HBxYuS82zann5nAj9ryF+6TXpZsq7Ftdjd I2kkXFmkGNvkmYzQk+O+7bsU= X-Received: by 2002:a05:6000:430a:b0:482:fb60:2f0 with SMTP id ffacd0b85a97d-486eb2ec2dfmr3661518f8f.8.1789117417810; Fri, 11 Sep 2026 02:03:37 -0700 (PDT) X-Received: by 2002:a05:6000:430a:b0:482:fb60:2f0 with SMTP id ffacd0b85a97d-486eb2ec2dfmr3661452f8f.8.1789117417091; Fri, 11 Sep 2026 02:03:37 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF , Yi Liu , Jason Wang , Paolo Bonzini , Richard Henderson Subject: [PULL v2 58/75] intel_iommu: Only set dirty bit when PTE exposes write permission Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117755250158500 From: Cl=C3=A9ment MATHIEU--DRIF Setting the dirty bit without the write bit in vIOMMU creates a spoofed shadow stack PTE that misleads the guest OS. This results in infinite PRI requests from the device, as no actual write permission is ever granted - the guest OS treats the PTE as a legitimate shadow stack entry and considers the permissions already correct. Fixes: 65c4f0999991 ("intel_iommu: Set accessed and dirty bits during stage= -1 translation") Signed-off-by: Clement Mathieu--Drif Reviewed-by: Yi Liu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903150649.2281104-2-clement.mathieu--drif@bull.com> --- hw/i386/intel_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 7c442a86ca..eccb16346c 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2039,7 +2039,7 @@ static int vtd_iova_to_fspte(IntelIOMMUState *s, VTDC= ontextEntry *ce, return -VTD_FR_FS_PAGING_ENTRY_RSVD; } =20 - if (vtd_is_last_pte(fspte, *fspte_level) && is_write) { + if (vtd_is_last_pte(fspte, *fspte_level) && *writes && is_write) { flag_ad |=3D VTD_FS_D; } =20 --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117737; cv=none; d=zohomail.com; s=zohoarc; b=hgc3eViiIPJlz2DzM7DPudEVMgqzbMnr5T5Vmmp/vltyUBUyuff6i5ik/JKe3xHCOOKzLO54BVQDui2zdpX8gtt6thijagb/4roPETw69cv5/q3Jonrg1wPZtu+p9i9Vr8QUAyn5c0C71CHIuPpuF/QEnt4NWcMk6xjeKsk6VjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117737; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ztrp18hGYXHuUYyUKf9DJwGmlf0B2MNBYEJ6m3HjUYc=; b=lIEwvAFH0HXMHHK54g+Eet07ho1UBtiYCCdxNUarpO2tBCcjn2jSDNcXvpDITz38gU2Es6rGCBStwlYrKfSv4gzSj3bI1MkeeqzQz28hnuIqdMwveWlQGibaVR71EroNJaK8DAH0hL8BB8tXrt66uaF7C9/aioVpxxzlN6JIzq4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117737006580.7515869032743; Fri, 11 Sep 2026 02:08:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBD-0007IB-Dq; Fri, 11 Sep 2026 05:04:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAi-0004Ye-1A for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAd-0008Lf-Au for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:46 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-UQCYyze0PkWGAZCQoPq5YA-1; Fri, 11 Sep 2026 05:03:41 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49e6683d48fso1182315e9.0 for ; Fri, 11 Sep 2026 02:03:41 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60a8a89esm59342745e9.1.2026.09.11.02.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117422; 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=Ztrp18hGYXHuUYyUKf9DJwGmlf0B2MNBYEJ6m3HjUYc=; b=K5TOptzF8xfjd/1pvTECgU5JBMAW5mYsO0Qyog7DWUSYbMKvMJNFVZYha5lx/j2Yrry/JG Y2zN+XkKe8V0r6TIEj8/SXPXELZXVdeX1SKcmHwvAGIMrHLh1DTQwv3sTVdxUNG3E4o6uQ gCqhMXogmo3qyStUDPXKb5Sx5FYS4aQ= X-MC-Unique: UQCYyze0PkWGAZCQoPq5YA-1 X-Mimecast-MFC-AGG-ID: UQCYyze0PkWGAZCQoPq5YA_1789117420 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117420; x=1789722220; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Ztrp18hGYXHuUYyUKf9DJwGmlf0B2MNBYEJ6m3HjUYc=; b=HgqKQn/E6SXkO1dGT/UTqZ6wUAUrlG8OvQephdbvnEkuHeQVqrPUBibWOXO4s01VqA nUPoqXrwW2idvNIDnu6SU5bbvjHdq93P/sW7jSyIEpBF8VNMXw6wMiPG9AYi5y6FFm94 Z95y4kKFX1/ocLwmt2ZDioD89DkNfsA3T8xyLsAzzMNKWHCoT1wSj/N2irDFGb5ti2Ny JdXA/SnDvWBWLqljJEAW5N3zlO/CZPZZbFvlqbs+NSZkGD+zjyTmIyFZJyY37tOAARsc 6h9NVMujVESG9KksPPhloADOWvl6x+0XNFk1R9qVyNcFN5A4sDZw6ISpnZXwy+wQz8Iz aiCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117420; x=1789722220; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Ztrp18hGYXHuUYyUKf9DJwGmlf0B2MNBYEJ6m3HjUYc=; b=BRZZfW+z4ov/LFs0+komL4P812Y/LqGX/fpMNpxARY5/wLiezYx5dnx0juslAOpUug 0959zsRjHjKw674MObkwB1VgjC1QrnvZfLP50A9hB5zHOBr2vsfvWv5O7auweoEg8XZ9 LlMGZ7i3mFAXkii/Mo2ye6h415FwJr6llPSOPZtA+7VsemiyWdlF7HgwPqJF13tVLVDE WSrvfNb5ZzAkQhPb7fV/qx7uC1boSx1tzKSvtb0n21NeQKaT3hP7PGN62IqcNU7As9sp qfNoQ1czlh/rtSgRLoLAJ4DDHvfvxO7JXw49OM7fkd6zV04fZ8SigsqAJt59n4jYbW+t xXFg== X-Gm-Message-State: AFuF++kUlqP6W/nqnV8nI6/GU/e5mYQugkVDeUVMMf/D/g4SyX5YtaWt Opr5s1kfsi4lTiAtWnfgC26n8QYwTsMMCpYqq6FW43UNPi/gHmmGMdCLlrPiyCdSivGd1yLIoJa MKlZJrFWct7xFbr8GXYTd4QTi9AeRZRyHUvtyeAAgRdfkdDE83v0b8Gm5thjNfz8x/wQBE2V6tv jelNBrASCmiuNOFnlbVmZl8ggwNl5hoTJPaA== X-Gm-Gg: AYBFou0TClHiv2kiuCj8QeyTY8KPzmC6yczFfVaVMOSjhJbztsFa3hRAMqkWKcqWc11 QUeyMXEJVIRhhv/f9LXyOwRAZ1ptteI4+LkBZJk3+KDpnHLaHSMXCSDjZczNWIMLhMR09aua5q/ Rku+qOo8cpTXF/SfzZGy6JrH4Q2E5fuWmDyLltyqRCs2aVLjYxASOwuvjUiGPZRvU92wtpdU0lM /6xVfoIduj9ORShF6bE1sjTAX+6DeV6dDrrtg/H5DiJAzUKyHQghhcy3r7uCUyd9BFxmv7Q0ZmE gK4ygDrZMXjI/TDlX5gLjUbkgeEi9zNd5wJvE+Rlpl4XolkbucYouSmxnP6lqysWtT7K4xAxoEh vJYi0pRccsPmR2Ihbdqt7oE4= X-Received: by 2002:a05:600d:8445:10b0:49c:cf18:494e with SMTP id 5b1f17b1804b1-49e6198a3b2mr25032055e9.12.1789117420111; Fri, 11 Sep 2026 02:03:40 -0700 (PDT) X-Received: by 2002:a05:600d:8445:10b0:49c:cf18:494e with SMTP id 5b1f17b1804b1-49e6198a3b2mr25031285e9.12.1789117419514; Fri, 11 Sep 2026 02:03:39 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF , Yi Liu , Zhenzhong Duan , Jason Wang , Paolo Bonzini , Richard Henderson Subject: [PULL v2 59/75] intel_iommu: Always write all the flags passed to vtd_set_flag_in_pte Message-ID: <79ce20146054de5a120f550b195ef236e6f02bf8.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117738831158500 From: Cl=C3=A9ment MATHIEU--DRIF This function was initially designed to write a single flag in a pte. The current implementation expects it to set several flags. Fixes: 65c4f0999991 ("intel_iommu: Set accessed and dirty bits during stage= -1 translation") Signed-off-by: Clement Mathieu--Drif Reviewed-by: Yi Liu Reviewed-by: Zhenzhong Duan Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903150649.2281104-3-clement.mathieu--drif@bull.com> --- hw/i386/intel_iommu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index eccb16346c..91ab549dbf 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1964,13 +1964,13 @@ static bool vtd_iova_fs_check_canonical(IntelIOMMUS= tate *s, uint64_t iova, } } =20 -static MemTxResult vtd_set_flag_in_pte(dma_addr_t base_addr, uint32_t inde= x, - uint64_t pte, uint64_t flag) +static MemTxResult vtd_set_flags_in_pte(dma_addr_t base_addr, uint32_t ind= ex, + uint64_t pte, uint64_t flags) { - if (pte & flag) { + if ((pte & flags) =3D=3D flags) { return MEMTX_OK; } - pte |=3D flag; + pte |=3D flags; pte =3D cpu_to_le64(pte); return dma_memory_write(&address_space_memory, base_addr + index * sizeof(pte), @@ -2043,7 +2043,7 @@ static int vtd_iova_to_fspte(IntelIOMMUState *s, VTDC= ontextEntry *ce, flag_ad |=3D VTD_FS_D; } =20 - if (vtd_set_flag_in_pte(addr, offset, fspte, flag_ad) !=3D MEMTX_O= K) { + if (vtd_set_flags_in_pte(addr, offset, fspte, flag_ad) !=3D MEMTX_= OK) { return -VTD_FR_FS_BIT_UPDATE_FAILED; } =20 --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117978; cv=none; d=zohomail.com; s=zohoarc; b=DNOMWdLhjGxFWZGoY8SeLPXKHHLjoPV9h6t2GRfx+ifW1GmRnZRTCI8HY69/5v6YrDuQx4rtmCeffRu1xV99qFCrldGAFlTjsTvVWKzDxIZePVSjiE300SbHX4O3+RME4pnE8FhSC/50x4vjOODlLxQl3BTz3pRxJ7uH/DPU6ys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117978; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2hNz4/jqFz0hJ0OYLcWq6vFd56S2mjD9cbtRudNy4aw=; b=jaj5U1q7jTwSXNVAWc4/DVNqjLbA2YsBxswGibzUf34Mgt4Osseo8nWj0elSnEBcl8e/H/Jo3kgOXDiXVkcksWReGT56ljSGm5gh+/bKo2jum1uylg1Kkpy2BzpcCHE1ePydvjjhbWrAJIk0580ucOKOb4VepvUCCxcOCyeyqlA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117978972505.40210227259763; Fri, 11 Sep 2026 02:12:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBe-0000QJ-KN; Fri, 11 Sep 2026 05:04:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAm-0004v9-8E for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAf-0008M0-T7 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:51 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-GOTgL5sHMTaszy2k7YxY2w-1; Fri, 11 Sep 2026 05:03:43 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49cd55ee2f7so6056655e9.0 for ; Fri, 11 Sep 2026 02:03:43 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62121747sm37594735e9.2.2026.09.11.02.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117425; 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=2hNz4/jqFz0hJ0OYLcWq6vFd56S2mjD9cbtRudNy4aw=; b=X2dU40H8W+UjCiJl+QDzNJF6VUEYuNtZxby8B20Z336syfjRVMl3eQy9HWaOHxv6rx+22T to/4/wK+egy6EwRUNncQr6Evej5OMSBHCtPk4BqUtp/D2YF2zdEwvc4J8ft/raMrFSJ3DY ZR3/9xzXDgTGWciSNoMvHUxiqrqGghs= X-MC-Unique: GOTgL5sHMTaszy2k7YxY2w-1 X-Mimecast-MFC-AGG-ID: GOTgL5sHMTaszy2k7YxY2w_1789117422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117422; x=1789722222; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=2hNz4/jqFz0hJ0OYLcWq6vFd56S2mjD9cbtRudNy4aw=; b=fwFxkGnudnCEfS6HV0RRqQPyHqlW6Xl3BRbdrfNJUwHGhzYDA3NpcarDvh1dLeKX7t uK3Zr7gUxhe2dhA0VyQ8eh+k0KTvusiYobJd7SplLbcbMOKe1yuCc0ZRzo4z0eAlv5g4 AOJB+8d87NSiS6gqYsO0yEKxp68mEbolDdNp8WbUw4pxoJUMHxDdXxBERXh1J1VcPEd1 3TqxZ+khXBw1N6ExZWvmP7rff/cDRzmbGgWMvjzTv6JG4NS4r5alyC5o/ry6ye5M3yVJ uGJVDvvggxcnjYmsfaecLg4PT5RLjVo+5hvMiJrNpw5VVwEf7+MhqTKbLUVyLfXnWWIF yHHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117422; x=1789722222; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=2hNz4/jqFz0hJ0OYLcWq6vFd56S2mjD9cbtRudNy4aw=; b=pzTksIkrJ8BDP9TPP/isXo7DlHWNlcQLxAkb3MAaxcKIwaOVE4ewkkDF14D+X1w53n z8EYhrxLW3CZIUjQtxN8HHV0HjjpINja+OYbae2M3g5VH4QvkBjv/5evQHwonD0qVWhN E4KqT3Xbw9f4VgPTpVI8mtJcvN4kSzakbP2XT+p/hmg+0yqHjRWA6QFBedqLR9hXKEEw pG40PRB/r74LpjWI3d8UJWWtwjesOncUqF52uSDliHpQzQnpriX9AElnJv1rTSSDAAUQ fSqTYxP55Ol99FwBlIgy7Xtpe6eQqFtEYw/ST6FeMvj228Vn0oLGLxcMdHnCgbGTNrBr TXpA== X-Gm-Message-State: AFuF++mmxWuKwYwr71o4Nhf/qsMmhq2O899jAnJLvAwiefs95ETkmyQg +ZrVCrDOYuykhCddxc00rzv9L3AfuJZsh1419dUZX1R8mkLimrJVDvC4TvtHBBbvAxx/uSsgirI Y0rnS9nZD0/lEIOHDY0E4PiJUXzj13eRPkH0IFjezpI0/Q4eyXM6omcISb12PCHgvaQ06JwMuHJ Sdc0iAbQs26eRjYXM0VHDS2ajD9hT6av79xQ== X-Gm-Gg: AYBFou3fdJabbyyY1r3kXS0tI1LDBvtphpqNH/xGhMarkZ/EaNgmPvGZWNXt2uYZNkI CNrvL3cbsmtO7RrgHqpYXZPrr7m0rY1MnsFajr0vJdzUoFaNeJNuHHuzXDEQxFPZ5rqhR+gqPrg tl1752GxTzc2xZiMaHvfNefCisIT/MV1h5xPDY/m6WDG3ycsckvsaP/LUAIcSsdYXI+XN1+Ckhl UjjU6kSJx/q385N4Gcyd/HkjHK7yMVA4ar4Q4P+e4TJaND8jvh9t5gBlT1cBENw4dWzzG66GV2R 0gH8rn+E6UwdoW4huqb9qdfzHg9slUaF4CjN12jr8qyDxnEWgtfQ4p/YhrblOQm8uIC3Wer7V35 SlCF1a58y7wIiLm5b8D8gK2o= X-Received: by 2002:a05:600c:5391:b0:49c:fa21:1c7e with SMTP id 5b1f17b1804b1-49e619bb6b3mr36033735e9.19.1789117422269; Fri, 11 Sep 2026 02:03:42 -0700 (PDT) X-Received: by 2002:a05:600c:5391:b0:49c:fa21:1c7e with SMTP id 5b1f17b1804b1-49e619bb6b3mr36032975e9.19.1789117421625; Fri, 11 Sep 2026 02:03:41 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , "Denis V. Lunev" , "Denis V. Lunev" Subject: [PULL v2 60/75] pci: batch BAR remapping into one memory transaction Message-ID: <6bda4e6abaafa3e6f49c4ca51d5a0f55337855fa.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117980108158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" pci_update_mappings() deletes and re-adds a subregion for each BAR whose address changed, and both of those commit their own transaction, so one BAR move costs two full flatview rebuilds. Nothing between the delete and the add touches an address space, so the walk can run inside a single transaction. pci_bridge_update_mappings() already does this for the bridge windows. CC: Michael S. Tsirkin Signed-off-by: Denis V. Lunev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903184542.2629976-2-den@openvz.org> --- hw/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c15f2b9f08..14c78e3c62 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1742,6 +1742,8 @@ static void pci_update_mappings(PCIDevice *d) int i; pcibus_t new_addr; =20 + memory_region_transaction_begin(); + for(i =3D 0; i < PCI_NUM_REGIONS; i++) { r =3D &d->io_regions[i]; =20 @@ -1778,6 +1780,8 @@ static void pci_update_mappings(PCIDevice *d) } =20 pci_update_vga(d); + + memory_region_transaction_commit(); } =20 int pci_irq_disabled(PCIDevice *d) --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117982; cv=none; d=zohomail.com; s=zohoarc; b=VSyrhIGoJDu99X2wQDDK3zdCGcr9q6QrdoxOmW/6p9ZyTvCeXRsWF5F9zOB+yv8g0TwyLSuE0QPGoelz41W1ShFMTaZxgnNptc13oOVmMbPISDLUcVLTX54Zt/OLYMLCA9c947wQA2MSgdVDZ7RXziGhLi65Iufy4MfJa1lUMGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117982; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c093DEqy/fkrW/Lhh1nhHFo8QJoMiHWxFZZ8F2Ne0/E=; b=bIY5lCvrV17UoiZYiAqjVmyN/qIYDtxRrPR7+hFc2CjdCxaO/i4QuomwUZPRMdp0TACDtB7U+Uhjv1begly4JIUXVAkOmVL27GPczOR0x7v3LmBCrmvYmqS17m6QQC6nOR5cn2i0l17gq3XXMxqpO4mjrs9T2cBHFxgaIx4WBtg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117982029234.3075306966614; Fri, 11 Sep 2026 02:13:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xB3-0006bK-Tn; Fri, 11 Sep 2026 05:04:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAj-0004ei-Ai for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAh-0008MO-QW for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:49 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-KjsOjIxmPbC1nwHNeZ9l5A-1; Fri, 11 Sep 2026 05:03:46 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-490a767c7dcso5386945e9.2 for ; Fri, 11 Sep 2026 02:03:45 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm29818345e9.4.2026.09.11.02.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117427; 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=c093DEqy/fkrW/Lhh1nhHFo8QJoMiHWxFZZ8F2Ne0/E=; b=LdeO+wk4RTpJo3/q3ggtPFtLjj/Ki5zW8ou+xfxofOrAPMGx4fDR9Tu0KYqLKg/kfyOGmI LF//HasPbN61Ve4UD1q0NZnHBe0s7YWMg4DmaJnLkDG1AR3tcQ2b/O56wDqTHBa0SeD6aG GF9KM8N1DanGRI5yVIHSI3ciz8DOXz4= X-MC-Unique: KjsOjIxmPbC1nwHNeZ9l5A-1 X-Mimecast-MFC-AGG-ID: KjsOjIxmPbC1nwHNeZ9l5A_1789117425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117425; x=1789722225; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=c093DEqy/fkrW/Lhh1nhHFo8QJoMiHWxFZZ8F2Ne0/E=; b=R7iqxbSvIpiTpdOoNYCGRVvlErUgUWvFoA3R5ZFC68rGssHRPMlAQs1xhhq94PcZeG 7lbuhLynP05Wt1MNkBxvxcfWFvUZcyIg8VUfTD6DE/pSz/l8sW41v2eTo0+wVQqAvaLP JaXn9uEMq3iRvy/UxWm5kHB6i36gb/q3ckFo0b+ftcNwHNaiMmEinV1j4SmAxUbHXyCb SsIFxgz9NpQnAYiSjikjHpPLrGL8yfAmkdY4D8eTZfYcZR4SNz/jXvfJ+fx8FYjCuZcH mLCQYVy+rn6HAxC5k3dsIPmEkY5TX35Q/LJedfGumz1orVeFmaSyQWdP3HDUd6YuVg71 iNAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117425; x=1789722225; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=c093DEqy/fkrW/Lhh1nhHFo8QJoMiHWxFZZ8F2Ne0/E=; b=IfvyphmX3BZkyNrcOYpPkHpOG43mrsX8uaP1YM8jL/XlLf6S4GJzyI0LGg7xTwgUek 6czJEzF/Too4VSB+eEaAq4Xf0Dx2mkId1H3cvKKuQ01lbQLGS2X+a8NgAII2vm17cScC PETgBBa6RTLENXjueSMiVT8YzpaZNszuBIsthLCSQUJIwKywLlz1Xafs3r63m7VTACNw uuhroOCGndqmEXlLBcXLl4e9vkKjIZgYLBGiannLD/ZVR1jlZIGLasbjTWhT/8thqXnx PdHFXis5ZZgtBXlEeaXJ3fZs7x536kV9H7QeMHoHQ8fBDkKZ8Wz3DqbEJvX+Gy1hjaD7 FS2w== X-Gm-Message-State: AFuF++n0S/97Jw0HcfljXhFYRDpZYoQ5HO3/NTzMUYwdROU19tSJBsvt GjQgkoJjkOHpb9f/EzOHMvLUozHbVrhI4lbxxp5V6A0JtEVGLVbsVrd5D6BftSraSQRz7shGym9 /zJxPLWJFqW2XYKsnr1BEIbKw6P7Qp/x88+1nKAxevKH3kh+GIHOeKfZHLrcVgmd9H1ZXoddnCP BWuudaOOwQzCw8qs+LRZJZGZu7POPb+PgVUQ== X-Gm-Gg: AYBFou3FDbQqBgH9M8o0FEhrJvO4/LPEFG7nipgOvz4cCuN9qH1hl6uD7kfnPA3Jqg/ /BQ8W2B/hVX0HVlOHJfzPDIl3Dk1qFg+3ALr6iMJQDRxxxDwEVd3xRIWPF1hX7Ftnk1Tsb5upLn w9YpaNNHyOTC/t68rBcxCxqxuIXtzIjnoZHW/rXn3QbE5SsO7yecezDkR1rhJIJc9pUjOnZUphi rfKY9Oqu3dpNxSUZXfByBuT2jpR1VQ6TvNtI8H4S9DDlkbTC3vKnsWwnMREzcD41PJV7lP4cp+X bEBhtmbkUlOpOr7/1O200xcVnlVYdCWYQR1/Qt/zhjEZEdu4aj2yOkTeQbDQ8bHR7eQuHudbh7K z4W2qgGsfFB+wkEEZ9DBuK0I= X-Received: by 2002:a05:600c:3d96:b0:49d:72d:9ba3 with SMTP id 5b1f17b1804b1-49e619b5dddmr30878335e9.14.1789117424440; Fri, 11 Sep 2026 02:03:44 -0700 (PDT) X-Received: by 2002:a05:600c:3d96:b0:49d:72d:9ba3 with SMTP id 5b1f17b1804b1-49e619b5dddmr30877635e9.14.1789117423926; Fri, 11 Sep 2026 02:03:43 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , "Denis V. Lunev" , "Denis V. Lunev" Subject: [PULL v2 61/75] pci: load a device's config inside one memory transaction Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117984124158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" Restoring config space remaps the BARs, updates the bridge windows when the device is a bridge, and toggles the bus master region. Each of those commits a transaction of its own, so one device costs several flatview rebuilds where one would do, and the cost of a rebuild grows with the number of regions in the machine. Nothing between them touches an address space, so the three can share a transaction. The saving scales with the number of PCI devices. CC: Michael S. Tsirkin Signed-off-by: Denis V. Lunev Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903184542.2629976-3-den@openvz.org> --- hw/pci/pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 14c78e3c62..0efb4eb4bb 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -840,6 +840,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv,= size_t size, } memcpy(s->config, config, size); =20 + memory_region_transaction_begin(); + pci_update_mappings(s); if (IS_PCI_BRIDGE(s)) { pci_bridge_update_mappings(PCI_BRIDGE(s)); @@ -848,6 +850,8 @@ static int get_pci_config_device(QEMUFile *f, void *pv,= size_t size, pci_set_master(s, pci_get_word(s->config + PCI_COMMAND) & PCI_COMMAND_MASTER); =20 + memory_region_transaction_commit(); + g_free(config); return 0; } --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117934; cv=none; d=zohomail.com; s=zohoarc; b=OmW2lSGhDju0/4jJl8kniczfoouClUoHRt2wwgCVWUTR8siduyBn8rUpFb4cB84t8ldxcUxLCHoPgYs4+u6G2huovItJU77HURc/0HLRqKJCAztRycBViDAU2MdnUc8TLlAaEt00LWB5rUMz5RLbpiq/Qme2wKPx24MQ+g0yYQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117934; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ztnEzJr9cLGP85wdavmJjLJZCpMNN2vWplsbH2YazF8=; b=FE85LdC7cwVUBsSJh7yB9WXvDWV7mSO/RL3xUcPhN+VYaHB8DF5Plxnz/FfPbtAd0tlduyG+/0Knzv6M1sqC6DHf2DNAYr4a1VbpADvYFbYdyZWeZTl4i9bU8Mhp4Un29bMV5iaju78mruH17UGedKUol8Rpg20J8gUt6qq12kE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117934928593.8907124771831; Fri, 11 Sep 2026 02:12:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBI-0007Wx-VU; Fri, 11 Sep 2026 05:04:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAm-0004tr-0x for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAk-0008NP-Ct for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:51 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-gB6eVd4sP2GoTpRU7CD-8g-1; Fri, 11 Sep 2026 05:03:48 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4839f9edb08so340935f8f.0 for ; Fri, 11 Sep 2026 02:03:48 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb330bdcsm4741514f8f.13.2026.09.11.02.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117429; 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=ztnEzJr9cLGP85wdavmJjLJZCpMNN2vWplsbH2YazF8=; b=f/jydRMY8hF8yepxZM14X3h+7H62+mUp2XL11y5TuLKk5NQzHdhVuyB5e8qJfSNMsLB0jd eoVgBrSHFiYqInMQDnlNzx6xtpeP+thw45Hz0VYbDPohhQQTdBaBCErZErK196bUVpTNp5 oyV+VgT55Nsg0X/CfauxebZVYC01Flw= X-MC-Unique: gB6eVd4sP2GoTpRU7CD-8g-1 X-Mimecast-MFC-AGG-ID: gB6eVd4sP2GoTpRU7CD-8g_1789117427 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117427; x=1789722227; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ztnEzJr9cLGP85wdavmJjLJZCpMNN2vWplsbH2YazF8=; b=ehBM6RkRCEyvTjvrmar1Ie1erl1PDbr4QtkhGjhdf5t2ffeFTJyctPsgkWTWCn/YRF ov7K11adSO203GNWfE0LHEFeio+dqvJRYNOLA+CDkEvu1d6BWPI/rVrTfTyUx48GrbYt rIPK0Q3UPrPDZm7u75I1/Ayuhlt42ykgmvP9bWabhZG3B/0/UvsvKQx9pQEog9JnlT84 I1hBuD0tum0LJ5g3aL7yAxHASj70QcHHbA8x3z4DFGyMKt9MyC4nm9eWWYGhr8Hd4bvj FZ+xJ4X+0f0717naby0nPJdBoWW7yKTZbHHIafIHJYBbmWoyxTXMKYjqWgKJ+8wKwuO/ IG2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117427; x=1789722227; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ztnEzJr9cLGP85wdavmJjLJZCpMNN2vWplsbH2YazF8=; b=cFdTLsez6FMrTG4LHLiyrBeIKPf+3Kz37ofLSFKEakYL1yuPf8LHxEjqS+Id/CDZQT AOQ39IdbB+M1WGMNXo+n/nVcaupRmS06eUtq5nyjJCnYGiGnsSNlIzWV0k4a5Ms01hh+ HsdjM1q+HEn0E5XYMy02jO+HhEOfYPqJTmGeNW/lIg91Jth++jB1lDdlXhNHF1R3ruAl amEoHXdf0/18L68tiHljIJx8pOUsMcWPw4Ifeh4iBjVtRnTT4oQ7pF+gJ3XuWRts6imC kS4LDErpOcM8p3F3iTO8GCCQP1cv6W/ITMnXakIDZJEBBduNV6VQPcZavWxTgSaGcP0i tflg== X-Gm-Message-State: AFuF++mGJprlzWm86B5TUm1CZJXJy+hoP6pu87A4SCzZ7+gu0dwyZaXh ymSe2FbKyjMmKftQGU6LLQOyareh5ATgEzimBPF/U9lRpqY26UGO8SLTAN1H0xvjlDFteSIlLuu afldzCOFX3r/w3zTZfJ6nfnXHwA8YMRuI8VtpaigBn9v+b3Eo5Ffscn7kQylC03SX3hPaPr8P4Q e4foLo/WorKBdUySK30JT6UB42bYLvDU/piw== X-Gm-Gg: AYBFou2KHPOcoU2cqXOf2k0fcpQnmyw+LVRURtE94oS0UBiojgs88H1F+kfqZ7SxNMY 4MGcQ/GeN2GUPs1dmxOkGv0lWQaEhDGG/2Et2AqBFwFlNu/daqHKL2oslsBVwLExN+pnRpL0S2C hGGsI4/MztqhZcknjLxGzZe68vQZ2sUWaBoDVBsdrSail6NTPb/UxuCMI4XyEPTkD97Yei+Joia /5BHYRB0b3KueJgg3W7EC6SblJqcAAKwTFdohzf/PLTqKJwxn9GgcNrDe2IXQ1P4OoLFNyYYalx MiuNDGEHsy2yG0pdSog24A8/mg/uqRs/LVtwpsO2RUD/MKxLh/y0mP/Hu7KMvySsYGtUH1lwZCA i0YNQjWyNTBqvxo0PcqSzP0Y= X-Received: by 2002:a05:6000:a8c:b0:485:8c17:9767 with SMTP id ffacd0b85a97d-486eb30c413mr2614982f8f.41.1789117427085; Fri, 11 Sep 2026 02:03:47 -0700 (PDT) X-Received: by 2002:a05:6000:a8c:b0:485:8c17:9767 with SMTP id ffacd0b85a97d-486eb30c413mr2614933f8f.41.1789117426572; Fri, 11 Sep 2026 02:03:46 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:44 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Ani Sinha Subject: [PULL v2 62/75] hw/acpi: Make AcpiGedState const in build_ged_aml() Message-ID: <5f5774ec8e4b7c4d00e68879fbabe00477ce244d.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117935834158500 From: Philippe Mathieu-Daud=C3=A9 build_ged_aml() do not modify the AcpiGedState structure. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903230245.65601-2-philmd@oss.qualcomm.com> --- hw/acpi/generic_event_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 67c9e9b3e8..5225e32513 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -48,7 +48,7 @@ static const uint32_t ged_supported_events[] =3D { void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_d= ev, uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base) { - AcpiGedState *s =3D ACPI_GED(hotplug_dev); + const AcpiGedState *s =3D ACPI_GED(hotplug_dev); Aml *crs =3D aml_resource_template(); Aml *evt, *field; Aml *dev =3D aml_device("%s", name); --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789118060; cv=none; d=zohomail.com; s=zohoarc; b=ZEQMDJL4k2NE1bX87oyYk3ZefZbqrtL8ulanKWVRoGQBiXlLI6LhSqACTjfCXO6ygzwI6pti5/Gh+X8uo6IVH8vx99BxLAWMc4IWPz47yNE7stEtOCzgcy4MgKBBTiRPUUG06/nlg3R5gthRtphwvF2TpFBeJXoLg0oCa6qyVQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789118060; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4CnyxDCKVe7u1Oo/VtDfYPCe5Gbe0/d1270GUGGe0eo=; b=kUID8ZOUTHYdLwXnhw6B+A7psv1nA39qfrkNY03a2zjav1PhBWGXSb+N4t4p2lswWe3+fLrFE53eoq99ityg8juHzizkepSx2QjI4WVsAN4rDzRKVtUCUdVo7K6j3OLbUHln7CL7LMJ5Bp7m02iv1JpZKHKSxl5pe/zDSEHOmS4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178911806002234.59912187052464; Fri, 11 Sep 2026 02:14:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBP-00086w-Ox; Fri, 11 Sep 2026 05:04:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAp-0005Ft-S4 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAo-0008O5-5M for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:55 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-436-OM2LBvbDMeWDrLXS5ZkvSA-1; Fri, 11 Sep 2026 05:03:51 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4994aebe932so8090965e9.3 for ; Fri, 11 Sep 2026 02:03:51 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb32d3c7sm4344189f8f.10.2026.09.11.02.03.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117433; 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=4CnyxDCKVe7u1Oo/VtDfYPCe5Gbe0/d1270GUGGe0eo=; b=XytJIMWSzpfyVmY13W96kgMk42Tq11Sm8MUTeiQzkQvS+gbQrU5/IYciFlFM4Zg/g4/7NF XpDejQ1irATLSuLQrnieb8zh1BB9wFOjpm2UIahuxxWpzR6UzE8pzX7cT6T0FJMWBJH46X EAYdCacbAmueCZQN5T4qvN+Tddu4hAg= X-MC-Unique: OM2LBvbDMeWDrLXS5ZkvSA-1 X-Mimecast-MFC-AGG-ID: OM2LBvbDMeWDrLXS5ZkvSA_1789117431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117430; x=1789722230; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=4CnyxDCKVe7u1Oo/VtDfYPCe5Gbe0/d1270GUGGe0eo=; b=FQqQ/knHTVjt6FeYIcqZ3WoqdUCCXjZq027spnDQ9c0prBHov2p7rhO8YE/uqAeWuo uaSD5DkTurK1N/dIb78ipX4DxPkJaTGH9wKK1G/YOcv+8xPCXO6QicK1YOLBwTvdYPhY Um4+K2b1aSlF9Q5NHi8hNtfq6tPwSv+v0tr9GQl/C8cAXPnp5dG8GCum2FaWMwpvR4ew f/WoZl9z5IeEBvMPAP0H0u7wGTKBbLi3WRWk0xjsN1AlqdBJlFo+WzAbdk0T0rrgV2EE qUhShl4zqHD6AEbBNfIofw3wFIdA9vcmd2u4+iKmrDLOK8P62VEquU47QKR7bXBVRxGV GLUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117430; x=1789722230; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=4CnyxDCKVe7u1Oo/VtDfYPCe5Gbe0/d1270GUGGe0eo=; b=JEO4Y+ilDAEQ3+8LB9V8JmtzEdxVutoHVhQ4Cg1JlHtPhbKSg8LJ0I0FTD4MWgHzXq g2f9X97Zuqawf4sdtoyN2p/M1ZL+DJHXf8rAKo0ZwkeDPOUf747iNV4HgIMi9h0zLfLB Pn0b5dLxskadx5zfROqQkxmJ0UhXZXscP3Sq5PtE8wR4InrVHmoaewCCOIhpQclhoEYa 2qSS3LEDhAXo91xWHAoNPHMgbMQhuAiYoTHJPe8WRX0nrNsbTO1VxONNAKpnsEDCjqNi 4PtH8+TVWSkStIe/sR2r/Xlj+nEo3WBejF1UGZWm4unrFRqlvpyaWRJipLpE6eHOfx+c U6xA== X-Gm-Message-State: AFuF++kzRlHiHvwidurQSlzOK1ULJplK5xnZyf6NQj0HSrsoTH35C0jL 073suu/OJTQ+GCofMng/zFsvkSISAP61+Cbq5eIqhDQ32egpwADdRIYVOhiPfDyhc8zVpjxD8gz dTf+/Rb9ZC10GeiRxK/cDzH7rGLoElOvX68jjqWQX3rk4LEFWzI/z3tXQO2m15XItR5u2a4pUHk hixGf9yZehxv4vPRlw8qrtYLNjgz4KUsQs6A== X-Gm-Gg: AYBFou04HBdL1zd/1yGy8mE9WoqJZx1zspT+gc9+EHU5MfhiPlulmY6OW5x2ZCtxJcF C2H2WT20RULA+HgltW8PemxDyZIOTjue1BDY6x7FWkejxhvsSaCNVVlJjV62p/zMpb4ED/vhpMg MtKjJmLwZc128dH0RoK1/pgq8L3KZccGrrBO0fKGGdXdSZGWdNAfGOW9YkM2XtAdzKIk0G6ixGT MvZdi9XdUDauYx89iq/n9MBbj661+DO5oADEFVOjTZV7+jNnFTgGJIuszA7LMh6nMrHcNjRAEol jDjRR1BY/UxAhF0WONWGvx+7VbC0+EKStnp66+kpHb0hPgmP2yo77EYZKWtsSkJ/BJ5M41ubgVD f7W5Ghb3w8ZbxZU1Jqw/RTto= X-Received: by 2002:a05:600c:19c8:b0:499:b65e:49c9 with SMTP id 5b1f17b1804b1-49e619f3ae1mr61272745e9.10.1789117430214; Fri, 11 Sep 2026 02:03:50 -0700 (PDT) X-Received: by 2002:a05:600c:19c8:b0:499:b65e:49c9 with SMTP id 5b1f17b1804b1-49e619f3ae1mr61271225e9.10.1789117429657; Fri, 11 Sep 2026 02:03:49 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , David Hildenbrand , Cornelia Huck , Halil Pasic , Eric Farman , Christian Borntraeger , Matthew Rosato , Richard Henderson , Ilya Leoshkevich , Paolo Bonzini , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , qemu-s390x@nongnu.org Subject: [PULL v2 63/75] hw/hotplug: Mark various HotplugHandlerClass variables as const Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789118062459158500 From: Philippe Mathieu-Daud=C3=A9 The HotplugHandlerClass pointers are only dereferenced, not updated. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903230245.65601-3-philmd@oss.qualcomm.com> --- include/hw/core/qdev.h | 2 +- hw/core/hotplug.c | 8 ++++---- hw/s390x/virtio-ccw-md.c | 2 +- hw/virtio/virtio-md-pci.c | 2 +- system/qdev-monitor.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h index f054a214fc..e4cb027ab3 100644 --- a/include/hw/core/qdev.h +++ b/include/hw/core/qdev.h @@ -1069,7 +1069,7 @@ static inline bool qbus_is_hotpluggable(BusState *bus) bool ret =3D !!plug_handler; =20 if (plug_handler) { - HotplugHandlerClass *hdc; + const HotplugHandlerClass *hdc; =20 hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); if (hdc->is_hotpluggable_bus) { diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c index 68aabad8ae..00e80a67c8 100644 --- a/hw/core/hotplug.c +++ b/hw/core/hotplug.c @@ -17,7 +17,7 @@ void hotplug_handler_pre_plug(HotplugHandler *plug_handle= r, DeviceState *plugged_dev, Error **errp) { - HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); + const HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_hand= ler); =20 if (hdc->pre_plug) { hdc->pre_plug(plug_handler, plugged_dev, errp); @@ -28,7 +28,7 @@ void hotplug_handler_plug(HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { - HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); + const HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_hand= ler); =20 if (hdc->plug) { hdc->plug(plug_handler, plugged_dev, errp); @@ -39,7 +39,7 @@ void hotplug_handler_unplug_request(HotplugHandler *plug_= handler, DeviceState *plugged_dev, Error **errp) { - HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); + const HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_hand= ler); =20 if (hdc->unplug_request) { hdc->unplug_request(plug_handler, plugged_dev, errp); @@ -50,7 +50,7 @@ void hotplug_handler_unplug(HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { - HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); + const HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_hand= ler); =20 if (hdc->unplug) { hdc->unplug(plug_handler, plugged_dev, errp); diff --git a/hw/s390x/virtio-ccw-md.c b/hw/s390x/virtio-ccw-md.c index 0370f58450..0b18b49bc4 100644 --- a/hw/s390x/virtio-ccw-md.c +++ b/hw/s390x/virtio-ccw-md.c @@ -73,7 +73,7 @@ void virtio_ccw_md_unplug_request(VirtIOMDCcw *vmd, Machi= neState *ms, VirtIOMDCcwClass *vmdc =3D VIRTIO_MD_CCW_GET_CLASS(vmd); DeviceState *dev =3D DEVICE(vmd); HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); - HotplugHandlerClass *hdc; + const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 if (!vmdc->unplug_request_check) { diff --git a/hw/virtio/virtio-md-pci.c b/hw/virtio/virtio-md-pci.c index 9278b32cf8..aa5b11c0f6 100644 --- a/hw/virtio/virtio-md-pci.c +++ b/hw/virtio/virtio-md-pci.c @@ -72,7 +72,7 @@ void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, Machi= neState *ms, VirtIOMDPCIClass *vmdc =3D VIRTIO_MD_PCI_GET_CLASS(vmd); DeviceState *dev =3D DEVICE(vmd); HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); - HotplugHandlerClass *hdc; + const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 if (!vmdc->unplug_request_check) { diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 5c87fda509..0c5502d45b 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -918,7 +918,7 @@ static DeviceState *find_device_state(const char *id, b= ool use_generic_error, void qdev_unplug(DeviceState *dev, Error **errp) { HotplugHandler *hotplug_ctrl; - HotplugHandlerClass *hdc; + const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 if (!qdev_hotunplug_allowed(dev, errp)) { --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789118018; cv=none; d=zohomail.com; s=zohoarc; b=GAIO5AS+0PNutfpa8qCT2taWQhbn7pJNyuOzc4XhGZseUulUoC2hXWfhPBBlmUAx0Txmf2ibDk3QnbFCFJTcJ7ALDPZkMXAyEDB6zO3zlVgpxvbGXqd7AiWGHoIXKNx2XeVxlCG/5wXUREoYs98GoORBmZTBy0V3oXDYSmsj2f8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789118018; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0xy/HYzVNQBnkK+frgobWoz0pO/IVcyKqhz4VJS2NJ0=; b=kAJS23lkXnezTFgwk5todCfTZr1uk0G6p6ujfAmDj6B1N5LrZsaxTo7zn6AL0yR+5UXok2EstmbtwSbzvvGGAsq1VJC/PD/LitIts6j5xdizaiRg7QVkDexw7n+WrXzTUIUpxFdM5aM2WKGf5DCZqEvB1Dno4Ssb6Be+zvV9HjI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789118017960309.9193022294003; Fri, 11 Sep 2026 02:13:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBM-0007sc-R0; Fri, 11 Sep 2026 05:04:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAr-0005SY-BI for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAp-0008OL-Kq for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:03:57 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-OYkU4ms4Oaan7kgFGvn6uA-1; Fri, 11 Sep 2026 05:03:53 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-485b0c83a89so531009f8f.2 for ; Fri, 11 Sep 2026 02:03:53 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb2ecf2esm5115074f8f.2.2026.09.11.02.03.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117435; 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=0xy/HYzVNQBnkK+frgobWoz0pO/IVcyKqhz4VJS2NJ0=; b=Ha+1QXHA6VrHlMT/nezCIYL33S+uu24XvuJM0ROYpIHUvCyTAmW88lxvJrOXIw49yrEqs1 WQ/sit2zYn7Twa3PH92yCoI9Sp97nQ6xBblN+ByjDJSZ3dYSn1faLrsjpGIS2YgQ3TYVXg UiDK/xbFVyHnWkJjNQ7meg0afJJSbXU= X-MC-Unique: OYkU4ms4Oaan7kgFGvn6uA-1 X-Mimecast-MFC-AGG-ID: OYkU4ms4Oaan7kgFGvn6uA_1789117433 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117432; x=1789722232; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=0xy/HYzVNQBnkK+frgobWoz0pO/IVcyKqhz4VJS2NJ0=; b=NjdJzcbKSshRK//FpwydApr2FsyIUeUvE2OKgJMP//FnAR1rao/0/pMM+Mq/7x68RT HMrE3UeEsokznuitF0XDFZStmtOWu4r0X5xloTeoZX2qH0mFNsWsX0utfchkw8O7Lu80 aanNlYwrgRYOkRt/TCkOtIBgAVL9vnj89BSVrb4cUfpet/JWTmNqGu2k8WLpwruwxj8v /D/PMhpum8WBjVna3plnzV/SzF49W9csGZimT8T/2iSEsYk4OQM0X33xJRXpjpp25epW CvrmSMFHtOtPrKw4nZUOTllvd9z+GDtBtbRNJs+6LiOfMt1sa9hteBKaZdcUnboUSCbG yumw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117432; x=1789722232; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=0xy/HYzVNQBnkK+frgobWoz0pO/IVcyKqhz4VJS2NJ0=; b=S7qUoYGky5bGOYCNAsVC7sWLj2d5xmKYCTdGSt3KwUlitBz7sCO68M7/ef9Oky2qsc bm53VGqbIMYZ7ET3P95XRg6y8sFRq0d9lFpBQ41s5+f5tV+NT+1US1zvXt/ktnupVZ43 euYfaCCPG20luAdBPlM6dOoh+iX+t/+Cmd21O9ApOHYlyUk/haUscNKCGq9m3PjzQbik sabrsvotYxpfEw/V1dYrDmtEjroXhG4asR9tVqAVmeN/A0EongQJuc4DXxGG2RElTgC7 U0SBzHdCsQCXU45o6XQfkbdV82C7hQAAN1NAiI1d6W+T4PxThSk6D6DteKRHQmUnvNKv z1kw== X-Gm-Message-State: AFuF++lIeYXEyNeBDxJhQ63Dh3a15JIgoJuTOGixVVW9nY0kBkK2Cny5 +UBV3aJHNEKps3X7REIqds8xD+fi0NZmzMHgJ+3lJB8U/JGZxz7/GlVWhm3RZhGr+CAkMdYpuG+ C+GHRm2D2RTiZuGW1Rz79Sqj+9bo30pGHjE4osd5fka/q8O/BAH1Iax4qESvjCeQZwbsDdKtABT WNOoHMRfzJxA0PH8JrtoAtZtCOISIo561GZw== X-Gm-Gg: AYBFou0LLFk/5HXg9OMYHCrcLMloD+lYALWNR1c/GXE/Hi8GK2S5kxVcWMqDggzZdPf +n+hAz5S6r9yZhv/wop7ArFxjHWuhKz1b+zFvZyleeODKRNfdLwf02S68tJG70spsmnv0h8ip28 ctnLNobKDzZftHMveG7PYwxtvvETyKS7Fwr9obsympnvEi9jTY6CHHi91PQM+Xe1fW3Sj6Q59Pe n2K1uRGfR3Hb+NQ/qPa3BJL4TvUGleKrjSmJ230aeUjCkvLtm7UFL8x3+DAbXLApqMBvm4Qgg7D 34DA+UqIgBHWjjmo3XN7T9BU5i9ual9LJgcgNLSjk3uT0ko4ovSS9wWAQmCHC/gHjZK/H1mMGdi zNWAp+Pv8W4AKUfitj1dG0tU= X-Received: by 2002:a05:6000:240c:b0:486:f282:5952 with SMTP id ffacd0b85a97d-486f2825c45mr627862f8f.2.1789117432427; Fri, 11 Sep 2026 02:03:52 -0700 (PDT) X-Received: by 2002:a05:6000:240c:b0:486:f282:5952 with SMTP id ffacd0b85a97d-486f2825c45mr627792f8f.2.1789117431807; Fri, 11 Sep 2026 02:03:51 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Ani Sinha Subject: [PULL v2 64/75] hw/hotplug: Reduce some HotplugHandler variables scope Message-ID: <187820773599ebb81463c2114a7a410df5651853.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789118020280158500 From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903230245.65601-4-philmd@oss.qualcomm.com> --- hw/acpi/memory_hotplug.c | 3 ++- hw/acpi/pcihp.c | 3 ++- hw/pci/shpc.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 1ddfdd17b7..f482c835a1 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -119,7 +119,6 @@ static void acpi_memory_hotplug_write(void *opaque, hwa= ddr addr, uint64_t data, MemStatus *mdev; ACPIOSTInfo *info; DeviceState *dev =3D NULL; - HotplugHandler *hotplug_ctrl =3D NULL; Error *local_err =3D NULL; =20 if (!mem_st->dev_count) { @@ -167,6 +166,8 @@ static void acpi_memory_hotplug_write(void *opaque, hwa= ddr addr, uint64_t data, mdev->is_removing =3D false; trace_mhp_acpi_clear_remove_evt(mem_st->selector); } else if (data & 8) { + HotplugHandler *hotplug_ctrl; + if (!mdev->is_enabled) { trace_mhp_acpi_ejecting_invalid_slot(mem_st->selector); break; diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index b26ddf0a26..336ebe1a13 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -173,7 +173,6 @@ static bool acpi_pcihp_pc_no_hotplug(AcpiPciHpState *s,= PCIDevice *dev) =20 static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsign= ed slots) { - HotplugHandler *hotplug_ctrl; BusChild *kid, *next; int slot =3D ctz32(slots); PCIBus *bus =3D acpi_pcihp_find_hotplug_bus(s, bsel); @@ -210,6 +209,8 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, un= signed bsel, unsigned slo */ qdev->pending_deleted_event =3D false; } else { + HotplugHandler *hotplug_ctrl; + hotplug_ctrl =3D qdev_get_hotplug_handler(qdev); hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abor= t); object_unparent(OBJECT(qdev)); diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 938602866d..1198e1ab8c 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -271,7 +271,6 @@ static void shpc_invalid_command(SHPCDevice *shpc) =20 static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot) { - HotplugHandler *hotplug_ctrl; int devfn; int pci_slot =3D SHPC_IDX_TO_PCI(slot); for (devfn =3D PCI_DEVFN(pci_slot, 0); @@ -279,6 +278,8 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc,= int slot) ++devfn) { PCIDevice *affected_dev =3D shpc->sec_bus->devices[devfn]; if (affected_dev) { + HotplugHandler *hotplug_ctrl; + hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE(affected_dev)= ); hotplug_handler_unplug(hotplug_ctrl, DEVICE(affected_dev), &error_abort); --=20 MST From nobody Sat Sep 26 20:50:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117471; cv=none; d=zohomail.com; s=zohoarc; b=CksidtWrzpA4OFA5PdtQHCthyAzvnOvZ8EHCsHUqqs2iFw4uwDMyb4GqN1YqklLuDKFMfFOGdjjftJQf7uSz/Egs8JY0/rOiEQdV1MTrmo59AGYwAEKyMJYOnOu5lxTPs2fon4M3ZwPw22sAvpPfYGcBNCcJnhJeTHsIbHrsfHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117471; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wP5nj9MfiPsEKxjmqX6H5CG7YIoHYGFHlaBEBpbtyXc=; b=cI2K412V0u+wCCnFg9eTc24PKLaDTRJuqf57fWjKojUP64XEf214oWI5f9vZKP1VFCI6nmnexPJqw7OP0Ci7Ps7kbCSfW/uZDUVm19M5GZDoJXVpiTXm4Un7PzXHrrs3b4Q9a6Op6CPSK2ZKgWM0fVoXegLxpsKPisAitdBja/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789117470999432.3848907684177; Fri, 11 Sep 2026 02:04:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1416046.1645215 (Exim 4.92) (envelope-from ) id 1x4xB3-0005m8-GZ; Fri, 11 Sep 2026 09:04:09 +0000 Received: by outflank-mailman (output) from mailman id 1416046.1645215; Fri, 11 Sep 2026 09:04:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4xB3-0005m1-BL; Fri, 11 Sep 2026 09:04:09 +0000 Received: by outflank-mailman (input) for mailman id 1416046; Fri, 11 Sep 2026 09:04:08 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4xB1-0005kp-O1 for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 09:04:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4xB1-003BIA-4V for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 11:04:07 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa3c404-2eae-0a2a0a5409dd-0a2a4506da0e-6 for ; Fri, 11 Sep 2026 11:04:06 +0200 Received: from [170.10.129.124] (helo=us-smtp-delivery-124.mimecast.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa3c405-195a-0a2a45060019-aa0a817cc45d-3 for ; Fri, 11 Sep 2026 11:04:06 +0200 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-175-7JgCgYNQPcuRven8zXkDgQ-1; Fri, 11 Sep 2026 05:04:02 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49cd83ca361so6764125e9.1 for ; Fri, 11 Sep 2026 02:04:02 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb33e020sm4665942f8f.18.2026.09.11.02.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:03:58 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mimecast20190719 header.d=redhat.com header.i="@redhat.com" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117444; 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=wP5nj9MfiPsEKxjmqX6H5CG7YIoHYGFHlaBEBpbtyXc=; b=ZLTfcT9MBiUgWBjJ1Afb7XWB3SIvm6l5fWX+KbcPEvFoZxHhwaH/y069h+/3EOmbMVmp+U NMlFOVNdW8kq1nUoSjhVIo80LI09MhKNBcOL+Tc27StAOzn3uw3K06t1JZwOj1mcfqhHER TC7TTQi6FO94GhTlAVUCQkODxiN9GeQ= X-MC-Unique: 7JgCgYNQPcuRven8zXkDgQ-1 X-Mimecast-MFC-AGG-ID: 7JgCgYNQPcuRven8zXkDgQ_1789117442 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117441; x=1789722241; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=wP5nj9MfiPsEKxjmqX6H5CG7YIoHYGFHlaBEBpbtyXc=; b=Mviz1yOk3Ex4pJqmvTpwcOy+QHPU7c8QWoCKTFH79B29koeV7b+nr2RqewT8H0ZBjU HQxmfVl1sQSjKw8iyIbYL2iNXtZlueDhdl8Pfs//UW1bkA5GMkht/IAhLhqGWHNSq2M8 bote6wa6m3y0MZ+brLzqIOmau7FLw1No6i0fX0CYO2vFzEWGT4jw+WsjeRO0sIRTUT43 zL5kXUEWwIHaeK5/lhg+/UctnlSEbK9KdcdicHZGYhZt4dEDjnOYDcPFCkpLuP+kcbdU w9UPPwA+VqlDyrPokABlUJbF4UfC7UKIjbJu5vw6mgRIYo+DFsMx+Vke9VnKjnHtxy3Y H5sg== X-Forwarded-Encrypted: i=1; AKwUvByjfTusScitFl7kv5mTLE7UOBK/j7cDVnhJXEiv09WUk7XfaKq8EmpZaC0Pd/N8d/qwFokpNrtOI1o=@lists.xenproject.org X-Gm-Message-State: AFuF++ncg1Iw70C7rTzbeNU3fWeN1Bkejom72d+mIgsTnZ3KbXBJr5kI IdP1b4o6nZf/YSUSUe3+dY4PJoqJ5Ye+yMXGDL9D32PtOz/N82Su7YWZ+Vk0TXBYEtQDeBWSWyy lpsI2+PELgtePELhRrD9tQy6MaP5wm1TyNdQ8rKBJqPzvpNCFNkHZ0X5df4ojxGTbyriY X-Gm-Gg: AYBFou1t54YQ/gxIxBiK/eqq5eKxL+j6N2obGdrjy8mW1zGSQirr0/gOsnPGc2O+IuC TxTth+5Zu6ETDgcSNSy/e5PqqLiuQr0juucW3/OVa0U/GMIASfjHWQStfZ1hEVEo8p1jBXT12ZB xopRA3HsBXIh2ghBt02dPlNHbE4ytY+Y8W23Ezof5wOT7WXo2a5x22mco1HsDmWY4x7ap/OZPWf DdvwQ9ut0dAeW46u1Ca/3J8vchjsB7MCokEfBxirqADf59/IYbfmgSRXCcGdYZuJP8DbmRfp9se NpVcfUGwgFDQTMW/ADdmvDDg99pM5GE4IixviKhsC8qzMpSUgXlzfByTLqRi2qAJtKwQLRM/EJt 5/efGdacT3wJdrHw4zYvvJoA= X-Received: by 2002:a05:600c:4fc8:b0:49c:cedc:3c36 with SMTP id 5b1f17b1804b1-49e619bd0femr35026225e9.16.1789117440216; Fri, 11 Sep 2026 02:04:00 -0700 (PDT) X-Received: by 2002:a05:600c:4fc8:b0:49c:cedc:3c36 with SMTP id 5b1f17b1804b1-49e619bd0femr35024785e9.16.1789117438990; Fri, 11 Sep 2026 02:03:58 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Ani Sinha , Aurelien Jarno , Laurent Vivier , Amit Shah , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Sergio Lopez , Richard Henderson , Song Gao <17746591750@163.com>, Bibo Mao , Xianglai Li , Jiaxun Yang , Jason Wang , Keith Busch , Klaus Jensen , Jesper Devantier , Bernhard Beschow , Nicholas Piggin , Harsh Prateek Bora , Amit Machhiwal , Elena Ufimtseva , Jagannathan Raman , Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , Halil Pasic , Christian Borntraeger , Eric Farman , Farhan Ali , Cornelia Huck , Matthew Rosato , Ilya Leoshkevich , David Hildenbrand , Fam Zheng , Dmitry Fleytman , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Zhao Liu , FangSheng Huang , qemu-arm@nongnu.org, qemu-block@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, xen-devel@lists.xenproject.org Subject: [PULL v2 65/75] hw/hotplug: Constify HotplugHandler Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: JDt-nFTBIePsUkkS8M68Gvot-asAqSw08RjNjdQ4Bcs_1789117442 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1789117446-FE0714DB-33620ADA/0/0 X-purgate-type: clean X-purgate-size: 99091 X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117473049158500 From: Philippe Mathieu-Daud=C3=A9 HotplugHandler value returned from qdev_get_hotplug_handler() points to the handler of and object implementing the TYPE_HOTPLUG_HANDLER interface. That handler mostly points to read-only section which shouldn't not be updated. Better protect it with the const qualifier. Mechanical change using 'sed' then manually adapted coding style. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260903230245.65601-5-philmd@oss.qualcomm.com> --- hw/s390x/ccw-device.h | 2 +- include/hw/acpi/cpu.h | 4 +-- include/hw/acpi/cpu_hotplug.h | 2 +- include/hw/acpi/generic_event_device.h | 3 +- include/hw/acpi/ich9.h | 10 +++--- include/hw/acpi/memory_hotplug.h | 4 +-- include/hw/acpi/pcihp.h | 8 ++--- include/hw/core/boards.h | 4 +-- include/hw/core/hotplug.h | 13 +++---- include/hw/core/qdev.h | 12 +++---- include/hw/i386/microvm.h | 4 +-- include/hw/i386/x86.h | 10 +++--- include/hw/mem/nvdimm.h | 2 +- include/hw/pci/pci_bridge.h | 6 ++-- include/hw/pci/pcie.h | 8 ++--- include/hw/pci/shpc.h | 6 ++-- include/hw/ppc/spapr_nvdimm.h | 2 +- hw/acpi/acpi-cpu-hotplug-stub.c | 4 +-- hw/acpi/acpi-mem-hotplug-stub.c | 4 +-- hw/acpi/acpi-nvdimm-stub.c | 2 +- hw/acpi/acpi-pci-hotplug-stub.c | 8 ++--- hw/acpi/cpu.c | 6 ++-- hw/acpi/generic_event_device.c | 11 +++--- hw/acpi/ich9.c | 10 +++--- hw/acpi/memory_hotplug.c | 6 ++-- hw/acpi/nvdimm.c | 2 +- hw/acpi/pcihp.c | 10 +++--- hw/acpi/piix4.c | 12 +++---- hw/arm/virt.c | 23 ++++++------ hw/char/virtio-serial-bus.c | 2 +- hw/core/hotplug.c | 8 ++--- hw/core/qdev-hotplug.c | 10 +++--- hw/core/qdev.c | 2 +- hw/i386/microvm.c | 12 +++---- hw/i386/pc.c | 28 +++++++-------- hw/i386/x86-common.c | 8 ++--- hw/intc/loongarch_dintc.c | 8 ++--- hw/intc/loongarch_extioi_common.c | 4 +-- hw/intc/loongarch_ipi.c | 4 +-- hw/loongarch/virt.c | 44 +++++++++++------------ hw/net/virtio-net.c | 4 +-- hw/nvme/ctrl.c | 8 ++--- hw/pci-bridge/pci_bridge_dev.c | 6 ++-- hw/pci/pcie.c | 10 +++--- hw/pci/pcie_port.c | 2 +- hw/pci/shpc.c | 10 +++--- hw/ppc/e500plat.c | 4 +-- hw/ppc/spapr.c | 48 +++++++++++++------------- hw/ppc/spapr_nvdimm.c | 2 +- hw/ppc/spapr_pci.c | 12 +++---- hw/remote/machine.c | 2 +- hw/riscv/virt.c | 6 ++-- hw/s390x/css-bridge.c | 2 +- hw/s390x/s390-pci-bus.c | 12 +++---- hw/s390x/s390-virtio-ccw.c | 16 ++++----- hw/s390x/virtio-ccw-md.c | 8 ++--- hw/s390x/virtio-ccw.c | 2 +- hw/scsi/virtio-scsi.c | 6 ++-- hw/scsi/vmw_pvscsi.c | 4 +-- hw/virtio/virtio-md-pci.c | 8 ++--- hw/xen/xen-bus.c | 2 +- stubs/hotplug-stubs.c | 6 ++-- system/qdev-monitor.c | 2 +- 63 files changed, 257 insertions(+), 253 deletions(-) diff --git a/hw/s390x/ccw-device.h b/hw/s390x/ccw-device.h index 15f64cfb63..c303f1de42 100644 --- a/hw/s390x/ccw-device.h +++ b/hw/s390x/ccw-device.h @@ -37,7 +37,7 @@ extern const VMStateDescription vmstate_ccw_dev; =20 struct CCWDeviceClass { DeviceClass parent_class; - void (*unplug)(HotplugHandler *, DeviceState *, Error **); + void (*unplug)(const HotplugHandler *, DeviceState *, Error **); bool (*realize)(CcwDevice *, Error **); void (*refill_ids)(CcwDevice *); }; diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h index 04c821d2b9..3664ac7a52 100644 --- a/include/hw/acpi/cpu.h +++ b/include/hw/acpi/cpu.h @@ -39,10 +39,10 @@ typedef struct CPUHotplugState { AcpiCpuStatus *devs; } CPUHotplugState; =20 -void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_plug_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **e= rrp); =20 -void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **errp); =20 diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h index 5b670b04eb..bac40ccfa0 100644 --- a/include/hw/acpi/cpu_hotplug.h +++ b/include/hw/acpi/cpu_hotplug.h @@ -25,7 +25,7 @@ typedef struct AcpiCpuHotplug { uint8_t sts[ACPI_GPE_PROC_LEN]; } AcpiCpuHotplug; =20 -void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, +void legacy_acpi_cpu_plug_cb(const HotplugHandler *hotplug_dev, AcpiCpuHotplug *g, DeviceState *dev, Error **= errp); =20 void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_event_device.h index 7cbfb5fe7d..42a8033a23 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -136,7 +136,8 @@ typedef struct AcpiGedClass { ResettablePhases parent_phases; } AcpiGedClass; =20 -void build_ged_aml(Aml *table, const char* name, HotplugHandler *hotplug_d= ev, +void build_ged_aml(Aml *table, const char *name, + const HotplugHandler *hotplug_dev, uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base); void acpi_dsdt_add_power_button(Aml *scope); =20 diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index 6d14544751..6956b2b9c9 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -85,15 +85,15 @@ void ich9_pm_reset_properties(ICH9LPCPMRegs *pm); =20 void ich9_pm_add_class_properties(ObjectClass *oc, ptrdiff_t pm_offset); =20 -void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *= dev, +void ich9_pm_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp); -void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void ich9_pm_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp); -void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void ich9_pm_device_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *de= v, +void ich9_pm_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp); -bool ich9_pm_is_hotpluggable_bus(HotplugHandler *hotplug_dev, BusState *bu= s); +bool ich9_pm_is_hotpluggable_bus(const HotplugHandler *hotplug_dev, BusSta= te *bus); =20 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); #endif /* HW_ACPI_ICH9_H */ diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotp= lug.h index eb7f460afe..6e4f82bcf9 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -36,9 +36,9 @@ typedef struct MemHotplugState { void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, MemHotplugState *state, hwaddr io_base); =20 -void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem= _st, +void acpi_memory_plug_cb(const HotplugHandler *hotplug_dev, MemHotplugStat= e *mem_st, DeviceState *dev, Error **errp); -void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_memory_unplug_request_cb(const HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp); void acpi_memory_unplug_cb(MemHotplugState *mem_st, diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h index efce5fd2e1..21c0b72355 100644 --- a/include/hw/acpi/pcihp.h +++ b/include/hw/acpi/pcihp.h @@ -66,13 +66,13 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *, MemoryRegion *io, uint16_t io_base); =20 bool acpi_pcihp_is_hotpluggable_bus(AcpiPciHpState *s, BusState *bus); -void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState= *s, +void acpi_pcihp_device_plug_cb(const HotplugHandler *hotplug_dev, AcpiPciH= pState *s, DeviceState *dev, Error **errp); -void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpSta= te *s, +void acpi_pcihp_device_unplug_cb(const HotplugHandler *hotplug_dev, AcpiPc= iHpState *s, DeviceState *dev, Error **errp); -void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_unplug_request_cb(const HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *d= ev, Error **errp); =20 diff --git a/include/hw/core/boards.h b/include/hw/core/boards.h index a436d48c8e..dba465efc2 100644 --- a/include/hw/core/boards.h +++ b/include/hw/core/boards.h @@ -322,8 +322,8 @@ struct MachineClass { SMPCompatProps smp_props; const char *default_ram_id; =20 - HotplugHandler *(*get_hotplug_handler)(MachineState *machine, - DeviceState *dev); + const HotplugHandler *(*get_hotplug_handler)(MachineState *machine, + DeviceState *dev); bool (*hotplug_allowed)(MachineState *state, DeviceState *dev, Error **errp); CpuInstanceProperties (*cpu_index_to_instance_props)(MachineState *mac= hine, diff --git a/include/hw/core/hotplug.h b/include/hw/core/hotplug.h index a9840ed485..0c69be60ee 100644 --- a/include/hw/core/hotplug.h +++ b/include/hw/core/hotplug.h @@ -30,7 +30,7 @@ typedef struct HotplugHandler HotplugHandler; * @plugged_dev: a device that has been (un)plugged * @errp: returns an error if this function fails */ -typedef void (*hotplug_fn)(HotplugHandler *plug_handler, +typedef void (*hotplug_fn)(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); =20 /** @@ -59,7 +59,8 @@ struct HotplugHandlerClass { hotplug_fn plug; hotplug_fn unplug_request; hotplug_fn unplug; - bool (*is_hotpluggable_bus)(HotplugHandler *plug_handler, BusState *bu= s); + bool (*is_hotpluggable_bus)(const HotplugHandler *plug_handler, + BusState *bus); }; =20 /** @@ -67,7 +68,7 @@ struct HotplugHandlerClass { * * Call #HotplugHandlerClass.plug callback of @plug_handler. */ -void hotplug_handler_plug(HotplugHandler *plug_handler, +void hotplug_handler_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); =20 @@ -76,7 +77,7 @@ void hotplug_handler_plug(HotplugHandler *plug_handler, * * Call #HotplugHandlerClass.pre_plug callback of @plug_handler. */ -void hotplug_handler_pre_plug(HotplugHandler *plug_handler, +void hotplug_handler_pre_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); =20 @@ -85,7 +86,7 @@ void hotplug_handler_pre_plug(HotplugHandler *plug_handle= r, * * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler. */ -void hotplug_handler_unplug_request(HotplugHandler *plug_handler, +void hotplug_handler_unplug_request(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); /** @@ -93,7 +94,7 @@ void hotplug_handler_unplug_request(HotplugHandler *plug_= handler, * * Calls #HotplugHandlerClass.unplug callback of @plug_handler. */ -void hotplug_handler_unplug(HotplugHandler *plug_handler, +void hotplug_handler_unplug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp); #endif diff --git a/include/hw/core/qdev.h b/include/hw/core/qdev.h index e4cb027ab3..1f6bf3fc1a 100644 --- a/include/hw/core/qdev.h +++ b/include/hw/core/qdev.h @@ -386,7 +386,7 @@ struct BusState { /* public: */ DeviceState *parent; char *name; - HotplugHandler *hotplug_handler; + const HotplugHandler *hotplug_handler; int max_index; bool realized; bool full; @@ -514,8 +514,8 @@ bool qdev_realize_and_unref(DeviceState *dev, BusState = *bus, Error **errp); void qdev_unrealize(DeviceState *dev); void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, int required_for_version); -HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev); -HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev); +const HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev); +const HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev); bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp); bool qdev_hotunplug_allowed(DeviceState *dev, Error **errp); =20 @@ -529,10 +529,10 @@ bool qdev_hotunplug_allowed(DeviceState *dev, Error *= *errp); * Return: pointer to object that implements TYPE_HOTPLUG_HANDLER interface * or NULL if there aren't any. */ -HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev); +const HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev); void qdev_unplug(DeviceState *dev, Error **errp); int qdev_sync_config(DeviceState *dev, Error **errp); -void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, +void qdev_simple_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); void qdev_machine_creation_done(void); bool qdev_machine_modified(void); @@ -1065,7 +1065,7 @@ void qbus_set_bus_hotplug_handler(BusState *bus); =20 static inline bool qbus_is_hotpluggable(BusState *bus) { - HotplugHandler *plug_handler =3D bus->hotplug_handler; + const HotplugHandler *plug_handler =3D bus->hotplug_handler; bool ret =3D !!plug_handler; =20 if (plug_handler) { diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h index 184b7a8c09..5d5eacd1c6 100644 --- a/include/hw/i386/microvm.h +++ b/include/hw/i386/microvm.h @@ -76,8 +76,8 @@ =20 struct MicrovmMachineClass { X86MachineClass parent; - HotplugHandler *(*orig_hotplug_handler)(MachineState *machine, - DeviceState *dev); + const HotplugHandler *(*orig_hotplug_handler)(MachineState *machine, + DeviceState *dev); void (*x86_load_linux)(X86MachineState *x86ms, FWCfgState *fw_cfg, int acpi_data_size); }; diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index 71fe6b5e12..abb073ca47 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -46,7 +46,7 @@ struct X86MachineState { qemu_irq *gsi; DeviceState *ioapic2; GMappedFile *initrd_mapped_file; - HotplugHandler *acpi_dev; + const HotplugHandler *acpi_dev; =20 /* * Map the whole BIOS just underneath the 4 GiB address boundary. Only= used @@ -112,13 +112,13 @@ uint32_t x86_cpu_apic_id_from_index(X86MachineState *= x86ms, =20 void x86_cpus_init(X86MachineState *pcms, int default_cpu_version); void x86_rtc_set_cpus_count(ISADevice *rtc, uint16_t cpus_count); -void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, +void x86_cpu_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void x86_cpu_plug(HotplugHandler *hotplug_dev, +void x86_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void x86_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void x86_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); -void x86_cpu_unplug_cb(HotplugHandler *hotplug_dev, +void x86_cpu_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 void x86_isa_bios_init(MemoryRegion *isa_bios, MemoryRegion *isa_memory, diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index d3b763453a..169a943e3c 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -157,5 +157,5 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *t= able_data, uint32_t ram_slots, const char *oem_id, const char *oem_table_id); void nvdimm_plug(NVDIMMState *state); -void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev); +void nvdimm_acpi_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *d= ev); #endif diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h index b61360b900..f114f0a651 100644 --- a/include/hw/pci/pci_bridge.h +++ b/include/hw/pci/pci_bridge.h @@ -141,11 +141,11 @@ void pci_bridge_reset(DeviceState *qdev); void pci_bridge_initfn(PCIDevice *pci_dev, const char *typename); void pci_bridge_exitfn(PCIDevice *pci_dev); =20 -void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pci_bridge_dev_plug_cb(const HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp); -void pci_bridge_dev_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *de= v, +void pci_bridge_dev_unplug_cb(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp); -void pci_bridge_dev_unplug_request_cb(HotplugHandler *hotplug_dev, +void pci_bridge_dev_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 /* diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 71ba94874b..ec25e7a7de 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -146,13 +146,13 @@ void pcie_ats_init(PCIDevice *dev, uint16_t offset, b= ool aligned); void pcie_cap_fill_link_ep_usp(PCIDevice *dev, PCIExpLinkWidth width, PCIExpLinkSpeed speed, bool flitmode); =20 -void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *d= ev, +void pcie_cap_slot_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp); -void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pcie_cap_slot_plug_cb(const HotplugHandler *hotplug_dev, DeviceState = *dev, Error **errp); -void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pcie_cap_slot_unplug_cb(const HotplugHandler *hotplug_dev, DeviceStat= e *dev, Error **errp); -void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 void pcie_pasid_common_init(PCIDevice *dev, uint16_t offset, diff --git a/include/hw/pci/shpc.h b/include/hw/pci/shpc.h index fce5bdd3bc..67becb5c56 100644 --- a/include/hw/pci/shpc.h +++ b/include/hw/pci/shpc.h @@ -45,11 +45,11 @@ void shpc_free(PCIDevice *dev); void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int = len); =20 =20 -void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void shpc_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *d= ev, Error **errp); -void shpc_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void shpc_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState = *dev, Error **errp); -void shpc_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void shpc_device_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); =20 extern const VMStateInfo shpc_vmstate_info; diff --git a/include/hw/ppc/spapr_nvdimm.h b/include/hw/ppc/spapr_nvdimm.h index e9436cb6ef..386da92042 100644 --- a/include/hw/ppc/spapr_nvdimm.h +++ b/include/hw/ppc/spapr_nvdimm.h @@ -18,7 +18,7 @@ typedef struct SpaprMachineState SpaprMachineState; int spapr_pmem_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr, void *fdt, int *fdt_start_offset, Error **errp); void spapr_dt_persistent_memory(SpaprMachineState *spapr, void *fdt); -bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdi= mm, +bool spapr_nvdimm_validate(const HotplugHandler *hotplug_dev, NVDIMMDevice= *nvdimm, uint64_t size, Error **errp); void spapr_add_nvdimm(DeviceState *dev, uint64_t slot); void spapr_nvdimm_finish_flushes(void); diff --git a/hw/acpi/acpi-cpu-hotplug-stub.c b/hw/acpi/acpi-cpu-hotplug-stu= b.c index 72c5f05f5c..2e05d7100b 100644 --- a/hw/acpi/acpi-cpu-hotplug-stub.c +++ b/hw/acpi/acpi-cpu-hotplug-stub.c @@ -14,7 +14,7 @@ void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOS= TInfoList ***list) { } =20 -void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_plug_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **e= rrp) { } @@ -24,7 +24,7 @@ void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st, { } =20 -void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **errp) { diff --git a/hw/acpi/acpi-mem-hotplug-stub.c b/hw/acpi/acpi-mem-hotplug-stu= b.c index 7ad0fdcdf2..c218813fd1 100644 --- a/hw/acpi/acpi-mem-hotplug-stub.c +++ b/hw/acpi/acpi-mem-hotplug-stub.c @@ -13,7 +13,7 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACP= IOSTInfoList ***list) { } =20 -void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem= _st, +void acpi_memory_plug_cb(const HotplugHandler *hotplug_dev, MemHotplugStat= e *mem_st, DeviceState *dev, Error **errp) { } @@ -23,7 +23,7 @@ void acpi_memory_unplug_cb(MemHotplugState *mem_st, { } =20 -void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_memory_unplug_request_cb(const HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp) { diff --git a/hw/acpi/acpi-nvdimm-stub.c b/hw/acpi/acpi-nvdimm-stub.c index 22ba17f511..0120bacaac 100644 --- a/hw/acpi/acpi-nvdimm-stub.c +++ b/hw/acpi/acpi-nvdimm-stub.c @@ -2,6 +2,6 @@ #include "hw/mem/nvdimm.h" #include "hw/core/hotplug.h" =20 -void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev) +void nvdimm_acpi_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *d= ev) { } diff --git a/hw/acpi/acpi-pci-hotplug-stub.c b/hw/acpi/acpi-pci-hotplug-stu= b.c index d58ea726a8..20625c7ed7 100644 --- a/hw/acpi/acpi-pci-hotplug-stub.c +++ b/hw/acpi/acpi-pci-hotplug-stub.c @@ -9,22 +9,22 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, { } =20 -void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState= *s, +void acpi_pcihp_device_plug_cb(const HotplugHandler *hotplug_dev, AcpiPciH= pState *s, DeviceState *dev, Error **errp) { } =20 -void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { } =20 -void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpSta= te *s, +void acpi_pcihp_device_unplug_cb(const HotplugHandler *hotplug_dev, AcpiPc= iHpState *s, DeviceState *dev, Error **errp) { } =20 -void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_unplug_request_cb(const HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *d= ev, Error **errp) { diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index d63ca83c1b..ef97ed779a 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -132,7 +132,7 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, u= int64_t data, trace_cpuhp_acpi_clear_remove_evt(cpu_st->selector); } else if (data & 8) { DeviceState *dev =3D NULL; - HotplugHandler *hotplug_ctrl =3D NULL; + const HotplugHandler *hotplug_ctrl; =20 if (!cdev->cpu || cdev->cpu =3D=3D first_cpu) { trace_cpuhp_acpi_ejecting_invalid_cpu(cpu_st->selector); @@ -247,7 +247,7 @@ static AcpiCpuStatus *get_cpu_status(CPUHotplugState *c= pu_st, DeviceState *dev) return NULL; } =20 -void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_plug_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **e= rrp) { AcpiCpuStatus *cdev; @@ -264,7 +264,7 @@ void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev, } } =20 -void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, CPUHotplugState *cpu_st, DeviceState *dev, Error **errp) { diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 5225e32513..65a5d1612f 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -45,7 +45,8 @@ static const uint32_t ged_supported_events[] =3D { * affected by the interrupt. This way, we can support up to 32 events * with a unique interrupt. */ -void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_d= ev, +void build_ged_aml(Aml *table, const char *name, + const HotplugHandler *hotplug_dev, uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base) { const AcpiGedState *s =3D ACPI_GED(hotplug_dev); @@ -250,7 +251,7 @@ static const MemoryRegionOps ged_regs_ops =3D { }, }; =20 -static void acpi_ged_device_pre_plug_cb(HotplugHandler *hotplug_dev, +static void acpi_ged_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { @@ -258,7 +259,7 @@ static void acpi_ged_device_pre_plug_cb(HotplugHandler = *hotplug_dev, } } =20 -static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, +static void acpi_ged_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { AcpiGedState *s =3D ACPI_GED(hotplug_dev); @@ -279,7 +280,7 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hot= plug_dev, } } =20 -static void acpi_ged_unplug_request_cb(HotplugHandler *hotplug_dev, +static void acpi_ged_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { AcpiGedState *s =3D ACPI_GED(hotplug_dev); @@ -298,7 +299,7 @@ static void acpi_ged_unplug_request_cb(HotplugHandler *= hotplug_dev, } } =20 -static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev, +static void acpi_ged_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { AcpiGedState *s =3D ACPI_GED(hotplug_dev); diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 8082eae428..6d421b990c 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -410,7 +410,7 @@ void ich9_pm_add_class_properties(ObjectClass *oc, ptrd= iff_t pm_offset) =20 #undef PM_REG_FIELD =20 -void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *= dev, +void ich9_pm_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); @@ -432,7 +432,7 @@ void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug= _dev, DeviceState *dev, } } =20 -void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void ich9_pm_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); @@ -455,7 +455,7 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev= , DeviceState *dev, } } =20 -void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void ich9_pm_device_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); @@ -489,7 +489,7 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *h= otplug_dev, } } =20 -void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *de= v, +void ich9_pm_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); @@ -507,7 +507,7 @@ void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_d= ev, DeviceState *dev, } } =20 -bool ich9_pm_is_hotpluggable_bus(HotplugHandler *hotplug_dev, BusState *bu= s) +bool ich9_pm_is_hotpluggable_bus(const HotplugHandler *hotplug_dev, BusSta= te *bus) { ICH9LPCState *lpc =3D ICH9_LPC_DEVICE(hotplug_dev); return acpi_pcihp_is_hotpluggable_bus(&lpc->pm.acpi_pci_hotplug, bus); diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index f482c835a1..b5b6d6ada6 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -166,7 +166,7 @@ static void acpi_memory_hotplug_write(void *opaque, hwa= ddr addr, uint64_t data, mdev->is_removing =3D false; trace_mhp_acpi_clear_remove_evt(mem_st->selector); } else if (data & 8) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; =20 if (!mdev->is_enabled) { trace_mhp_acpi_ejecting_invalid_slot(mem_st->selector); @@ -254,7 +254,7 @@ acpi_memory_slot_status(MemHotplugState *mem_st, return &mem_st->devs[slot]; } =20 -void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem= _st, +void acpi_memory_plug_cb(const HotplugHandler *hotplug_dev, MemHotplugStat= e *mem_st, DeviceState *dev, Error **errp) { MemStatus *mdev; @@ -277,7 +277,7 @@ void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, M= emHotplugState *mem_st, } } =20 -void acpi_memory_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_memory_unplug_request_cb(const HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp) { diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 703e854951..5a7ff1ede8 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -887,7 +887,7 @@ static const MemoryRegionOps nvdimm_dsm_ops =3D { }, }; =20 -void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev) +void nvdimm_acpi_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *d= ev) { if (dev->hotplugged) { acpi_send_event(DEVICE(hotplug_dev), ACPI_NVDIMM_HOTPLUG_STATUS); diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 336ebe1a13..b69379a18b 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -209,7 +209,7 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, un= signed bsel, unsigned slo */ qdev->pending_deleted_event =3D false; } else { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; =20 hotplug_ctrl =3D qdev_get_hotplug_handler(qdev); hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abor= t); @@ -261,7 +261,7 @@ void acpi_pcihp_reset(AcpiPciHpState *s) acpi_pcihp_update(s); } =20 -void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCIDevice *pdev =3D PCI_DEVICE(dev); @@ -275,7 +275,7 @@ void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotp= lug_dev, } } =20 -void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState= *s, +void acpi_pcihp_device_plug_cb(const HotplugHandler *hotplug_dev, AcpiPciH= pState *s, DeviceState *dev, Error **errp) { PCIDevice *pdev =3D PCI_DEVICE(dev); @@ -317,7 +317,7 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_= dev, AcpiPciHpState *s, acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS); } =20 -void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpSta= te *s, +void acpi_pcihp_device_unplug_cb(const HotplugHandler *hotplug_dev, AcpiPc= iHpState *s, DeviceState *dev, Error **errp) { PCIDevice *pdev =3D PCI_DEVICE(dev); @@ -328,7 +328,7 @@ void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplu= g_dev, AcpiPciHpState *s, qdev_unrealize(dev); } =20 -void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void acpi_pcihp_device_unplug_request_cb(const HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *d= ev, Error **errp) { diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 52bd61667f..a7d5356340 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -303,8 +303,8 @@ static void piix4_pm_powerdown_req(Notifier *n, void *o= paque) acpi_pm1_evt_power_down(&s->ar); } =20 -static void piix4_device_pre_plug_cb(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void piix4_device_pre_plug_cb(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); =20 @@ -323,7 +323,7 @@ static void piix4_device_pre_plug_cb(HotplugHandler *ho= tplug_dev, } } =20 -static void piix4_device_plug_cb(HotplugHandler *hotplug_dev, +static void piix4_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); @@ -344,7 +344,7 @@ static void piix4_device_plug_cb(HotplugHandler *hotplu= g_dev, } } =20 -static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, +static void piix4_device_unplug_request_cb(const HotplugHandler *hotplug_d= ev, DeviceState *dev, Error **errp) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); @@ -364,7 +364,7 @@ static void piix4_device_unplug_request_cb(HotplugHandl= er *hotplug_dev, } } =20 -static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev, +static void piix4_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); @@ -383,7 +383,7 @@ static void piix4_device_unplug_cb(HotplugHandler *hotp= lug_dev, } } =20 -static bool piix4_is_hotpluggable_bus(HotplugHandler *hotplug_dev, +static bool piix4_is_hotpluggable_bus(const HotplugHandler *hotplug_dev, BusState *bus) { PIIX4PMState *s =3D PIIX4_PM(hotplug_dev); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0871a35e11..3eecf094bc 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3753,7 +3753,7 @@ static const CPUArchIdList *virt_possible_cpu_arch_id= s(MachineState *ms) return ms->possible_cpus; } =20 -static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState = *dev, +static void virt_memory_pre_plug(const HotplugHandler *hotplug_dev, Device= State *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3779,7 +3779,7 @@ static void virt_memory_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), errp); } =20 -static void virt_memory_plug(HotplugHandler *hotplug_dev, +static void virt_memory_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3798,7 +3798,7 @@ static void virt_memory_plug(HotplugHandler *hotplug_= dev, } } =20 -static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, +static void virt_machine_device_pre_plug_cb(const HotplugHandler *hotplug_= dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3896,7 +3896,7 @@ static void virt_machine_device_pre_plug_cb(HotplugHa= ndler *hotplug_dev, } } =20 -static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, +static void virt_machine_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3957,7 +3957,7 @@ static void virt_machine_device_plug_cb(HotplugHandle= r *hotplug_dev, } } =20 -static void virt_dimm_unplug_request(HotplugHandler *hotplug_dev, +static void virt_dimm_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3977,7 +3977,7 @@ static void virt_dimm_unplug_request(HotplugHandler *= hotplug_dev, errp); } =20 -static void virt_dimm_unplug(HotplugHandler *hotplug_dev, +static void virt_dimm_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); @@ -3995,8 +3995,9 @@ out: error_propagate(errp, local_err); } =20 -static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_= dev, - DeviceState *dev, Error **errp) +static void +virt_machine_device_unplug_request_cb(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { virt_dimm_unplug_request(hotplug_dev, dev, errp); @@ -4009,7 +4010,7 @@ static void virt_machine_device_unplug_request_cb(Hot= plugHandler *hotplug_dev, } } =20 -static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev, +static void virt_machine_device_unplug_cb(const HotplugHandler *hotplug_de= v, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -4022,8 +4023,8 @@ static void virt_machine_device_unplug_cb(HotplugHand= ler *hotplug_dev, } } =20 -static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, - DeviceState *dev) +static const HotplugHandler * +virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 81db0bdc91..c36e18a4cf 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -979,7 +979,7 @@ static void virtser_port_device_realize(DeviceState *de= v, Error **errp) port->elem =3D NULL; } =20 -static void virtser_port_device_plug(HotplugHandler *hotplug_dev, +static void virtser_port_device_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtIOSerialPort *port =3D VIRTIO_SERIAL_PORT(dev); diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c index 00e80a67c8..3aca068840 100644 --- a/hw/core/hotplug.c +++ b/hw/core/hotplug.c @@ -13,7 +13,7 @@ #include "hw/core/hotplug.h" #include "qemu/module.h" =20 -void hotplug_handler_pre_plug(HotplugHandler *plug_handler, +void hotplug_handler_pre_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { @@ -24,7 +24,7 @@ void hotplug_handler_pre_plug(HotplugHandler *plug_handle= r, } } =20 -void hotplug_handler_plug(HotplugHandler *plug_handler, +void hotplug_handler_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { @@ -35,7 +35,7 @@ void hotplug_handler_plug(HotplugHandler *plug_handler, } } =20 -void hotplug_handler_unplug_request(HotplugHandler *plug_handler, +void hotplug_handler_unplug_request(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { @@ -46,7 +46,7 @@ void hotplug_handler_unplug_request(HotplugHandler *plug_= handler, } } =20 -void hotplug_handler_unplug(HotplugHandler *plug_handler, +void hotplug_handler_unplug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c index 1d547e0dbd..d7fa8a5ed2 100644 --- a/hw/core/qdev-hotplug.c +++ b/hw/core/qdev-hotplug.c @@ -14,7 +14,7 @@ #include "hw/core/boards.h" #include "qapi/error.h" =20 -HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) +const HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev) { MachineState *machine; MachineClass *mc; @@ -90,7 +90,7 @@ bool qdev_hotunplug_allowed(DeviceState *dev, Error **err= p) qdev_hotplug_unplug_allowed_common(dev, dev->parent_bus, errp); } =20 -HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev) +const HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev) { if (dev->parent_bus) { return dev->parent_bus->hotplug_handler; @@ -98,9 +98,9 @@ HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState = *dev) return NULL; } =20 -HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) +const HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_machine_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_machine_hotplug_handle= r(dev); =20 if (hotplug_ctrl =3D=3D NULL && dev->parent_bus) { hotplug_ctrl =3D qdev_get_bus_hotplug_handler(dev); @@ -109,7 +109,7 @@ HotplugHandler *qdev_get_hotplug_handler(DeviceState *d= ev) } =20 /* can be used as ->unplug() callback for the simple cases */ -void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, +void qdev_simple_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { qdev_unrealize(dev); diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 0b0f2f47fa..c6540bec56 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -501,7 +501,7 @@ static void device_set_realized(Object *obj, bool value= , Error **errp) { DeviceState *dev =3D DEVICE(obj); DeviceClass *dc =3D DEVICE_GET_CLASS(dev); - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; BusState *bus; NamedClockList *ncl; Error *local_err =3D NULL; diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index e7adab7d2e..a49de33749 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -416,7 +416,7 @@ static void microvm_fix_kernel_cmdline(MachineState *ma= chine) g_free(cmdline); } =20 -static void microvm_device_pre_plug_cb(HotplugHandler *hotplug_dev, +static void microvm_device_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { X86CPU *cpu =3D X86_CPU(dev); @@ -425,26 +425,26 @@ static void microvm_device_pre_plug_cb(HotplugHandler= *hotplug_dev, x86_cpu_pre_plug(hotplug_dev, dev, errp); } =20 -static void microvm_device_plug_cb(HotplugHandler *hotplug_dev, +static void microvm_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { x86_cpu_plug(hotplug_dev, dev, errp); } =20 -static void microvm_device_unplug_request_cb(HotplugHandler *hotplug_dev, +static void microvm_device_unplug_request_cb(const HotplugHandler *hotplug= _dev, DeviceState *dev, Error **err= p) { error_setg(errp, "unplug not supported by microvm"); } =20 -static void microvm_device_unplug_cb(HotplugHandler *hotplug_dev, +static void microvm_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { error_setg(errp, "unplug not supported by microvm"); } =20 -static HotplugHandler *microvm_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *microvm_get_hotplug_handler(MachineState *mac= hine, + DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { return HOTPLUG_HANDLER(machine); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e9e4fc262b..9006e7c29e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1181,7 +1181,7 @@ void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259= _irqs) g_free(i8259); } =20 -static void pc_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, +static void pc_memory_pre_plug(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp) { const X86MachineState *x86ms =3D X86_MACHINE(hotplug_dev); @@ -1214,7 +1214,7 @@ static void pc_memory_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), errp); } =20 -static void pc_memory_plug(HotplugHandler *hotplug_dev, +static void pc_memory_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); @@ -1231,7 +1231,7 @@ static void pc_memory_plug(HotplugHandler *hotplug_de= v, hotplug_handler_plug(x86ms->acpi_dev, dev, &error_abort); } =20 -static void pc_memory_unplug_request(HotplugHandler *hotplug_dev, +static void pc_memory_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { X86MachineState *x86ms =3D X86_MACHINE(hotplug_dev); @@ -1256,7 +1256,7 @@ static void pc_memory_unplug_request(HotplugHandler *= hotplug_dev, errp); } =20 -static void pc_memory_unplug(HotplugHandler *hotplug_dev, +static void pc_memory_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); @@ -1274,7 +1274,7 @@ static void pc_memory_unplug(HotplugHandler *hotplug_= dev, error_propagate(errp, local_err); } =20 -static void pc_hv_balloon_pre_plug(HotplugHandler *hotplug_dev, +static void pc_hv_balloon_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { /* The vmbus handler has no hotplug handler; we should never end up he= re. */ @@ -1282,13 +1282,13 @@ static void pc_hv_balloon_pre_plug(HotplugHandler *= hotplug_dev, memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), errp); } =20 -static void pc_hv_balloon_plug(HotplugHandler *hotplug_dev, +static void pc_hv_balloon_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); } =20 -static void pc_sp_mem_pre_plug(HotplugHandler *hotplug_dev, +static void pc_sp_mem_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { MachineState *ms =3D MACHINE(hotplug_dev); @@ -1304,7 +1304,7 @@ static void pc_sp_mem_pre_plug(HotplugHandler *hotplu= g_dev, memory_device_pre_plug(MEMORY_DEVICE(dev), ms, errp); } =20 -static void pc_sp_mem_plug(HotplugHandler *hotplug_dev, +static void pc_sp_mem_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { SpMemDevice *spm =3D SP_MEM(dev); @@ -1318,7 +1318,7 @@ static void pc_sp_mem_plug(HotplugHandler *hotplug_de= v, e820_add_entry(addr, size, E820_SOFT_RESERVED); } =20 -static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, +static void pc_machine_device_pre_plug_cb(const HotplugHandler *hotplug_de= v, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -1356,7 +1356,7 @@ static void pc_machine_device_pre_plug_cb(HotplugHand= ler *hotplug_dev, } } =20 -static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev, +static void pc_machine_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -1372,7 +1372,7 @@ static void pc_machine_device_plug_cb(HotplugHandler = *hotplug_dev, } } =20 -static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_de= v, +static void pc_machine_device_unplug_request_cb(const HotplugHandler *hotp= lug_dev, DeviceState *dev, Error **= errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -1388,7 +1388,7 @@ static void pc_machine_device_unplug_request_cb(Hotpl= ugHandler *hotplug_dev, } } =20 -static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev, +static void pc_machine_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -1403,8 +1403,8 @@ static void pc_machine_device_unplug_cb(HotplugHandle= r *hotplug_dev, } } =20 -static HotplugHandler *pc_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *pc_get_hotplug_handler(MachineState *machine, + DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_SP_MEM) || diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c index 8f9419e7d3..ae58352760 100644 --- a/hw/i386/x86-common.c +++ b/hw/i386/x86-common.c @@ -158,7 +158,7 @@ static CPUArchId *x86_find_cpu_slot(MachineState *ms, u= int32_t id, int *idx) return found_cpu; } =20 -void x86_cpu_plug(HotplugHandler *hotplug_dev, +void x86_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CPUArchId *found_cpu; @@ -199,7 +199,7 @@ out: error_propagate(errp, local_err); } =20 -void x86_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, +void x86_cpu_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { int idx =3D -1; @@ -222,7 +222,7 @@ void x86_cpu_unplug_request_cb(HotplugHandler *hotplug_= dev, errp); } =20 -void x86_cpu_unplug_cb(HotplugHandler *hotplug_dev, +void x86_cpu_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CPUArchId *found_cpu; @@ -248,7 +248,7 @@ void x86_cpu_unplug_cb(HotplugHandler *hotplug_dev, error_propagate(errp, local_err); } =20 -void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, +void x86_cpu_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { int idx; diff --git a/hw/intc/loongarch_dintc.c b/hw/intc/loongarch_dintc.c index c01f1fe07e..1bedfbce43 100644 --- a/hw/intc/loongarch_dintc.c +++ b/hw/intc/loongarch_dintc.c @@ -168,8 +168,8 @@ static DINTCCore *loongarch_dintc_get_cpu(LoongArchDINT= CState *s, return loongarch_dintc_cpu_by_arch_id(s, arch_id); } =20 -static void loongarch_dintc_cpu_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void loongarch_dintc_cpu_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchDINTCState *s =3D LOONGARCH_DINTC(hotplug_dev); Object *obj =3D OBJECT(dev); @@ -194,8 +194,8 @@ static void loongarch_dintc_cpu_plug(HotplugHandler *ho= tplug_dev, return; } =20 -static void loongarch_dintc_cpu_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void loongarch_dintc_cpu_unplug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchDINTCState *s =3D LOONGARCH_DINTC(hotplug_dev); Object *obj =3D OBJECT(dev); diff --git a/hw/intc/loongarch_extioi_common.c b/hw/intc/loongarch_extioi_c= ommon.c index 5cb0d396c6..22cbb7a097 100644 --- a/hw/intc/loongarch_extioi_common.c +++ b/hw/intc/loongarch_extioi_common.c @@ -28,7 +28,7 @@ static ExtIOICore *loongarch_extioi_get_cpu(LoongArchExtI= OICommonState *s, return NULL; } =20 -static void loongarch_extioi_cpu_plug(HotplugHandler *hotplug_dev, +static void loongarch_extioi_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongArchExtIOICommonState *s =3D LOONGARCH_EXTIOI_COMMON(hotplug_dev); @@ -60,7 +60,7 @@ static void loongarch_extioi_cpu_plug(HotplugHandler *hot= plug_dev, } } =20 -static void loongarch_extioi_cpu_unplug(HotplugHandler *hotplug_dev, +static void loongarch_extioi_cpu_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongArchExtIOICommonState *s =3D LOONGARCH_EXTIOI_COMMON(hotplug_dev); diff --git a/hw/intc/loongarch_ipi.c b/hw/intc/loongarch_ipi.c index 28d816e3f5..c8f775a93e 100644 --- a/hw/intc/loongarch_ipi.c +++ b/hw/intc/loongarch_ipi.c @@ -129,7 +129,7 @@ static void loongarch_ipi_reset_hold(Object *obj, Reset= Type type) } } =20 -static void loongarch_ipi_cpu_plug(HotplugHandler *hotplug_dev, +static void loongarch_ipi_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongsonIPICommonState *lics =3D LOONGSON_IPI_COMMON(hotplug_dev); @@ -155,7 +155,7 @@ static void loongarch_ipi_cpu_plug(HotplugHandler *hotp= lug_dev, qdev_connect_gpio_out(DEVICE(lics), index, qdev_get_gpio_in(dev, IRQ_I= PI)); } =20 -static void loongarch_ipi_cpu_unplug(HotplugHandler *hotplug_dev, +static void loongarch_ipi_cpu_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongsonIPICommonState *lics =3D LOONGSON_IPI_COMMON(hotplug_dev); diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 9cc79929a8..9c5371af9d 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -1167,7 +1167,7 @@ static CPUArchId *virt_find_empty_cpu_slot(MachineSta= te *ms) return NULL; } =20 -static void virt_cpu_pre_plug(HotplugHandler *hotplug_dev, +static void virt_cpu_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); @@ -1229,7 +1229,7 @@ static void virt_cpu_pre_plug(HotplugHandler *hotplug= _dev, numa_cpu_pre_plug(cpu_slot, dev, errp); } =20 -static void virt_cpu_unplug_request(HotplugHandler *hotplug_dev, +static void virt_cpu_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); @@ -1246,7 +1246,7 @@ static void virt_cpu_unplug_request(HotplugHandler *h= otplug_dev, hotplug_handler_unplug_request(HOTPLUG_HANDLER(lvms->acpi_ged), dev, e= rrp); } =20 -static void virt_cpu_unplug(HotplugHandler *hotplug_dev, +static void virt_cpu_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CPUArchId *cpu_slot; @@ -1268,7 +1268,7 @@ static void virt_cpu_unplug(HotplugHandler *hotplug_d= ev, cpu_slot->cpu =3D NULL; } =20 -static void virt_cpu_plug(HotplugHandler *hotplug_dev, +static void virt_cpu_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CPUArchId *cpu_slot; @@ -1304,14 +1304,14 @@ static bool memhp_type_supported(DeviceState *dev) !object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); } =20 -static void virt_mem_pre_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, - Error **errp) +static void virt_mem_pre_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), errp); } =20 -static void virt_device_pre_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_device_pre_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { if (memhp_type_supported(dev)) { virt_mem_pre_plug(hotplug_dev, dev, errp); @@ -1320,8 +1320,8 @@ static void virt_device_pre_plug(HotplugHandler *hotp= lug_dev, } } =20 -static void virt_mem_unplug_request(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_mem_unplug_request(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); =20 @@ -1330,8 +1330,8 @@ static void virt_mem_unplug_request(HotplugHandler *h= otplug_dev, errp); } =20 -static void virt_device_unplug_request(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_device_unplug_request(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { if (memhp_type_supported(dev)) { virt_mem_unplug_request(hotplug_dev, dev, errp); @@ -1340,8 +1340,8 @@ static void virt_device_unplug_request(HotplugHandler= *hotplug_dev, } } =20 -static void virt_mem_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_mem_unplug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); =20 @@ -1350,8 +1350,8 @@ static void virt_mem_unplug(HotplugHandler *hotplug_d= ev, qdev_unrealize(dev); } =20 -static void virt_device_unplug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_device_unplug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { if (memhp_type_supported(dev)) { virt_mem_unplug(hotplug_dev, dev, errp); @@ -1360,8 +1360,8 @@ static void virt_device_unplug(HotplugHandler *hotplu= g_dev, } } =20 -static void virt_mem_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_mem_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); =20 @@ -1370,8 +1370,8 @@ static void virt_mem_plug(HotplugHandler *hotplug_dev, dev, &error_abort); } =20 -static void virt_device_plug_cb(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void virt_device_plug_cb(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(hotplug_dev= ); MachineClass *mc =3D MACHINE_GET_CLASS(lvms); @@ -1389,8 +1389,8 @@ static void virt_device_plug_cb(HotplugHandler *hotpl= ug_dev, } } =20 -static HotplugHandler *virt_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *virt_get_hotplug_handler(MachineState *machin= e, + DeviceState *dev) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 23c26aa08c..986ceff514 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3816,7 +3816,7 @@ void virtio_net_set_netclient_name(VirtIONet *n, cons= t char *name, =20 static bool failover_unplug_primary(VirtIONet *n, DeviceState *dev) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; PCIDevice *pci_dev; Error *err =3D NULL; =20 @@ -3839,7 +3839,7 @@ static bool failover_replug_primary(VirtIONet *n, Dev= iceState *dev, Error **errp) { Error *err =3D NULL; - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; PCIDevice *pdev =3D PCI_DEVICE(dev); BusState *primary_bus; =20 diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 7478f0b33a..c641226e27 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -10615,8 +10615,8 @@ static const TypeInfo nvme_info =3D { }, }; =20 -static void nvme_ns_hot_plug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) +static void nvme_ns_hot_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { NvmeNamespace *ns =3D NVME_NS(dev); NvmeSubsystem *subsys =3D ns->subsys; @@ -10647,8 +10647,8 @@ static void nvme_ns_hot_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, } } =20 -static void nvme_ns_hot_unplug(HotplugHandler *hotplug_dev, DeviceState *d= ev, - Error **errp) +static void nvme_ns_hot_unplug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { NvmeNamespace *ns =3D NVME_NS(dev); NvmeSubsystem *subsys =3D ns->subsys; diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c index 0c1383562d..bc53bcb69d 100644 --- a/hw/pci-bridge/pci_bridge_dev.c +++ b/hw/pci-bridge/pci_bridge_dev.c @@ -205,7 +205,7 @@ static const VMStateDescription pci_bridge_dev_vmstate = =3D { } }; =20 -void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pci_bridge_dev_plug_cb(const HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); @@ -218,7 +218,7 @@ void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev= , DeviceState *dev, shpc_device_plug_cb(hotplug_dev, dev, errp); } =20 -void pci_bridge_dev_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *de= v, +void pci_bridge_dev_unplug_cb(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); @@ -227,7 +227,7 @@ void pci_bridge_dev_unplug_cb(HotplugHandler *hotplug_d= ev, DeviceState *dev, shpc_device_unplug_cb(hotplug_dev, dev, errp); } =20 -void pci_bridge_dev_unplug_request_cb(HotplugHandler *hotplug_dev, +void pci_bridge_dev_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 4622c75e48..42bcb9206d 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -508,7 +508,7 @@ static void pcie_cap_slot_plug_common(PCIDevice *hotplu= g_dev, DeviceState *dev, } } =20 -void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *d= ev, +void pcie_cap_slot_pre_plug_cb(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp) { PCIDevice *hotplug_pdev =3D PCI_DEVICE(hotplug_dev); @@ -525,7 +525,7 @@ void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_= dev, DeviceState *dev, pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, errp); } =20 -void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pcie_cap_slot_plug_cb(const HotplugHandler *hotplug_dev, DeviceState = *dev, Error **errp) { PCIDevice *hotplug_pdev =3D PCI_DEVICE(hotplug_dev); @@ -571,7 +571,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev,= DeviceState *dev, } } =20 -void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void pcie_cap_slot_unplug_cb(const HotplugHandler *hotplug_dev, DeviceStat= e *dev, Error **errp) { qdev_unrealize(dev); @@ -579,7 +579,7 @@ void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_de= v, DeviceState *dev, =20 static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE(dev)); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE= (dev)); =20 if (dev->partially_hotplugged) { dev->qdev.pending_deleted_event =3D false; @@ -608,7 +608,7 @@ static void pcie_cap_slot_do_unplug(PCIDevice *dev) PCI_EXP_SLTSTA_PDC); } =20 -void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, +void pcie_cap_slot_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { Error *local_err =3D NULL; diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c index dbb6032160..57fcc9079a 100644 --- a/hw/pci/pcie_port.c +++ b/hw/pci/pcie_port.c @@ -188,7 +188,7 @@ int pcie_count_ds_ports(PCIBus *bus) return dsp_count; } =20 -static bool pcie_slot_is_hotpluggable_bus(HotplugHandler *plug_handler, +static bool pcie_slot_is_hotpluggable_bus(const HotplugHandler *plug_handl= er, BusState *bus) { PCIESlot *s =3D PCIE_SLOT(bus->parent); diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 1198e1ab8c..3f24ca84f5 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -278,7 +278,7 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc,= int slot) ++devfn) { PCIDevice *affected_dev =3D shpc->sec_bus->devices[devfn]; if (affected_dev) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; =20 hotplug_ctrl =3D qdev_get_hotplug_handler(DEVICE(affected_dev)= ); hotplug_handler_unplug(hotplug_ctrl, DEVICE(affected_dev), @@ -561,8 +561,8 @@ static bool shpc_device_get_slot(PCIDevice *affected_de= v, int *slot, return true; } =20 -void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) +void shpc_device_plug_cb(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); SHPCDevice *shpc =3D pci_hotplug_dev->shpc; @@ -601,13 +601,13 @@ void shpc_device_plug_cb(HotplugHandler *hotplug_dev,= DeviceState *dev, shpc_interrupt_update(pci_hotplug_dev); } =20 -void shpc_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, +void shpc_device_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState = *dev, Error **errp) { qdev_unrealize(dev); } =20 -void shpc_device_unplug_request_cb(HotplugHandler *hotplug_dev, +void shpc_device_unplug_request_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { PCIDevice *pci_hotplug_dev =3D PCI_DEVICE(hotplug_dev); diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index 85cec810d9..4bc1426dc8 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -42,7 +42,7 @@ static void e500plat_init(MachineState *machine) ppce500_init(machine); } =20 -static void e500plat_machine_device_plug_cb(HotplugHandler *hotplug_dev, +static void e500plat_machine_device_plug_cb(const HotplugHandler *hotplug_= dev, DeviceState *dev, Error **errp) { PPCE500MachineState *pms =3D PPCE500_MACHINE(hotplug_dev); @@ -53,7 +53,7 @@ static void e500plat_machine_device_plug_cb(HotplugHandle= r *hotplug_dev, } } =20 -static +static const HotplugHandler *e500plat_machine_get_hotpug_handler(MachineState *machine, DeviceState *dev) { diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 20e024907b..6d99464486 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3616,7 +3616,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t= addr_start, uint64_t size, } } =20 -static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *de= v) +static void spapr_memory_plug(const HotplugHandler *hotplug_dev, DeviceSta= te *dev) { SpaprMachineState *ms =3D SPAPR_MACHINE(hotplug_dev); PCDIMMDevice *dimm =3D PC_DIMM(dev); @@ -3642,7 +3642,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug= _dev, DeviceState *dev) } } =20 -static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState= *dev, +static void spapr_memory_pre_plug(const HotplugHandler *hotplug_dev, Devic= eState *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(hotplug_dev); @@ -3807,7 +3807,7 @@ void spapr_memory_unplug_rollback(SpaprMachineState *= spapr, DeviceState *dev) /* Callback to be called during DRC release. */ void spapr_lmb_release(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); SpaprMachineState *spapr =3D SPAPR_MACHINE(hotplug_ctrl); SpaprDimmState *ds =3D spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(= dev)); =20 @@ -3832,7 +3832,7 @@ void spapr_lmb_release(DeviceState *dev) object_unparent(OBJECT(dev)); } =20 -static void spapr_memory_unplug(HotplugHandler *hotplug_dev, DeviceState *= dev) +static void spapr_memory_unplug(const HotplugHandler *hotplug_dev, DeviceS= tate *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(hotplug_dev); SpaprDimmState *ds =3D spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(= dev)); @@ -3845,7 +3845,7 @@ static void spapr_memory_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev) spapr_pending_dimm_unplugs_remove(spapr, ds); } =20 -static void spapr_memory_unplug_request(HotplugHandler *hotplug_dev, +static void spapr_memory_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(hotplug_dev); @@ -3899,14 +3899,14 @@ static void spapr_memory_unplug_request(HotplugHand= ler *hotplug_dev, /* Callback to be called during DRC release. */ void spapr_core_release(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); =20 /* Call the unplug handler chain. This can never fail. */ hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort); object_unparent(OBJECT(dev)); } =20 -static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *de= v) +static void spapr_core_unplug(const HotplugHandler *hotplug_dev, DeviceSta= te *dev) { MachineState *ms =3D MACHINE(hotplug_dev); CPUCore *cc =3D CPU_CORE(dev); @@ -3918,7 +3918,7 @@ static void spapr_core_unplug(HotplugHandler *hotplug= _dev, DeviceState *dev) } =20 static -void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *d= ev, +void spapr_core_unplug_request(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); @@ -3988,7 +3988,7 @@ int spapr_core_dt_populate(SpaprDrc *drc, SpaprMachin= eState *spapr, return 0; } =20 -static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev) +static void spapr_core_plug(const HotplugHandler *hotplug_dev, DeviceState= *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); MachineClass *mc =3D MACHINE_GET_CLASS(spapr); @@ -4043,7 +4043,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev) =20 } =20 -static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *= dev, +static void spapr_core_pre_plug(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp) { MachineState *machine =3D MACHINE(OBJECT(hotplug_dev)); @@ -4169,7 +4169,7 @@ static bool spapr_phb_placement(SpaprMachineState *sp= apr, uint32_t index, return true; } =20 -static bool spapr_phb_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, +static bool spapr_phb_pre_plug(const HotplugHandler *hotplug_dev, DeviceSt= ate *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); @@ -4198,7 +4198,7 @@ static bool spapr_phb_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, windows_supported, sphb->dma_liobn, errp); } =20 -static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev) +static void spapr_phb_plug(const HotplugHandler *hotplug_dev, DeviceState = *dev) { SpaprPhbState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); SpaprDrc *drc; @@ -4220,18 +4220,18 @@ static void spapr_phb_plug(HotplugHandler *hotplug_= dev, DeviceState *dev) =20 void spapr_phb_release(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); =20 hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort); object_unparent(OBJECT(dev)); } =20 -static void spapr_phb_unplug(HotplugHandler *hotplug_dev, DeviceState *dev) +static void spapr_phb_unplug(const HotplugHandler *hotplug_dev, DeviceStat= e *dev) { qdev_unrealize(dev); } =20 -static void spapr_phb_unplug_request(HotplugHandler *hotplug_dev, +static void spapr_phb_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { SpaprPhbState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); @@ -4251,7 +4251,7 @@ static void spapr_phb_unplug_request(HotplugHandler *= hotplug_dev, } =20 static -bool spapr_tpm_proxy_pre_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, +bool spapr_tpm_proxy_pre_plug(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); @@ -4264,7 +4264,7 @@ bool spapr_tpm_proxy_pre_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, return true; } =20 -static void spapr_tpm_proxy_plug(HotplugHandler *hotplug_dev, DeviceState = *dev) +static void spapr_tpm_proxy_plug(const HotplugHandler *hotplug_dev, Device= State *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); SpaprTpmProxy *tpm_proxy =3D SPAPR_TPM_PROXY(dev); @@ -4275,7 +4275,7 @@ static void spapr_tpm_proxy_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev) spapr->tpm_proxy =3D tpm_proxy; } =20 -static void spapr_tpm_proxy_unplug(HotplugHandler *hotplug_dev, DeviceStat= e *dev) +static void spapr_tpm_proxy_unplug(const HotplugHandler *hotplug_dev, Devi= ceState *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); =20 @@ -4284,7 +4284,7 @@ static void spapr_tpm_proxy_unplug(HotplugHandler *ho= tplug_dev, DeviceState *dev spapr->tpm_proxy =3D NULL; } =20 -static void spapr_machine_device_plug(HotplugHandler *hotplug_dev, +static void spapr_machine_device_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -4298,7 +4298,7 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, } } =20 -static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev, +static void spapr_machine_device_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -4324,7 +4324,7 @@ bool spapr_memory_hot_unplug_supported(SpaprMachineSt= ate *spapr) spapr_ovec_empty(spapr->ov5_cas); } =20 -static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_de= v, +static void spapr_machine_device_unplug_request(const HotplugHandler *hotp= lug_dev, DeviceState *dev, Error **= errp) { SpaprMachineState *sms =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); @@ -4349,7 +4349,7 @@ static void spapr_machine_device_unplug_request(Hotpl= ugHandler *hotplug_dev, } } =20 -static void spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev, +static void spapr_machine_device_pre_plug(const HotplugHandler *hotplug_de= v, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { @@ -4363,8 +4363,8 @@ static void spapr_machine_device_pre_plug(HotplugHand= ler *hotplug_dev, } } =20 -static HotplugHandler *spapr_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *spapr_get_hotplug_handler(MachineState *machi= ne, + DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE) || diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index 6647428391..542ed79497 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -64,7 +64,7 @@ struct SPAPRNVDIMMClass { void (*unrealize)(NVDIMMDevice *dimm, Error **errp); }; =20 -bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdi= mm, +bool spapr_nvdimm_validate(const HotplugHandler *hotplug_dev, NVDIMMDevice= *nvdimm, uint64_t size, Error **errp) { const MachineClass *mc =3D MACHINE_GET_CLASS(hotplug_dev); diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index c1d4b7806e..f7fc544d35 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1445,7 +1445,7 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, P= CIDevice *dev, /* Callback to be called during DRC release. */ void spapr_phb_remove_pci_device_cb(DeviceState *dev) { - HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); + const HotplugHandler *hotplug_ctrl =3D qdev_get_hotplug_handler(dev); =20 hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort); object_unparent(OBJECT(dev)); @@ -1454,7 +1454,7 @@ void spapr_phb_remove_pci_device_cb(DeviceState *dev) int spapr_pci_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr, void *fdt, int *fdt_start_offset, Error **errp) { - HotplugHandler *plug_handler =3D qdev_get_hotplug_handler(drc->dev); + const HotplugHandler *plug_handler =3D qdev_get_hotplug_handler(drc->d= ev); SpaprPhbState *sphb =3D SPAPR_PCI_HOST_BRIDGE(plug_handler); PCIDevice *pdev =3D PCI_DEVICE(drc->dev); =20 @@ -1521,7 +1521,7 @@ static bool bridge_has_valid_chassis_nr(Object *bridg= e, Error **errp) return true; } =20 -static void spapr_pci_pre_plug(HotplugHandler *plug_handler, +static void spapr_pci_pre_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); @@ -1556,7 +1556,7 @@ static void spapr_pci_pre_plug(HotplugHandler *plug_h= andler, } } =20 -static void spapr_pci_plug(HotplugHandler *plug_handler, +static void spapr_pci_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); @@ -1614,7 +1614,7 @@ static void spapr_pci_bridge_unplug(SpaprPhbState *ph= b, remove_drcs(phb, bus); } =20 -static void spapr_pci_unplug(HotplugHandler *plug_handler, +static void spapr_pci_unplug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); @@ -1639,7 +1639,7 @@ static void spapr_pci_unplug(HotplugHandler *plug_han= dler, qdev_unrealize(plugged_dev); } =20 -static void spapr_pci_unplug_request(HotplugHandler *plug_handler, +static void spapr_pci_unplug_request(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **err= p) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); diff --git a/hw/remote/machine.c b/hw/remote/machine.c index ced782f6a9..f79f5a0565 100644 --- a/hw/remote/machine.c +++ b/hw/remote/machine.c @@ -111,7 +111,7 @@ static void remote_machine_instance_init(Object *obj) s->auto_shutdown =3D true; } =20 -static void remote_machine_dev_unplug_cb(HotplugHandler *hotplug_dev, +static void remote_machine_dev_unplug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { qdev_unrealize(dev); diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index f3a1cc5ba3..d4b501802f 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1088,8 +1088,8 @@ static void virt_set_acpi(Object *obj, Visitor *v, co= nst char *name, visit_type_OnOffAuto(v, name, &s->acpi, errp); } =20 -static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, - DeviceState *dev) +static const HotplugHandler * +virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); RISCVVirtState *s =3D RISCV_VIRT_MACHINE(machine); @@ -1104,7 +1104,7 @@ static HotplugHandler *virt_machine_get_hotplug_handl= er(MachineState *machine, return NULL; } =20 -static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, +static void virt_machine_device_plug_cb(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { RISCVVirtState *s =3D RISCV_VIRT_MACHINE(hotplug_dev); diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c index 440fefb7d0..e7cd9ac7b6 100644 --- a/hw/s390x/css-bridge.c +++ b/hw/s390x/css-bridge.c @@ -26,7 +26,7 @@ * (including sending a channel report to the guest) and remove the * device from the virtual css bus. */ -static void ccw_device_unplug(HotplugHandler *hotplug_dev, +static void ccw_device_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { CcwDevice *ccw_dev =3D CCW_DEVICE(dev); diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index eff980fdfe..2eb4e8cec4 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -158,7 +158,7 @@ static void s390_pci_shutdown_notifier(Notifier *n, voi= d *opaque) =20 static void s390_pci_perform_unplug(S390PCIBusDevice *pbdev) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; =20 if (pbdev->pft =3D=3D ZPCI_PFT_ISM) { notifier_remove(&pbdev->shutdown_notifier); @@ -1005,8 +1005,8 @@ static bool s390_pci_alloc_idx(S390pciState *s, S390P= CIBusDevice *pbdev) return true; } =20 -static void s390_pcihost_pre_plug(HotplugHandler *hotplug_dev, DeviceState= *dev, - Error **errp) +static void s390_pcihost_pre_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { S390pciState *s =3D S390_PCI_HOST_BRIDGE(hotplug_dev); =20 @@ -1079,7 +1079,7 @@ static int s390_pci_interp_plug(S390pciState *s, S390= PCIBusDevice *pbdev) return 0; } =20 -static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, +static void s390_pcihost_plug(const HotplugHandler *hotplug_dev, DeviceSta= te *dev, Error **errp) { S390pciState *s =3D S390_PCI_HOST_BRIDGE(hotplug_dev); @@ -1216,7 +1216,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, } } =20 -static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *= dev, +static void s390_pcihost_unplug(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp) { S390pciState *s =3D S390_PCI_HOST_BRIDGE(hotplug_dev); @@ -1255,7 +1255,7 @@ static void s390_pcihost_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, } } =20 -static void s390_pcihost_unplug_request(HotplugHandler *hotplug_dev, +static void s390_pcihost_unplug_request(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 17266779a6..7fb78d8fa1 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -343,8 +343,8 @@ static void ccw_init(MachineState *machine) =20 } =20 -static void s390_cpu_plug(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) +static void s390_cpu_plug(const HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) { ERRP_GUARD(); MachineState *ms =3D MACHINE(hotplug_dev); @@ -608,7 +608,7 @@ out_lock: bql_lock(); } =20 -static void s390_machine_device_pre_plug(HotplugHandler *hotplug_dev, +static void s390_machine_device_pre_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW)) { @@ -618,7 +618,7 @@ static void s390_machine_device_pre_plug(HotplugHandler= *hotplug_dev, } } =20 -static void s390_machine_device_plug(HotplugHandler *hotplug_dev, +static void s390_machine_device_plug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { S390CcwMachineState *s390ms =3D S390_CCW_MACHINE(hotplug_dev); @@ -648,7 +648,7 @@ static void s390_machine_device_plug(HotplugHandler *ho= tplug_dev, } } =20 -static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev, +static void s390_machine_device_unplug_request(const HotplugHandler *hotpl= ug_dev, DeviceState *dev, Error **e= rrp) { if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { @@ -662,7 +662,7 @@ static void s390_machine_device_unplug_request(HotplugH= andler *hotplug_dev, } } =20 -static void s390_machine_device_unplug(HotplugHandler *hotplug_dev, +static void s390_machine_device_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW)) { @@ -715,8 +715,8 @@ static const CPUArchIdList *s390_possible_cpu_arch_ids(= MachineState *ms) return ms->possible_cpus; } =20 -static HotplugHandler *s390_get_hotplug_handler(MachineState *machine, - DeviceState *dev) +static const HotplugHandler *s390_get_hotplug_handler(MachineState *machin= e, + DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) || object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_CCW) || diff --git a/hw/s390x/virtio-ccw-md.c b/hw/s390x/virtio-ccw-md.c index 0b18b49bc4..70dbea819a 100644 --- a/hw/s390x/virtio-ccw-md.c +++ b/hw/s390x/virtio-ccw-md.c @@ -19,7 +19,7 @@ void virtio_ccw_md_pre_plug(VirtIOMDCcw *vmd, MachineState *ms, Error **er= rp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 @@ -48,7 +48,7 @@ void virtio_ccw_md_pre_plug(VirtIOMDCcw *vmd, MachineStat= e *ms, Error **errp) void virtio_ccw_md_plug(VirtIOMDCcw *vmd, MachineState *ms, Error **errp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 @@ -72,7 +72,7 @@ void virtio_ccw_md_unplug_request(VirtIOMDCcw *vmd, Machi= neState *ms, { VirtIOMDCcwClass *vmdc =3D VIRTIO_MD_CCW_GET_CLASS(vmd); DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 @@ -112,7 +112,7 @@ void virtio_ccw_md_unplug_request(VirtIOMDCcw *vmd, Mac= hineState *ms, void virtio_ccw_md_unplug(VirtIOMDCcw *vmd, MachineState *ms, Error **errp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index d82874ed27..30fb2c0681 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1235,7 +1235,7 @@ static void virtio_ccw_busdev_unrealize(DeviceState *= dev) virtio_ccw_device_unrealize(_dev); } =20 -static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev, +static void virtio_ccw_busdev_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtioCcwDevice *_dev =3D to_virtio_ccw_dev_fast(dev); diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 132f833226..d7e2662aa7 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -1144,14 +1144,14 @@ static void virtio_scsi_change(SCSIBus *bus, SCSIDe= vice *dev, SCSISense sense) } } =20 -static void virtio_scsi_pre_hotplug(HotplugHandler *hotplug_dev, +static void virtio_scsi_pre_hotplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { SCSIDevice *sd =3D SCSI_DEVICE(dev); sd->hba_supports_iothread =3D true; } =20 -static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *= dev, +static void virtio_scsi_hotplug(const HotplugHandler *hotplug_dev, DeviceS= tate *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(hotplug_dev); @@ -1183,7 +1183,7 @@ static void virtio_scsi_hotplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, } } =20 -static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState= *dev, +static void virtio_scsi_hotunplug(const HotplugHandler *hotplug_dev, Devic= eState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(hotplug_dev); diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index 05f93171cd..77c9b843b4 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -612,7 +612,7 @@ pvscsi_send_msg(PVSCSIState *s, SCSIDevice *dev, uint32= _t msg_type) } =20 static void -pvscsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) +pvscsi_hotplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Error = **errp) { PVSCSIState *s =3D PVSCSI(hotplug_dev); =20 @@ -620,7 +620,7 @@ pvscsi_hotplug(HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp) } =20 static void -pvscsi_hot_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **e= rrp) +pvscsi_hot_unplug(const HotplugHandler *hotplug_dev, DeviceState *dev, Err= or **errp) { PVSCSIState *s =3D PVSCSI(hotplug_dev); =20 diff --git a/hw/virtio/virtio-md-pci.c b/hw/virtio/virtio-md-pci.c index aa5b11c0f6..97ea0ec7b3 100644 --- a/hw/virtio/virtio-md-pci.c +++ b/hw/virtio/virtio-md-pci.c @@ -19,7 +19,7 @@ void virtio_md_pci_pre_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **er= rp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 @@ -47,7 +47,7 @@ void virtio_md_pci_pre_plug(VirtIOMDPCI *vmd, MachineStat= e *ms, Error **errp) void virtio_md_pci_plug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 @@ -71,7 +71,7 @@ void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, Machi= neState *ms, { VirtIOMDPCIClass *vmdc =3D VIRTIO_MD_PCI_GET_CLASS(vmd); DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 @@ -110,7 +110,7 @@ void virtio_md_pci_unplug_request(VirtIOMDPCI *vmd, Mac= hineState *ms, void virtio_md_pci_unplug(VirtIOMDPCI *vmd, MachineState *ms, Error **errp) { DeviceState *dev =3D DEVICE(vmd); - HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev); + const HotplugHandler *bus_handler =3D qdev_get_bus_hotplug_handler(dev= ); MemoryDeviceState *md =3D MEMORY_DEVICE(vmd); Error *local_err =3D NULL; =20 diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c index 1762816bf4..8def3bb68b 100644 --- a/hw/xen/xen-bus.c +++ b/hw/xen/xen-bus.c @@ -374,7 +374,7 @@ fail: g_free(key); } =20 -static void xen_bus_unplug_request(HotplugHandler *hotplug, +static void xen_bus_unplug_request(const HotplugHandler *hotplug, DeviceState *dev, Error **errp) { diff --git a/stubs/hotplug-stubs.c b/stubs/hotplug-stubs.c index 0f592ee139..32b4af7997 100644 --- a/stubs/hotplug-stubs.c +++ b/stubs/hotplug-stubs.c @@ -14,19 +14,19 @@ #include "qemu/osdep.h" #include "hw/core/qdev.h" =20 -HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) +const HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev) { return NULL; } =20 -void hotplug_handler_pre_plug(HotplugHandler *plug_handler, +void hotplug_handler_pre_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { g_assert_not_reached(); } =20 -void hotplug_handler_plug(HotplugHandler *plug_handler, +void hotplug_handler_plug(const HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) { diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 0c5502d45b..a62ad23ecf 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -917,7 +917,7 @@ static DeviceState *find_device_state(const char *id, b= ool use_generic_error, =20 void qdev_unplug(DeviceState *dev, Error **errp) { - HotplugHandler *hotplug_ctrl; + const HotplugHandler *hotplug_ctrl; const HotplugHandlerClass *hdc; Error *local_err =3D NULL; =20 --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117479; cv=none; d=zohomail.com; s=zohoarc; b=RwFo9AN2vvkBFkFuJEZGa9rTcssbMhwPpzSi3wNZOOPLSjcjNG+3XANOKYIg8ZgKCVvWp54kdo6DqlV8TaTp2F6DAVYv7sc4MmTMuA0znMOM+F3hSpqHxcavZMUYn2cbywzqdUCC1EN9uCtcU0sz9Xabx0uD8ILkdhUL+wzAtaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117479; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KaGnA6790D1crogtaW20lAmdvIS1bCL1ahQfy0qBOJg=; b=c8ZMPfvux/dKfnXTLaItBgjFnHBMc7JhmfCcSxyOs/JcbMM5zuDSeJbtDTS2+oGtWwYkG/TuoWTyMpgGwVRWvNWQfAySDtWE+K23E8d1QlZoL+lLXyZin+q+8aiEDWY+oYgUtCq/IDw1ZL6TBmiapCH23xlNZJgITtCHulYTWGc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117479723302.7351299521796; Fri, 11 Sep 2026 02:04:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBO-00082U-PG; Fri, 11 Sep 2026 05:04:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xB1-0006XI-Mv for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xAz-0008R6-Fv for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:07 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-225-g_YeLaZLPeyZopd9ZPgA2g-1; Fri, 11 Sep 2026 05:04:03 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49e6683d48fso1187505e9.0 for ; Fri, 11 Sep 2026 02:04:02 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e6221963dsm30230865e9.2.2026.09.11.02.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117444; 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=KaGnA6790D1crogtaW20lAmdvIS1bCL1ahQfy0qBOJg=; b=Uuzk8cdtI92OvL3RUbfRdDFw+n0nNEBXyh2JLTo3SfYLUztM4nNNcmGJ/Jk4nxy/eF2H04 1nBKGOchW2T1yXWCJyvPQx56UbNknNOstRWPmZGWvikB0XhUDqvILifK2YWAf/BBVAHDR6 b9Chbkg7dccYmHDKdvUD/76j4r7z8uI= X-MC-Unique: g_YeLaZLPeyZopd9ZPgA2g-1 X-Mimecast-MFC-AGG-ID: g_YeLaZLPeyZopd9ZPgA2g_1789117442 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117442; x=1789722242; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=KaGnA6790D1crogtaW20lAmdvIS1bCL1ahQfy0qBOJg=; b=VYrjE0rb8SwIFu6dUg/aAL2scZWSr9XB2MG1IWupXGUATZlvrA8awtBrOhP0akqkBm NthD0XpIsvmKIT0uA9zcq1a5YlrwjpQPK69zvNlSjnKhUuu9t0FSE6/UxUpepCHupW3/ IX0XG0xq2MNkVisoDzUa/mfsf1+zXxy7A8QI3uvHFzii8BbfRXu6XjzfU+UFW2LhLxt0 +w6wVUHP1SAye3m+WOnO+kz06e5NVgCnahinmdedDt/viB4HpXFFXM3maOx8ojuUlOzn yGun98CGLKAvdTX0jvM1rnCiH6wwej2G+49pGbbyREsJL+Sp+DRjuCbOB+v41p7r/ux7 XTxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117442; x=1789722242; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KaGnA6790D1crogtaW20lAmdvIS1bCL1ahQfy0qBOJg=; b=HqS9ouotDja4Hb48nFeeHhKsRRZk9F48PGC9n/iYHXYjT/liZhC6/y6xSAMv26qtS1 EnsZLlzvmqWU8hOffeXkbne0VNdI+9xRF0Sn1JxxxaEhL6rbbM7ZsuxCcbuWuDkccyYh 7+gR7J/K2foeBomqSdgDxZxEzPExuABr1NhQmQFiuq4vnvbeciGOEKxiuN1T8cw8VgW5 /7DZ9ojtEpg01Jd+vf7Yza5bwpVtyAwCEdaZvmNnsMG55EdGz7kL5+nZpjBRYaq2spW/ mSvQESccf3xjZ+Pi2sIESgJYHziiGYAAiItxjF738Bnq84Gg840uA1wBtOMzcKoY1jDQ /acw== X-Gm-Message-State: AFuF++mv4eSky67RCzbvsD1/hkuOGOSAMP7w83+5crVgD3yk/IorMDi6 RwPiTIT18DT7vLlEAm/n5+Xb19huTmGf2oGAJPtmtu6a30b+kBxkPm23U5sZMKBZ+LAbS+ZyNQ8 sN4NLVXsX/Ly1hyU0/hVv1NsXdXZBWdK29z+p0gJL+wXGQK8dVT+OamIEBU6uWEKH1sfA7ndEoW iM/xVjQGz9XSpFitwW+nueo4ex3RPHCzPwjQ== X-Gm-Gg: AYBFou2SUV0VrLiBSnsGsVqSNE7JiPDHt4383FvOD1ILpi0gAC+qIt+m8fEXanNAjPj sYLjAe+prtRJb4450MDoBtPuYcmY7ahylxT9M2dZFs1CAsXt4/KoW5ipJrdSeIhbV+SWnaamVgj BlzBURa8cizTO2MQKJdmbrHaev6exJIXm1QLNYYAsOLyfivxQ7enxeMPs0iyTmCZjdlEPTpYJlR zcskmgC2dQstsRg6CMlieo6c5T0hIRBr5xnOKFpXT6Fs8HtSvYn329mnORHpP6rfl5FR33cnacZ 8dboUZf2XFDgLCTYvTjjF6Nq8AjLcL+DsltbkbQFO+74DQNpmLktGIqHr4elGgMpVlgUT3k91JJ roGh3Q7DCoKIYF3zSupKxqcU= X-Received: by 2002:a05:600c:3145:b0:49c:fc6e:8cae with SMTP id 5b1f17b1804b1-49e619bbca8mr32818185e9.18.1789117441734; Fri, 11 Sep 2026 02:04:01 -0700 (PDT) X-Received: by 2002:a05:600c:3145:b0:49c:fc6e:8cae with SMTP id 5b1f17b1804b1-49e619bbca8mr32817485e9.18.1789117441165; Fri, 11 Sep 2026 02:04:01 -0700 (PDT) Date: Fri, 11 Sep 2026 05:03:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Weimin Xiong , Jason Wang Subject: [PULL v2 66/75] net/tap-solaris: Fix resource leaks on error paths Message-ID: <44345a8a5f03f459ce6ff81b14ece81afd9c90d5.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117480635158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Weimin Xiong Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/tap-solaris.c | 69 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 8704b1084b..2c6c7af15e 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -60,8 +60,6 @@ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxl= en) */ static int tap_alloc(char *dev, size_t dev_size, Error **errp) { - /* FIXME leaks like a sieve on error paths */ - /* FIXME suspicious: many errors are reported, then ignored */ int tap_fd, if_fd, ppa =3D -1; static int ip_fd =3D 0; char *ptr; @@ -102,45 +100,61 @@ static int tap_alloc(char *dev, size_t dev_size, Erro= r **errp) strioc_ppa.ic_timout =3D 0; strioc_ppa.ic_len =3D sizeof(ppa); strioc_ppa.ic_dp =3D (char *)&ppa; - if ((ppa =3D ioctl (tap_fd, I_STR, &strioc_ppa)) < 0) + if ((ppa =3D ioctl (tap_fd, I_STR, &strioc_ppa)) < 0) { error_report("Can't assign new interface"); + goto fail_tap_fd; + } =20 if_fd =3D RETRY_ON_EINTR(open("/dev/tap", O_RDWR, 0)); if (if_fd < 0) { error_setg_file_open(errp, errno, "/dev/tap"); - return -1; + goto fail_tap_fd; } if(ioctl(if_fd, I_PUSH, "ip") < 0){ error_setg(errp, "Can't push IP module"); - return -1; + goto fail_if_fd; } =20 - if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) + if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { error_report("Can't get flags"); + goto fail_if_fd; + } =20 - snprintf (actual_name, 32, "tap%d", ppa); + snprintf(actual_name, 32, "tap%d", ppa); pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name); =20 ifr.lifr_ppa =3D ppa; - /* Assign ppa according to the unit number returned by tun device */ - - if (ioctl (if_fd, SIOCSLIFNAME, &ifr) < 0) + if (ioctl(if_fd, SIOCSLIFNAME, &ifr) < 0) { error_report("Can't set PPA %d", ppa); - if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) <0) + goto fail_if_fd; + } + + if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { error_report("Can't get flags"); + goto fail_if_fd; + } + /* Push arp module to if_fd */ - if (ioctl (if_fd, I_PUSH, "arp") < 0) + if (ioctl(if_fd, I_PUSH, "arp") < 0) { error_report("Can't push ARP module (2)"); + goto fail_if_fd; + } =20 /* Push arp module to ip_fd */ - if (ioctl (ip_fd, I_POP, NULL) < 0) + if (ioctl(ip_fd, I_POP, NULL) < 0) { error_report("I_POP failed"); - if (ioctl (ip_fd, I_PUSH, "arp") < 0) + goto fail_if_fd; + } + if (ioctl(ip_fd, I_PUSH, "arp") < 0) { error_report("Can't push ARP module (3)"); + goto fail_if_fd; + } /* Open arp_fd */ arp_fd =3D RETRY_ON_EINTR(open("/dev/tap", O_RDWR, 0)); - if (arp_fd < 0) + if (arp_fd < 0) { error_report("Can't open %s", "/dev/tap"); + goto fail_if_fd; + } =20 /* Set ifname to arp */ strioc_if.ic_cmd =3D SIOCSLIFNAME; @@ -149,32 +163,45 @@ static int tap_alloc(char *dev, size_t dev_size, Erro= r **errp) strioc_if.ic_dp =3D (char *)𝔦 if (ioctl(arp_fd, I_STR, &strioc_if) < 0){ error_report("Can't set ifname to arp"); + goto fail_arp_fd; } =20 if((ip_muxid =3D ioctl(ip_fd, I_LINK, if_fd)) < 0){ error_setg(errp, "Can't link TAP device to IP"); - return -1; + goto fail_arp_fd; } =20 - if ((arp_muxid =3D ioctl (ip_fd, link_type, arp_fd)) < 0) + if ((arp_muxid =3D ioctl(ip_fd, link_type, arp_fd)) < 0) { error_report("Can't link TAP device to ARP"); + goto fail_ip_muxid; + } =20 - close (if_fd); + close(if_fd); =20 memset(&ifr, 0x0, sizeof(ifr)); pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name); ifr.lifr_ip_muxid =3D ip_muxid; ifr.lifr_arp_muxid =3D arp_muxid; =20 - if (ioctl (ip_fd, SIOCSLIFMUXID, &ifr) < 0) + if (ioctl(ip_fd, SIOCSLIFMUXID, &ifr) < 0) { - ioctl (ip_fd, I_PUNLINK , arp_muxid); - ioctl (ip_fd, I_PUNLINK, ip_muxid); + ioctl(ip_fd, I_PUNLINK, arp_muxid); + ioctl(ip_fd, I_PUNLINK, ip_muxid); error_report("Can't set multiplexor id"); } =20 snprintf(dev, dev_size, "tap%d", ppa); return tap_fd; + +fail_ip_muxid: + ioctl(ip_fd, I_PUNLINK, ip_muxid); +fail_arp_fd: + close(arp_fd); +fail_if_fd: + close(if_fd); +fail_tap_fd: + close(tap_fd); + return -1; } =20 int tap_open(char *ifname, int ifname_size, int *vnet_hdr, --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117707; cv=none; d=zohomail.com; s=zohoarc; b=Z+8Hc3zF+TE0Zwk+0FEtPTOKtjgGowXxEVu8/Rhbr5TahccpfP6fXBKK3a7cniD9ZXXsNPrLdKxv9UJSJHTITTbHNbEXB+U+xI5C0bYWl/oY9N6rwyaxZ2xjD4HR5lf1JvNYweu4rg288r10WKTI/5YjDb46NGz/c848l3Q7ARA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117707; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hzJidFmu3cCZ/gNI5oejlvZ2j1X9hxYd2KmntrLLK2Q=; b=UZWHH/3ReylvBiUo+FkGRjXsCLLOzxGVJxH8/0Sr9Lht44NZDNppjJ3zOgzLmjyvmon2BsD4u64ePTq0bOe7wIuW9MFgGqvkF0UZ2qKSH6ivsXuyAjm3FFbE8OjM70gw8+Y3Golqla/jY3FsVWyNPOgC7keRkMD/SFKs7Iys9bY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17891177078341018.7912613751671; Fri, 11 Sep 2026 02:08:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBV-0008SR-SJ; Fri, 11 Sep 2026 05:04:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xB7-0006z7-Sb for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xB2-0008S9-4V for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:13 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-BBQeC5pzOy2N6e3MKmY8HQ-1; Fri, 11 Sep 2026 05:04:05 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49cd83ca361so6764805e9.1 for ; Fri, 11 Sep 2026 02:04:05 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49d26be3e35sm134916805e9.2.2026.09.11.02.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117447; 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=hzJidFmu3cCZ/gNI5oejlvZ2j1X9hxYd2KmntrLLK2Q=; b=KSbnWpUvkE84TrlbzRLL+SpkWaj6YEg+XcDn9SCXOq2FucutYc3cfKtJKsf72Kq3B/SV7X F9KlTg6hF/qj32CFAdt/rl85IEU11fX+vBnIL17WGJutUw8FIBjsi/wDgKQvH3ygB5qrtP uGF2xiMjo/gcL7uGR2L7CCJofMdbdCA= X-MC-Unique: BBQeC5pzOy2N6e3MKmY8HQ-1 X-Mimecast-MFC-AGG-ID: BBQeC5pzOy2N6e3MKmY8HQ_1789117444 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117444; x=1789722244; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=hzJidFmu3cCZ/gNI5oejlvZ2j1X9hxYd2KmntrLLK2Q=; b=s2YppWhfpKIgyoxauYNkqOxRXj+c29fKWUUTCqu+qtPZXKylGPqBXSOXD/8xAQqfUd FfDnh5/KNwVH193w7tNDNrRUuxR4uj6xcK0VEwv3cSX7YgCRxXVvZz2VQWONg3m90XcL J5iSiLFLmMxjUtjZW3G+A02mutVurvyD6eeXw8p2U4QdCHuU/6nYwq7hJZKEL33QtjPn WoXkUDBtQ2grngAVF2Qf2eqnQWpZsl7ZKvipqBpBKBucjm5uYyyn4PY7QmfBs7ERDz66 0iL+Skfief8sNHfdYz4Jt0tbmLCzbF/YKM8Rq9RSNjcFedSJJndMJyac+nn9GQLy6tUQ dz5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117444; x=1789722244; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hzJidFmu3cCZ/gNI5oejlvZ2j1X9hxYd2KmntrLLK2Q=; b=K+8VpKobV+ism0t1SFOMQlc5V6e7u/5ruKxzgHWHBRaW0LbbnJZNAnlHyfxHtJcjTT nstX8o9RmcTd1dzt/kbz1omE0nPbVooLVfZdrgxF7YvAPzeepqc5etcP3EUgvl6GJgMc hMA/Rtq9ihQlAD8WKtoBqt7oIhyMCpeg3cm9anmRyIy6WJVGbXfZ7qucVZkpenJoiY4K 5eA1wyges54jUi6fctZ+8WV+DOZD2pXuqXgaKH+vGOWGxdMNcwIFpTb5txwoCCO8FmaI wFNCLeTAQBW9m5B9R46Ne35wSRpbX7o2Nshe4jg0s9iada1L/uwS1qsyP9ZAPnGAWFHX 4Ihw== X-Gm-Message-State: AFuF++kVGFBjEnQdBQR2BaTWUI8wMXF86UhciNSPC2NmgPQ9QAqVIneA pafW4eUJEOLmH2ynnKNtFdABkzexGoavAip/NYCA29B+wdBBXP+jx+xkKdnGISLaGNbfx6uwcre xrK1kGfStFYxGqCZZUxlEfEZntWzx73hOavk+yOX+IW1bsThUxVIxWe9Ph/rm00DN7FWR47aoX2 gOCJ00X0OwKtSxNBCiFPwQG7YsbAfTa8w4xQ== X-Gm-Gg: AYBFou0VuQ5jbnC5/ayOtlPYi1LlGIdf1kEvek0SA8/6b6SN1mwWD/7rwPcsf3qsGxw hxbfQthuSuEijAEk91iJXRecA+LM7qyhCpyIyMEY9aXRIrP3F0CiSa5TQsM4qC9YOdzn5lhA+q7 t3LGDaag3QC0GvV/bVBkc7AmuMx5bmYF8NBG09OdWpMgV1oBmDdm0t4lYVQZ0qTLfwgMEcVKyOx yNrKIzsy+jhBUJv16fQv2WqsvVSBkeAYy7vX7z+AVdji6dxd9cQ3AMk7XbUDShWqwaW9ssDhLy3 Hn45ShRpES0LdQGx/991SIoyW14HhO2Ek2JDbq7l50kH/kQ1PdxhwMdL11lH3n4ThjqaYMXA3hy U/uM3tx/J9b93J4XPeB3MOKQ= X-Received: by 2002:a05:600c:8b41:b0:49b:d45:703e with SMTP id 5b1f17b1804b1-49e6198865dmr42375245e9.8.1789117443825; Fri, 11 Sep 2026 02:04:03 -0700 (PDT) X-Received: by 2002:a05:600c:8b41:b0:49b:d45:703e with SMTP id 5b1f17b1804b1-49e6198865dmr42374315e9.8.1789117443205; Fri, 11 Sep 2026 02:04:03 -0700 (PDT) Date: Fri, 11 Sep 2026 05:04:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jason Wang , Yuri Benditovich Subject: [PULL v2 67/75] virtio-net: validate IHL in virtio_net_rsc_extract_unit4 before use Message-ID: <8649730874bde0412e3c531e5fad43dde96bab08.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117709902158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtio_net_rsc_extract_unit4() uses the IPv4 IHL nibble from the wire to compute the TCP header offset, but the caller's length check only guarantees space for a minimum 20-byte IP header. A crafted IHL of 15 causes a read 32 bytes past a 66-byte buffer when the frame was parked in net/queue.c's exact-size allocation. virtio_net_rsc_sanity_check4() rejects IHL !=3D 5 on the next line, but runs after the OOB read already happened. Validate IHL before using it as an offset. Since virtio_net_rsc_sanity_check4() only accepts IHL =3D=3D 5 anyway, reject anything else early and let the caller fall through to the bypass path. Fixes: 2974e916df ("virtio-net: support RSC v4/v6 tcp traffic for Windows H= CK") Cc: Jason Wang Cc: Yuri Benditovich Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4166 Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 986ceff514..19f453fb7d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2104,6 +2104,14 @@ static void virtio_net_rsc_extract_unit4(VirtioNetRs= cChain *chain, unit->ip =3D (void *)ip; ip_hdrlen =3D (ip->ip_ver_len & 0xF) << 2; unit->ip_plen =3D &ip->ip_len; + + if (ip_hdrlen !=3D sizeof(struct ip_header)) { + unit->tcp =3D NULL; + unit->tcp_hdrlen =3D 0; + unit->payload =3D 0; + return; + } + unit->tcp =3D (struct tcp_header *)(((uint8_t *)unit->ip) + ip_hdrlen); unit->tcp_hdrlen =3D (htons(unit->tcp->th_offset_flags) & 0xF000) >> 1= 0; unit->payload =3D read_unit_ip_len(unit) - ip_hdrlen - unit->tcp_hdrle= n; --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117559; cv=none; d=zohomail.com; s=zohoarc; b=F2fH3slljDcgvJkc9/8F6BzYCuNyOTos6Ah4NcJI2SVpWKo8fnvtf3eofCG6+R49mGxJJX1UrBhlco/ovH24u3tG0512Ods42vqAGe/5Ph0CVQqTzVLWEcG4EDT4tpQkvqhQK6QX/3l2NpaJcl3ZU6Q6SEsGkOzKR7+SY1DO85I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117559; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bUsqkqSEg6ABsPYNlxkrlq9VUldheG28GlxZUj5JBUE=; b=Boki7rQIsqxBtVSFrW1P6ELsyG8NRpyWbDYAGed4HhXkp5Q6wN2rUNdDxu7naMuy54IW0EvPSRXnpQvd8DGI9EyeY9z5Dc/sFM0Abju8XJZXiCNBG7HPudOZXHyeGJL85ynS/dRwhPdUszRoWHPsa72KoejgyCnfpQlklmqKTGc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117559731887.910315450222; Fri, 11 Sep 2026 02:05:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBg-0000W6-Bd; Fri, 11 Sep 2026 05:04:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xB8-00071g-JE for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xB3-0008SX-Sh for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:14 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-kzFOfbpXOKmfSmyrj64PRg-1; Fri, 11 Sep 2026 05:04:07 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48436a5fb42so321948f8f.1 for ; Fri, 11 Sep 2026 02:04:07 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb34e4b5sm4630040f8f.22.2026.09.11.02.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117449; 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=bUsqkqSEg6ABsPYNlxkrlq9VUldheG28GlxZUj5JBUE=; b=fUUm6TYbhHh5f/lzi52ONMCjUB0OtIT7wpp16kvHZApzvyrSzREBs0sSQ5Ly9dE148I/oY ubUELk01+0f22L+I7nzCgisB2lHquZ0LETmeSC69Xp/QUE1Y7BzElVMdViX/tJVcuRUmkA tQMpiEI5J5YSpGjjP8+2Km+msJhod0o= X-MC-Unique: kzFOfbpXOKmfSmyrj64PRg-1 X-Mimecast-MFC-AGG-ID: kzFOfbpXOKmfSmyrj64PRg_1789117447 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117446; x=1789722246; darn=nongnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=bUsqkqSEg6ABsPYNlxkrlq9VUldheG28GlxZUj5JBUE=; b=H6b5BsiM/lPDG2gq3qXbrvE5g0nfVvpU39nzO2gDDUf8aR5dFUWFrPtZgD0x036W4d uly0r7JoBjikGtj2vJOJPHn18RVwyQe++39s+Kbre5Yeav/J9g6bf6iRJbrMX+bOImnL rSnRQVZRi8aHdQTeuHa1cDLQGhD4zMFfLkREkWKoCUot9UCTYqXa4/F/EBXgNTxS7XCv 0tnNwFebX07zAMkTdwBDSA6iSTLvRiq8DAPdXD2vJxN6MVtkYMfUpFp+NNB610wTsJVy ouQwrtuWjYcigoS5iL+9Kp2ynCjR/1aEqrt9mr2o5mtv/EggMSK7pcX0eZvQ8aabOn+Y vgug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117446; x=1789722246; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=bUsqkqSEg6ABsPYNlxkrlq9VUldheG28GlxZUj5JBUE=; b=JXsGGEHl9GeccEBL3MUy5MRLBMzTsH1fHZnqD7X7m90fTRuvUIjRm1nQbOZytikhx1 QfwUoxR5zyMOILK1hE7CAM0Q5XWdsjs94GQe3AnRpHKx6QukFZL760b2CNppwAKpTVvx ci1ivhLDju8WS0rRe4EDYg3w/aeqD3gd+wHuaMmSqVEh41Emiakgxu4+c0YTpm8nCN0n FlQ1O1NJ2g1HYwkQETbCuqbMELx5E5q6FIIJVnD2cbH7cdiIyR8ovwjFrwqxvOa9FTVU u/ZV8qrIh+oDuoPMdBobHRTJPJNSoJ6Rz97ve3DmNXhLh66o62MZLppf11esK9MyQcdV tbsg== X-Gm-Message-State: AFuF++kIuN+0gjsH56MzFRL7baTTrb3ogqr8NVTt/ympxb8J4JqbQI0h /DBVyEyIY5II0aD7WnmIKYg0rQBMKqnZi6YE4cAHwy22jFONooqM41T9W/Bw3IVWPZtzKIOEqP/ rYXqZ5xRzWOb+jLUDdyydfvUjtcZDe3fZlT6PDCiqggDgIzx73QkDvNYi84QBvqLlZwt4FKsUqI r2whvLvGz7SniT5+xED1eyFTNS2Y6yjpSUFA== X-Gm-Gg: AYBFou1TxRiOKKy+/JNL9BUV5ebMQSyra/P000XS34NqlZxN6/3fhu/7eWFbnnV+L1p V/chnAhkx9jZVNTlMMhY9XET43GdYMsUTbqfhPFg4jmQWGkM1gVb9SE2NAQnyE3EddnDaeN8ovV STEUhF6FLm6Q35Wl0IuuQEYEC6sAu4XW853GzwRNRRF/sSJD0m6tFfN8Z62YsmGKBQeO0nRzbHJ KNANoek7x7Etsv/2bt9etTi01013NvKClKRXHCKnm0oHr0ksY4wa2ETfDr7B4p+ecQlRgl62Xrw 0vvLf2iqTbnDvP3Rt1D9Psz+Ri8eS2e4QkrOughprZRWgTWdSSXKdm0J/6z198BjY+nvoiiYywy 1kG3gm757agYlPMPMG7/KPxs= X-Received: by 2002:a05:6000:2c10:b0:486:e37d:c57d with SMTP id ffacd0b85a97d-486eb345e9dmr3832197f8f.43.1789117446450; Fri, 11 Sep 2026 02:04:06 -0700 (PDT) X-Received: by 2002:a05:6000:2c10:b0:486:e37d:c57d with SMTP id ffacd0b85a97d-486eb345e9dmr3832137f8f.43.1789117445869; Fri, 11 Sep 2026 02:04:05 -0700 (PDT) Date: Fri, 11 Sep 2026 05:04:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Cl=C3=A9ment?= MATHIEU--DRIF , Zhenzhong Duan , Jason Wang , Yi Liu , Paolo Bonzini , Richard Henderson Subject: [PULL v2 68/75] intel_iommu: Expose SMPWC when SVM is enabled Message-ID: <49094452768e61416f2b7dad3393bb69bad5d654.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117561464158500 From: Cl=C3=A9ment MATHIEU--DRIF SVM in Linux requires SMPWC. This is free in the current implementation as it is already in line with the expected behaviour. Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3D780dfed68862 Fixes: 952e1a6e90eb ("intel_iommu: Add a CLI option to enable SVM") Signed-off-by: Clement Mathieu--Drif Reviewed-by: Zhenzhong Duan Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260808153626.873965-1-clement.mathieu--drif@bull.com> --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 3 ++- hw/i386/intel_iommu_accel.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 924e91cb8a..df7a0efa6e 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -202,6 +202,7 @@ #define VTD_ECAP_SMTS (1ULL << 43) #define VTD_ECAP_SSTS (1ULL << 46) #define VTD_ECAP_FSTS (1ULL << 47) +#define VTD_ECAP_SMPWCS (1ULL << 48) =20 /* CAP_REG */ /* (offset >> 4) << 24 */ diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 91ab549dbf..350d2b7753 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -5121,7 +5121,8 @@ static void vtd_init(IntelIOMMUState *s) } =20 if (s->svm) { - s->ecap |=3D VTD_ECAP_PRS | VTD_ECAP_PDS | VTD_ECAP_NWFS; + s->ecap |=3D VTD_ECAP_PRS | VTD_ECAP_PDS | VTD_ECAP_NWFS | + VTD_ECAP_SMPWCS; } =20 vtd_reset_caches(s); diff --git a/hw/i386/intel_iommu_accel.c b/hw/i386/intel_iommu_accel.c index c03435f8a2..c3677775e9 100644 --- a/hw/i386/intel_iommu_accel.c +++ b/hw/i386/intel_iommu_accel.c @@ -37,6 +37,12 @@ bool vtd_check_hiod_accel(IntelIOMMUState *s, VTDHostIOM= MUDevice *vtd_hiod, return false; } =20 + if ((s->ecap & VTD_ECAP_SMPWCS) && !(vtd->ecap_reg & VTD_ECAP_SMPWCS))= { + error_setg(errp, + "Scalable-mode coherent walk is unsupported by host IOM= MU"); + return false; + } + if (s->fs1gp && !(vtd->cap_reg & VTD_CAP_FS1GP)) { error_setg(errp, "First stage 1GB large page is unsupported by host IOMM= U"); --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117753; cv=none; d=zohomail.com; s=zohoarc; b=XVsHpaIpM/eWonhsknI8XuysGv+gWBhYbq244lw7cQ1pURCmvC5QJyidRzGqaBWB1kugqy08MBsW1AnrrSYg8dgdGqj2Qkxres8a70plTobTggLGppSzMVrNzSmxyP5N48tzkcNYMpKzl46FGfZrdZJKyPwyjIlsO+tzdIfF/Gk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117753; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=v1olWRoVJuPWwSBJbdW2ynlLoWLMs3mS5pnDLdXpZdk=; b=mtv3UCZMwLZjRkt9pqJf5pfClIoNZZd7jHviTkiXyfta5xh6/UmqErDhGMFySv4C8/GRgCdzD8Sduu44rnIBn3G92+oT58DZ/FLCWBZiPp4a9RyJyEZaFAbFODEZBfEVz00kkuHMpF7QmhAgXu8xOR8/6BAkNOos174HVD+RP0w= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117753267100.25876174807752; Fri, 11 Sep 2026 02:09:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBR-0008Hn-Um; Fri, 11 Sep 2026 05:04:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBA-00078g-DH for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xB8-0008TT-36 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:16 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-Gl-pElc3OMuKZvVwB54ehw-1; Fri, 11 Sep 2026 05:04:12 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-486f1eee015so122754f8f.1 for ; Fri, 11 Sep 2026 02:04:11 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-486eb35bed0sm4420473f8f.32.2026.09.11.02.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117453; 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=v1olWRoVJuPWwSBJbdW2ynlLoWLMs3mS5pnDLdXpZdk=; b=Jj8RQkCwtzOcaAgYrNj5ae+iaypixPB5ly8Mw11tS7NFPnnVU0qQdOeJyhgHl9GT5W8CHA MfMRwMVpfyv+ZScSj6dhkSy14V/MCr9yRAt0G44j405cV2121CGuNoYaSy2KdyRHMJcLvt gXw1nG6YcEa8sqfcXW0VSjlGGFYwxcY= X-MC-Unique: Gl-pElc3OMuKZvVwB54ehw-1 X-Mimecast-MFC-AGG-ID: Gl-pElc3OMuKZvVwB54ehw_1789117451 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117451; x=1789722251; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=v1olWRoVJuPWwSBJbdW2ynlLoWLMs3mS5pnDLdXpZdk=; b=WnTh/7e18O96NjvIeY0+PdqcputxsTWRYhwvjuOKxSdlW3VvPSD3XmwnltwIGb7e/m ksen+jvQWaNfuDkl8SBlET+z/kYqWrPqb80QeEFAsfei2qhD4pwJwdYyaCBfncz+5FZu t8mj9MICybAgbON12wRBhh8xY+hK44SzwGGNsqN6ces+hXZoydQp9onkcwoo4tSMg8Rh yZp/FVfsDbr2ZvlKJS7lH7IP4H8U1EsaS/qwbeAqvkcEa+KPyCnSNa07D+ar9d6X9oOl Z3v3D1HdWo0xhoiJ0gBHqG1O1UvRs+VbgDd5CJj6rtxLsuvSLBkrRFL4e72QkRwRcsvo kiMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117451; x=1789722251; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=v1olWRoVJuPWwSBJbdW2ynlLoWLMs3mS5pnDLdXpZdk=; b=MUl/gzLGoB85lZdFvzjTva7FJXOaHDRl48KRLmBrc4B6xFcboWPtxLnBasVUKJSvNu ce8HA0p9dJ+w8Uqe9U2Td1gC7ecBHEAtbixyHQtJ+l9aAAT2jOUAfkwUhBtoEbLroyki yHGeFcvc5bsISOg6vXR0u7WCZTeagYfsZ+92rFrdgFKQRm62TCEzVGdChyynzZpygySy zqf+RMCWlLprWdoWudkHNTdRTamWllA/GSoXOLh9VoE92OB/m31Y4J0dT4/2DF6wMYuv wgqziO5weVD+55wF++4L284ie6QumDAmMrlRAjbTGYVPzgHGuHjpsmw9v9YtJVWo9Qwt MQ2g== X-Gm-Message-State: AFuF++kSgCKpmaQLFTmrAzIYnjUlADM0xPw/KvUzT8HgT5RIbERJQRDP 8bHmcMZmKD/OmoPfJzVfrj1IfGkSqAbAOn8M0HGKJ78bnOUYYaSJiEDFnPPUlB34AJipHDUrD/2 d70RRzwknnpGC73R3AK9REPOA4X2bJxXSBicU8sSvWoQkhexkH/f+rL5bbXgaO0GeVTPdHadHHV zJWcLsb1DfZtBJazNEiEoiZ5LgQYo7NX3iaQ== X-Gm-Gg: AYBFou0M9E0KYS5wqgFjjNlOBs1QJae2P9zKKZxmlJcihFKI7TsiWLCmpH2D+2B7hb5 dbNAsNMBmCvT+3/7gJo1wqLLXrR4DuqF0zfkZXSyOrPS8HuPfznuMTxe0EMcvPeOe/bZ16UShd8 WiHugKqdHlnima3wytqmKtxT2IyGGMzBvZADaSyg0YbDFU2GSeDpZphDMesep2yWmYBeOcjpZMS vjDZS7186QN4axsMRkqt8OrskPIRBnPEgg7erC7I1UmHcrZV0sOVNQEVDIXROQg7omrGncns+cH c6ipTbm7/0eiVATWMhSz4CJB/MMiYnwPgO7PFmG9UR4PZcJcheXeoNtk5pLzNMOpCklK/ZGzYj0 E99VoN+1uH8qZqXy0nWTAuQI= X-Received: by 2002:adf:e00b:0:10b0:484:3310:710c with SMTP id ffacd0b85a97d-486eb351000mr4953734f8f.24.1789117450515; Fri, 11 Sep 2026 02:04:10 -0700 (PDT) X-Received: by 2002:adf:e00b:0:10b0:484:3310:710c with SMTP id ffacd0b85a97d-486eb351000mr4953596f8f.24.1789117449920; Fri, 11 Sep 2026 02:04:09 -0700 (PDT) Date: Fri, 11 Sep 2026 05:04:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , "Gonglei (Arei)" , zhenwei pi , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Albert Esteve , Jason Wang , Paolo Bonzini , Fam Zheng , Alex =?utf-8?Q?Benn=C3=A9e?= , Stefan Hajnoczi , Milan Zamazal , qemu-block@nongnu.org, virtio-fs@lists.linux.dev Subject: [PULL v2 69/75] vhost-user: add skip_drain param to do_vhost_virtqueue_stop Message-ID: <2e6881e1198dcb0c9ec0fe2dbbc04ac5d13ea696.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117755153158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov Currently do_vhost_virtqueue_stop always sends GET_VRING_BASE to the back-end, which requires the back-end to drain all in-flight I/O before stopping the vring. Add a skip_drain parameter to do_vhost_virtqueue_stop and propagate it up through vhost_virtqueue_stop, vhost_dev_stop and their callers. The parameter will be used in a follow-up commit to send a new protocol message that instructs the back-end to suspend in-flight I/O immediately instead of draining it. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-2-dtalexundeer@yandex-team.ru> --- include/hw/virtio/vhost.h | 7 +++++-- backends/cryptodev-vhost.c | 2 +- backends/vhost-user.c | 2 +- hw/block/vhost-user-blk.c | 2 +- hw/display/vhost-user-media.c | 2 +- hw/net/vhost_net.c | 9 +++++---- hw/scsi/vhost-scsi-common.c | 2 +- hw/virtio/vdpa-dev.c | 2 +- hw/virtio/vhost-user-base.c | 2 +- hw/virtio/vhost-user-fs.c | 2 +- hw/virtio/vhost-user-scmi.c | 2 +- hw/virtio/vhost-vsock-common.c | 2 +- hw/virtio/vhost.c | 28 +++++++++++++++++++--------- 13 files changed, 39 insertions(+), 25 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 3db56433b6..0a322efec1 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -228,6 +228,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevic= e *vdev, bool vrings); * @hdev: common vhost_dev structure * @vdev: the VirtIODevice structure * @vrings: true to have vrings disabled in this call + * @skip_drain: true to notice back-end to skip draining all in-flight req= uests * * Stop the vhost device. After the device is stopped the notifiers * can be disabled (@vhost_dev_disable_notifiers) and the device can @@ -235,7 +236,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevic= e *vdev, bool vrings); * * Return: 0 on success, !=3D 0 on error when stopping dev. */ -int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings= ); +int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings, + bool skip_drain); =20 /** * vhost_dev_force_stop() - force stop the vhost device @@ -396,7 +398,8 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint= 64_t iova, int write); int vhost_virtqueue_start(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, unsigned idx); int vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, - struct vhost_virtqueue *vq, unsigned idx); + struct vhost_virtqueue *vq, unsigned idx, + bool skip_drain); =20 void vhost_dev_reset_inflight(struct vhost_inflight *inflight); void vhost_dev_free_inflight(struct vhost_inflight *inflight); diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index c6069f4e5b..f1ca6bcd4e 100644 --- a/backends/cryptodev-vhost.c +++ b/backends/cryptodev-vhost.c @@ -109,7 +109,7 @@ static void cryptodev_vhost_stop_one(CryptoDevBackendVhost *crypto, VirtIODevice *dev) { - vhost_dev_stop(&crypto->dev, dev, false); + vhost_dev_stop(&crypto->dev, dev, false, false); vhost_dev_disable_notifiers(&crypto->dev, dev); } =20 diff --git a/backends/vhost-user.c b/backends/vhost-user.c index 46dadb7480..de6b1ba267 100644 --- a/backends/vhost-user.c +++ b/backends/vhost-user.c @@ -108,7 +108,7 @@ vhost_user_backend_stop(VhostUserBackend *b) return 0; } =20 - ret =3D vhost_dev_stop(&b->dev, b->vdev, true); + ret =3D vhost_dev_stop(&b->dev, b->vdev, true, false); =20 if (k->set_guest_notifiers && (err =3D k->set_guest_notifiers(qbus->parent, b->dev.nvqs, false))= < 0) { diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 2e5b3ae1b1..c3e3c37f8c 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -238,7 +238,7 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) qemu_force_shutdown_requested(); =20 ret =3D force_stop ? vhost_dev_force_stop(&s->dev, vdev, true) : - vhost_dev_stop(&s->dev, vdev, true); + vhost_dev_stop(&s->dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (err < 0) { diff --git a/hw/display/vhost-user-media.c b/hw/display/vhost-user-media.c index eaf99dc6a2..851af8ddc2 100644 --- a/hw/display/vhost-user-media.c +++ b/hw/display/vhost-user-media.c @@ -110,7 +110,7 @@ static void vu_media_stop(VirtIODevice *vdev) return; } =20 - vhost_dev_stop(&media->vhost_dev, vdev, true); + vhost_dev_stop(&media->vhost_dev, vdev, true, false); =20 ret =3D k->set_guest_notifiers(qbus->parent, media->vhost_dev.nvqs, fa= lse); if (ret < 0) { diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 323d117735..6e05c995f1 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -384,7 +384,7 @@ fail: if (net->nc->info->poll) { net->nc->info->poll(net->nc, true); } - vhost_dev_stop(&net->dev, dev, false); + vhost_dev_stop(&net->dev, dev, false, false); fail_start: return r; } @@ -403,7 +403,7 @@ static void vhost_net_stop_one(struct vhost_net *net, if (net->nc->info->poll) { net->nc->info->poll(net->nc, true); } - vhost_dev_stop(&net->dev, dev, false); + vhost_dev_stop(&net->dev, dev, false, false); if (net->nc->info->stop) { net->nc->info->stop(net->nc); } @@ -636,7 +636,8 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetC= lientState *nc, vhost_virtqueue_stop(&net->dev, vdev, net->dev.vqs + idx, - net->dev.vq_index + idx); + net->dev.vq_index + idx, + false); } =20 int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc, @@ -686,7 +687,7 @@ err_start: assert(ret >=3D 0); } =20 - vhost_dev_stop(&net->dev, vdev, false); + vhost_dev_stop(&net->dev, vdev, false, false); =20 return r; } diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c index e19800a0bc..e546a6dc75 100644 --- a/hw/scsi/vhost-scsi-common.c +++ b/hw/scsi/vhost-scsi-common.c @@ -108,7 +108,7 @@ int vhost_scsi_common_stop(VHostSCSICommon *vsc) VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); int ret =3D 0; =20 - ret =3D vhost_dev_stop(&vsc->dev, vdev, true); + ret =3D vhost_dev_stop(&vsc->dev, vdev, true, false); =20 if (k->set_guest_notifiers) { int r =3D k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, fals= e); diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c index 6dc684ab09..7e5cc040e9 100644 --- a/hw/virtio/vdpa-dev.c +++ b/hw/virtio/vdpa-dev.c @@ -301,7 +301,7 @@ static void vhost_vdpa_device_stop(VirtIODevice *vdev) return; } =20 - vhost_dev_stop(&s->dev, vdev, false); + vhost_dev_stop(&s->dev, vdev, false, false); =20 ret =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (ret < 0) { diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 478ec68f09..1a377016e7 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -78,7 +78,7 @@ static int vub_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(&vub->vhost_dev, vdev, true); + ret =3D vhost_dev_stop(&vub->vhost_dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, fals= e); if (err < 0) { diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 209993918a..0d8842817a 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -111,7 +111,7 @@ static int vuf_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(&fs->vhost_dev, vdev, true); + ret =3D vhost_dev_stop(&fs->vhost_dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, fs->vhost_dev.nvqs, false= ); if (err < 0) { diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c index 02dc088ea9..c4692bd6aa 100644 --- a/hw/virtio/vhost-user-scmi.c +++ b/hw/virtio/vhost-user-scmi.c @@ -101,7 +101,7 @@ static int vu_scmi_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(vhost_dev, vdev, true); + ret =3D vhost_dev_stop(vhost_dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); if (err < 0) { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index b79f4c9ce6..4ef037627b 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -106,7 +106,7 @@ int vhost_vsock_common_stop(VirtIODevice *vdev) return 0; } =20 - ret =3D vhost_dev_stop(&vvc->vhost_dev, vdev, true); + ret =3D vhost_dev_stop(&vvc->vhost_dev, vdev, true, false); =20 err =3D k->set_guest_notifiers(qbus->parent, vvc->vhost_dev.nvqs, fals= e); if (err < 0) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 52ea142bd4..48fe1805bb 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -23,6 +23,7 @@ #include "qemu/log.h" #include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user.h" #include "hw/mem/memory-device.h" #include "migration/blocker.h" #include "migration/qemu-file-types.h" @@ -1499,8 +1500,13 @@ fail: static int do_vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, - unsigned idx, bool force) + unsigned idx, bool force, + bool skip_drain) { + if (skip_drain) { + assert(vhost_user_has_protocol_feature(dev, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT)); + } int vhost_vq_index =3D dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_state state =3D { .index =3D vhost_vq_index, @@ -1550,9 +1556,10 @@ static int do_vhost_virtqueue_stop(struct vhost_dev = *dev, int vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, - unsigned idx) + unsigned idx, + bool skip_drain) { - return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false); + return do_vhost_virtqueue_stop(dev, vdev, vq, idx, false, skip_drain); } =20 static int vhost_virtqueue_set_busyloop_timeout(struct vhost_dev *dev, @@ -2307,7 +2314,8 @@ fail_vq: vhost_virtqueue_stop(hdev, vdev, hdev->vqs + i, - hdev->vq_index + i); + hdev->vq_index + i, + false); } =20 fail_mem: @@ -2322,7 +2330,7 @@ fail_features: =20 /* Host notifiers must be enabled at this point. */ static int do_vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, - bool vrings, bool force) + bool vrings, bool force, bool skip_drain) { int i; int rc =3D 0; @@ -2349,7 +2357,8 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev, = VirtIODevice *vdev, vdev, hdev->vqs + i, hdev->vq_index + i, - force); + force, + skip_drain); } if (hdev->vhost_ops->vhost_reset_status) { hdev->vhost_ops->vhost_reset_status(hdev); @@ -2371,15 +2380,16 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev= , VirtIODevice *vdev, return rc; } =20 -int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) +int vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings, + bool skip_drain) { - return do_vhost_dev_stop(hdev, vdev, vrings, false); + return do_vhost_dev_stop(hdev, vdev, vrings, false, skip_drain); } =20 int vhost_dev_force_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) { - return do_vhost_dev_stop(hdev, vdev, vrings, true); + return do_vhost_dev_stop(hdev, vdev, vrings, true, false); } =20 int vhost_net_set_backend(struct vhost_dev *hdev, --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789118080; cv=none; d=zohomail.com; s=zohoarc; b=gjS1TU8YX5tQy1kr6shXD71YwohvLRsOdEcz0cRW2QTBn5L+XshyT0QY8vIzug4fs1tA3uKMDc3za5fCoNqO3XmP0BTyg1PXQnE62NiNF2ikfMKhSXFUzfl0QWjVC1WwoCNNJxdAZCHxv8dyy04UDid7kCBobRp6sfbTjf0o8zY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789118080; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kv6CCIrIXJvLpjzmZssI+FwJjOygdF7NEojk6fqWKwE=; b=JVticaO/GFGaj1Inisd+dU4ejqxdZskF5r0+PubxQYeEfDfnMiy5vZiv91j4+8rnayofnVMB29fyjUZConBNhmeNfNHrtQQZmP8JOI5Dho1KUnshYKlNCuikZPujnjLnt/L0QPLRK4yvcAO3pwmAQbRpMsOEVONt88OWOOTDTpg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789118079896282.72335095673077; Fri, 11 Sep 2026 02:14:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBa-0000HE-9h; Fri, 11 Sep 2026 05:04:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBC-0007J4-GK for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBA-0008Ty-7S for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:18 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-302--ok__oaxPrucfjPkg9MVSQ-1; Fri, 11 Sep 2026 05:04:14 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490a767b782so5977125e9.2 for ; Fri, 11 Sep 2026 02:04:14 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e6499d57bsm44946575e9.3.2026.09.11.02.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117455; 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=kv6CCIrIXJvLpjzmZssI+FwJjOygdF7NEojk6fqWKwE=; b=Y7WX9JXyXkOlpmEOm5j1yfIBUKD8/ExzKuGkTgH6wAsTKfSbwe3hPWID4wr/fddTSxYbf0 2YPFCDpLtOKjEirh14tZ6ZOG76hCeoHn1UAbRXIAPdKQyGX3wOiIW/FajwKjBY7Oz17LbZ bbTusB9W0ttRkrLmj5rABrZLui5+M8o= X-MC-Unique: -ok__oaxPrucfjPkg9MVSQ-1 X-Mimecast-MFC-AGG-ID: -ok__oaxPrucfjPkg9MVSQ_1789117453 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117453; x=1789722253; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=kv6CCIrIXJvLpjzmZssI+FwJjOygdF7NEojk6fqWKwE=; b=kvjNZ7aHa7JNcCvHDPwIbcrS48bVET8gl4MSg200HjzAT37jjEcqmwaaYrortfhyR5 UIPLUbf3RZJv4SdB5CJHKCGvLPg/MkJpqAbQQbeY9MeH+gj6PjATZlejp/RukYuTlm+v USeWMoqryPp6WdEFIpBy6GusUrp4eBA2GE9ENUWDoX+PyboRFhV03og1TgcknumEDyB8 Kw2mBin1SRB65CZ/VuTc3L+7AnAb3RFhhNyOQgpLOnuzAAGOzpnkQI0uxxnwPyaT8TPU or3IkjAkYxOAa9gjFd8yNMT25XsLLzmpHctD0O7kgmecF8xAXe69FxP4ZTDWVmWcIWH7 SGYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117453; x=1789722253; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=kv6CCIrIXJvLpjzmZssI+FwJjOygdF7NEojk6fqWKwE=; b=iEkPomq7aOGeiFgwouuEShDnyqCN+ZtKRMO34BsXwZxmakZV2UxjyUnO/dAHQ2+PCv Ih+cyBtT8CqBSJ9TSCsrJvOkMnb4T/z+rNP4E69D43RJonkJduokaDGKDo1vJKZm78/5 2sodj+fpzZDK6+27fAOAQTqkQyO2+7dQ7XHzEaOSo6u2R6bwLOXyrNBXgR6me1Z6i39D zCAvKI396jzF/F720X24RsJc7bblRlbp14u+J+NBesMzbpHtaDv4o/5ELl1pSfR88ERB DI7wolqfBMTF9OWnc5BuU2BrEN2MogG0Ih2bP6Mk/Gw2OXX/jCUvvfmS782hwsyrHCG3 Vl1Q== X-Gm-Message-State: AFuF++lpptayDng8Ie6xLOyj9iHpdOoh8Pj96UIXJn09mjF4ob73tgtU 2kdSm+IiLsu5Bp46uQhjgQVVAdzeLrzUCgHRQIZ9cz9H3IFDldfao+0B/jHpA540QCVQ1nfxenK JT4IYqVJN3x/jJOtaw0IYkBtYle5LJ9QUBj59MbineUUVylQgfmtiDkgmSpmyYr5JTvyJOHPiG+ OzeG96zjGjsCObrNZooBwA4DDRDfJXCRfTqw== X-Gm-Gg: AYBFou2IA4O6pWjKJbHb7TVWIAtXe7psbb9cLDCi7PuN4YkYkkz+U+F9Kf9gY94Pa3G JRVjc/BNSlOf3EmhJ6QNIsKF9inS7ki74POwd2ZZkSYqPZ3F+/eCT66H5zvInLuk21TmTBaH2LI WNne2VkXhtGjeECwb8oBmRe/ZNgdFCCHegB4N0JkMh74886QlmQd+/lDQib/8DwLuSLMLusCEJy qnfnYb1i7N6c6SzCxz6qooJ7pzEzcv4Ovqx3zZHBn6bASQVMhndRI/XQD8DRG4oGvvWNp81/nvJ f/DjyarhHs3Udt3RyLBR4TgWgQa6dOA4inV7cr4Cep6ab0HCuzY8niywogVlGHf7y5MaF23hpVZ j0iyha0fT6D39wweW3CsWqWA= X-Received: by 2002:a05:600d:444c:20b0:49b:96a0:5c00 with SMTP id 5b1f17b1804b1-49e6198d09bmr25441305e9.13.1789117452870; Fri, 11 Sep 2026 02:04:12 -0700 (PDT) X-Received: by 2002:a05:600d:444c:20b0:49b:96a0:5c00 with SMTP id 5b1f17b1804b1-49e6198d09bmr25440645e9.13.1789117452108; Fri, 11 Sep 2026 02:04:12 -0700 (PDT) Date: Fri, 11 Sep 2026 05:04:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Stefano Garzarella , Pierrick Bouvier Subject: [PULL v2 70/75] vhost-user: add GET_VRING_BASE_SKIP_DRAIN message Message-ID: <3e309656bbcc8367f2b4adf2997b69c402ee453f.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789118082657158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT was introduced to allow the back-end to suspend in-flight I/O during GET_VRING_BASE instead of draining it, enabling live migration of in-flight requests. However, this behaviour is tied to the protocol feature itself - once negotiated, there is no way for the front-end to tell the back-end to fall back to the normal drain behaviour on a per-stop basis. Introduce a separate message VHOST_USER_GET_VRING_BASE_SKIP_DRAIN (id=3D45) guarded by a new protocol feature VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN. The message is identical to GET_VRING_BASE except that the back-end must immediately suspe= nd all in-flight I/O and record it in the inflight region. This way the front-end has explicit per-call control: send GET_VRING_BASE for normal dra= in, send GET_VRING_BASE_SKIP_DRAIN when immediate suspend is needed. The new feature requires both VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT and VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD to be negotiated. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-3-dtalexundeer@yandex-team.ru> --- docs/interop/vhost-user.rst | 42 ++++++++++++++++++++--------- include/hw/virtio/vhost-backend.h | 1 + include/hw/virtio/vhost-user.h | 1 + hw/virtio/vhost-user.c | 44 +++++++++++++++++++++++++++---- hw/virtio/vhost.c | 2 +- 5 files changed, 72 insertions(+), 18 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index fbfb9d01c6..c1e02ff7e9 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -457,6 +457,7 @@ replies, except for the following requests: * ``VHOST_USER_GET_FEATURES`` * ``VHOST_USER_GET_PROTOCOL_FEATURES`` * ``VHOST_USER_GET_VRING_BASE`` +* ``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN`` * ``VHOST_USER_SET_LOG_BASE`` (if ``VHOST_USER_PROTOCOL_F_LOG_SHMFD``) * ``VHOST_USER_GET_INFLIGHT_FD`` (if ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMF= D``) =20 @@ -533,7 +534,7 @@ Rings have two independent states: started/stopped, and= enabled/disabled. Each ring is initialized in a stopped and disabled state. Rings are start= ed with ``VHOST_USER_SET_VRING_KICK`` (or ``VHOST_USER_VRING_KICK`` if ``VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS`` is negotiated) and stopped = with -``VHOST_USER_GET_VRING_BASE``. A stopped ring enters the started state ag= ain +``VHOST_USER_GET_VRING_BASE`` or ``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN``.= A stopped ring enters the started state again with ``VHOST_USER_SET_VRING_KICK`` (or ``VHOST_USER_VRING_KICK`` if ``VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS`` is negotiated) and the back= -end resumes processing requests. @@ -1159,6 +1160,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT 20 #define VHOST_USER_PROTOCOL_F_GPA_ADDRESSES 21 #define VHOST_USER_PROTOCOL_F_SHMEM 22 + #define VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN 23 =20 Front-end message types ----------------------- @@ -1355,17 +1357,11 @@ Front-end message types set to 0. =20 By default, the back-end must complete all inflight I/O requests for the - specified vring before stopping it. - - If the ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT`` protocol - feature has been negotiated, the back-end may suspend in-flight I/O - requests and record them as described in :ref:`Inflight I/O tracking - ` instead of completing them before stopping the v= ring. - How to suspend an in-flight request depends on the implementation of the= back-end - but it typically can be done by aborting or cancelling the underlying I/O - request. The ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT`` - protocol feature must only be negotiated if - ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` is also negotiated. + specified vring before stopping it. If the + ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN`` protocol feature has + been negotiated, the front-end may instead use + ``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN`` to request the back-end to + suspend in-flight I/O immediately. =20 ``VHOST_USER_SET_VRING_KICK`` :id: 12 @@ -1868,6 +1864,28 @@ Front-end message types =20 * The size may be 0 if the region is unused. =20 +``VHOST_USER_GET_VRING_BASE_SKIP_DRAIN`` + :id: 45 + :equivalent ioctl: N/A + :request payload: vring state description + :reply payload: vring descriptor index/indices + + This message requires the ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DR= AIN`` + protocol feature to be negotiated. + + Identical to ``VHOST_USER_GET_VRING_BASE`` except that the back-end + must not wait for inflight I/O requests to complete before stopping + the vring. Instead, the back-end must immediately suspend all + in-flight I/O requests and record them as described in + :ref:`Inflight I/O tracking `. How to suspend + an in-flight request depends on the implementation of the back-end, + but it typically can be done by aborting or cancelling the underlying + I/O request. + + The ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN`` protocol feature + must only be negotiated if both ``VHOST_USER_PROTOCOL_F_GET_VRING_BASE_I= NFLIGHT`` + and ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` are also negotiated. + Back-end message types ---------------------- =20 diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index d878d7b733..daa979a1aa 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -190,6 +190,7 @@ typedef struct VhostOps { vhost_set_vring_num_op vhost_set_vring_num; vhost_set_vring_base_op vhost_set_vring_base; vhost_get_vring_base_op vhost_get_vring_base; + vhost_get_vring_base_op vhost_get_vring_base_skip_drain; vhost_set_vring_kick_op vhost_set_vring_kick; vhost_set_vring_call_op vhost_set_vring_call; vhost_set_vring_err_op vhost_set_vring_err; diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 06c360af18..47c13f8677 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -36,6 +36,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT =3D 20, VHOST_USER_PROTOCOL_F_GPA_ADDRESSES =3D 21, VHOST_USER_PROTOCOL_F_SHMEM =3D 22, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN =3D 23, VHOST_USER_PROTOCOL_F_MAX }; =20 diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 2881cec72d..5fb5d61afb 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -101,6 +101,7 @@ typedef enum VhostUserRequest { VHOST_USER_SET_DEVICE_STATE_FD =3D 42, VHOST_USER_CHECK_DEVICE_STATE =3D 43, VHOST_USER_GET_SHMEM_CONFIG =3D 44, + VHOST_USER_GET_VRING_BASE_SKIP_DRAIN =3D 45, VHOST_USER_MAX } VhostUserRequest; =20 @@ -167,6 +168,7 @@ static const char *vhost_req_name(VhostUserRequest req) VHOST_USER_CASE(GET_SHARED_OBJECT) VHOST_USER_CASE(SET_DEVICE_STATE_FD) VHOST_USER_CASE(CHECK_DEVICE_STATE) + VHOST_USER_CASE(GET_VRING_BASE_SKIP_DRAIN) default: return ""; } @@ -1402,12 +1404,18 @@ static VhostUserHostNotifier *fetch_notifier(VhostU= serState *u, return g_ptr_array_index(u->notifiers, idx); } =20 -static int vhost_user_get_vring_base(struct vhost_dev *dev, - struct vhost_vring_state *ring) +static int get_vring_base(struct vhost_dev *dev, + struct vhost_vring_state *ring, + bool skip_drain) { int ret; + int request =3D VHOST_USER_GET_VRING_BASE; + if (skip_drain) { + request =3D VHOST_USER_GET_VRING_BASE_SKIP_DRAIN; + } + VhostUserMsg msg =3D { - .hdr.request =3D VHOST_USER_GET_VRING_BASE, + .hdr.request =3D request, .hdr.flags =3D VHOST_USER_VERSION, .payload.state =3D *ring, .hdr.size =3D sizeof(msg.payload.state), @@ -1427,9 +1435,9 @@ static int vhost_user_get_vring_base(struct vhost_dev= *dev, return ret; } =20 - if (msg.hdr.request !=3D VHOST_USER_GET_VRING_BASE) { + if (msg.hdr.request !=3D request) { error_report("Received unexpected msg type. Expected %d received %= d", - VHOST_USER_GET_VRING_BASE, msg.hdr.request); + request, msg.hdr.request); return -EPROTO; } =20 @@ -1443,6 +1451,25 @@ static int vhost_user_get_vring_base(struct vhost_de= v *dev, return 0; } =20 +static int vhost_user_get_vring_base(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + return get_vring_base(dev, ring, false); +} + +static int vhost_user_get_vring_base_skip_drain(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + bool skip_drain_supported =3D vhost_user_has_protocol_feature(dev, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_D= RAIN); + + if (!skip_drain_supported) { + return 0; + } + + return get_vring_base(dev, ring, true); +} + static int vhost_set_vring_file(struct vhost_dev *dev, VhostUserRequest request, struct vhost_vring_file *file) @@ -2576,6 +2603,12 @@ static int vhost_user_backend_init(struct vhost_dev = *dev, void *opaque, VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); } =20 + if (!virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT= )) { + protocol_features &=3D ~(1ULL << + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRA= IN); + } + /* final set of protocol features */ u->protocol_features =3D protocol_features; err =3D vhost_user_set_protocol_features(dev, u->protocol_features= ); @@ -3434,6 +3467,7 @@ const VhostOps user_ops =3D { .vhost_set_vring_num =3D vhost_user_set_vring_num, .vhost_set_vring_base =3D vhost_user_set_vring_base, .vhost_get_vring_base =3D vhost_user_get_vring_base, + .vhost_get_vring_base_skip_drain =3D vhost_user_get_vring_base_ski= p_drain, .vhost_set_vring_kick =3D vhost_user_set_vring_kick, .vhost_set_vring_call =3D vhost_user_set_vring_call, .vhost_set_vring_err =3D vhost_user_set_vring_err, diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 48fe1805bb..7294d3c42a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1505,7 +1505,7 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *= dev, { if (skip_drain) { assert(vhost_user_has_protocol_feature(dev, - VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT)); + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN)); } int vhost_vq_index =3D dev->vhost_ops->vhost_get_vq_index(dev, idx); struct vhost_vring_state state =3D { --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789118069; cv=none; d=zohomail.com; s=zohoarc; b=R7+BHy3mTePCU03F955spZdsatXrKVh1Xcne8PQbFLbuBtHmDI/De3ST+DnbiSRqvr1AF0poRm5Tw8BGWHJgqX6sMJMlfek1f9aEhVAKUicpo31CtvfH0X2WaYekWssEew7OjiOyIavuFCE6NIVYA5QIUhkidAzmgC5wqiSyABw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789118069; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HnLpK+N89F2XPAWPb6Tl/ZpnNhALrwGevG6SaIgN5js=; b=S6Ks1XbLjJUCNkI+vjGAt7Gfbx3QBpHEEOCz45rvl4bYQFD8/qwTBecptwUXl3BGwW0/30drlM8+p9rTnHLekv7c3Ch2Jxot6jcA2LblENePhUC8z+0m3z26EfUKdTq/e/gLcBxl+GuwjrTLadAn+AVglBvSnWicDzR5Z+BLmZ8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789118069932141.53464500407654; Fri, 11 Sep 2026 02:14:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBi-0000bB-Rz; Fri, 11 Sep 2026 05:04:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBD-0007Ni-R4 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBC-0008Ua-26 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:19 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-IpZtiYwXM1ykJIqCmAqnpw-1; Fri, 11 Sep 2026 05:04:16 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49cd83ca361so6766945e9.1 for ; Fri, 11 Sep 2026 02:04:15 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62227071sm31429585e9.3.2026.09.11.02.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117457; 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=HnLpK+N89F2XPAWPb6Tl/ZpnNhALrwGevG6SaIgN5js=; b=IJVO5GctvLCRiDaxYTflBMsknTBjPUiS0KQR7qDeKOay5Xl1VQKTBI+HvlRyra5pj6CgaZ hBAd71BSX7w8rmWahqjHHF+L9WUXnq9789OUpwe7rRTzSBUt266Y276lwzL0sEWDz/Fn8h WF4HLRPX7+kdxX4hLQ/y/AUmgf3a01E= X-MC-Unique: IpZtiYwXM1ykJIqCmAqnpw-1 X-Mimecast-MFC-AGG-ID: IpZtiYwXM1ykJIqCmAqnpw_1789117455 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117455; x=1789722255; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=HnLpK+N89F2XPAWPb6Tl/ZpnNhALrwGevG6SaIgN5js=; b=FeUlAqlTV0fCTCfk2nwfIODi/aZ5UhNMiadWh1Up6DaiK7t+dnaTmrLTe0ryMvJm8z pd/HJ6tWut4m5d11aADTNPNubflQzMO4qEKsV+TIX5us5Dt5hcpqjqu74DDXAW1sQ+dV ndPJJf4tYPsrHwrfWe9BSKW8C0uk3NksfXOmLrqJAXB82qqc9TW+9ywtKLHbZR6LVnlt YWl5El8t019vc9XU5/ggDqEaxybmC0gGuJ+bY9tjnKIs+BJGDLMF3VsEDapY+p6B6E0I kNfGtH5SbV+h/FI66BAtrodFFmXDZWS7/spHm+q9Ix4ZhpnkB6JznqH+L+5aym/SES1F DUyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117455; x=1789722255; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HnLpK+N89F2XPAWPb6Tl/ZpnNhALrwGevG6SaIgN5js=; b=Jc7sJ+Q0nSFIqVgNHIVpJCuMkqaecIzMUhpWrWEv9z5v4qQjnJsoaauKMg9yDG+4Td lgS3bsRvFynvD+VA2baA5BLmYftp+lWcVQLW8ANmCWBQEICNCHr4wVrJSdDyEL8xGaPT lKhX6IGmuxjvUP8OiWb2kLQd0+y4smBK3zz+Irz9Rv2bG2DOtcB77sbtskhCpixTwFwL 55nlxpBdwS07uBrewSxKZpsf4WAZvWsb7iURX6U/+FP3ESAdSKQ9b3KkL6V8/x3CL6dP ZVqdCQ3DY8oY9c/R10uApiC0mW/I0RIMnFnD3T0CKrlDYgYNCVE7xA78WC9lLubxZqOG dlhQ== X-Gm-Message-State: AFuF++k3PKXhhqC3kD9wWH0Vi0UYl2+tBB9TyPFOzJZ+us0xgvtwIz7t HfggRVPud0fmFBIr4pOhPZ6mkZMVRoQn8ttdugWYIzjItoeo350XryWVUl657fecRWnsAd9xqfM pFpkqJgSw5Hs6A+r1WuqKgl2683srEdcPx9W+DKZHa6hjgXo1gcwy2xNP4pc6S1PQ3GYv0lwDxd o7a0n/3ypf7+ASM/b8INQ3N5BwERy1NZ88XQ== X-Gm-Gg: AYBFou3mNCCQ1cZybo3k94Kyk0F8cK+gqKqBeKTsKv+acidmORY6ryqsrOQpfkep1NC QD7g4U5cjposAL2IW8mts7u7EV6dU8s8/DEO5sFBB2dBxaNJ3kgv+C8BGeN3UbiMSDrIGzrurMz m3F+avUo3JepMss5xF6BesNi/r5rRF47q6RryTF1CLVb1DuGklFU/fjlri39VTbTDYw7ch3gHqG cXCxL3HAL5wF8b2qCv4pQwbmCrtpk4BUQ5vOVOYjrYgljR/xZ3YwNvH8VC0e9grWHIfeWgeSTJy sILsMf9fCCJel615+y2Nj6g2ucBOpqCawfda6/SnV8eMnsGsbQf7DLJ0xNWi0xCeyrKlsCfaDk0 NpyKt9L3hZ394u6A/07F69t0= X-Received: by 2002:a05:600d:6414:10b0:49c:fc6c:be16 with SMTP id 5b1f17b1804b1-49e619c64cfmr24063085e9.28.1789117454756; Fri, 11 Sep 2026 02:04:14 -0700 (PDT) X-Received: by 2002:a05:600d:6414:10b0:49c:fc6c:be16 with SMTP id 5b1f17b1804b1-49e619c64cfmr24062605e9.28.1789117454200; Fri, 11 Sep 2026 02:04:14 -0700 (PDT) Date: Fri, 11 Sep 2026 05:04:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Stefano Garzarella Subject: [PULL v2 71/75] vhost-user: use skip_drain with GET_VRING_BASE_SKIP_DRAIN message Message-ID: <226544a5fd4b4c40a45a318942cb998e1fa39e19.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789118070470158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov Wire up the skip_drain parameter introduced in the previous commit to the new GET_VRING_BASE_SKIP_DRAIN message. When skip_drain is set, send GET_VRING_BASE_SKIP_DRAIN instead of GET_VRING_BASE, instructing the back-end to suspend in-flight I/O immediately. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-4-dtalexundeer@yandex-team.ru> --- hw/virtio/vhost.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 7294d3c42a..68a8e40481 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1521,7 +1521,11 @@ static int do_vhost_virtqueue_stop(struct vhost_dev = *dev, } =20 if (!force) { - r =3D dev->vhost_ops->vhost_get_vring_base(dev, &state); + if (!skip_drain) { + r =3D dev->vhost_ops->vhost_get_vring_base(dev, &state); + } else { + r =3D dev->vhost_ops->vhost_get_vring_base_skip_drain(dev, &st= ate); + } if (r < 0) { VHOST_OPS_DEBUG(r, "vhost VQ %u ring restore failed: %d", idx,= r); } --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117843; cv=none; d=zohomail.com; s=zohoarc; b=Y+9WplgjHfmMiOH3WMiCb9Tde+9bDcRyhTAxI3gjfwBnzjNbJniPC0Hy9xjkBwywLRxBGwVK1Nl6gIH/cxyTZYMwDc5va/6x42ygiEHR0mjCXs9dgjfMWVgC/+HH3Cr4gzmLJVLHC8BETPkNRQdyB3Zs8aj3MkJkPgUK/Pgr+lc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117843; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zoVg9FbJe5Igrwha4XGcOTDxhYoC4yK3OmKWb/Idxgg=; b=nr+RU7pO+8+X0rsacmfSEwBKzOBXC33fojk6ZGoOCpwJ5fADFo5eFf/c/oZllaOdFdShd9flby6BVezvlDpUauF1UeMTeKKMG6ClEYznfFbUGBT0c8Mv7coqM8YG0+odBVm9g1M3HRkZ8Wf1rP1jSjLjKsa0eTNDap21K7V9eb8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117842924107.88131020881644; Fri, 11 Sep 2026 02:10:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBW-000059-M2; Fri, 11 Sep 2026 05:04:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBG-0007WG-3h for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBE-0008Ux-IS for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:21 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-501-u1GYSw7NNvC9iqSrfb7xnw-1; Fri, 11 Sep 2026 05:04:18 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49cd55ee2f7so6062745e9.0 for ; Fri, 11 Sep 2026 02:04:18 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62225628sm33347155e9.3.2026.09.11.02.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117459; 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=zoVg9FbJe5Igrwha4XGcOTDxhYoC4yK3OmKWb/Idxgg=; b=O1aZWVb5r8WlJbyI1icSm2rdHZ/w6VXOK2xYlYZkMHdFVUgpnvF/EOZqcaEegSiJuYfcj+ hsoILe2Dk28KhTq3+BZhRJmVxq2xnisJOl6F/RcD9l1ICnhP3MqXKz/9dkDH+jhF5swjQf D0OPeRvXiNi1PQL6mVggbU7XEYHD9g8= X-MC-Unique: u1GYSw7NNvC9iqSrfb7xnw-1 X-Mimecast-MFC-AGG-ID: u1GYSw7NNvC9iqSrfb7xnw_1789117457 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117457; x=1789722257; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=zoVg9FbJe5Igrwha4XGcOTDxhYoC4yK3OmKWb/Idxgg=; b=WyGnRMnEYJN1ue3aGGikSyOkMuaDdiziMrilZNM1iQw3vxl0RxTSxatcHpxCg1/6UJ YGwqNcCG6ozH57+T05haXjjHsy98K3pSNL8eIlSUHnkdtxCrj8BS79EuzTfQENKZCEOI JNMlKzGiKaXGjM/NSaweiYfy7mtk1AIoVfDP1q9bWZ1F0nZ8A/st86Pd8/BHKE5SZrPR Y/o86frrTVJLYTugtiDsZt9vCGvU+bPlcwNHxWZ4mHq6Y1u6UpHFD5JmfKhIVQwgy1Jq W/0/91TtYKf93EuVfFwEH8y4SARkye6Y3NOPsG9HJwxRCEe+CpBPMGidL6L4GgTNmMyH diIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117457; x=1789722257; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=zoVg9FbJe5Igrwha4XGcOTDxhYoC4yK3OmKWb/Idxgg=; b=Zk2+oGaM48HfBZHHlPa560zobqmf4+GHsUGG0yqRQ9M2NnLeuEYGIZWJa6CeulPolb S2m3M6qTUMEmstXWmQD4hXMLOe/7Im/7pBfhtRsYL5gcV84aNeLeA6agpKSm761EJeaG KlekwJeDQwcHNic3EoBV77pRnUHCUXJXFV1guSKUYazV6qq+L1HLgf6NIE/VMV6fjfNa atQvCeUDBvxFG6uw9byRmCM0VnQKiaKj+M4aJYG9XM2GvbnWtdBpsbqN+Txy1tMsiWoW EYEMccOQ3iTb4DOHnuKw8NCSC3uW8smPHUpCnSl2N2bwHnUWXo3ENIwL2KeBqtGW94e5 PA2w== X-Gm-Message-State: AFuF++k8g8oj0e+R4wP+i/BVjogojRe257ZN9G43XVP5hj9dyMgzzACW 2fTTuZBe4WNPAWIb2ty4+g9TBpK8+PR5wUt6mqrztrz6XWNaVdFCQ/stGwmD93vGRC1ugiyIqs5 6dM2rY9X53aMwiNh/sIGL8lQuLQ5phcsMHCyV5sMtayMBQmS5b4FYBQ6WaY4Xh96qWDSlFhDjRl 3vNynXLpgZPTUpkNgM0lqxFWSZnBF34p3M0A== X-Gm-Gg: AYBFou2knF93UmHjncEIOCknAlSXG3/3FxYocSSFvnm/gJ9TUovWPugbYK8vdUqgOOR 13v57Pt1wYRRs6AazYq1nj/KT5UwUIhk4+urHYhAPkKECjUOx8WY5/GfA7Zl3PLqYqaAFeEHPey 7gzHKj9pW97mGO/vO8+OLFBr7CSUkap7Ci1ZxUqI9ULc8F9t1fBAEtFBSA+WYq6IsD1aATv79I5 sEqYTdbPZU0jdcMqU8XcGaQnI6HOp3mHtrUGOiUBj7Dw/ruPbXAlq5VY/HPv4dNlCyZX6D1J/eG Yctv8l/2DBy/lMUb/g0Eu7foqtWU2kQ/W8OfbxQav+90BwHhHtU+vW0noDwJV8lM9RdkAJ5Max6 sghyXp8/mMKjDDZWpXvyfL7E= X-Received: by 2002:a05:600c:6309:b0:49c:ff3c:973f with SMTP id 5b1f17b1804b1-49e619c45f9mr31554085e9.24.1789117457092; Fri, 11 Sep 2026 02:04:17 -0700 (PDT) X-Received: by 2002:a05:600c:6309:b0:49c:ff3c:973f with SMTP id 5b1f17b1804b1-49e619c45f9mr31553495e9.24.1789117456531; Fri, 11 Sep 2026 02:04:16 -0700 (PDT) Date: Fri, 11 Sep 2026 05:04:14 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Raphael Norwitz , Stefano Garzarella , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL v2 72/75] vhost-user-blk: make inflight-migration prop mutable on running vm Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117845507158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov The inflight-migration property currently can only be set before the device is realized. This makes it impossible to disable inflight migration at runtime without restarting the VM. Make the property mutable, but only while the VM is running. Blocking changes when the VM is not running ensures that the value at stop time reliably reflects the intent set on a live VM, which allows vhost_user_blk_stop() to use skip_drain unconditionally based on the property value without inspecting migration runstate. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-5-dtalexundeer@yandex-team.ru> --- hw/block/vhost-user-blk.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index c3e3c37f8c..501de30796 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -629,6 +629,8 @@ static const VMStateDescription vmstate_vhost_user_blk = =3D { } }; =20 +static PropertyInfo vhost_user_blk_inflight_migration_prop; + static const Property vhost_user_blk_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserBlk, chardev), DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues, @@ -644,8 +646,9 @@ static const Property vhost_user_blk_properties[] =3D { VIRTIO_BLK_F_WRITE_ZEROES, true), DEFINE_PROP_BOOL("skip-get-vring-base-on-force-shutdown", VHostUserBlk, skip_get_vring_base_on_force_shutdown, false), - DEFINE_PROP_BOOL("inflight-migration", VHostUserBlk, - inflight_migration, false), + DEFINE_PROP("inflight-migration", VHostUserBlk, inflight_migration, + vhost_user_blk_inflight_migration_prop, bool, + .set_default =3D true, .defval.u =3D false), }; =20 static void vhost_user_blk_class_init(ObjectClass *klass, const void *data) @@ -675,8 +678,29 @@ static const TypeInfo vhost_user_blk_info =3D { .class_init =3D vhost_user_blk_class_init, }; =20 +static void vhost_user_blk_set_inflight_migration(Object *obj, Visitor *v, + const char *name, + void *opaque, Error **er= rp) +{ + DeviceState *dev =3D DEVICE(obj); + + if (dev->realized && !runstate_is_running()) { + error_setg(errp, "Property '%s' cannot be changed " + "while VM is not running", name); + return; + } + + qdev_prop_bool.set(obj, v, name, opaque, errp); +} + + static void virtio_register_types(void) { + vhost_user_blk_inflight_migration_prop =3D qdev_prop_bool; + vhost_user_blk_inflight_migration_prop.realized_set_allowed =3D true; + vhost_user_blk_inflight_migration_prop.set =3D + vhost_user_blk_set_inflight_migration; + type_register_static(&vhost_user_blk_info); } =20 --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117702; cv=none; d=zohomail.com; s=zohoarc; b=QhEr5ghSVKjlwbEw6MFyiIyf/BUhz0Yl1FbAJ0aWjC599+KsCUNVYWe1MlPWKmdDLmr4pzEvYvMzkFODU9H+Y2Qf5uUDKLdATsEkyEeigrUAa4l8kdSu1hibwOGDqDI2x/9r2u/nWDDsVObOr+Cac7MdZyfQZwruuIlnfqF1JaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117702; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nSx6T21s1gGNGKoeJ/fw1fyWuRbnS5MwK7Kbb47ZVSQ=; b=nXNSX/DlWdK5tujB8VT9KkOSp9qoI5P8cWXBc1pfKOwti+Yq/zBoSoq/qSg6n/YBha9nLt1Hc8ce1r0eQonzhAJF6I5CNYGf1JvLZvoPU7oWYvXKxTg1tnnM78sSdJsNHMIjsMDuMP8Ts3BtOE4zDhIn8STWAmaSi7RJfL4V6CE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178911770226151.302824024621714; Fri, 11 Sep 2026 02:08:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBL-0007ms-Um; Fri, 11 Sep 2026 05:04:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBI-0007ZL-Ar for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBG-0008VN-U2 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:24 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-296-lMgAsKLnNnGhAfrYo-dAzg-1; Fri, 11 Sep 2026 05:04:20 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490a767b782so5978295e9.2 for ; Fri, 11 Sep 2026 02:04:20 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e6576122bsm36413805e9.2.2026.09.11.02.04.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117462; 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=nSx6T21s1gGNGKoeJ/fw1fyWuRbnS5MwK7Kbb47ZVSQ=; b=QVfZu8itkd1ZfU2ta6aKdJ4c6tQYQhj9KCH90sqV10NBYRzh8fuJRxqt/U7OnHJOlD3Ck5 F3xBqEefEowscsBkkGc/J+Ba4M3V0Scm50srONBwH6XW6Q1LsSqQRRbI+M3F6usJJsC3aX gp8qy5G9Ca0wzEHDCnSpi9L86Qnd740= X-MC-Unique: lMgAsKLnNnGhAfrYo-dAzg-1 X-Mimecast-MFC-AGG-ID: lMgAsKLnNnGhAfrYo-dAzg_1789117460 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117460; x=1789722260; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=nSx6T21s1gGNGKoeJ/fw1fyWuRbnS5MwK7Kbb47ZVSQ=; b=CVslz74VWweqAbOIt+lM9JY0PlDfiFPWj0NiSC7jMst7cVGGrJrLph1tYs+I+1PLcG EEW62YgctYC6Thq0N5l6nGUoRqn7Jmd1dRh9ZiniuanNOOQ7e4570DhJdX21ql4UiFTV X3cxkMVLjixNsY6gjPcHxAaZBIOsvNNNx0qyOmCMy69Uoua/SH1X7uOR+fzYCZM9XZIX MKjpvblq0sMcNycmCNm+e+oI4tjv4Il/kwJqDdL7YGOaX0+9H2ppe5FhYNss84VGqU1V L/d2f8tSMPi5r2hb51d4Ov3Z6S3mPkB44qgOoKUenDpRfTgDPZL/xGe5ZhuNufJ4mkOy Ao6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117460; x=1789722260; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=nSx6T21s1gGNGKoeJ/fw1fyWuRbnS5MwK7Kbb47ZVSQ=; b=XUqKYNYWPqgMdCjBp5La7aG3nUl+d13LK2VFbo6xWPjV5qEs7tcArHozxJa2qPWtQS A0ynGJ+COqPQBzEm01dJKwRIX06NV8vZ7rRQIQLku+ld2h/RWfMrVmROXyV0nEM8hd94 e8RreA0qnn4slLJ62pynEcZ6tfmjsaR8HwGLxStfj7gmzQ+G3hKptLYJsCSAOZ11Bnog 9Vk7v05Efd3cBmjIUT6n9XJ79jKEag+tpDrghW3sWWSoydx8UQTmWrJw6XGb/chHqFdj DAi5a47qOqVC8SwW7qRDRENmZU5gN5zabt+EQjrmsua4YFrbgHI+eDYJYVXCb6WHC89u CDaw== X-Gm-Message-State: AFuF++nMX6+Dxs2NtsBzVdYEKV2oMXjxhWYiOeqI/0zHp8B7tHIh7g7f ozR893gfmTEtzdXA7cTvKwMzXRFtYJuPkPS1JfYkQb2XabRM/el+t5zS/8Tq7ahjqSy/AxnmqGc oTo/4ceiztB6Aqbww5tksOzpTfU8ejQOHO1dZEAHQHR5dZjvu53LcTsNiVwNzydXFfOZtdOVkgM 9Z0GibCWHEcAA62dtLm1sF/H6330m59kqbbg== X-Gm-Gg: AYBFou0W4dW4/7spg/v//P9A9nTL8AiG3Nqr/UZfhetUuYDMkAGHDkMbj8pJKtFEqHm SDEjwIoh0SD7z971ajXfvLL8pt72+UKj8cAInTtq3L0EYW8+GQ89+4iseHZyyhthLJMr+hiWEs/ onoMxoVmSgNOYB250POBLvCIiQLvTwyH548bcCR+Aj9Ksf7t6dZmWDKad13ApnHX8yx3Xm9qOE8 JWcwQR9qdK598v9oLZ5rsXJ070G54I/IUYrbAeSXjyBZkqxeQ38cqBOuGd+xPKbQqKyrlLQF0C1 0ywadjb+pEzoWRyNRyIQ7o9mC735f0J5NnwIy2QtMaIba3XoSrdBbPPtfcD8TBw4PU/nPSpbHON n0p2k+T90stwvQxOHp0wXmT4= X-Received: by 2002:a05:600d:8648:10b0:49d:1f10:8b9f with SMTP id 5b1f17b1804b1-49e619836aemr26260455e9.7.1789117459545; Fri, 11 Sep 2026 02:04:19 -0700 (PDT) X-Received: by 2002:a05:600d:8648:10b0:49d:1f10:8b9f with SMTP id 5b1f17b1804b1-49e619836aemr26259835e9.7.1789117459026; Fri, 11 Sep 2026 02:04:19 -0700 (PDT) Date: Fri, 11 Sep 2026 05:04:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Vladimir Sementsov-Ogievskiy , Raphael Norwitz , Stefano Garzarella , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL v2 73/75] vhost-user-blk: move inflight_needed higher Message-ID: <301f703fe71cce590d1c597536a08b359fc05b76.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117706016158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov Move vhost_user_blk_inflight_needed() earlier in the file so it can be called from vhost_user_blk_stop(), which is defined before the VMState section. No functional change. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-6-dtalexundeer@yandex-team.ru> --- hw/block/vhost-user-blk.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 501de30796..3eaaa19719 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -137,6 +137,17 @@ const VhostDevConfigOps blk_ops =3D { .vhost_dev_config_notifier =3D vhost_user_blk_handle_config_change, }; =20 +static bool vhost_user_blk_inflight_needed(void *opaque) +{ + struct VHostUserBlk *s =3D opaque; + + bool inflight_migration =3D virtio_has_feature(s->dev.protocol_feature= s, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); + + return inflight_migration; +} + + static int vhost_user_blk_start(VirtIODevice *vdev, Error **errp) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); @@ -597,14 +608,6 @@ static struct vhost_dev *vhost_user_blk_get_vhost(Virt= IODevice *vdev) return &s->dev; } =20 -static bool vhost_user_blk_inflight_needed(void *opaque) -{ - struct VHostUserBlk *s =3D opaque; - - return vhost_user_has_protocol_feature( - &s->dev, VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIGHT); -} - static const VMStateDescription vmstate_vhost_user_blk_inflight =3D { .name =3D "vhost-user-blk/inflight", .version_id =3D 1, --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117572; cv=none; d=zohomail.com; s=zohoarc; b=ZdOoIdhdQkUQo1Y7CJcm4vNtRTcy7fX3iGbRGl65WOFACUJ7utQkOCOlFmWcwrKLHuj/05G5soJAlmEZQqRqehIZsNEXiKs6Erk54Is852p8AzG1gM86NeUlxbftzkWOUu30MmwC165Tq/7pdYehnvy+dwpHIImP1NJ40K0wc4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117572; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NJG8zAQc5H+oCN0LN3glhJqYJbaYPku/Yu37P8u17zg=; b=PPaM+owpNKosRPsj4Tjz8KsDg5k9P5hOlF9pnfBlUrFdk8TzeiD6QSKtuP6cEWZdfim7x6+PYuM+f6vP5x48XFFy1Wv6in86i5fTGVGbzvPn5Kd4b9H6d+oRoUHnuNtCdoRqBKpLd2ZCCN6VRqe4Qf451X37IfMoA5XAMt3UuZ0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117572642583.2181011598873; Fri, 11 Sep 2026 02:06:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBg-0000US-4Q; Fri, 11 Sep 2026 05:04:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBL-0007kD-4c for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBJ-0008Vm-1x for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:26 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-492-jzHfd-BBMZeH-sqfdtINyg-1; Fri, 11 Sep 2026 05:04:23 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49953abe51fso3685665e9.1 for ; Fri, 11 Sep 2026 02:04:23 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49db038401fsm128804265e9.13.2026.09.11.02.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117464; 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=NJG8zAQc5H+oCN0LN3glhJqYJbaYPku/Yu37P8u17zg=; b=MDzxfVhjRq8WrNHVmBugnqKdlmjQqr9OfbPkywG1oWRequb0/ERbt4aoUKbRZcRiqTiovd kgoVQ05CQZdwV/9OecMTWWJsZ3J1QPteubA4DCLE0BuGtpMnOpAzMAYJO+Xff3PSadTOCy aKmq43Cir2yLSkx6EmIvHsbLgavd/5s= X-MC-Unique: jzHfd-BBMZeH-sqfdtINyg-1 X-Mimecast-MFC-AGG-ID: jzHfd-BBMZeH-sqfdtINyg_1789117462 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117462; x=1789722262; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=NJG8zAQc5H+oCN0LN3glhJqYJbaYPku/Yu37P8u17zg=; b=i2gV/hX14I6JijnCIXHm4bygsklWA3/qeBMh2sBlZ4CBFDSlCeT6QwkZPNRQSByHza 9Fd6wVVDlHsO9z7qlKP+ek0OfW54Aoe9n/HIt01fCK8w29hCapBbZem4vya7TQ7xq9Bf G7adD9Clh0eFUgYPsMp88FdzfHIdYcLHiuDsLJyDRwZp2IHAdKomsJz4SByIKXWNE4Y8 ZxjoZi2D5pEyvb4VM4/OGHflJFv6lqYOvWWPeQGi4G/fDUG1reBLKku0l2pleLTc+Ko2 qeLnV+zT45SDpmvpEwhVJk9p92qLl7DIqP0sEhE5aypue5yzKclgOV88AnWQ0fERLnOx zyEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117462; x=1789722262; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=NJG8zAQc5H+oCN0LN3glhJqYJbaYPku/Yu37P8u17zg=; b=VsYtUCUg/SbVBBzvobI2rlAaHkS8J3cOPoTidAeKbO0wzNHHB4vApiXquSKCdQrYyQ lvCfenx88ZUoXCOfoqeFvMnmKOTdZnBgqiSeWGict0s+FPTlVzgIX/4tZ1IcQR3n2yTl 9CZikH3dp2Y3izUUZHvFBIHHLr5/1ws46VlufjjesqP3nsoEqFb7JPDsSqx4rfZmg1i9 ANqa4IzFvcEY1c3ZBRFa7hkyXmeUJ8t1vHZ38t7YKswlRgZSqGa+oPC1eUJZ9VouHC1a czaFxrh18uzeVgOwgOLjlqnoO9AA4scvAds7fPHF3JWnG5syY7ZI+QEPBCPEaytA0yPu 71Dw== X-Gm-Message-State: AFuF++nfMbzT3QbBFrq52+T7Mns7jA5Ke0yhu6FbzYeSCeWrG8b/XgQc 01mmGwf7tUG5/lHWlVZ3p7CnECTy4boAodmY4q+vA+M8FWBKKHRmGZJsxdzOpqf1YKns/ezBSis nrDNYZBicf4qmrwJg60xbEmZQgC96dVq9vWSiL2DYFzaNF5wSR7zvnSGPWTmApx3moHzmP9IuTv 7LmFBKW47zi0KUWfytdxvXDNuCKdPg03QR+Q== X-Gm-Gg: AYBFou0hI8hmm2SwSiiMKkV53l6zET6++V9Z9OzldBzXR/N8gBiuaUw5mcyga3BYELA 4+ypEjODi8o/v0p9E+scWHsPQv5VUgv/nuT/ODwQ7AJ3gMfcwAosuGWo+b/5haOKcLZSQbl0iiU 5jfuou/c9QKtvHTJ7nF3Z/jj+HVbF2ZoyydinEp2+QfWkpf78mM4h65hE9JjlGuKHr5P8uyu6ly awsNhD6Rd7FJN87xigSBBxgWu/lezsCL3FdLgx5eHe0TXK3a0wYom88hDXrVL+f9Hi3xDpjMMZG zeA33lwJ8eEQ3KzNM4YTpoDFCJ5pCmkqo/+g/KOjnG79tfkknyd18Fg09nPsA7LnqqSyFNyqEFW HXTLMMNduAKSw5WhQPSNkFys= X-Received: by 2002:a05:600c:c490:b0:49c:fc6c:bdfa with SMTP id 5b1f17b1804b1-49e619e1cf0mr31565225e9.17.1789117461949; Fri, 11 Sep 2026 02:04:21 -0700 (PDT) X-Received: by 2002:a05:600c:c490:b0:49c:fc6c:bdfa with SMTP id 5b1f17b1804b1-49e619e1cf0mr31564545e9.17.1789117461355; Fri, 11 Sep 2026 02:04:21 -0700 (PDT) Date: Fri, 11 Sep 2026 05:04:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexandr Moshkov , Raphael Norwitz , Stefano Garzarella , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL v2 74/75] vhost-user-blk: use GET_VRING_BASE_SKIP_DRAIN when inflight-migration is on Message-ID: <684fbddb62362a910aa0251624ba0f692048c906.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117573308158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alexandr Moshkov Currently during live migration vhost-user-blk sends GET_VRING_BASE to stop vrings, which causes the back-end to drain all in-flight I/O before returning. This blocks the migration source until all I/O completes, adding significant downtime proportional to the I/O load. When inflight-migration is enabled, send GET_VRING_BASE_SKIP_DRAIN instead. This instructs the back-end to immediately suspend in-flight I/O and record it in the shared inflight region, which is then migrated to the destination host along with the rest of the device state. Since inflight-migration can only be toggled while the VM is running, i2ts value at stop time reliably reflects the intent set on a live VM. There is no need to check migration runstate to decide whether to skip draining. Using GET_VRING_BASE_SKIP_DRAIN on a regular VM stop is safe - the back-end records any in-flight requests in the shared inflight region, and they will be resubmitted when the VM starts again via SET_INFLIGHT_FD. If the back-end does not support VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN, migration is aborted with an error in pre_save rather than hitting an assert at runtime. Signed-off-by: Alexandr Moshkov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260803072853.2920007-7-dtalexundeer@yandex-team.ru> --- include/hw/virtio/vhost-user.h | 1 - hw/block/vhost-user-blk.c | 29 +++++++++++++++++++++++------ hw/virtio/vhost-user.c | 3 +-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 47c13f8677..78b4fba27f 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -73,7 +73,6 @@ typedef struct VhostUserState { GPtrArray *notifiers; int memory_slots; bool supports_config; - bool supports_inflight_migration; } VhostUserState; =20 /** diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 3eaaa19719..3dade143c9 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -141,10 +141,7 @@ static bool vhost_user_blk_inflight_needed(void *opaqu= e) { struct VHostUserBlk *s =3D opaque; =20 - bool inflight_migration =3D virtio_has_feature(s->dev.protocol_feature= s, - VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); - - return inflight_migration; + return s->inflight_migration; } =20 =20 @@ -245,11 +242,13 @@ static int vhost_user_blk_stop(VirtIODevice *vdev) return 0; } =20 + bool skip_drain =3D vhost_user_blk_inflight_needed(s); + force_stop =3D s->skip_get_vring_base_on_force_shutdown && qemu_force_shutdown_requested(); =20 ret =3D force_stop ? vhost_dev_force_stop(&s->dev, vdev, true) : - vhost_dev_stop(&s->dev, vdev, true, false); + vhost_dev_stop(&s->dev, vdev, true, skip_drain); =20 err =3D k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false); if (err < 0) { @@ -381,7 +380,6 @@ static int vhost_user_blk_connect(DeviceState *dev, Err= or **errp) vhost_dev_set_config_notifier(&s->dev, &blk_ops); =20 s->vhost_user.supports_config =3D true; - s->vhost_user.supports_inflight_migration =3D s->inflight_migration; ret =3D vhost_dev_init(&s->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USE= R, 0, errp); if (ret < 0) { @@ -608,10 +606,29 @@ static struct vhost_dev *vhost_user_blk_get_vhost(Vir= tIODevice *vdev) return &s->dev; } =20 +static bool vhost_user_blk_pre_save(void *opaque, Error **errp) +{ + VHostUserBlk *s =3D VHOST_USER_BLK(opaque); + + bool inflight_migration_enabled =3D vhost_user_has_protocol_feature(&s= ->dev, + VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_D= RAIN); + + if (vhost_user_blk_inflight_needed(s) && !inflight_migration_enabled) { + error_setg(errp, "can't migrate vhost-user-blk device: " + "backend doesn't support " + "VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN " + "protocol feature"); + return false; + } + + return true; +} + static const VMStateDescription vmstate_vhost_user_blk_inflight =3D { .name =3D "vhost-user-blk/inflight", .version_id =3D 1, .needed =3D vhost_user_blk_inflight_needed, + .pre_save_errp =3D vhost_user_blk_pre_save, .fields =3D (const VMStateField[]) { VMSTATE_VHOST_INFLIGHT_REGION(inflight, VHostUserBlk), VMSTATE_END_OF_LIST() diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 5fb5d61afb..65889b0776 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2596,8 +2596,7 @@ static int vhost_user_backend_init(struct vhost_dev *= dev, void *opaque, } } =20 - if (!u->user->supports_inflight_migration || - !virtio_has_feature(protocol_features, + if (!virtio_has_feature(protocol_features, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { protocol_features &=3D ~(1ULL << VHOST_USER_PROTOCOL_F_GET_VRING_BASE_INFLIG= HT); --=20 MST From nobody Sat Sep 26 20:50:16 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1789117905; cv=none; d=zohomail.com; s=zohoarc; b=UJqBb6kKvg7H6aVMtKOwMJkJZ387naUXbKE6qMPV7vXrgbWsiRdX5IHEvmm2MR1Nd5BzfwVtho2rBxY0nFEgDVXz4Mgn6EZxJqVKK8jbnTEQfeCwuN25dhbrt1PVOGDspHlt1qPUE1aXOokrkdaGQc2H6vDXIqyK6w+L5vC7uJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789117905; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oztlL0t0JZ8ezWj98qmIsDqrr8kTq2UUhazLUKK+7WQ=; b=EWB3RJDwz6rIJgoHcJLb4KL2NyITfRe0GWgEZb1zpw6xQIk2LQfKIJO3x/lFA1wxJgwDHKkidfllAWQ/GEhZ8n0VI2Q7ckNU7TCuJD24wFepPhRS28verYYI4inYwvmLlhz73jATjPC5vSE+wkyZC5jYINPzfkXgr2jmdIvfJOc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1789117905835706.7389459348408; Fri, 11 Sep 2026 02:11:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4xBl-0000nd-6p; Fri, 11 Sep 2026 05:04:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBN-0007ye-G7 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4xBL-0008Vx-VO for qemu-devel@nongnu.org; Fri, 11 Sep 2026 05:04:29 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-277-zsm7V7omNduBTucJqiPaJg-1; Fri, 11 Sep 2026 05:04:25 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49d156c917cso11798325e9.1 for ; Fri, 11 Sep 2026 02:04:25 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-236.inter.net.il. [80.230.79.236]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e60abab54sm60681385e9.5.2026.09.11.02.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 02:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789117467; 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=oztlL0t0JZ8ezWj98qmIsDqrr8kTq2UUhazLUKK+7WQ=; b=LASEOESDKsYyHqAAZ5rwyWne9ABOse3jNKmE+jf5TCWmp7s7c1Kc3/uFNETs+DEQ+uBU/V YvbkhlGQR2orCEeuo1s4bblRHMTiH7SCgc04S8R7GZt46nyIGTUKhEysAc06/2ugEO5O7C 5FUw42yjq30U13so30hK87kIE/LrrDk= X-MC-Unique: zsm7V7omNduBTucJqiPaJg-1 X-Mimecast-MFC-AGG-ID: zsm7V7omNduBTucJqiPaJg_1789117464 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1789117464; x=1789722264; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=oztlL0t0JZ8ezWj98qmIsDqrr8kTq2UUhazLUKK+7WQ=; b=Ikco2GRT26Upo9vFhVoxhuDFXPU+kvTZyPNtwD4cQ3QFEoG9am5n0xWG9uyvQU8a0F kD4UNGChs9RCJEVdwlvhmLR/10idqA5HfelF4O2VgpfIZ0DfWb+xoQd4OFRlpFrF/bVh M+3pIyk5tCfsEHfBwaWPLjbF5ZN9r2Qs+Y5GCUd6Ampbi0aa7Owljg3tbSW/TfT68nwQ iSm5OVrWlrciaeXBgiqRsIWCvZbxR6SeFMga7Dpe+oIh5w1e1A52owZAe8JjH9knovLR A/VGzmzm3ZjfYIwzi6EEVtZPbNe1/ZbzKoPuJKN+iwu8Q462dIJqXKkDt1gws1Fs20DM CsOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789117464; x=1789722264; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=oztlL0t0JZ8ezWj98qmIsDqrr8kTq2UUhazLUKK+7WQ=; b=NfEdPT9x2XqssRzDm2fR3IK9E+lw5LBRneFwOUT4HVfguseHTeRA2qev7sRbeq1kl5 tKyZmwcmbduR0fiXQ9MnMwZ2SVvJ0pbSgYeRy2h5kBY2ybjIR5paz5e9TrbX30/Iiiuj i6MpobuDN85iMEXQan3zHU5hQ47O1d5/q3kqPonrzlxq3rm2VNEv6t2C7UxFSHRkYeG3 qLfVQNPIK1b7o+0iLcF9h74PNNRbQTrFm45ARExumb/PQfWPMhIdXbSfmdQ9mkbZxZbC slLBU03LmJBGimh4VIfZ1wSX9ApbGmrNlyGHOVNCrpYtVy2wPEhIfQWUXgaWO41KLVtE XZ9w== X-Gm-Message-State: AFuF++kEyat01bYTszUXZyvkeLgG+2tANXTvEaGHi6GDvOYiPa/yAgbM t9aH4VhiygsLivnSngKXuoJlvP05tn1Ztda03rP7C/a1cnl6QSLVYET8jnqnyd1JYPSdjtjgd5R uQqZRYPiSams76wYOmwAhS/H5IIR2XPJG4aFps6WBsRuyCy4R8O/TDJ0VeYF6JScCd/qc0JXxZE pTzJ7GGesFDdnhlAQoIcFFooOv6GAHRvptnA== X-Gm-Gg: AYBFou3jCq7xm+j5H3R4HGB/ga1sPD863IJawXziolOBq8Yk/RZsSCaBrySAyBTVXuY UrY2bkKG/H7DODceoxdspvCaw494j/d77J0Z9nRAinnaOVstkI/z9FHU/5zur3YKazLN1wYAEtc C1a2yNDNKgliYxVX1UQ+WzK7YC+OezuQ1MYvW4zgF0vMvolFfEZvS3lzUfxDY+t+MhuGilxn9DN ebAHTSenJxRHqi5uS95a84UT8yaEMJ3uPnO7H6CYIdxOCG3k1bhF0GJu+yla/ixvioux+K7OL1A 1hZ1JH06fogRMjQcY90MXqLS3NqQaZK0/52bqDIj0bxOGOiiR/SJAF7G+aeJKJJ1YJXmTN6K9Zj PGmkEBx8DdT0fwoTWlF2ERd4= X-Received: by 2002:a05:600d:849b:20b0:49d:257c:a735 with SMTP id 5b1f17b1804b1-49e61082867mr29138595e9.11.1789117464345; Fri, 11 Sep 2026 02:04:24 -0700 (PDT) X-Received: by 2002:a05:600d:849b:20b0:49d:257c:a735 with SMTP id 5b1f17b1804b1-49e61082867mr29138055e9.11.1789117463833; Fri, 11 Sep 2026 02:04:23 -0700 (PDT) Date: Fri, 11 Sep 2026 05:04:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Junjie Cao , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Markus Armbruster , Pierrick Bouvier , Thomas Huth Subject: [PULL v2 75/75] MAINTAINERS: add Junjie Cao as CXL reviewer Message-ID: <2f8991c0b9c400f55897849a538580039b61865a.1789117222.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-0.2.13.1.5.4/289.97.79 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1789117907656158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Junjie Cao I have been reviewing, testing and contributing to hw/cxl for the past few months, and would like to be Cc'd on incoming CXL changes to help with review. Suggested-by: Michael S. Tsirkin Signed-off-by: Junjie Cao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-ID: <20260908042310.493882-1-junjie.cao@intel.com> --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index ec313c3259..d5eac4b42d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3334,6 +3334,7 @@ F: docs/devel/migration/CPR.rst =20 Compute Express Link M: Jonathan Cameron +R: Junjie Cao L: linux-cxl@vger.kernel.org S: Supported F: hw/cxl/ --=20 MST