baseband: fix segfault in Intel drivers
cover baseband: fix segfault in Intel drivers
This series fixes segfaults in fpga_5gnr_fec and fpga_lte_fec drivers when bbdev debug is enabled.
Maxime Coquelin (2):
baseband/fpga_5gnr_fec: fix segfaults with debug baseband/fpga_lte_fec: fix segfaults with debug
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 ++-- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 baseband/fpga_5gnr_fec: fix segfaults with debug
When RTE_LIBRTE_BBDEV_DEBUG is enabled, rte_device's driver pointer is dereferenced twice in fpga_5gnr_fec's probe callback. It causes a segmentation fault because this pointer is only assigned after probe callback call.
This patch makes use of rte_pci_driver pointer instead.
--- drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +2 -2
@@ -1839,7 +1839,7 @@ fpga_5gnr_fec_init(struct rte_bbdev *dev, struct rte_pci_driver *drv)rte_bbdev_log_debug ("Init device %s [%s] @ virtaddr %p phyaddr %#" PRIx64, - dev->device->driver->name, dev->data->name, + drv->driver.name, dev->data->name, (void *)pci_dev->mem_resource[0 ].addr, pci_dev->mem_resource[0 ].phys_addr); }
@@ -1895,7 +1895,7 @@ fpga_5gnr_fec_probe(struct rte_pci_driver *pci_drv, ((uint16_t)(version_id >> 16)), ((uint16_t)version_id));#ifdef RTE_LIBRTE_BBDEV_DEBUG -if (!strcmp (bbdev->device->driver->name, +if (!strcmp (pci_drv->driver.name,RTE_STR (FPGA_5GNR_FEC_PF_DRIVER_NAME )))print_static_reg_debug_info (d->mmio_base);#endif
Signature · 1 line
2.26.2
Re: [dpdk-dev] [PATCH 1/2] baseband/fpga_5gnr_fec: fix segfaults with debug
Thanks Maxime
I am not totally sure that this actually got broken in the very commit you point to (I think that there was another pci generic commit which changed the assumption when this pointer was set), but it doesn't harm to change anyway for stable build. Note this is already like this in the new PMD acc100.
Quoted 39 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, October 6, 2020 3:04 AM
To: [email protected]; [email protected]; Chautru, Nicolas <[email protected]>; [email protected]
Cc: Maxime Coquelin <[email protected]>
Subject: [PATCH 1/2] baseband/fpga_5gnr_fec: fix segfaults with debugWhen
RTE_LIBRTE_BBDEV_DEBUGis enabled, rte_device's driver pointer is dereferenced twice in fpga_5gnr_fec's probe callback.
It causes a segmentation fault because this pointer is only assigned after probe callback call.This patch makes use of
rte_pci_driverpointer instead.Fixes 0b5927cbcba7 ("baseband/fpga_5gnr_fec: add PMD for FPGA 5GNRFEC")
Signed-off-by Maxime Coquelin <[email protected]>--- drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +1
-1@@ -1839,7 +1839,7 @@ fpga_5gnr_fec_init(struct rte_bbdev *dev, struct rte_pci_driver *drv) rte_bbdev_log_debug("Init device %s [%s] @ virtaddr %p phyaddr %#" PRIx64, - dev->device->driver->name, dev->data->name, + drv->driver.name, dev->data->name, (void *)pci_dev->mem_resource[0 ].addr, pci_dev->mem_resource[0].phys_addr);}
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c fpga_5gnr_fec_probe(struct rte_pci_driver *pci_drv, · line 1898
Quoted 5 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +1
-1@@ -1895,7 +1895,7 @@ fpga_5gnr_fec_probe(struct rte_pci_driver *pci_drv, ((uint16_t)(version_id >> 16)), ((uint16_t)version_id)); #ifdef RTE_LIBRTE_BBDEV_DEBUG - if (!strcmp(bbdev->device->driver->name, + if (!strcmp(pci_drv->driver.name,
Why do you have to change this one?
Quoted 5 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +0
-1RTE_STR(FPGA_5GNR_FEC_PF_DRIVER_NAME)))print_static_reg_debug_info (d->mmio_base);#endif --2.26.2
Re: [dpdk-dev] [PATCH 1/2] baseband/fpga_5gnr_fec: fix segfaults with debug
Hi Nicolas,
Quoted 3 lines · Nicolas
Thanks Maxime
I am not totally sure that this actually got broken in the very commit you point to (I think that there was another pci generic commit which changed the assumption when this pointer was set), but it doesn't harm to change anyway for stable build. Note this is already like this in the new PMD acc100.
For fpga_5gnr_fec, we reproduced the issue with v20.05, which was the version the driver was introduced.
For fpga_lte_fec, it seems to be the same. The driver was in introduced in v19.08, and dev->device.driver was also assigned after driver's probe callback is called:
http://code.dpdk.org/dpdk/v19.08/source/drivers/bus/pci/pci_common.c#L212
Thanks,
Maxime
Quoted 57 lines
Acked-by Nicolas Chautru <[email protected]>Quoted 39 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, October 6, 2020 3:04 AM
To: [email protected]; [email protected]; Chautru, Nicolas <[email protected]>; [email protected]
Cc: Maxime Coquelin <[email protected]>
Subject: [PATCH 1/2] baseband/fpga_5gnr_fec: fix segfaults with debugWhen
RTE_LIBRTE_BBDEV_DEBUGis enabled, rte_device's driver pointer is dereferenced twice in fpga_5gnr_fec's probe callback.
It causes a segmentation fault because this pointer is only assigned after probe callback call.This patch makes use of
rte_pci_driverpointer instead.Fixes 0b5927cbcba7 ("baseband/fpga_5gnr_fec: add PMD for FPGA 5GNRFEC")
Signed-off-by Maxime Coquelin <[email protected]>--- drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +1
-1@@ -1839,7 +1839,7 @@ fpga_5gnr_fec_init(struct rte_bbdev *dev, struct rte_pci_driver *drv) rte_bbdev_log_debug("Init device %s [%s] @ virtaddr %p phyaddr %#" PRIx64, - dev->device->driver->name, dev->data->name, + drv->driver.name, dev->data->name, (void *)pci_dev->mem_resource[0 ].addr, pci_dev->mem_resource[0].phys_addr);}
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c fpga_5gnr_fec_probe(struct rte_pci_driver *pci_drv, · line 1898
Quoted 5 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +1
-1@@ -1895,7 +1895,7 @@ fpga_5gnr_fec_probe(struct rte_pci_driver *pci_drv, ((uint16_t)(version_id >> 16)), ((uint16_t)version_id)); #ifdef RTE_LIBRTE_BBDEV_DEBUG - if (!strcmp(bbdev->device->driver->name, + if (!strcmp(pci_drv->driver.name,Why do you have to change this one?
Acked-by Nicolas Chautru <[email protected]>Quoted 5 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +0
-1RTE_STR(FPGA_5GNR_FEC_PF_DRIVER_NAME)))print_static_reg_debug_info (d->mmio_base);#endif --2.26.2
Re: [dpdk-dev] [PATCH 1/2] baseband/fpga_5gnr_fec: fix segfaults with debug
Hi Maxime,
Quoted 20 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, October 6, 2020 9:34 AM
To: Chautru, Nicolas <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] baseband/fpga_5gnr_fec: fix segfaults with debugHi Nicolas,
Quoted 2 lines · Nicolas
Thanks Maxime
I am not totally sure that this actually got broken in the very commit youpoint to (I think that there was another pci generic commit which changed the assumption when this pointer was set), but it doesn't harm to change anyway for stable build.
Quoted 1 line
Note this is already like this in the new PMD acc100.
For
fpga_5gnr_fec, we reproduced the issue with v20.05, which was the version the driver was introduced.
Quoted 6 lines
For
fpga_lte_fec, it seems to be the same. The driver was in introduced in v19.08, anddev->device.driverwas also assigned after driver's probe callback is called:http://code.dpdk.org/dpdk/v19.08/source/drivers/bus/pci/pci_common.c#L
212
OK Thanks you are right. The change moving the driver assignment to end of probing was done in parallel prior to the formal upstreaming of these drivers.
Quoted 63 lines
Thanks,
MaximeQuoted 33 lines
Acked-by Nicolas Chautru <[email protected]>Quoted 31 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Tuesday, October 6, 2020 3:04 AM
To: [email protected]; [email protected]; Chautru, Nicolas <[email protected]>; [email protected]
Cc: Maxime Coquelin <[email protected]>
Subject: [PATCH 1/2] baseband/fpga_5gnr_fec: fix segfaults with debugWhen
RTE_LIBRTE_BBDEV_DEBUGis enabled, rte_device's driver pointer is dereferenced twice in fpga_5gnr_fec's probe callback. It causes a segmentation fault because this pointer is only assigned after probe callback call.This patch makes use of
rte_pci_driverpointer instead.Fixes 0b5927cbcba7 ("baseband/fpga_5gnr_fec: add PMD for FPGA 5GNRFEC")
Signed-off-by Maxime Coquelin <[email protected]>--- drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +0
-0@@ -1839,7 +1839,7 @@ fpga_5gnr_fec_init(struct rte_bbdev *dev, struct rte_pci_driver *drv)Quoted 2 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c fpga_5gnr_fec_init(struct rte_bbdev *dev, · line 1842
Quoted 2 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +0
-0rte_bbdev_log_debug( "Init device %s [%s] @ virtaddr %p phyaddr%#"PRIx64,
Quoted 6 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c fpga_5gnr_fec_probe(struct rte_pci_driver
Quoted 6 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +1
-1- dev->device->driver->name, dev->data->name, + drv->driver.name, dev->data->name, (void *)pci_dev->mem_resource[0 ].addr, pci_dev->mem_resource[0].phys_addr);}
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +0
-0@@ -1895,7 +1895,7 @@ fpga_5gnr_fec_probe(struct rte_pci_driver
*pci_drv,Quoted 16 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c fpga_5gnr_fec_probe(struct rte_pci_driver *pci_drv, · line 1898
Quoted 5 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +1
-1((uint16_t)(version_id >> 16)), ((uint16_t)version_id)); #ifdef RTE_LIBRTE_BBDEV_DEBUG - if (!strcmp(bbdev->device->driver->name, + if (!strcmp(pci_drv->driver.name,Why do you have to change this one?
Acked-by Nicolas Chautru <[email protected]>Quoted 5 lines
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c +0
-1RTE_STR(FPGA_5GNR_FEC_PF_DRIVER_NAME)))print_static_reg_debug_info (d->mmio_base);#endif --2.26.2
PATCH 2/2 baseband/fpga_lte_fec: fix segfaults with debug
In reply to Maxime CoquelinWhen RTE_LIBRTE_BBDEV_DEBUG is enabled, rte_device's driver pointer is dereferenced twice in fpga_lte_fec's probe callback. It causes a segmentation fault because this pointer is only assigned after probe callback call.
This patch makes use of rte_pci_driver pointer instead
--- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/baseband/fpga_lte_fec/fpga_lte_fec.c +2 -2
@@ -2328,7 +2328,7 @@ fpga_lte_fec_init(struct rte_bbdev *dev, struct rte_pci_driver *drv)rte_bbdev_log_debug ("Init device %s [%s] @ virtaddr %p phyaddr %#" PRIx64, - dev->device->driver->name, dev->data->name, + drv->driver.name, dev->data->name, (void *)pci_dev->mem_resource[0 ].addr, pci_dev->mem_resource[0 ].phys_addr); }
@@ -2383,7 +2383,7 @@ fpga_lte_fec_probe(struct rte_pci_driver *pci_drv, ((uint16_t)(version_id >> 16)), ((uint16_t)version_id));#ifdef RTE_LIBRTE_BBDEV_DEBUG -if (!strcmp (bbdev->device->driver->name, +if (!strcmp (pci_drv->driver.name,RTE_STR (FPGA_LTE_FEC_PF_DRIVER_NAME )))print_static_reg_debug_info (d->mmio_base);#endif
Signature · 1 line
2.26.2
This change looks fine.
In looking at the surrounding code i see the is-pf bool being found by checking the driver name.
That is a fairly expensive check.
Is there a better way to do that ?
Tom
Quoted 11 lines · Maxime Coquelin
This series fixes segfaults in
fpga_5gnr_fecandfpga_lte_fecdrivers when bbdev debug is enabled.Maxime Coquelin (2):
baseband/fpga_5gnr_fec: fix segfaults with debug baseband/fpga_lte_fec: fix segfaults with debugdrivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 ++-- drivers/baseband/fpga_lte_fec/fpga_lte_fec.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
Akhil Goyal
AppliedQuoted 9 lines
Subject: [dpdk-dev] [PATCH 0/2] baseband: fix segfault in Intel drivers
This series fixes segfaults in
fpga_5gnr_fecandfpga_lte_fecdrivers when bbdev debug is enabled.Maxime Coquelin (2):
baseband/fpga_5gnr_fec: fix segfaults with debug baseband/fpga_lte_fec: fix segfaults with debug
Applied to dpdk-next-crypto
Thanks.