From nobody Thu Apr 25 23:46:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590167941; cv=none; d=zohomail.com; s=zohoarc; b=F+4ZjwVBhSs77GqLHNjAsCkhFu45PVEYkEgSBcS/R1dUzPkKVjUCLspOMHJpa+xpc8gdtIxVA/f1eM8UJDDCEtztkxPJFx8wm3WtAoJ3+7pIFq7WsZfIkUEFrAoIKfz328NA/ACz4zAto4u1t5ArEVrzrgbORsb1gwtrLDP6PvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590167941; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L920wjdi+xW55WmrO3rlVY3adomm8968IC13fk32krM=; b=O4mSbc92WrFMWNhR0E5nvLNKoFC+7r9z4GpoTmokwAJtH94Lrz5GZA4+ormMOsu7NXadaSpTHnweex3DNhEtDHOWdhKYXZUvB7EFNY0D/xVJGs/rtQ7+bwiK0wOHgDU2RTUAxHXUvDRwIaLVcpBlvMeqzpTWqX756poYDN2BnXo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590167941029888.046087762347; Fri, 22 May 2020 10:19:01 -0700 (PDT) Received: from localhost ([::1]:48538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcBJz-0006ae-Gp for importer@patchew.org; Fri, 22 May 2020 13:18:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcBJ5-0004rg-KO for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:03 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:36456 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jcBJ2-0000dQ-FU for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-cQy26KD2PNqC91Srr43hVw-1; Fri, 22 May 2020 13:17:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00F1E80058A; Fri, 22 May 2020 17:17:54 +0000 (UTC) Received: from localhost (ovpn-112-243.ams2.redhat.com [10.36.112.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C08C5D9CC; Fri, 22 May 2020 17:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590167879; 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=L920wjdi+xW55WmrO3rlVY3adomm8968IC13fk32krM=; b=gT/0CKiH4aMxp/ZUzpy7JNANoFO5zgcejYHdkVEkrhxyRVKi7uqklg0bP4Qe/8bJWiaQoF xhjqPHI3ooXKP11o1OEUdLr+p5jk48cuq0tGiBt9zi7GcRHCe+6Zil68FMvlgkS4oUiDEK 2dznc0L74dr5g/bhMb8tKv44DUV8EK4= X-MC-Unique: cQy26KD2PNqC91Srr43hVw-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH 1/5] tests/libqos: mask out VIRTIO_F_RING_PACKED for now Date: Fri, 22 May 2020 18:17:22 +0100 Message-Id: <20200522171726.648279-2-stefanha@redhat.com> In-Reply-To: <20200522171726.648279-1-stefanha@redhat.com> References: <20200522171726.648279-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=stefanha@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 08:01:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Laurent Vivier , Thomas Huth , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , jasowang@redhat.com, cohuck@redhat.com, Stefan Hajnoczi , "Dr. David Alan Gilbert" , Raphael Norwitz , "Gonglei \(Arei\)" , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fam Zheng , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The libqos VIRTIO code does not implement the packed virtqueue layout yet. Mask out the feature bit for now because tests have a habit of enabling all device feature bits and we don't want packed virtqueues to be enabled. Later patches will enable VIRTIO_F_RING_PACKED so prepare libqos now. Cc: Thomas Huth Signed-off-by: Stefan Hajnoczi Acked-by: Thomas Huth --- tests/qtest/libqos/virtio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c index 9aa360620c..1c3f4a0c8b 100644 --- a/tests/qtest/libqos/virtio.c +++ b/tests/qtest/libqos/virtio.c @@ -96,7 +96,8 @@ uint64_t qvirtio_config_readq(QVirtioDevice *d, uint64_t = addr) =20 uint64_t qvirtio_get_features(QVirtioDevice *d) { - return d->bus->get_features(d); + /* qvirtio does not support packed virtqueues yet */ + return d->bus->get_features(d) & ~(1ull << VIRTIO_F_RING_PACKED); } =20 void qvirtio_set_features(QVirtioDevice *d, uint64_t features) --=20 2.25.3 From nobody Thu Apr 25 23:46:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590167941; cv=none; d=zohomail.com; s=zohoarc; b=gv27kUj4wDI8seOeCgFxDz1mMsg+dgUpP4ZSFtHnx+LdUIg2c+NXh/On6Mhbb7vJ1/bJ9I+FyS3djcxjJp/9ChvR4kQDVXmnMPq1smwJ/TIu80kcNKR3gq0b4AYT+jWxH+wM649OtJZ9KolQ4/cRmgkl10H0b+VTtJLtxggn0cU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590167941; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4+WAH92SNYw1I0R63EWnB7Xfs3BvI/uefRj3o3pNaD4=; b=n+xVzsmDB5qXmZvwEynvIDRKO/ezqH8FzlKUBuEDiH2thjT9bsliwddi+GsyeAv9Q8erqv4pbVnqLnflA8/FZ+Q2qURfHbTuMrzoog1hUKmhxFhNlxPpz5JfwWj5y8Ati2+TpFIV9q1zjIzNGIv913MwqNf0I5BKmCuJt8m6Tv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590167941407313.8105754271222; Fri, 22 May 2020 10:19:01 -0700 (PDT) Received: from localhost ([::1]:48588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcBK0-0006bk-3r for importer@patchew.org; Fri, 22 May 2020 13:19:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcBJ7-0004vK-Gr for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25929 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jcBJ5-0000di-Rx for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:05 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-6S4Dbln-OWaN1Tqzn83lHQ-1; Fri, 22 May 2020 13:17:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7191480058A; Fri, 22 May 2020 17:17:56 +0000 (UTC) Received: from localhost (ovpn-112-243.ams2.redhat.com [10.36.112.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 965F55D9CC; Fri, 22 May 2020 17:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590167882; 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=4+WAH92SNYw1I0R63EWnB7Xfs3BvI/uefRj3o3pNaD4=; b=HebC2I2RIRSnxw1p6c0NJenk4de/+VQEO4GhZi1rbpx45h20xSeHIuPyIlMwoY1rQbKhOq tdAcWWT5J/A6oz1hkjjCQONV9M5wFntk2roeda7PAKG89Jc3+frKUuz60513GOWEhScmzm 2AVtHDPhNBRQpGV//NTd0NAIGGSSIoI= X-MC-Unique: 6S4Dbln-OWaN1Tqzn83lHQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH 2/5] vhost: involve device backends in feature negotiation Date: Fri, 22 May 2020 18:17:23 +0100 Message-Id: <20200522171726.648279-3-stefanha@redhat.com> In-Reply-To: <20200522171726.648279-1-stefanha@redhat.com> References: <20200522171726.648279-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=stefanha@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 10:36:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Laurent Vivier , Thomas Huth , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , jasowang@redhat.com, cohuck@redhat.com, Stefan Hajnoczi , "Dr. David Alan Gilbert" , Raphael Norwitz , "Gonglei \(Arei\)" , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fam Zheng , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Many vhost devices in QEMU currently do not involve the device backend in feature negotiation. This seems fine at first glance for device types without their own feature bits (virtio-net has many but other device types have none). This overlooks the fact that QEMU's virtqueue implementation and the device backend's implementation may support different features. QEMU must not report features to the guest that the the device backend doesn't support. For example, QEMU supports VIRTIO 1.1 packed virtqueues while many existing vhost device backends do not. When the user sets packed=3Don the device backend breaks. This should have been handled gracefully by feature negotiation instead. Introduce vhost_get_default_features() and update all vhost devices in QEMU to involve the device backend in feature negotiation. This patch fixes the following error: $ x86_64-softmmu/qemu-system-x86_64 \ -drive if=3Dvirtio,file=3Dtest.img,format=3Draw \ -chardev socket,path=3D/tmp/vhost-user-blk.sock,id=3Dchar0 \ -device vhost-user-blk-pci,chardev=3Dchar0,packed=3Don \ -object memory-backend-memfd,size=3D1G,share=3Don,id=3Dram0 \ -M accel=3Dkvm,memory-backend=3Dram0 qemu-system-x86_64: Failed to set msg fds. qemu-system-x86_64: vhost VQ 0 ring restore failed: -1: Success (0) The vhost-user-blk backend failed as follows: $ ./vhost-user-blk --socket-path=3D/tmp/vhost-user-blk.sock -b test2.img vu_panic: virtio: zero sized buffers are not allowed virtio-blk request missing headers Signed-off-by: Stefan Hajnoczi --- include/hw/virtio/vhost.h | 1 + include/hw/virtio/virtio-gpu.h | 2 ++ include/sysemu/cryptodev-vhost.h | 11 +++++++++++ backends/cryptodev-vhost.c | 19 +++++++++++++++++++ hw/display/vhost-user-gpu.c | 17 +++++++++++++++++ hw/display/virtio-gpu-base.c | 2 +- hw/input/vhost-user-input.c | 9 +++++++++ hw/virtio/vhost-user-fs.c | 5 +++-- hw/virtio/vhost-vsock.c | 5 +++-- hw/virtio/vhost.c | 22 ++++++++++++++++++++++ hw/virtio/virtio-crypto.c | 3 ++- 11 files changed, 90 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 085450c6f8..d2e54dd4a8 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -112,6 +112,7 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtI= ODevice *vdev, int n, bool mask); uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bit= s, uint64_t features); +uint64_t vhost_get_default_features(struct vhost_dev *hdev, uint64_t featu= res); void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, uint64_t features); bool vhost_has_free_slot(void); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 6dd57f2025..41d270d80e 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -192,6 +192,8 @@ bool virtio_gpu_base_device_realize(DeviceState *qdev, void virtio_gpu_base_reset(VirtIOGPUBase *g); void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, struct virtio_gpu_resp_display_info *dpy_info); +uint64_t virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t feature= s, + Error **errp); =20 /* virtio-gpu.c */ void virtio_gpu_ctrl_response(VirtIOGPU *g, diff --git a/include/sysemu/cryptodev-vhost.h b/include/sysemu/cryptodev-vh= ost.h index f42824fbde..e629446bfb 100644 --- a/include/sysemu/cryptodev-vhost.h +++ b/include/sysemu/cryptodev-vhost.h @@ -122,6 +122,17 @@ int cryptodev_vhost_start(VirtIODevice *dev, int total= _queues); */ void cryptodev_vhost_stop(VirtIODevice *dev, int total_queues); =20 +/** + * cryptodev_vhost_get_features: + * @dev: the virtio crypto object + * @requested_features: the features being offered + * + * Returns: the requested features bits that are supported by the vhost de= vice, + * or the original request feature bits if vhost is disabled + * + */ +uint64_t cryptodev_vhost_get_features(VirtIODevice *dev, uint64_t features= ); + /** * cryptodev_vhost_virtqueue_mask: * @dev: the virtio crypto object diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index 8337c9a495..5f5a4fda7b 100644 --- a/backends/cryptodev-vhost.c +++ b/backends/cryptodev-vhost.c @@ -266,6 +266,20 @@ void cryptodev_vhost_stop(VirtIODevice *dev, int total= _queues) assert(r >=3D 0); } =20 +uint64_t cryptodev_vhost_get_features(VirtIODevice *dev, uint64_t features) +{ + VirtIOCrypto *vcrypto =3D VIRTIO_CRYPTO(dev); + CryptoDevBackend *b =3D vcrypto->cryptodev; + CryptoDevBackendClient *cc =3D b->conf.peers.ccs[0]; + CryptoDevBackendVhost *vhost_crypto =3D cryptodev_get_vhost(cc, b, 0); + + if (!vhost_crypto) { + return features; /* vhost disabled */ + } + + return vhost_get_default_features(&vhost_crypto->dev, features); +} + void cryptodev_vhost_virtqueue_mask(VirtIODevice *dev, int queue, int idx, bool mask) @@ -333,6 +347,11 @@ void cryptodev_vhost_stop(VirtIODevice *dev, int total= _queues) { } =20 +uint64_t cryptodev_vhost_get_features(VirtIODevice *dev, uint64_t features) +{ + return features; +} + void cryptodev_vhost_virtqueue_mask(VirtIODevice *dev, int queue, int idx, bool mask) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 4cdaee1bde..e483df2a9e 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -466,6 +466,22 @@ vhost_user_gpu_set_config(VirtIODevice *vdev, } } =20 +static uint64_t +vhost_user_gpu_get_features(VirtIODevice *vdev, uint64_t features, + Error **errp) +{ + VhostUserGPU *g =3D VHOST_USER_GPU(vdev); + Error *local_err =3D NULL; + + features =3D virtio_gpu_base_get_features(vdev, features, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return 0; + } + + return vhost_get_default_features(&g->vhost->dev, features); +} + static void vhost_user_gpu_set_status(VirtIODevice *vdev, uint8_t val) { @@ -582,6 +598,7 @@ vhost_user_gpu_class_init(ObjectClass *klass, void *dat= a) =20 vdc->realize =3D vhost_user_gpu_device_realize; vdc->reset =3D vhost_user_gpu_reset; + vdc->get_features =3D vhost_user_gpu_get_features; vdc->set_status =3D vhost_user_gpu_set_status; vdc->guest_notifier_mask =3D vhost_user_gpu_guest_notifier_mask; vdc->guest_notifier_pending =3D vhost_user_gpu_guest_notifier_pending; diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index c159351be3..05d1ff2db2 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -176,7 +176,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev, return true; } =20 -static uint64_t +uint64_t virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, Error **errp) { diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c index 63984a8ba7..1371fb32cc 100644 --- a/hw/input/vhost-user-input.c +++ b/hw/input/vhost-user-input.c @@ -45,6 +45,14 @@ static void vhost_input_change_active(VirtIOInput *vinpu= t) } } =20 +static uint64_t vhost_input_get_features(VirtIODevice *vdev, uint64_t feat= ures, + Error **errp) +{ + VHostUserInput *vhi =3D VHOST_USER_INPUT(vdev); + + return vhost_get_default_features(&vhi->vhost->dev, features); +} + static void vhost_input_get_config(VirtIODevice *vdev, uint8_t *config_dat= a) { VirtIOInput *vinput =3D VIRTIO_INPUT(vdev); @@ -89,6 +97,7 @@ static void vhost_input_class_init(ObjectClass *klass, vo= id *data) DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->vmsd =3D &vmstate_vhost_input; + vdc->get_features =3D vhost_input_get_features; vdc->get_config =3D vhost_input_get_config; vdc->set_config =3D vhost_input_set_config; vic->realize =3D vhost_input_realize; diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 1bc5d03a00..56015ca3d4 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -130,8 +130,9 @@ static uint64_t vuf_get_features(VirtIODevice *vdev, uint64_t requested_features, Error **errp) { - /* No feature bits used yet */ - return requested_features; + VHostUserFS *fs =3D VHOST_USER_FS(vdev); + + return vhost_get_default_features(&fs->vhost_dev, requested_features); } =20 static void vuf_handle_output(VirtIODevice *vdev, VirtQueue *vq) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 4a228f5168..7276587be6 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -180,8 +180,9 @@ static uint64_t vhost_vsock_get_features(VirtIODevice *= vdev, uint64_t requested_features, Error **errp) { - /* No feature bits used yet */ - return requested_features; + VHostVSock *vsock =3D VHOST_VSOCK(vdev); + + return vhost_get_default_features(&vsock->vhost_dev, requested_feature= s); } =20 static void vhost_vsock_handle_output(VirtIODevice *vdev, VirtQueue *vq) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index aff98a0ede..f8a144dcd0 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -48,6 +48,23 @@ static unsigned int used_memslots; static QLIST_HEAD(, vhost_dev) vhost_devices =3D QLIST_HEAD_INITIALIZER(vhost_devices); =20 +/* + * Feature bits that device backends must explicitly report. Feature bits = not + * listed here maybe set by QEMU without checking with the device backend. + * Ideally all feature bits would be listed here but existing vhost device + * implementations do not explicitly report bits like VIRTIO_F_VERSION_1, = so we + * can only assume they are supported. + * + * New feature bits added to the VIRTIO spec should usually be included he= re + * so that existing vhost device backends that do not support them yet con= tinue + * to work. + */ +static const int vhost_default_feature_bits[] =3D { + VIRTIO_F_IOMMU_PLATFORM, + VIRTIO_F_RING_PACKED, + VHOST_INVALID_FEATURE_BIT +}; + bool vhost_has_free_slot(void) { unsigned int slots_limit =3D ~0U; @@ -1468,6 +1485,11 @@ uint64_t vhost_get_features(struct vhost_dev *hdev, = const int *feature_bits, return features; } =20 +uint64_t vhost_get_default_features(struct vhost_dev *hdev, uint64_t featu= res) +{ + return vhost_get_features(hdev, vhost_default_feature_bits, features); +} + void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, uint64_t features) { diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index bd9165c565..ef711b56f4 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -739,7 +739,8 @@ static uint64_t virtio_crypto_get_features(VirtIODevice= *vdev, uint64_t features, Error **errp) { - return features; + /* Just returns features when vhost is disabled */ + return cryptodev_vhost_get_features(vdev, features); } =20 static void virtio_crypto_reset(VirtIODevice *vdev) --=20 2.25.3 From nobody Thu Apr 25 23:46:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590168047; cv=none; d=zohomail.com; s=zohoarc; b=l5wNwMD1l7YQt/nHkogo3VhFQaQR2YDmKZgwuRGWht3wT0Id1WBr52F5K1MwxTt1+5mZP1G0o+P8nMp74wkzqk7ojBIbPVwy/fZMf8jUAiR5QOpZD97n/LahYAh5MShhvuR96D1d5LIsyDdUFkKRntlFiTVeOxnD8D3AoWc4CuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590168047; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6OUjV9d42OaeNTy7tX62TdWiw4w1pIbo02ovt56hIfY=; b=I4+Zx/ZXYZSosyCMph7+Qo0phfm2b9MxuwdgHbbNB2mw9Lhoz5Es5lA69A4plYJ+ROnCsX9P87LI4CPceAWDvk+pmYwabSv0KkrTDRk+7xAyBrvPxF5dnou9p+u38KETeeUF4a1Hv+vRp0JGT3qow9NM10oyqTsT0mA9Ro4gXJk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590168047640875.4639434289697; Fri, 22 May 2020 10:20:47 -0700 (PDT) Received: from localhost ([::1]:55778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcBLi-00019H-Fg for importer@patchew.org; Fri, 22 May 2020 13:20:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcBJG-0005K4-HS for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:14 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:45716 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jcBJF-0000fY-Q6 for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-505-PeRgRvSAPt--n5YcwV-Kgw-1; Fri, 22 May 2020 13:18:11 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EECF780B700; Fri, 22 May 2020 17:18:09 +0000 (UTC) Received: from localhost (ovpn-112-243.ams2.redhat.com [10.36.112.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id D41535798D; Fri, 22 May 2020 17:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590167892; 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=6OUjV9d42OaeNTy7tX62TdWiw4w1pIbo02ovt56hIfY=; b=CVP3xeChnK6Erd8jv6xC+nwwesLsg558j2NF0vhj7Y9vCS6wKnvkYEdB5T1ZQ7zmrvzhXO k34zSfD1n67YCJi5tPwyhQnHfIO8h3O8isSFqt4erg2nrQYUI96A32O4YlFxQEU5UfSYUx 8u3VgkYOD0RXwBIgnWvfkhsWYMUeZco= X-MC-Unique: PeRgRvSAPt--n5YcwV-Kgw-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH 3/5] vhost-user-blk: add VIRTIO_F_RING_PACKED feature bit Date: Fri, 22 May 2020 18:17:24 +0100 Message-Id: <20200522171726.648279-4-stefanha@redhat.com> In-Reply-To: <20200522171726.648279-1-stefanha@redhat.com> References: <20200522171726.648279-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 11:12:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Laurent Vivier , Thomas Huth , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , jasowang@redhat.com, cohuck@redhat.com, Stefan Hajnoczi , "Dr. David Alan Gilbert" , Raphael Norwitz , "Gonglei \(Arei\)" , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fam Zheng , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Vhost devices have a list of feature bits that the device backend is allowed to control. The VIRTIO_F_RING_PACKED feature is a feature that must be negotiated through all the way to the device backend. Add it so the device backend can declare whether or not it supports the packed ring layout. Signed-off-by: Stefan Hajnoczi Reviewed-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9d8c0b3909..10e114a19a 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -44,6 +44,7 @@ static const int user_feature_bits[] =3D { VIRTIO_BLK_F_DISCARD, VIRTIO_BLK_F_WRITE_ZEROES, VIRTIO_F_VERSION_1, + VIRTIO_F_RING_PACKED, VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, VIRTIO_F_NOTIFY_ON_EMPTY, --=20 2.25.3 From nobody Thu Apr 25 23:46:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590168005; cv=none; d=zohomail.com; s=zohoarc; b=Db7bvNQI6nIWrcSvfA0bXKhN60CmhBYWuQlIbRHC3Vg2vSaYSTV/WrOABEwmu/fHkGZW8gPSAxCujD+nW9n7C1/vng3qFbLRyRUOA7cEbqg7swpn3FH1x+69urhgK/P9gbDIBUMN/6A2c1mct3tSnltETQ+kZzoc00DH9x0UZMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590168005; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VfEehpGDUiUAoeGDAnzCD1TZiUEMeKWipRXXUThsAm0=; b=fpe+wcf2VQUGepq841wK+tkzimuTfQA5FRTOqQ93/gyJqiWe6y7s17YUOJ5yS//EvLO4G/Ech3syRcl4Xg44mYwnaVw0FX/9MGjBqJeGQzg1KwlK6V+V3tm8PIE7TMIwAUbYgXPSu1Fxh0jSQXPri3DhCsTE6indID92ylMMGSs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590168005532127.44869701027415; Fri, 22 May 2020 10:20:05 -0700 (PDT) Received: from localhost ([::1]:53924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcBL2-0000LG-01 for importer@patchew.org; Fri, 22 May 2020 13:20:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcBJT-0005tp-EN for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:28 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39439 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jcBJR-0000gg-VI for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:26 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-sohZndYtPcmxSUnI2mXA7g-1; Fri, 22 May 2020 13:18:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F9C8100CC87; Fri, 22 May 2020 17:18:22 +0000 (UTC) Received: from localhost (ovpn-112-243.ams2.redhat.com [10.36.112.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E4D35C1D0; Fri, 22 May 2020 17:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590167905; 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=VfEehpGDUiUAoeGDAnzCD1TZiUEMeKWipRXXUThsAm0=; b=NxQO77wieDaaMCXZ/NVcuI219ZxhAMJmlISIGcMOJ3Uwu8tyQiAVmHo5Plcp4XCRUhhwhF nmaELpj3SuXnIRW08DXDrQW8t/kcgSDEMzxboHiFdBFfmHjhpoeYSk7VdsA4hjIfv/xqvT yH2yMgs3zhI7mP5IpKaN238fDLtjwlM= X-MC-Unique: sohZndYtPcmxSUnI2mXA7g-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH 4/5] vhost-scsi: add VIRTIO_F_VERSION_1 and VIRTIO_F_RING_PACKED Date: Fri, 22 May 2020 18:17:25 +0100 Message-Id: <20200522171726.648279-5-stefanha@redhat.com> In-Reply-To: <20200522171726.648279-1-stefanha@redhat.com> References: <20200522171726.648279-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=stefanha@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 08:01:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Laurent Vivier , Thomas Huth , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , jasowang@redhat.com, cohuck@redhat.com, Stefan Hajnoczi , "Dr. David Alan Gilbert" , Raphael Norwitz , "Gonglei \(Arei\)" , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fam Zheng , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Let vhost-scsi and vhost-user-scsi device backends determine whether VIRTIO 1.0 and packed virtqueues are supported. It doesn't make sense to handle these feature bits in QEMU since the device backend needs to support them if we want to use them. Signed-off-by: Stefan Hajnoczi Reviewed-by: Raphael Norwitz --- hw/scsi/vhost-scsi.c | 2 ++ hw/scsi/vhost-user-scsi.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index c1b012aea4..a7fb788af5 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -34,6 +34,8 @@ =20 /* Features supported by host kernel. */ static const int kernel_feature_bits[] =3D { + VIRTIO_F_VERSION_1, + VIRTIO_F_RING_PACKED, VIRTIO_F_NOTIFY_ON_EMPTY, VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index cbb5d97599..6aa0d5ded2 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -32,6 +32,8 @@ =20 /* Features supported by the host application */ static const int user_feature_bits[] =3D { + VIRTIO_F_VERSION_1, + VIRTIO_F_RING_PACKED, VIRTIO_F_NOTIFY_ON_EMPTY, VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, --=20 2.25.3 From nobody Thu Apr 25 23:46:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1590168090; cv=none; d=zohomail.com; s=zohoarc; b=ESwyGpyONiLHRVTnMcLGSPZPFvZ4Az63xQQiLH2Cu86agXxlUgyJoBKGvJ57AuQc+sIYnXRgj1ZtPCsP7rf9xN3k5oiNe+2uGg09xm8uWhvZ5d8GFgJDL2v6dRj/VcoRYXZcXg7IRFvTrMm+kaDur4ulxNPr8L4JfkhYyZW+o9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590168090; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IUvdZ9WOLD61EuJIHtGb6cIb8n0l3/qyiO43STZSrdY=; b=MddLiFHXpCmRKzg4Xmo58W9oov1SOd7bpRVbEG3w3fEHibkVcUEpDXUlmj4j9c0pILEyP8hWyY71GFtD9UUuiLgJ3y++Y5wB4hOrnpfBv2W5JvJnUAvPg5ljb+mLZkuVSi7ZlpjaaoAR1YR/GGgnfENr743+6lNm+ARHNWMQFp4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590168090498166.26939186816548; Fri, 22 May 2020 10:21:30 -0700 (PDT) Received: from localhost ([::1]:58162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcBMP-0002B9-BO for importer@patchew.org; Fri, 22 May 2020 13:21:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcBJg-0006P8-PE for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:40 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:34006 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jcBJf-0000iy-VF for qemu-devel@nongnu.org; Fri, 22 May 2020 13:18:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-943U-aW1MuaIJyqJiK7W1w-1; Fri, 22 May 2020 13:18:37 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF1F88005AA; Fri, 22 May 2020 17:18:35 +0000 (UTC) Received: from localhost (ovpn-112-243.ams2.redhat.com [10.36.112.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id D69857820A; Fri, 22 May 2020 17:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590167918; 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=IUvdZ9WOLD61EuJIHtGb6cIb8n0l3/qyiO43STZSrdY=; b=cUmx9dJpdM225LGWo+dNa+nfYhNfdwv4z69PADj30Za4Q8q8WvU9Kd8ulwFgC47wNZl3aK ijBhbh2mtJxhWlZL8mBDFxGyB0SQ+O7TEt5T1tb7AXQODcpz4am1fW4H+SoO7asjSFfDyf zn/fDJ6FxHetWOhOhEdbtCQ25UPjxEk= X-MC-Unique: 943U-aW1MuaIJyqJiK7W1w-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH 5/5] virtio: enable VIRTIO_F_RING_PACKED for all devices Date: Fri, 22 May 2020 18:17:26 +0100 Message-Id: <20200522171726.648279-6-stefanha@redhat.com> In-Reply-To: <20200522171726.648279-1-stefanha@redhat.com> References: <20200522171726.648279-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 11:11:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Laurent Vivier , Thomas Huth , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , jasowang@redhat.com, cohuck@redhat.com, Stefan Hajnoczi , "Dr. David Alan Gilbert" , Raphael Norwitz , "Gonglei \(Arei\)" , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fam Zheng , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The packed virtqueue layout was introduced in VIRTIO 1.1. It is a single ring instead of a split avail/used ring design. There are CPU cache advantages to this layout and it is also suited better to hardware implementation. The vhost-net backend has already supported packed virtqueues for some time. Performance benchmarks show that virtio-blk performance on NVMe drives is also improved. Go ahead and enable this feature for all VIRTIO devices. Keep it disabled for QEMU 5.0 and earlier machine types. Signed-off-by: Stefan Hajnoczi Reviewed-by: Dr. David Alan Gilbert --- include/hw/virtio/virtio.h | 2 +- hw/core/machine.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b69d517496..fd5b4a2044 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -292,7 +292,7 @@ typedef struct VirtIORNGConf VirtIORNGConf; DEFINE_PROP_BIT64("iommu_platform", _state, _field, \ VIRTIO_F_IOMMU_PLATFORM, false), \ DEFINE_PROP_BIT64("packed", _state, _field, \ - VIRTIO_F_RING_PACKED, false) + VIRTIO_F_RING_PACKED, true) =20 hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n); bool virtio_queue_enabled(VirtIODevice *vdev, int n); diff --git a/hw/core/machine.c b/hw/core/machine.c index bb3a7b18b1..3598c3c825 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -28,7 +28,23 @@ #include "hw/mem/nvdimm.h" #include "migration/vmstate.h" =20 -GlobalProperty hw_compat_5_0[] =3D {}; +GlobalProperty hw_compat_5_0[] =3D { + { "vhost-user-blk", "packed", "off" }, + { "vhost-user-fs-device", "packed", "off" }, + { "vhost-vsock-device", "packed", "off" }, + { "virtio-9p-device", "packed", "off" }, + { "virtio-balloon-device", "packed", "off" }, + { "virtio-blk-device", "packed", "off" }, + { "virtio-crypto-device", "packed", "off" }, + { "virtio-gpu-device", "packed", "off" }, + { "virtio-input-device", "packed", "off" }, + { "virtio-iommu-device", "packed", "off" }, + { "virtio-net-device", "packed", "off" }, + { "virtio-pmem", "packed", "off" }, + { "virtio-rng-device", "packed", "off" }, + { "virtio-scsi-common", "packed", "off" }, + { "virtio-serial-device", "packed", "off" }, +}; const size_t hw_compat_5_0_len =3D G_N_ELEMENTS(hw_compat_5_0); =20 GlobalProperty hw_compat_4_2[] =3D { --=20 2.25.3