virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-s390@vger.kernel.org, lguest@lists.ozlabs.org,
	thuth@linux.vnet.ibm.com,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	rusty@au1.ibm.com,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	virtualization@lists.linux-foundation.org,
	dahi@linux.vnet.ibm.com,
	Siva Yerramreddy <yshivakrishna@gmail.com>,
	Joel Stanley <joel@jms.id.au>,
	linux390@de.ibm.com, pbonzini@redhat.com,
	David Miller <davem@davemloft.net>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [PATCH v6 04/46] virtio: add support for 64 bit features.
Date: Thu, 27 Nov 2014 22:07:55 +0200	[thread overview]
Message-ID: <1417118789-18231-5-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1417118789-18231-1-git-send-email-mst@redhat.com>

Change u32 to u64, and use BIT_ULL and 1ULL everywhere.

Note: transports are unchanged, and only set low 32 bit.
This guarantees that no transport sets e.g. VERSION_1
by mistake without proper support.

Based on patch by Rusty.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/linux/virtio.h                 |  2 +-
 include/linux/virtio_config.h          | 20 ++++++++++----------
 tools/virtio/linux/virtio.h            |  2 +-
 drivers/lguest/lguest_device.c         |  2 +-
 drivers/misc/mic/card/mic_virtio.c     |  2 +-
 drivers/remoteproc/remoteproc_virtio.c |  2 +-
 drivers/s390/kvm/kvm_virtio.c          |  2 +-
 drivers/s390/kvm/virtio_ccw.c          |  2 +-
 drivers/virtio/virtio.c                |  8 ++++----
 drivers/virtio/virtio_mmio.c           |  2 +-
 drivers/virtio/virtio_pci.c            |  2 +-
 11 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 7828a7f..149284e 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -101,7 +101,7 @@ struct virtio_device {
 	const struct virtio_config_ops *config;
 	const struct vringh_config_ops *vringh_config;
 	struct list_head vqs;
-	u32 features;
+	u64 features;
 	void *priv;
 };
 
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 1761106..b465c3f 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -66,7 +66,7 @@ struct virtio_config_ops {
 			vq_callback_t *callbacks[],
 			const char *names[]);
 	void (*del_vqs)(struct virtio_device *);
-	u32 (*get_features)(struct virtio_device *vdev);
+	u64 (*get_features)(struct virtio_device *vdev);
 	void (*finalize_features)(struct virtio_device *vdev);
 	const char *(*bus_name)(struct virtio_device *vdev);
 	int (*set_vq_affinity)(struct virtqueue *vq, int cpu);
@@ -88,11 +88,11 @@ static inline bool __virtio_test_bit(const struct virtio_device *vdev,
 {
 	/* Did you forget to fix assumptions on max features? */
 	if (__builtin_constant_p(fbit))
-		BUILD_BUG_ON(fbit >= 32);
+		BUILD_BUG_ON(fbit >= 64);
 	else
-		BUG_ON(fbit >= 32);
+		BUG_ON(fbit >= 64);
 
-	return vdev->features & BIT(fbit);
+	return vdev->features & BIT_ULL(fbit);
 }
 
 /**
@@ -105,11 +105,11 @@ static inline void __virtio_set_bit(struct virtio_device *vdev,
 {
 	/* Did you forget to fix assumptions on max features? */
 	if (__builtin_constant_p(fbit))
-		BUILD_BUG_ON(fbit >= 32);
+		BUILD_BUG_ON(fbit >= 64);
 	else
-		BUG_ON(fbit >= 32);
+		BUG_ON(fbit >= 64);
 
-	vdev->features |= BIT(fbit);
+	vdev->features |= BIT_ULL(fbit);
 }
 
 /**
@@ -122,11 +122,11 @@ static inline void __virtio_clear_bit(struct virtio_device *vdev,
 {
 	/* Did you forget to fix assumptions on max features? */
 	if (__builtin_constant_p(fbit))
-		BUILD_BUG_ON(fbit >= 32);
+		BUILD_BUG_ON(fbit >= 64);
 	else
-		BUG_ON(fbit >= 32);
+		BUG_ON(fbit >= 64);
 
-	vdev->features &= ~BIT(fbit);
+	vdev->features &= ~BIT_ULL(fbit);
 }
 
 /**
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h
index 72bff70..8eb6421 100644
--- a/tools/virtio/linux/virtio.h
+++ b/tools/virtio/linux/virtio.h
@@ -10,7 +10,7 @@
 
 struct virtio_device {
 	void *dev;
-	u32 features;
+	u64 features;
 };
 
 struct virtqueue {
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 97aeb7d..d81170a 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -94,7 +94,7 @@ static unsigned desc_size(const struct lguest_device_desc *desc)
 }
 
 /* This gets the device's feature bits. */
-static u32 lg_get_features(struct virtio_device *vdev)
+static u64 lg_get_features(struct virtio_device *vdev)
 {
 	unsigned int i;
 	u32 features = 0;
diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c
index d5da9ff..f5e7561 100644
--- a/drivers/misc/mic/card/mic_virtio.c
+++ b/drivers/misc/mic/card/mic_virtio.c
@@ -68,7 +68,7 @@ static inline struct device *mic_dev(struct mic_vdev *mvdev)
 }
 
 /* This gets the device's feature bits. */
