Skip to content

Commit 79ebb53

Browse files
Hariprasad Kelamdavem330
authored andcommitted
octeontx2-af: Add validation before accessing cgx and lmac
with the addition of new MAC blocks like CN10K RPM and CN10KB RPM_USX, LMACs are noncontiguous and CGX blocks are also noncontiguous. But during RVU driver initialization, the driver is assuming they are contiguous and trying to access cgx or lmac with their id which is resulting in kernel panic. This patch fixes the issue by adding proper checks. [ 23.219150] pc : cgx_lmac_read+0x38/0x70 [ 23.219154] lr : rvu_program_channels+0x3f0/0x498 [ 23.223852] sp : ffff000100d6fc80 [ 23.227158] x29: ffff000100d6fc80 x28: ffff00010009f880 x27: 000000000000005a [ 23.234288] x26: ffff000102586768 x25: 0000000000002500 x24: fffffffffff0f000 Fixes: 91c6945 ("octeontx2-af: cn10k: Add RPM MAC support") Signed-off-by: Hariprasad Kelam <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2e7bc57 commit 79ebb53

File tree

1 file changed

+7
-0
lines changed
  • drivers/net/ethernet/marvell/octeontx2/af

1 file changed

+7
-0
lines changed

drivers/net/ethernet/marvell/octeontx2/af/cgx.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,20 @@ void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val)
169169
{
170170
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
171171

172+
/* Software must not access disabled LMAC registers */
173+
if (!is_lmac_valid(cgx_dev, lmac_id))
174+
return;
172175
cgx_write(cgx_dev, lmac_id, offset, val);
173176
}
174177

175178
u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset)
176179
{
177180
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
178181

182+
/* Software must not access disabled LMAC registers */
183+
if (!is_lmac_valid(cgx_dev, lmac_id))
184+
return 0;
185+
179186
return cgx_read(cgx_dev, lmac_id, offset);
180187
}
181188

0 commit comments

Comments
 (0)