net/virtio: remove address width limit for modern devices
PATCH 1/1 net/virtio: remove address width limit for modern devices
Modern devices don't have the same limitation as legacy devices, because vring addresses are not configured using a 32-bit register.
--- drivers/net/virtio/virtio_pci.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
drivers/net/virtio/virtio_pci.c +8 -20
@@ -33,22 +33,6 @@struct virtio_pci_internal virtio_pci_internal[RTE_MAX_ETHPORTS ]; -static inline int -check_vq_phys_addr_ok (struct virtqueue *vq) -{ -/* Virtio PCI device VIRTIO_PCI_QUEUE_PF register is 32bit, -* and only accepts 32 bit page frame number. -* Check if the allocated physical memory exceeds 16TB. -*/ -if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> - (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { -PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!" ); -return 0 ; - } - -return 1 ; -} -#define PCI_MSIX_ENABLE 0x8000 static enum virtio_msix_status
@@ -273,8 +257,15 @@ legacy_setup_queue(struct virtio_hw *hw, struct virtqueue *vq) {uint32_t src; -if (!check_vq_phys_addr_ok (vq)) +/* Virtio PCI device VIRTIO_PCI_QUEUE_PFN register is 32bit, +* and only accepts 32 bit page frame number. +* Check if the allocated physical memory exceeds 16TB. +*/ +if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> + (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { +PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!" );return -1 ; + }rte_pci_ioport_write (VTPCI_IO (hw), &vq->vq_queue_index,2 ,VIRTIO_PCI_QUEUE_SEL );
@@ -476,9 +467,6 @@ modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)uint64_t desc_addr, avail_addr, used_addr;uint16_t notify_off; -if (!check_vq_phys_addr_ok (vq)) -return -1 ; - desc_addr = vq->vq_ring_mem; avail_addr = desc_addr + vq->vq_nentries *sizeof (struct vring_desc ); used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
Signature · 1 line
2.39.2
Hi David,
Quoted 3 lines · David Marchand
Modern devices don't have the same limitation as legacy devices, because vring addresses are not configured using a 32-bit register.
Do we want to backport it? This is a bug in my opinion.
Thanks!
Maxime
Quoted 59 lines
Signed-off-by David Marchand <[email protected]>--- drivers/net/virtio/virtio_pci.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)drivers/net/virtio/virtio_pci.c +8
-20@@ -33,22 +33,6 @@struct virtio_pci_internal virtio_pci_internal[RTE_MAX_ETHPORTS ]; -static inline int -check_vq_phys_addr_ok (struct virtqueue *vq) -{ -/* Virtio PCI device VIRTIO_PCI_QUEUE_PF register is 32bit, -* and only accepts 32 bit page frame number. -* Check if the allocated physical memory exceeds 16TB. -*/ -if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> - (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { -PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!" ); -return 0 ; - } - -return 1 ; -} -#define PCI_MSIX_ENABLE 0x8000 static enum virtio_msix_status@@ -273,8 +257,15 @@ legacy_setup_queue(struct virtio_hw *hw, struct virtqueue *vq) {uint32_t src; -if (!check_vq_phys_addr_ok (vq)) +/* Virtio PCI device VIRTIO_PCI_QUEUE_PFN register is 32bit, +* and only accepts 32 bit page frame number. +* Check if the allocated physical memory exceeds 16TB. +*/ +if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> + (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { +PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!" );return -1 ; + }rte_pci_ioport_write (VTPCI_IO (hw), &vq->vq_queue_index,2 ,VIRTIO_PCI_QUEUE_SEL );@@ -476,9 +467,6 @@ modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)uint64_t desc_addr, avail_addr, used_addr;uint16_t notify_off; -if (!check_vq_phys_addr_ok (vq)) -return -1 ; - desc_addr = vq->vq_ring_mem; avail_addr = desc_addr + vq->vq_nentries *sizeof (struct vring_desc ); used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
Quoted 9 lines · Maxime Coquelin
Hi David,
Quoted 3 lines · David Marchand
Modern devices don't have the same limitation as legacy devices, because vring addresses are not configured using a 32-bit register.
Do we want to backport it? This is a bug in my opinion.
I wonder, this is the first time we see some report about this issue. I'd like to first get more details from Andy who reported this issue, like in which setup / condition this problem was caught.
Signature · 1 line
David Marchand
Hi David,
The case is just want to enable ASAN to scan customer developed code.
Quoted 28 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, March 9, 2023 11:08 PM
To: Maxime Coquelin <[email protected]>
Cc: [email protected]; Pei, Andy <[email protected]>; Xia, Chenbo <[email protected]>
Subject: Re: [PATCH] net/virtio: remove address width limit for modern devicesQuoted 9 lines · Maxime Coquelin
Hi David,
Quoted 3 lines · David Marchand
Modern devices don't have the same limitation as legacy devices, because vring addresses are not configured using a 32-bit register.
Do we want to backport it? This is a bug in my opinion.
I wonder, this is the first time we see some report about this issue. I'd like to first get more details from Andy who reported this issue, like in which setup / condition this problem was caught.
--
David Marchand
HI
Quoted 71 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, March 9, 2023 10:36 PM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>
Subject: [PATCH] net/virtio: remove address width limit for modern devicesModern devices don't have the same limitation as legacy devices, because vring addresses are not configured using a 32-bit register.
Signed-off-by David Marchand <[email protected]>--- drivers/net/virtio/virtio_pci.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)drivers/net/virtio/virtio_pci.c +8
-16@@ -33,22 +33,6 @@struct virtio_pci_internal virtio_pci_internal[RTE_MAX_ETHPORTS ]; -static inline int -check_vq_phys_addr_ok(struct virtqueue *vq) -{ -/* Virtio PCI device VIRTIO_PCI_QUEUE_PF register is 32bit, -* and only accepts 32 bit page frame number. -* Check if the allocated physical memory exceeds 16TB. -*/ -if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> - (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { -PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!"); -return 0 ; - } - -return 1 ; -} -#define PCI_MSIX_ENABLE 0x8000 static enum virtio_msix_status@@ -273,8 +257,15 @@ legacy_setup_queue(struct virtio_hw *hw, struct virtqueue *vq) {uint32_t src; -if (!check_vq_phys_addr_ok (vq)) +/* Virtio PCI device VIRTIO_PCI_QUEUE_PFN register is 32bit, +* and only accepts 32 bit page frame number. +* Check if the allocated physical memory exceeds 16TB. +*/ +if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> + (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { +PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!");return -1 ; + } rte_pci_ioport_write(VTPCI_IO(hw), &vq->vq_queue_index, 2,drivers/net/virtio/virtio_pci.c +0
-3VIRTIO_PCI_QUEUE_SEL);@@ -476,9 +467,6 @@ modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)uint64_t desc_addr, avail_addr, used_addr;uint16_t notify_off; -if (!check_vq_phys_addr_ok (vq)) -return -1 ; - desc_addr = vq->vq_ring_mem; avail_addr = desc_addr + vq->vq_nentries *sizeof (struct vring_desc );
Quoted 3 lines
used_addr= RTE_ALIGN_CEIL(avail_addr + offsetof(structvring_avail,
--
2.39.2
Quoted 72 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, March 9, 2023 10:36 PM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>
Subject: [PATCH] net/virtio: remove address width limit for modern devicesModern devices don't have the same limitation as legacy devices, because vring addresses are not configured using a 32-bit register.
Signed-off-by David Marchand <[email protected]>--- drivers/net/virtio/virtio_pci.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)drivers/net/virtio/virtio_pci.c +8
-17@@ -33,22 +33,6 @@struct virtio_pci_internal virtio_pci_internal[RTE_MAX_ETHPORTS ]; -static inline int -check_vq_phys_addr_ok (struct virtqueue *vq) -{ -/* Virtio PCI device VIRTIO_PCI_QUEUE_PF register is 32bit, -* and only accepts 32 bit page frame number. -* Check if the allocated physical memory exceeds 16TB. -*/ -if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> - (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { -PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!" ); -return 0 ; - } - -return 1 ; -} -#define PCI_MSIX_ENABLE 0x8000 static enum virtio_msix_status@@ -273,8 +257,15 @@ legacy_setup_queue(struct virtio_hw *hw, struct virtqueue *vq) {uint32_t src; -if (!check_vq_phys_addr_ok (vq)) +/* Virtio PCI device VIRTIO_PCI_QUEUE_PFN register is 32bit, +* and only accepts 32 bit page frame number. +* Check if the allocated physical memory exceeds 16TB. +*/ +if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> + (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { +PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!" );return -1 ; + } rte_pci_ioport_write(VTPCI_IO(hw), &vq->vq_queue_index, 2,drivers/net/virtio/virtio_pci.c +0
-3VIRTIO_PCI_QUEUE_SEL);@@ -476,9 +467,6 @@ modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)uint64_t desc_addr, avail_addr, used_addr;uint16_t notify_off; -if (!check_vq_phys_addr_ok (vq)) -return -1 ; - desc_addr = vq->vq_ring_mem; avail_addr = desc_addr + vq->vq_nentries *sizeof (struct vring_desc );
Quoted 3 lines
used_addr= RTE_ALIGN_CEIL(avail_addr + offsetof(structvring_avail,
--
2.39.2
Agree that we should backport it.
PATCH v2 1/1 net/virtio: remove address width limit for modern devices
In reply to David MarchandModern devices don't have the same limitation as legacy devices, because vring addresses are not configured using a 32-bit register.
--- drivers/net/virtio/virtio_pci.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
drivers/net/virtio/virtio_pci.c +8 -20
@@ -33,22 +33,6 @@struct virtio_pci_internal virtio_pci_internal[RTE_MAX_ETHPORTS ]; -static inline int -check_vq_phys_addr_ok (struct virtqueue *vq) -{ -/* Virtio PCI device VIRTIO_PCI_QUEUE_PF register is 32bit, -* and only accepts 32 bit page frame number. -* Check if the allocated physical memory exceeds 16TB. -*/ -if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> - (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { -PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!" ); -return 0 ; - } - -return 1 ; -} -#define PCI_MSIX_ENABLE 0x8000 static enum virtio_msix_status
@@ -273,8 +257,15 @@ legacy_setup_queue(struct virtio_hw *hw, struct virtqueue *vq) {uint32_t src; -if (!check_vq_phys_addr_ok (vq)) +/* Virtio PCI device VIRTIO_PCI_QUEUE_PFN register is 32bit, +* and only accepts 32 bit page frame number. +* Check if the allocated physical memory exceeds 16TB. +*/ +if ((vq->vq_ring_mem + vq->vq_ring_size -1 ) >> + (VIRTIO_PCI_QUEUE_ADDR_SHIFT +32 )) { +PMD_INIT_LOG (ERR ,"vring address shouldn't be above 16TB!" );return -1 ; + }rte_pci_ioport_write (VTPCI_IO (hw), &vq->vq_queue_index,2 ,VIRTIO_PCI_QUEUE_SEL );
@@ -476,9 +467,6 @@ modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)uint64_t desc_addr, avail_addr, used_addr;uint16_t notify_off; -if (!check_vq_phys_addr_ok (vq)) -return -1 ; - desc_addr = vq->vq_ring_mem; avail_addr = desc_addr + vq->vq_nentries *sizeof (struct vring_desc ); used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
Signature · 1 line
2.39.2
Maxime Coquelin
AppliedQuoted 6 lines · David Marchand
Modern devices don't have the same limitation as legacy devices, because vring addresses are not configured using a 32-bit register.
Fixes 6ba1f63b5ab0 ("virtio: support specification 1.0")
Quoted 8 lines
Signed-off-by David Marchand <[email protected]>Reviewed-by Maxime Coquelin <[email protected]>Acked-by Andy Pei <[email protected]>Reviewed-by Chenbo Xia <[email protected]>--- drivers/net/virtio/virtio_pci.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
Applied to dpdk-next-virtio/main.
Thanks,
Maxime