-static u32 mic_get_features(struct virtio_device *vdev)
+static u64 mic_get_features(struct virtio_device *vdev)
 {
 	unsigned int i, bits;
 	u32 features = 0;
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index dafaf38..62897db 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -207,7 +207,7 @@ static void rproc_virtio_reset(struct virtio_device *vdev)
 }
 
 /* provide the vdev features as retrieved from the firmware */
-static u32 rproc_virtio_get_features(struct virtio_device *vdev)
+static u64 rproc_virtio_get_features(struct virtio_device *vdev)
 {
 	struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
 	struct fw_rsc_vdev *rsc;
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index fcd312d..2336c7e 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -80,7 +80,7 @@ static unsigned desc_size(const struct kvm_device_desc *desc)
 }
 
 /* This gets the device's feature bits. */
-static u32 kvm_get_features(struct virtio_device *vdev)
+static u64 kvm_get_features(struct virtio_device *vdev)
 {
 	unsigned int i;
 	u32 features = 0;
diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index 1dbee95..56d7895 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -660,7 +660,7 @@ static void virtio_ccw_reset(struct virtio_device *vdev)
 	kfree(ccw);
 }
 
-static u32 virtio_ccw_get_features(struct virtio_device *vdev)
+static u64 virtio_ccw_get_features(struct virtio_device *vdev)
 {
 	struct virtio_ccw_device *vcdev = to_vc_device(vdev);
 	struct virtio_feature_desc *features;
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 2b9aafb..746d350 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -159,7 +159,7 @@ static int virtio_dev_probe(struct device *_d)
 	int err, i;
 	struct virtio_device *dev = dev_to_virtio(_d);
 	struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
-	u32 device_features;
+	u64 device_features;
 
 	/* We have a driver! */
 	add_status(dev, VIRTIO_CONFIG_S_DRIVER);
@@ -171,14 +171,14 @@ static int virtio_dev_probe(struct device *_d)
 	dev->features = 0;
 	for (i = 0; i < drv->feature_table_size; i++) {
 		unsigned int f = drv->feature_table[i];
-		BUG_ON(f >= 32);
-		if (device_features & (1 << f))
+		BUG_ON(f >= 64);
+		if (device_features & (1ULL << f))
 			__virtio_set_bit(dev, f);
 	}
 
 	/* Transport features always preserved to pass to finalize_features. */
 	for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++)
-		if (device_features & (1 << i))
+		if (device_features & (1ULL << i))
 			__virtio_set_bit(dev, i);
 
 	dev->config->finalize_features(dev);
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index eb5b0e2..c63d0ef 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -142,7 +142,7 @@ struct virtio_mmio_vq_info {
 
 /* Configuration interface */
 
-static u32 vm_get_features(struct virtio_device *vdev)
+static u64 vm_get_features(struct virtio_device *vdev)
 {
 	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
 
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index ab95a4c..80be24a 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -102,7 +102,7 @@ static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev)
 }
 
 /* virtio config->get_features() implementation */
