raw/ioat: fix queue index calculation
PATCH 1/1 raw/ioat: fix queue index calculation
Coverity flags a possible problem where the 8-bit wq_idx value may have errors when shifted and sign-extended to 64-bits. Since this can only occur if the shift index is larger than any expected value from hardware, it's unlikely to cause any real problems, but we can eliminate any possible errors, and the coverity issue, by explicitly typecasting the uint8_t value to 64-bits before any shift operations occur.
Coverity issue: 363695
--- drivers/raw/ioat/idxd_pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/raw/ioat/idxd_pci.c +2 -1
@@ -47,7 +47,8 @@ idxd_pci_dev_command(struct idxd_rawdev *idxd, enum rte_idxd_cmds command)static uint32_t *idxd_get_wq_cfg (struct idxd_pci_common *pci,uint8_t wq_idx) { -return RTE_PTR_ADD (pci->wq_regs_base, wq_idx << (5 + pci->wq_cfg_sz)); +return RTE_PTR_ADD (pci->wq_regs_base, + (uint64_t )wq_idx << (5 + pci->wq_cfg_sz)); } static int
Signature · 1 line
2.25.1
Thomas Monjalon
Applied03/11/2020 15:48, Bruce Richardson:
Quoted 11 lines
Coverity flags a possible problem where the 8-bit
wq_idxvalue may have errors when shifted and sign-extended to 64-bits. Since this can only occur if the shift index is larger than any expected value from hardware, it's unlikely to cause any real problems, but we can eliminate any possible errors, and the coverity issue, by explicitly typecasting theuint8_tvalue to 64-bits before any shift operations occur.Coverity issue: 363695
Fixes a33969462135 ("raw/ioat: fix work-queue config size")Signed-off-by Bruce Richardson <[email protected]>
Applied, thanks
03/11/2020 21:21, Thomas Monjalon:
Quoted 8 lines
03/11/2020 15:48, Bruce Richardson:
Quoted 7 lines
Coverity flags a possible problem where the 8-bit
wq_idxvalue may have errors when shifted and sign-extended to 64-bits. Since this can only occur if the shift index is larger than any expected value from hardware, it's unlikely to cause any real problems, but we can eliminate any possible errors, and the coverity issue, by explicitly typecasting theuint8_tvalue to 64-bits before any shift operations occur.
Quoted 6 lines
Quoted 4 lines
Coverity issue: 363695
Fixes a33969462135 ("raw/ioat: fix work-queue config size")Signed-off-by Bruce Richardson <[email protected]>Applied, thanks
Actually no, sorry for the confusion, there is a build issue with 32-bit compiler:
error: cast to pointer from integer of different size
(thanks David for the heads up)
Quoted 14 lines · Thomas Monjalon
03/11/2020 21:21, Thomas Monjalon:
Quoted 13 lines
03/11/2020 15:48, Bruce Richardson:
Quoted 11 lines
Coverity flags a possible problem where the 8-bit
wq_idxvalue may have errors when shifted and sign-extended to 64-bits. Since this can only occur if the shift index is larger than any expected value from hardware, it's unlikely to cause any real problems, but we can eliminate any possible errors, and the coverity issue, by explicitly typecasting theuint8_tvalue to 64-bits before any shift operations occur.Coverity issue: 363695
Fixes a33969462135 ("raw/ioat: fix work-queue config size")Signed-off-by Bruce Richardson <[email protected]>
Quoted 8 lines
Quoted 1 line
Applied, thanks
Actually no, sorry for the confusion, there is a build issue with 32-bit compiler:
error: cast to pointer from integer of different size(thanks David for the heads up)
Ok, thanks for heads-up, I'll see about a v2.
PATCH v2 1/1 raw/ioat: fix queue index calculation
In reply to Bruce RichardsonCoverity flags a possible problem where the 8-bit wq_idx value may have errors when shifted and sign-extended to pointer size. Since this can only occur if the shift index is larger than any expected value from hardware, it's unlikely to cause any real problems, but we can eliminate any possible errors, and the coverity issue, by explicitly typecasting the uint8_t value to uintptr_t before any shift operations occur.
Coverity issue: 363695
---
V2: Change uint64_t cast to uintptr_t to prevent 32-bit build issues
--- drivers/raw/ioat/idxd_pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/raw/ioat/idxd_pci.c +2 -1
@@ -47,7 +47,8 @@ idxd_pci_dev_command(struct idxd_rawdev *idxd, enum rte_idxd_cmds command)static uint32_t *idxd_get_wq_cfg (struct idxd_pci_common *pci,uint8_t wq_idx) { -return RTE_PTR_ADD (pci->wq_regs_base, wq_idx << (5 + pci->wq_cfg_sz)); +return RTE_PTR_ADD (pci->wq_regs_base, + (uintptr_t )wq_idx << (5 + pci->wq_cfg_sz)); } static int
Signature · 1 line
2.25.1
Thomas Monjalon
Applied05/11/2020 11:41, Bruce Richardson:
Quoted 11 lines
Coverity flags a possible problem where the 8-bit
wq_idxvalue may have errors when shifted and sign-extended to pointer size. Since this can only occur if the shift index is larger than any expected value from hardware, it's unlikely to cause any real problems, but we can eliminate any possible errors, and the coverity issue, by explicitly typecasting theuint8_tvalue touintptr_tbefore any shift operations occur.Coverity issue: 363695
Fixes a33969462135 ("raw/ioat: fix work-queue config size")Signed-off-by Bruce Richardson <[email protected]>
Applied, thanks