From nobody Mon Nov 17 15:40:56 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604580248; cv=none; d=zohomail.com; s=zohoarc; b=F6Y5tlfX+w73ENirJgAG1fHFSP2xxbzqSBVuIB7G3JDiBTPml11IBsQTZbLSR3xxrAJDt422T9XDFedEptMw6x/kZWSbzPMrub/JXwQwcl14kU5iy3hbrnA7z+voHQyT8cJL1JDAllvwdYBmUhsNXerRcAc1VScij+0jWxnwaKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604580248; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=QbMTJ3ao+EWjH5At6//uqbDIysge1ZWepFJJby54Ojc=; b=Mj6U5Pwta1u2TKyRtJLyAKZfxllrhC/7zkJslQCVGixRlHZrZ0xApsKKQVTZk1H/XOYs9R+bZuN53FpbD5WvrvZxGTGaixSHyZZFoPPrnbFfNSOVIUM1ThZQLQhNM7GLsg1lUsu9QYLlmowEUYc2blDmyeEd2CEbzSwTZX//RRU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604580248704600.4603237008779; Thu, 5 Nov 2020 04:44:08 -0800 (PST) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-na7Zb9pLOUC1pRNNsFgbLQ-1; Thu, 05 Nov 2020 07:44:03 -0500 Received: by mail-wr1-f70.google.com with SMTP id t11so664987wrv.10 for ; Thu, 05 Nov 2020 04:44:02 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (234.red-83-42-66.dynamicip.rima-tde.net. [83.42.66.234]) by smtp.gmail.com with ESMTPSA id e5sm2170548wrw.93.2020.11.05.04.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 04:44:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604580247; 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=QbMTJ3ao+EWjH5At6//uqbDIysge1ZWepFJJby54Ojc=; b=JzxHoGUKdtidMvMbK1vi+zk0LJzcYczYZESZSmJVoP1DhgYCjoJPJ41z7TJBAsYAOGVUnA CmdLeYjkKReVnb1vuHEk1yPZvcLZHuy97L9vi8V3oJoH/wU9cwrPP57mDMKwqXQq5o0ecJ mEoNOASm87/3v7QDl8BmKcAwYGs1EgE= X-MC-Unique: na7Zb9pLOUC1pRNNsFgbLQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QbMTJ3ao+EWjH5At6//uqbDIysge1ZWepFJJby54Ojc=; b=o/R8i+ILqRxmi3eZXo+Uo8+npQakHz7nk+BeksYigrjxjvSebcSOBxWF27Dyft+BGT +BdXTkEHZxCM4kJKuXkAdZrxQAChkHRiFPRGm1nLOR7FNIhFg30Ck28aF9H+rjoOdzqH od4bq3KovT+lMLsUmN3mnAo/cdLX74VIyhp5a3rLkNwJ3XDEL2EynQmq4t4B2Kbd9hN8 tYjSMuFvcw093qm7Hv9PugGzcQq4OqH/LcL9ETCsmNq7rZhX8QhQ1S9EILUCCJJkfRU9 Tqudif3HIL/bmwf/B01HJIZt1Y5CNsjuQxGyvYoO9P5LJDKDcMhvGnMETMnOUcIhhXzp /n3A== X-Gm-Message-State: AOAM530pf5WxNQ/eAdw7BRUkP3b1qq3+6Wi5mo6hXPwc8Qkll/UVtgWH SM+ivs/5lHVcH2nqqReDnJk96mLR8RhonTvase5pyTLfuOJZDMzu97h/wtTzngnlbsJE5pRaJl8 9m0rt+aPWxE+XgA== X-Received: by 2002:adf:f285:: with SMTP id k5mr2710316wro.299.1604580241673; Thu, 05 Nov 2020 04:44:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDBKXqoZGV6QVR06D/ZHdIYvVnb7Xr/YHMllDCX1Blc96HXFdWLgRfsrKSWKsSK/e2UxC/qA== X-Received: by 2002:adf:f285:: with SMTP id k5mr2710301wro.299.1604580241450; Thu, 05 Nov 2020 04:44:01 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Elena Ufimtseva , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Schoenebeck , Greg Kurz , Jagannathan Raman , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Wainer dos Santos Moschetta , Stefan Hajnoczi , Thomas Huth , Jason Wang , Cornelia Huck , Paolo Bonzini , Kevin Wolf Subject: [PATCH-for-6.0 1/3] hw/virtio: Add configure switch to disable legacy VIRTIO Date: Thu, 5 Nov 2020 13:43:51 +0100 Message-Id: <20201105124353.3680057-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201105124353.3680057-1-philmd@redhat.com> References: <20201105124353.3680057-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Per [1] (Terminology): Legacy interfaces are not required; ie. don=E2=80=99t implement them unless you have a need for backwards compatibility! [2] (Version 1.0): The device configuration space uses the little-endian format for multi-byte fields. and [3] (Legacy Interface): for legacy interfaces, device configuration space is generally the guest=E2=80=99s native endian, rather than PCI=E2=80=99s little-endia= n. The correct endian-ness is documented for each device. Add the --disable-virtio-legacy configure flag to produce builds with VIRTIO 1.0 only, and the --enable-virtio-legacy to include legacy VIRTIO support (supporting legacy VIRTIO is the default). [1] http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.htm= l#x1-60001 [2] http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.htm= l#x1-170003 [3] http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.htm= l#x1-200003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- configure | 10 ++++++++++ meson.build | 1 + include/hw/virtio/virtio-access.h | 19 +++++-------------- hw/virtio/virtio-legacy.c | 29 +++++++++++++++++++++++++++++ hw/virtio/meson.build | 1 + 5 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 hw/virtio/virtio-legacy.c diff --git a/configure b/configure index 2c3c69f1188..f46216b3788 100755 --- a/configure +++ b/configure @@ -302,6 +302,7 @@ fdt=3D"auto" netmap=3D"no" sdl=3D"auto" sdl_image=3D"auto" +virtio_legacy=3D"enabled" virtiofsd=3D"auto" virtfs=3D"" libudev=3D"auto" @@ -1001,6 +1002,10 @@ for opt do ;; --enable-libudev) libudev=3D"enabled" ;; + --disable-virtio-legacy) virtio_legacy=3D"disabled" + ;; + --enable-virtio-legacy) virtio_legacy=3D"enabled" + ;; --disable-virtiofsd) virtiofsd=3D"disabled" ;; --enable-virtiofsd) virtiofsd=3D"enabled" @@ -1764,6 +1769,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: vnc-png PNG compression for VNC server cocoa Cocoa UI (Mac OS X only) virtfs VirtFS + virtio-legacy enable support for legacy virtio (before VIRTIO 1.0) virtiofsd build virtiofs daemon (virtiofsd) libudev Use libudev to enumerate host devices mpath Multipath persistent reservation passthrough @@ -6816,6 +6822,10 @@ if test "$safe_stack" =3D "yes"; then echo "CONFIG_SAFESTACK=3Dy" >> $config_host_mak fi =20 +if test "$virtio_legacy" =3D "enabled"; then + echo "CONFIG_VIRTIO_LEGACY=3Dy" >> $config_host_mak +fi + # If we're using a separate build tree, set it up now. # DIRS are directories which we simply mkdir in the build tree; # LINKS are things to symlink back into the source tree diff --git a/meson.build b/meson.build index 39ac5cf6d8a..51406c28c6e 100644 --- a/meson.build +++ b/meson.build @@ -2061,6 +2061,7 @@ summary_info +=3D {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHI= TELIST']} summary_info +=3D {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHI= TELIST']} summary_info +=3D {'VirtFS support': config_host.has_key('CONFIG_VIRTFS= ')} +summary_info +=3D {'Legacy VIRTIO support': config_host.has_key('CONFIG_VI= RTIO_LEGACY')} summary_info +=3D {'build virtiofs daemon': have_virtiofsd} summary_info +=3D {'Multipath support': mpathpersist.found()} summary_info +=3D {'VNC support': vnc.found()} diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-a= ccess.h index 6818a23a2d3..b6c060f8cc6 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -20,24 +20,15 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-bus.h" =20 -#if defined(TARGET_PPC64) || defined(TARGET_ARM) -#define LEGACY_VIRTIO_IS_BIENDIAN 1 -#endif - +#ifdef CONFIG_VIRTIO_LEGACY +bool virtio_access_is_big_endian(VirtIODevice *vdev); +#else static inline bool virtio_access_is_big_endian(VirtIODevice *vdev) { -#if defined(LEGACY_VIRTIO_IS_BIENDIAN) - return virtio_is_big_endian(vdev); -#elif defined(TARGET_WORDS_BIGENDIAN) - if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { - /* Devices conforming to VIRTIO 1.0 or later are always LE. */ - return false; - } - return true; -#else + /* Devices conforming to VIRTIO 1.0 or later are always LE. */ return false; -#endif } +#endif =20 static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, hwaddr pa) { diff --git a/hw/virtio/virtio-legacy.c b/hw/virtio/virtio-legacy.c new file mode 100644 index 00000000000..bf28c824a25 --- /dev/null +++ b/hw/virtio/virtio-legacy.c @@ -0,0 +1,29 @@ +/* + * Legacy virtio endian helpers. + * + * Copyright Red Hat, Inc. 2020 + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/virtio-access.h" + +#if defined(TARGET_PPC64) || defined(TARGET_ARM) +# define LEGACY_VIRTIO_IS_BIENDIAN 1 +#endif + +bool virtio_access_is_big_endian(VirtIODevice *vdev) +{ +#if defined(LEGACY_VIRTIO_IS_BIENDIAN) + return virtio_is_big_endian(vdev); +#elif defined(TARGET_WORDS_BIGENDIAN) + if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { + /* Devices conforming to VIRTIO 1.0 or later are always LE. */ + return false; + } + return true; +#else + return false; +#endif +} diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index fbff9bc9d4d..95415913a9a 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -11,6 +11,7 @@ =20 virtio_ss =3D ss.source_set() virtio_ss.add(files('virtio.c')) +virtio_ss.add(when: 'CONFIG_VIRTIO_LEGACY', if_true: files('virtio-legacy.= c')) virtio_ss.add(when: 'CONFIG_VHOST', if_true: files('vhost.c', 'vhost-backe= nd.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user.c')) virtio_ss.add(when: 'CONFIG_VHOST_VDPA', if_true: files('vhost-vdpa.c')) --=20 2.26.2