mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ntb: use 64-bit arithmetic for the MSI doorbell mask
@ 2025-01-15 18:28 Fedor Pchelkin
  2025-01-16 15:44 ` Dave Jiang
  0 siblings, 1 reply; 2+ messages in thread
From: Fedor Pchelkin @ 2025-01-15 18:28 UTC (permalink / raw)
  To: Jon Mason
  Cc: Fedor Pchelkin, Dave Jiang, Allen Hubbe, Logan Gunthorpe, ntb,
	linux-kernel, lvc-project, stable

msi_db_mask is of type 'u64', still the standard 'int' arithmetic is
performed to compute its value.

While most of the ntb_hw drivers actually don't utilize the higher 32
bits of the doorbell mask now, this may be the case for Switchtec - see
switchtec_ntb_init_db().

Found by Linux Verification Center (linuxtesting.org) with SVACE static
analysis tool.

Fixes: 2b0569b3b7e6 ("NTB: Add MSI interrupt support to ntb_transport")
Cc: stable@vger.kernel.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
 drivers/ntb/ntb_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index a22ea4a4b202..4f775c3e218f 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -1353,7 +1353,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
 	qp_count = ilog2(qp_bitmap);
 	if (nt->use_msi) {
 		qp_count -= 1;
-		nt->msi_db_mask = 1 << qp_count;
+		nt->msi_db_mask = BIT_ULL(qp_count);
 		ntb_db_clear_mask(ndev, nt->msi_db_mask);
 	}
 
-- 
2.39.5


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

* Re: [PATCH] ntb: use 64-bit arithmetic for the MSI doorbell mask
  2025-01-15 18:28 [PATCH] ntb: use 64-bit arithmetic for the MSI doorbell mask Fedor Pchelkin
@ 2025-01-16 15:44 ` Dave Jiang
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Jiang @ 2025-01-16 15:44 UTC (permalink / raw)
  To: Fedor Pchelkin, Jon Mason
  Cc: Allen Hubbe, Logan Gunthorpe, ntb, linux-kernel, lvc-project, stable



On 1/15/25 11:28 AM, Fedor Pchelkin wrote:
> msi_db_mask is of type 'u64', still the standard 'int' arithmetic is
> performed to compute its value.
> 
> While most of the ntb_hw drivers actually don't utilize the higher 32
> bits of the doorbell mask now, this may be the case for Switchtec - see
> switchtec_ntb_init_db().
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE static
> analysis tool.
> 
> Fixes: 2b0569b3b7e6 ("NTB: Add MSI interrupt support to ntb_transport")
> Cc: stable@vger.kernel.org
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>

LGTM. Should be using the BIT() macro to begin with. 

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/ntb/ntb_transport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index a22ea4a4b202..4f775c3e218f 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -1353,7 +1353,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
>  	qp_count = ilog2(qp_bitmap);
>  	if (nt->use_msi) {
>  		qp_count -= 1;
> -		nt->msi_db_mask = 1 << qp_count;
> +		nt->msi_db_mask = BIT_ULL(qp_count);
>  		ntb_db_clear_mask(ndev, nt->msi_db_mask);
>  	}
>  


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

end of thread, other threads:[~2025-01-16 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-15 18:28 [PATCH] ntb: use 64-bit arithmetic for the MSI doorbell mask Fedor Pchelkin
2025-01-16 15:44 ` Dave Jiang

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®