DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] raw/ioat: fix queue index calculation
@ 2020-11-03 14:48 Bruce Richardson
  2020-11-03 20:21 ` Thomas Monjalon
  2020-11-05 10:41 ` [dpdk-dev] [PATCH v2] " Bruce Richardson
  0 siblings, 2 replies; 6+ messages in thread
From: Bruce Richardson @ 2020-11-03 14:48 UTC (permalink / raw)
  To: dev; +Cc: kevin.laatz, Bruce Richardson

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
Fixes: a33969462135 ("raw/ioat: fix work-queue config size")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/raw/ioat/idxd_pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/raw/ioat/idxd_pci.c b/drivers/raw/ioat/idxd_pci.c
index 99ecfbbb4..7bc125014 100644
--- a/drivers/raw/ioat/idxd_pci.c
+++ b/drivers/raw/ioat/idxd_pci.c
@@ -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
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] raw/ioat: fix queue index calculation
  2020-11-03 14:48 [dpdk-dev] [PATCH] raw/ioat: fix queue index calculation Bruce Richardson
@ 2020-11-03 20:21 ` Thomas Monjalon
  2020-11-03 21:51   ` Thomas Monjalon
  2020-11-05 10:41 ` [dpdk-dev] [PATCH v2] " Bruce Richardson
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2020-11-03 20:21 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, kevin.laatz

03/11/2020 15:48, Bruce Richardson:
> 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
> Fixes: a33969462135 ("raw/ioat: fix work-queue config size")
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] raw/ioat: fix queue index calculation
  2020-11-03 20:21 ` Thomas Monjalon
@ 2020-11-03 21:51   ` Thomas Monjalon
  2020-11-04  9:43     ` Bruce Richardson
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2020-11-03 21:51 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, kevin.laatz, david.marchand

03/11/2020 21:21, Thomas Monjalon:
> 03/11/2020 15:48, Bruce Richardson:
> > 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
> > Fixes: a33969462135 ("raw/ioat: fix work-queue config size")
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> 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)



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] raw/ioat: fix queue index calculation
  2020-11-03 21:51   ` Thomas Monjalon
@ 2020-11-04  9:43     ` Bruce Richardson
  0 siblings, 0 replies; 6+ messages in thread
From: Bruce Richardson @ 2020-11-04  9:43 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, kevin.laatz, david.marchand

On Tue, Nov 03, 2020 at 10:51:17PM +0100, Thomas Monjalon wrote:
> 03/11/2020 21:21, Thomas Monjalon:
> > 03/11/2020 15:48, Bruce Richardson:
> > > 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
> > > Fixes: a33969462135 ("raw/ioat: fix work-queue config size")
> > > 
> > > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > 
> > 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2] raw/ioat: fix queue index calculation
  2020-11-03 14:48 [dpdk-dev] [PATCH] raw/ioat: fix queue index calculation Bruce Richardson
  2020-11-03 20:21 ` Thomas Monjalon
@ 2020-11-05 10:41 ` Bruce Richardson
  2020-11-13 14:32   ` Thomas Monjalon
  1 sibling, 1 reply; 6+ messages in thread
From: Bruce Richardson @ 2020-11-05 10:41 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

Coverity 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
Fixes: a33969462135 ("raw/ioat: fix work-queue config size")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

---
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(-)

diff --git a/drivers/raw/ioat/idxd_pci.c b/drivers/raw/ioat/idxd_pci.c
index 99ecfbbb4..01623f33f 100644
--- a/drivers/raw/ioat/idxd_pci.c
+++ b/drivers/raw/ioat/idxd_pci.c
@@ -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
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] raw/ioat: fix queue index calculation
  2020-11-05 10:41 ` [dpdk-dev] [PATCH v2] " Bruce Richardson
@ 2020-11-13 14:32   ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2020-11-13 14:32 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

05/11/2020 11:41, Bruce Richardson:
> Coverity 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
> Fixes: a33969462135 ("raw/ioat: fix work-queue config size")
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-13 14:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 14:48 [dpdk-dev] [PATCH] raw/ioat: fix queue index calculation Bruce Richardson
2020-11-03 20:21 ` Thomas Monjalon
2020-11-03 21:51   ` Thomas Monjalon
2020-11-04  9:43     ` Bruce Richardson
2020-11-05 10:41 ` [dpdk-dev] [PATCH v2] " Bruce Richardson
2020-11-13 14:32   ` Thomas Monjalon

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git