-static u32 vp_get_features(struct virtio_device *vdev)
+static u64 vp_get_features(struct virtio_device *vdev)
 {
 	struct virtio_pci_device *vp_dev = to_vp_device(vdev);
 
-- 
MST

  parent reply	other threads:[~2014-11-27 20:07 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1417118789-18231-1-git-send-email-mst@redhat.com>
2014-11-27 20:07 ` [PATCH v6 01/46] virtio: add low-level APIs for feature bits Michael S. Tsirkin
2014-11-28 10:02   ` Cornelia Huck
2014-11-29 17:30     ` Michael S. Tsirkin
2014-11-28 12:10   ` David Hildenbrand
2014-11-29 17:32     ` Michael S. Tsirkin
2014-11-27 20:07 ` [PATCH v6 02/46] virtio: use u32, not bitmap for features Michael S. Tsirkin
2014-11-28 12:44   ` Cornelia Huck
2014-11-29 17:34     ` Michael S. Tsirkin
2014-11-27 20:07 ` Michael S. Tsirkin [this message]
2014-11-28  8:52   ` [PATCH v6 04/46] virtio: add support for 64 bit features David Hildenbrand
2014-11-28 12:47   ` Cornelia Huck
2014-11-27 20:08 ` [PATCH v6 05/46] virtio: assert 32 bit features in transports Michael S. Tsirkin
2014-11-28  8:54   ` David Hildenbrand
2014-11-28 12:50   ` Cornelia Huck
2014-11-27 20:08 ` [PATCH v6 07/46] virtio: add virtio 1.0 feature bit Michael S. Tsirkin
2014-11-27 20:08 ` [PATCH v6 08/46] virtio: memory access APIs Michael S. Tsirkin
2014-11-27 20:08 ` [PATCH v6 09/46] virtio_ring: switch to new " Michael S. Tsirkin
2014-11-27 20:08 ` [PATCH v6 10/46] virtio_config: endian conversion for v1.0 Michael S. Tsirkin
2014-11-27 20:08 ` [PATCH v6 11/46] virtio: allow transports to get avail/used addresses Michael S. Tsirkin
2014-11-27 20:08 ` [PATCH v6 12/46] virtio: set FEATURES_OK Michael S. Tsirkin
2014-11-27 20:08 ` [PATCH v6 13/46] virtio: simplify feature bit handling Michael S. Tsirkin
2014-11-27 20:08 ` [PATCH v6 14/46] virtio: add legacy feature table support Michael S. Tsirkin
2014-11-27 20:09 ` [PATCH v6 15/46] virtio_net: v1.0 endianness Michael S. Tsirkin
2014-11-27 20:09 ` [PATCH v6 16/46] virtio_blk: v1.0 support Michael S. Tsirkin
2014-11-27 20:09 ` [PATCH v6 21/46] virtio_blk: make serial attribute static Michael S. Tsirkin
2014-11-27 20:09 ` [PATCH v6 22/46] virtio_blk: fix race at module removal Michael S. Tsirkin
2014-11-27 20:09 ` [PATCH v6 23/46] virtio_net: pass vi around Michael S. Tsirkin
2014-11-27 20:09 ` [PATCH v6 24/46] virtio_net: get rid of virtio_net_hdr/skb_vnet_hdr Michael S. Tsirkin
2014-11-27 20:09 ` [PATCH v6 25/46] virtio_net: stricter short buffer length checks Michael S. Tsirkin
2014-11-28  8:31   ` Jason Wang
2014-11-27 20:10 ` [PATCH v6 26/46] virtio_net: bigger header when VERSION_1 is set Michael S. Tsirkin
2014-11-27 20:10 ` [PATCH v6 27/46] virtio_net: enable v1.0 support Michael S. Tsirkin
2014-11-27 20:10 ` [PATCH v6 28/46] vhost: make features 64 bit Michael S. Tsirkin
2014-11-28  8:32   ` Jason Wang
2014-11-27 20:10 ` [PATCH v6 29/46] vhost: add memory access wrappers Michael S. Tsirkin
2014-11-27 20:10 ` [PATCH v6 30/46] vhost/net: force len for TX to host endian Michael S. Tsirkin
2014-11-27 20:10 ` [PATCH v6 31/46] vhost: virtio 1.0 endian-ness support Michael S. Tsirkin
2014-11-27 20:10 ` [PATCH v6 32/46] vhost/net: virtio 1.0 byte swap Michael S. Tsirkin
2014-11-27 20:10 ` [PATCH v6 33/46] vhost/net: larger header for virtio 1.0 Michael S. Tsirkin
2014-11-27 20:10 ` [PATCH v6 34/46] virtio_net: disable mac write " Michael S. Tsirkin
2014-11-27 20:10 ` [PATCH v6 35/46] vhost/net: enable " Michael S. Tsirkin
2014-11-27 20:10 ` [PATCH v6 36/46] vhost/net: suppress compiler warning Michael S. Tsirkin
2014-11-27 20:11 ` [PATCH v6 42/46] virtio_scsi: v1.0 support Michael S. Tsirkin
2014-11-27 20:11 ` [PATCH v6 44/46] virtio_scsi: export to userspace Michael S. Tsirkin
2014-11-27 20:11 ` [PATCH v6 45/46] vhost/scsi: partial virtio 1.0 support Michael S. Tsirkin
     [not found] ` <1417118789-18231-25-git-send-email-mst@redhat.com>
2014-11-28  8:30   ` [PATCH v6 24/46] virtio_net: get rid of virtio_net_hdr/skb_vnet_hdr Jason Wang
     [not found] ` <1417118789-18231-27-git-send-email-mst@redhat.com>
2014-11-28  8:31   ` [PATCH v6 26/46] virtio_net: bigger header when VERSION_1 is set Jason Wang
     [not found] ` <1417118789-18231-30-git-send-email-mst@redhat.com>
2014-11-28  8:35   ` [PATCH v6 29/46] vhost: add memory access wrappers Jason Wang
     [not found] ` <1417118789-18231-31-git-send-email-mst@redhat.com>
2014-11-28  8:36   ` [PATCH v6 30/46] vhost/net: force len for TX to host endian Jason Wang
     [not found] ` <1417118789-18231-34-git-send-email-mst@redhat.com>
2014-11-28  8:38   ` [PATCH v6 33/46] vhost/net: larger header for virtio 1.0 Jason Wang
     [not found] ` <1417118789-18231-35-git-send-email-mst@redhat.com>
2014-11-28  8:40   ` [PATCH v6 34/46] virtio_net: disable mac write " Jason Wang
2014-11-29 17:28     ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417118789-18231-5-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=dahi@linux.vnet.ibm.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=joel@jms.id.au \
    --cc=lguest@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux390@de.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=rusty@au1.ibm.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=thuth@linux.vnet.ibm.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=yshivakrishna@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).