Skip to contentSkip to conversation

virtio: fix wrong features returned for legacy virtio

PATCH Applied Yuanhan Liu 5 participants 8 messages Mar 10, 2016 – Mar 14, 2016 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio: fix wrong features returned for legacy virtio

Declare dst as type uint32_t instead of uint64_t, otherwise, we will get a random upper 32 bit feature bits, as the following io port read reads lower 32 bit only. It could lead a feature bits that include VIRTIO_F_VERSION_1 (the 32th bit) for legacy virtio, which is obviously wrong.

Fixes b8f04520ad71 ("virtio: use PCI ioport API")
Cc David Marchand <[email protected]>
---
 drivers/net/virtio/virtio_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio/virtio_pci.c +1 -1
index 98fc370..c007959 100644
@@ -74,7 +74,7 @@ legacy_write_dev_config(struct virtio_hw *hw, size_t offset,
 static uint64_t
 legacy_get_features(struct virtio_hw *hw)
 {
-	uint64_t dst;
+	uint32_t dst;
 
 	rte_eal_pci_ioport_read(&hw->io, &dst, 4, VIRTIO_PCI_HOST_FEATURES);
 	return dst;
Signature · 1 line
1.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines · Yuanhan Liu

Declare dst as type uint32_t instead of uint64_t, otherwise, we will get a random upper 32 bit feature bits, as the following io port read reads lower 32 bit only. It could lead a feature bits that include VIRTIO_F_VERSION_1 (the 32th bit) for legacy virtio, which is obviously wrong.

Fixes b8f04520ad71 ("virtio: use PCI ioport API")
Cc David Marchand <[email protected]>
---
  drivers/net/virtio/virtio_pci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio/virtio_pci.c +0 -0
index 98fc370..c007959 100644

drivers/net/virtio/virtio_pci.c legacy_write_dev_config(struct virtio_hw *hw, size_t offset, · line 80

Quoted 8 lines
drivers/net/virtio/virtio_pci.c +1 -1
@@ -74,7 +74,7 @@ legacy_write_dev_config(struct virtio_hw *hw, size_t offset,
  static uint64_t
  legacy_get_features(struct virtio_hw *hw)
  {
-	uint64_t dst;
+	uint32_t dst;
 
  	rte_eal_pci_ioport_read(&hw->io, &dst, 4, VIRTIO_PCI_HOST_FEATURES);
  	return dst;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Yuanhan Liu
Quoted 9 lines · Yuanhan Liu

Declare dst as type uint32_t instead of uint64_t, otherwise, we will get a random upper 32 bit feature bits, as the following io port read reads lower 32 bit only. It could lead a feature bits that include VIRTIO_F_VERSION_1 (the 32th bit) for legacy virtio, which is obviously wrong.

Fixes b8f04520ad71 ("virtio: use PCI ioport API")
Cc David Marchand <[email protected]>

Argh, good catch.
Relooked at my patch, this should be the only bug (of this kind ;-)).

Signature · 1 line
David Marchand
#3 lore raw
Quoted 7 lines · David Marchand
Quoted 5 lines · Yuanhan Liu

Declare dst as type uint32_t instead of uint64_t, otherwise, we will get a random upper 32 bit feature bits, as the following io port read reads lower 32 bit only. It could lead a feature bits that include VIRTIO_F_VERSION_1 (the 32th bit) for legacy virtio, which is obviously wrong.

Quoted 7 lines
Quoted 4 lines
Fixes b8f04520ad71 ("virtio: use PCI ioport API")
Cc David Marchand <[email protected]>

Argh, good catch.
Relooked at my patch, this should be the only bug (of this kind ;-)).

Yes, I also have a check while making this patch.

	--yliu
Quoted 6 lines
Signature · 1 line
David Marchand
#4 lore raw
Quoted 13 lines · Yuanhan Liu
Quoted 12 lines · David Marchand
Quoted 9 lines · Yuanhan Liu

Declare dst as type uint32_t instead of uint64_t, otherwise, we will get a random upper 32 bit feature bits, as the following io port read reads lower 32 bit only. It could lead a feature bits that include VIRTIO_F_VERSION_1 (the 32th bit) for legacy virtio, which is obviously wrong.

Fixes b8f04520ad71 ("virtio: use PCI ioport API")
Cc David Marchand <[email protected]>
Quoted 12 lines
Quoted 2 lines

Argh, good catch.
Relooked at my patch, this should be the only bug (of this kind ;-)).

Yes, I also have a check while making this patch.

	--yliu
Quoted 6 lines
Signature · 1 line
David Marchand

Hi,

this patch no longer applies to dpdk-next-net/rel_16_04 branch due to changes in legacy_get_features function. Is it still needed? If so, please do a V2.

Regards,
/Bruce

#5 lore raw
Quoted 24 lines · Bruce Richardson
Quoted 23 lines · Yuanhan Liu
Quoted 7 lines · David Marchand
Quoted 5 lines · Yuanhan Liu

Declare dst as type uint32_t instead of uint64_t, otherwise, we will get a random upper 32 bit feature bits, as the following io port read reads lower 32 bit only. It could lead a feature bits that include VIRTIO_F_VERSION_1 (the 32th bit) for legacy virtio, which is obviously wrong.

Quoted 7 lines
Quoted 4 lines
Fixes b8f04520ad71 ("virtio: use PCI ioport API")
Cc David Marchand <[email protected]>

Argh, good catch.
Relooked at my patch, this should be the only bug (of this kind ;-)).

Yes, I also have a check while making this patch.

	--yliu
Quoted 4 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Signature · 1 line
David Marchand

Hi,

this patch no longer applies to dpdk-next-net/rel_16_04 branch due to changes in legacy_get_features function.

Hi Bruce,

It's a patch based on Thomas' tree. And this patch fixes an regression at there, too.

	--yliu
Quoted 4 lines

Is it still needed? If so, please do a V2.

Regards,
/Bruce

#6 lore raw
Quoted 32 lines · Yuanhan Liu
Quoted 24 lines · Bruce Richardson
Quoted 23 lines · Yuanhan Liu
Quoted 7 lines · David Marchand
Quoted 5 lines · Yuanhan Liu

Declare dst as type uint32_t instead of uint64_t, otherwise, we will get a random upper 32 bit feature bits, as the following io port read reads lower 32 bit only. It could lead a feature bits that include VIRTIO_F_VERSION_1 (the 32th bit) for legacy virtio, which is obviously wrong.

Quoted 7 lines
Quoted 4 lines
Fixes b8f04520ad71 ("virtio: use PCI ioport API")
Cc David Marchand <[email protected]>

Argh, good catch.
Relooked at my patch, this should be the only bug (of this kind ;-)).

Yes, I also have a check while making this patch.

	--yliu
Quoted 4 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Signature · 1 line
David Marchand

Hi,

this patch no longer applies to dpdk-next-net/rel_16_04 branch due to changes in legacy_get_features function.

Quoted 7 lines

Hi Bruce,

It's a patch based on Thomas' tree. And this patch fixes an regression at there, too.

	--yliu

Ok, thanks for the info.
Thomas, I'm delegating this patch to you in patchwork to apply to your tree.

/Bruce

#7 lore raw
In reply to David Marchand

2016-03-10 08:43, David Marchand:

Quoted 9 lines
Quoted 7 lines · Yuanhan Liu

Declare dst as type uint32_t instead of uint64_t, otherwise, we will get a random upper 32 bit feature bits, as the following io port read reads lower 32 bit only. It could lead a feature bits that include VIRTIO_F_VERSION_1 (the 32th bit) for legacy virtio, which is obviously wrong.

Fixes b8f04520ad71 ("virtio: use PCI ioport API")
Quoted 7 lines
Quoted 2 lines
Cc David Marchand <[email protected]>

Argh, good catch.
Relooked at my patch, this should be the only bug (of this kind ;-)).

Applied, thanks