From nobody Sat Sep 26 20:02: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=baidu.com ARC-Seal: i=1; a=rsa-sha256; t=1788969112; cv=none; d=zohomail.com; s=zohoarc; b=nvRRRGb9ccsEZPpF1vK9BfkZw2bxGoZ8NrjvYnhXlfGF4rgZzQ5VEmKOPJQl3tZzCva/GMWuJqAtCEb1UnAY1+MqekqE9/iHfYFpwlGy+E3VVSpS9HJj819cGt1lr3v9l7ZK+3Ox7+VWixix/Fm4HmZW2dhZ1Q111GMHUC/PZfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788969112; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eTFcnfnl7oo4atRZW4Qg9NDLjIulJhUCHUVi67e1pF0=; b=S6shEVsHywiGT1TA4u/xO7mJTBF12+yqa0ev4l3WcPbz2rkOMIl71FjDWrjpk5jsTJGqtnVOR57TFIF49ZpAGRCtESqTaD8z1aWfqcUefCH4uoFJ9ujalWnZdjRDJwyCGEoHAzCnkR4fZdUV5AFVlCbfXrBuAdbpQVr6NlD0x7Y= 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 1788969109707582.3226981410227; Wed, 9 Sep 2026 08:51:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4KZw-0000Zp-Ob; Wed, 09 Sep 2026 11:51: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 1x4KZs-0000ZQ-Cg for qemu-devel@nongnu.org; Wed, 09 Sep 2026 11:51:13 -0400 Received: from mx14.baidu.com ([220.181.3.101] helo=outbound.baidu.com) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1x4KZm-00022u-N2 for qemu-devel@nongnu.org; Wed, 09 Sep 2026 11:51:12 -0400 X-MD-Sfrom: lizhaoxin04@baidu.com X-MD-SrcIP: 172.31.4.16 From: Li Zhaoxin To: CC: "Michael S . Tsirkin" , Jason Wang , Longpeng , Paolo Bonzini , Li Zhaoxin Subject: [PATCH] vdpa-dev: implement guest_notifier_mask/pending Date: Wed, 9 Sep 2026 23:50:42 +0800 Message-ID: <20260909155042.34186-1-lizhaoxin04@baidu.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.127.73.8] X-ClientProxiedBy: bjhj-exc12.internal.baidu.com (172.31.3.22) To bjhj-exc18.internal.baidu.com (172.31.4.16) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baidu.com; s=selector1; t=1788969052; bh=eTFcnfnl7oo4atRZW4Qg9NDLjIulJhUCHUVi67e1pF0=; h=From:To:CC:Subject:Date:Message-ID:Content-Type; b=P/e5mkvrdQw6wdieF10rNNTvUrch+Q+I5Anb186JjEecIX1bHa8lLvfMVvsGE1bx7 nvmSV+Mamx7V9dXwmeaZ5058Kammg+rYwHSBA4G2ts9gqMaq3Yhj9oNqs6+6Mf/GmK hfPzBtNaObKdoUav7jacXbK7lP1LL/TeE5oc9305ri4wFY5KEd15i3eSoKQO2Ux5O5 XZcChY3cWb16fnIAnUAlyJRHG1MQsJlWxNyiGd+WLJ3mD/06HpKCevkZMExKcP1L3b FY/3xDDRXwgZK0JIv8yiaWVcoj0GF0IwRo3KYcd9sN49HJnT/I/YOnE6M9DTs6uVRU M2YQD+ZaOydqQ== 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=220.181.3.101; envelope-from=prvs=md17063E5F9E=lizhaoxin04@baidu.com; helo=outbound.baidu.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZohoMail-DKIM: pass (identity @baidu.com) X-ZM-MESSAGEID: 1788969115524158500 Content-Type: text/plain; charset="utf-8" Forward guest notifier masking to the vhost layer via VHOST_SET_VRING_CALL, so the KVM irqfd stays installed across MSI-X mask/unmask cycles instead of being torn down and re-added each time. Signed-off-by: Li Zhaoxin --- hw/virtio/vdpa-dev.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c index 6dc684ab09..1b75f6afdd 100644 --- a/hw/virtio/vdpa-dev.c +++ b/hw/virtio/vdpa-dev.c @@ -267,11 +267,7 @@ static int vhost_vdpa_device_start(VirtIODevice *vdev,= Error **errp) } s->started =3D true; =20 - /* - * guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ + /* Point every vring call fd at its guest notifier. */ for (i =3D 0; i < s->dev.nvqs; i++) { vhost_virtqueue_mask(&s->dev, vdev, i, false); } @@ -285,6 +281,28 @@ err_host_notifiers: return ret; } =20 +static void vhost_vdpa_device_guest_notifier_mask(VirtIODevice *vdev, int = idx, + bool mask) +{ + VhostVdpaDevice *s =3D VHOST_VDPA_DEVICE(vdev); + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return; + } + vhost_virtqueue_mask(&s->dev, vdev, idx, mask); +} + +static bool vhost_vdpa_device_guest_notifier_pending(VirtIODevice *vdev, + int idx) +{ + VhostVdpaDevice *s =3D VHOST_VDPA_DEVICE(vdev); + + if (idx =3D=3D VIRTIO_CONFIG_IRQ_IDX) { + return false; + } + return vhost_virtqueue_pending(&s->dev, idx); +} + static void vhost_vdpa_device_stop(VirtIODevice *vdev) { VhostVdpaDevice *s =3D VHOST_VDPA_DEVICE(vdev); @@ -376,6 +394,8 @@ static void vhost_vdpa_device_class_init(ObjectClass *k= lass, const void *data) vdc->get_features =3D vhost_vdpa_device_get_features; vdc->set_status =3D vhost_vdpa_device_set_status; vdc->get_vhost =3D vhost_vdpa_device_get_vhost; + vdc->guest_notifier_mask =3D vhost_vdpa_device_guest_notifier_mask; + vdc->guest_notifier_pending =3D vhost_vdpa_device_guest_notifier_pendi= ng; } =20 static void vhost_vdpa_device_instance_init(Object *obj) --=20 2.43.0