mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH rdma-next 1/2] RDMA/ionic: Fix build failure on SPARC due to xchg() operand size
@ 2025-09-19 12:13 Abhijit Gangurde
  2025-09-19 12:13 ` [PATCH rdma-next 2/2] RDMA/ionic: Use ether_addr_copy instead of memcpy Abhijit Gangurde
  2025-09-21 11:32 ` [PATCH rdma-next 1/2] RDMA/ionic: Fix build failure on SPARC due to xchg() operand size Leon Romanovsky
  0 siblings, 2 replies; 3+ messages in thread
From: Abhijit Gangurde @ 2025-09-19 12:13 UTC (permalink / raw)
  To: jgg, leon; +Cc: allen.hubbe, linux-rdma, linux-kernel, Abhijit Gangurde

xchg() is used to safely handle the event queue arming.
However SPARC xchg operates only 4B of variable.
Change variable type from bool to int.

Unverified Error/Warning (likely false positive, kindly check if interested):

    ERROR: modpost: "__xchg_called_with_bad_pointer" [drivers/infiniband/hw/ionic/ionic_rdma.ko] undefined!

Error/Warning ids grouped by kconfigs:

recent_errors
`-- sparc-allmodconfig
    `-- ERROR:__xchg_called_with_bad_pointer-drivers-infiniband-hw-ionic-ionic_rdma.ko-undefined

Fixes: f3bdbd42702c ("RDMA/ionic: Create device queues to support admin operations")
Reported-by: Leon Romanovsky <leon@kernel.org>
Closes: https://lore.kernel.org/lkml/20250918180750.GA135135@unreal/
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
 drivers/infiniband/hw/ionic/ionic_admin.c | 8 ++++----
 drivers/infiniband/hw/ionic/ionic_ibdev.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/ionic/ionic_admin.c b/drivers/infiniband/hw/ionic/ionic_admin.c
index 1ba7a8ecc073..d9221ef134c4 100644
--- a/drivers/infiniband/hw/ionic/ionic_admin.c
+++ b/drivers/infiniband/hw/ionic/ionic_admin.c
@@ -945,7 +945,7 @@ static void ionic_poll_eq_work(struct work_struct *work)
 				   npolled, 0);
 		queue_work(ionic_evt_workq, &eq->work);
 	} else {
-		xchg(&eq->armed, true);
+		xchg(&eq->armed, 1);
 		ionic_intr_credits(eq->dev->lif_cfg.intr_ctrl, eq->intr,
 				   0, IONIC_INTR_CRED_UNMASK);
 	}
@@ -954,10 +954,10 @@ static void ionic_poll_eq_work(struct work_struct *work)
 static irqreturn_t ionic_poll_eq_isr(int irq, void *eqptr)
 {
 	struct ionic_eq *eq = eqptr;
-	bool was_armed;
+	int was_armed;
 	u32 npolled;
 
-	was_armed = xchg(&eq->armed, false);
+	was_armed = xchg(&eq->armed, 0);
 
 	if (unlikely(!eq->enable) || !was_armed)
 		return IRQ_HANDLED;
@@ -968,7 +968,7 @@ static irqreturn_t ionic_poll_eq_isr(int irq, void *eqptr)
 				   npolled, 0);
 		queue_work(ionic_evt_workq, &eq->work);
 	} else {
-		xchg(&eq->armed, true);
+		xchg(&eq->armed, 1);
 		ionic_intr_credits(eq->dev->lif_cfg.intr_ctrl, eq->intr,
 				   0, IONIC_INTR_CRED_UNMASK);
 	}
diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h
index b7a1a57bae03..82fda1e3cdb6 100644
--- a/drivers/infiniband/hw/ionic/ionic_ibdev.h
+++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h
@@ -126,7 +126,7 @@ struct ionic_eq {
 
 	struct ionic_queue	q;
 
-	bool			armed;
+	int			armed;
 	bool			enable;
 
 	struct work_struct	work;
-- 
2.43.0


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

* [PATCH rdma-next 2/2] RDMA/ionic: Use ether_addr_copy instead of memcpy
  2025-09-19 12:13 [PATCH rdma-next 1/2] RDMA/ionic: Fix build failure on SPARC due to xchg() operand size Abhijit Gangurde
@ 2025-09-19 12:13 ` Abhijit Gangurde
  2025-09-21 11:32 ` [PATCH rdma-next 1/2] RDMA/ionic: Fix build failure on SPARC due to xchg() operand size Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Abhijit Gangurde @ 2025-09-19 12:13 UTC (permalink / raw)
  To: jgg, leon; +Cc: allen.hubbe, linux-rdma, linux-kernel, Abhijit Gangurde

eth header from ib_ud_header structure packs the mac
into 4B high and 2B low parts. But when 4B high is used
in memcpy, it sees it as overflow. However, this is safe
due to the 4B high and 2B low arrangement in the structure.
To avoid the memcpy warning, use ether_addr_copy to copy
the mac address.

In function ‘fortify_memcpy_chk’,
    inlined from ‘ionic_set_ah_attr.isra’ at drivers/infiniband/hw/ionic/ionic_controlpath.c:609:3:
./include/linux/fortify-string.h:580:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
  580 |                         __read_overflow2_field(q_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:287: drivers/infiniband/hw/ionic/ionic_controlpath.o] Error 1
make[5]: *** [scripts/Makefile.build:556: drivers/infiniband/hw/ionic] Error 2
make[5]: *** Waiting for unfinished jobs....
make[4]: *** [scripts/Makefile.build:556: drivers/infiniband/hw] Error 2
make[3]: *** [scripts/Makefile.build:556: drivers/infiniband] Error 2
make[2]: *** [scripts/Makefile.build:556: drivers] Error 2
make[1]: *** [/tmp/tmp53nb1nwr/Makefile:2011: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2

Fixes: e8521822c733 ("RDMA/ionic: Register device ops for control path")
Reported-by: Leon Romanovsky <leon@kernel.org>
Closes: https://lore.kernel.org/lkml/20250918180750.GA135135@unreal/
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
 drivers/infiniband/hw/ionic/ionic_controlpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c
index 9ce7c2e6d7a8..ea12d9b8e125 100644
--- a/drivers/infiniband/hw/ionic/ionic_controlpath.c
+++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c
@@ -606,7 +606,7 @@ static void ionic_set_ah_attr(struct ionic_ibdev *dev,
 	memset(ah_attr, 0, sizeof(*ah_attr));
 	ah_attr->type = RDMA_AH_ATTR_TYPE_ROCE;
 	if (hdr->eth_present)
-		memcpy(&ah_attr->roce.dmac, &hdr->eth.dmac_h, ETH_ALEN);
+		ether_addr_copy(ah_attr->roce.dmac, hdr->eth.dmac_h);
 	rdma_ah_set_sl(ah_attr, vlan >> VLAN_PRIO_SHIFT);
 	rdma_ah_set_port_num(ah_attr, 1);
 	rdma_ah_set_grh(ah_attr, NULL, flow_label, sgid_index, ttl, tos);
-- 
2.43.0


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

* Re: [PATCH rdma-next 1/2] RDMA/ionic: Fix build failure on SPARC due to xchg() operand size
  2025-09-19 12:13 [PATCH rdma-next 1/2] RDMA/ionic: Fix build failure on SPARC due to xchg() operand size Abhijit Gangurde
  2025-09-19 12:13 ` [PATCH rdma-next 2/2] RDMA/ionic: Use ether_addr_copy instead of memcpy Abhijit Gangurde
@ 2025-09-21 11:32 ` Leon Romanovsky
  1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2025-09-21 11:32 UTC (permalink / raw)
  To: jgg, Abhijit Gangurde; +Cc: allen.hubbe, linux-rdma, linux-kernel


On Fri, 19 Sep 2025 17:43:00 +0530, Abhijit Gangurde wrote:
> xchg() is used to safely handle the event queue arming.
> However SPARC xchg operates only 4B of variable.
> Change variable type from bool to int.
> 
> Unverified Error/Warning (likely false positive, kindly check if interested):
> 
>     ERROR: modpost: "__xchg_called_with_bad_pointer" [drivers/infiniband/hw/ionic/ionic_rdma.ko] undefined!
> 
> [...]

Applied, thanks!

[1/2] RDMA/ionic: Fix build failure on SPARC due to xchg() operand size
      https://git.kernel.org/rdma/rdma/c/ed9836c040bac2
[2/2] RDMA/ionic: Use ether_addr_copy instead of memcpy
      https://git.kernel.org/rdma/rdma/c/260cce64aaa282

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


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

end of thread, other threads:[~2025-09-21 11:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-19 12:13 [PATCH rdma-next 1/2] RDMA/ionic: Fix build failure on SPARC due to xchg() operand size Abhijit Gangurde
2025-09-19 12:13 ` [PATCH rdma-next 2/2] RDMA/ionic: Use ether_addr_copy instead of memcpy Abhijit Gangurde
2025-09-21 11:32 ` [PATCH rdma-next 1/2] RDMA/ionic: Fix build failure on SPARC due to xchg() operand size Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®