netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] pds_core: fix irq index bug and compiler warnings
@ 2023-11-13 18:32 Shannon Nelson
  2023-11-13 18:32 ` [PATCH net v2 1/2] pds_core: use correct index to mask irq Shannon Nelson
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shannon Nelson @ 2023-11-13 18:32 UTC (permalink / raw)
  To: netdev, brett.creeley, davem, edumazet, kuba, pabeni
  Cc: drivers, joao.m.martins, Shannon Nelson

The first patch fixes a bug in our interrupt masking where we used the
wrong index.  The second patch addresses a couple of kernel test robot
string truncation warnings.

v2: added Fixes tags to commit messages and more detail to first commit msg

Shannon Nelson (2):
  pds_core: use correct index to mask irq
  pds_core: fix up some format-truncation complaints

 drivers/net/ethernet/amd/pds_core/adminq.c  | 2 +-
 drivers/net/ethernet/amd/pds_core/core.h    | 2 +-
 drivers/net/ethernet/amd/pds_core/dev.c     | 8 ++++++--
 drivers/net/ethernet/amd/pds_core/devlink.c | 2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)

-- 
2.17.1


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

* [PATCH net v2 1/2] pds_core: use correct index to mask irq
  2023-11-13 18:32 [PATCH net v2 0/2] pds_core: fix irq index bug and compiler warnings Shannon Nelson
@ 2023-11-13 18:32 ` Shannon Nelson
  2023-11-13 18:32 ` [PATCH net v2 2/2] pds_core: fix up some format-truncation complaints Shannon Nelson
  2023-11-15  4:00 ` [PATCH net v2 0/2] pds_core: fix irq index bug and compiler warnings patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Shannon Nelson @ 2023-11-13 18:32 UTC (permalink / raw)
  To: netdev, brett.creeley, davem, edumazet, kuba, pabeni
  Cc: drivers, joao.m.martins, Shannon Nelson

Use the qcq's interrupt index, not the irq number, to mask
the interrupt.  Since the irq number can be out of range from
the number of possible interrupts, we can end up accessing
and potentially scribbling on out-of-range and/or unmapped
memory, making the kernel angry.

    [ 3116.039364] BUG: unable to handle page fault for address: ffffbeea1c3edf84
    [ 3116.047059] #PF: supervisor write access in kernel mode
    [ 3116.052895] #PF: error_code(0x0002) - not-present page
    [ 3116.058636] PGD 100000067 P4D 100000067 PUD 1001f2067 PMD 10f82e067 PTE 0
    [ 3116.066221] Oops: 0002 [#1] SMP NOPTI
    [ 3116.092948] RIP: 0010:iowrite32+0x9/0x76
    [ 3116.190452] Call Trace:
    [ 3116.193185]  <IRQ>
    [ 3116.195430]  ? show_trace_log_lvl+0x1d6/0x2f9
    [ 3116.200298]  ? show_trace_log_lvl+0x1d6/0x2f9
    [ 3116.205166]  ? pdsc_adminq_isr+0x43/0x55 [pds_core]
    [ 3116.210618]  ? __die_body.cold+0x8/0xa
    [ 3116.214806]  ? page_fault_oops+0x16d/0x1ac
    [ 3116.219382]  ? exc_page_fault+0xbe/0x13b
    [ 3116.223764]  ? asm_exc_page_fault+0x22/0x27
    [ 3116.228440]  ? iowrite32+0x9/0x76
    [ 3116.232143]  pdsc_adminq_isr+0x43/0x55 [pds_core]
    [ 3116.237627]  __handle_irq_event_percpu+0x3a/0x184
    [ 3116.243088]  handle_irq_event+0x57/0xb0
    [ 3116.247575]  handle_edge_irq+0x87/0x225
    [ 3116.252062]  __common_interrupt+0x3e/0xbc
    [ 3116.256740]  common_interrupt+0x7b/0x98
    [ 3116.261216]  </IRQ>
    [ 3116.263745]  <TASK>
    [ 3116.266268]  asm_common_interrupt+0x22/0x27

Reported-by: Joao Martins <joao.m.martins@oracle.com>
Fixes: 01ba61b55b20 ("pds_core: Add adminq processing and commands")
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/amd/pds_core/adminq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/pds_core/adminq.c b/drivers/net/ethernet/amd/pds_core/adminq.c
index 045fe133f6ee..5beadabc2136 100644
--- a/drivers/net/ethernet/amd/pds_core/adminq.c
+++ b/drivers/net/ethernet/amd/pds_core/adminq.c
@@ -146,7 +146,7 @@ irqreturn_t pdsc_adminq_isr(int irq, void *data)
 	}
 
 	queue_work(pdsc->wq, &qcq->work);
-	pds_core_intr_mask(&pdsc->intr_ctrl[irq], PDS_CORE_INTR_MASK_CLEAR);
+	pds_core_intr_mask(&pdsc->intr_ctrl[qcq->intx], PDS_CORE_INTR_MASK_CLEAR);
 
 	return IRQ_HANDLED;
 }
-- 
2.17.1


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

* [PATCH net v2 2/2] pds_core: fix up some format-truncation complaints
  2023-11-13 18:32 [PATCH net v2 0/2] pds_core: fix irq index bug and compiler warnings Shannon Nelson
  2023-11-13 18:32 ` [PATCH net v2 1/2] pds_core: use correct index to mask irq Shannon Nelson
@ 2023-11-13 18:32 ` Shannon Nelson
  2023-11-15  4:00 ` [PATCH net v2 0/2] pds_core: fix irq index bug and compiler warnings patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Shannon Nelson @ 2023-11-13 18:32 UTC (permalink / raw)
  To: netdev, brett.creeley, davem, edumazet, kuba, pabeni
  Cc: drivers, joao.m.martins, Shannon Nelson

Our friendly kernel test robot pointed out a couple of potential
string truncation issues.  None of which were we worried about,
but can be relatively easily fixed to quiet the complaints.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310211736.66syyDpp-lkp@intel.com/
Fixes: 45d76f492938 ("pds_core: set up device and adminq")
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
---
 drivers/net/ethernet/amd/pds_core/core.h    | 2 +-
 drivers/net/ethernet/amd/pds_core/dev.c     | 8 ++++++--
 drivers/net/ethernet/amd/pds_core/devlink.c | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/amd/pds_core/core.h b/drivers/net/ethernet/amd/pds_core/core.h
index f3a7deda9972..e35d3e7006bf 100644
--- a/drivers/net/ethernet/amd/pds_core/core.h
+++ b/drivers/net/ethernet/amd/pds_core/core.h
@@ -15,7 +15,7 @@
 #define PDSC_DRV_DESCRIPTION	"AMD/Pensando Core Driver"
 
 #define PDSC_WATCHDOG_SECS	5
-#define PDSC_QUEUE_NAME_MAX_SZ  32
+#define PDSC_QUEUE_NAME_MAX_SZ  16
 #define PDSC_ADMINQ_MIN_LENGTH	16	/* must be a power of two */
 #define PDSC_NOTIFYQ_LENGTH	64	/* must be a power of two */
 #define PDSC_TEARDOWN_RECOVERY	false
diff --git a/drivers/net/ethernet/amd/pds_core/dev.c b/drivers/net/ethernet/amd/pds_core/dev.c
index 7c1b965d61a9..31940b857e0e 100644
--- a/drivers/net/ethernet/amd/pds_core/dev.c
+++ b/drivers/net/ethernet/amd/pds_core/dev.c
@@ -261,10 +261,14 @@ static int pdsc_identify(struct pdsc *pdsc)
 	struct pds_core_drv_identity drv = {};
 	size_t sz;
 	int err;
+	int n;
 
 	drv.drv_type = cpu_to_le32(PDS_DRIVER_LINUX);
-	snprintf(drv.driver_ver_str, sizeof(drv.driver_ver_str),
-		 "%s %s", PDS_CORE_DRV_NAME, utsname()->release);
+	/* Catching the return quiets a Wformat-truncation complaint */
+	n = snprintf(drv.driver_ver_str, sizeof(drv.driver_ver_str),
+		     "%s %s", PDS_CORE_DRV_NAME, utsname()->release);
+	if (n > sizeof(drv.driver_ver_str))
+		dev_dbg(pdsc->dev, "release name truncated, don't care\n");
 
 	/* Next let's get some info about the device
 	 * We use the devcmd_lock at this level in order to
diff --git a/drivers/net/ethernet/amd/pds_core/devlink.c b/drivers/net/ethernet/amd/pds_core/devlink.c
index 57f88c8b37de..e9948ea5bbcd 100644
--- a/drivers/net/ethernet/amd/pds_core/devlink.c
+++ b/drivers/net/ethernet/amd/pds_core/devlink.c
@@ -104,7 +104,7 @@ int pdsc_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
 	struct pds_core_fw_list_info fw_list;
 	struct pdsc *pdsc = devlink_priv(dl);
 	union pds_core_dev_comp comp;
-	char buf[16];
+	char buf[32];
 	int listlen;
 	int err;
 	int i;
-- 
2.17.1


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

* Re: [PATCH net v2 0/2] pds_core: fix irq index bug and compiler warnings
  2023-11-13 18:32 [PATCH net v2 0/2] pds_core: fix irq index bug and compiler warnings Shannon Nelson
  2023-11-13 18:32 ` [PATCH net v2 1/2] pds_core: use correct index to mask irq Shannon Nelson
  2023-11-13 18:32 ` [PATCH net v2 2/2] pds_core: fix up some format-truncation complaints Shannon Nelson
@ 2023-11-15  4:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-15  4:00 UTC (permalink / raw)
  To: Shannon Nelson
  Cc: netdev, brett.creeley, davem, edumazet, kuba, pabeni, drivers,
	joao.m.martins

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 13 Nov 2023 10:32:55 -0800 you wrote:
> The first patch fixes a bug in our interrupt masking where we used the
> wrong index.  The second patch addresses a couple of kernel test robot
> string truncation warnings.
> 
> v2: added Fixes tags to commit messages and more detail to first commit msg
> 
> Shannon Nelson (2):
>   pds_core: use correct index to mask irq
>   pds_core: fix up some format-truncation complaints
> 
> [...]

Here is the summary with links:
  - [net,v2,1/2] pds_core: use correct index to mask irq
    https://git.kernel.org/netdev/net/c/09d4c14c6c5e
  - [net,v2,2/2] pds_core: fix up some format-truncation complaints
    https://git.kernel.org/netdev/net/c/7c02f6ae676a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-11-15  4:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-13 18:32 [PATCH net v2 0/2] pds_core: fix irq index bug and compiler warnings Shannon Nelson
2023-11-13 18:32 ` [PATCH net v2 1/2] pds_core: use correct index to mask irq Shannon Nelson
2023-11-13 18:32 ` [PATCH net v2 2/2] pds_core: fix up some format-truncation complaints Shannon Nelson
2023-11-15  4:00 ` [PATCH net v2 0/2] pds_core: fix irq index bug and compiler warnings patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).