Skip to content

Commit acfb98b

Browse files
Rick Farringtondavem330
authored andcommitted
liquidio: fix crash in presence of zeroed-out base address regs
Fix crash in linux PF driver when BARs have been cleared/de-programmed; fail early init (prior to mapping BARs) if the BAR0 or BAR1 registers are zero. This situation can arise when the PF is added to a VM (PCI pass-through), then a PF FLR is issued (in the VM). After this occurs, the BAR registers will be zero. If we attempt to load the PF driver in the host (after VM has been shutdown), the host can reset. Signed-off-by: Rick Farrington <ricardo.farrington@cavium.com> Signed-off-by: Raghu Vatsavayi <raghu.vatsavayi@cavium.com> Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 12bdc5e commit acfb98b

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,26 @@ static int cn23xx_sriov_config(struct octeon_device *oct)
13051305

13061306
int setup_cn23xx_octeon_pf_device(struct octeon_device *oct)
13071307
{
1308+
u32 data32;
1309+
u64 BAR0, BAR1;
1310+
1311+
pci_read_config_dword(oct->pci_dev, PCI_BASE_ADDRESS_0, &data32);
1312+
BAR0 = (u64)(data32 & ~0xf);
1313+
pci_read_config_dword(oct->pci_dev, PCI_BASE_ADDRESS_1, &data32);
1314+
BAR0 |= ((u64)data32 << 32);
1315+
pci_read_config_dword(oct->pci_dev, PCI_BASE_ADDRESS_2, &data32);
1316+
BAR1 = (u64)(data32 & ~0xf);
1317+
pci_read_config_dword(oct->pci_dev, PCI_BASE_ADDRESS_3, &data32);
1318+
BAR1 |= ((u64)data32 << 32);
1319+
1320+
if (!BAR0 || !BAR1) {
1321+
if (!BAR0)
1322+
dev_err(&oct->pci_dev->dev, "device BAR0 unassigned\n");
1323+
if (!BAR1)
1324+
dev_err(&oct->pci_dev->dev, "device BAR1 unassigned\n");
1325+
return 1;
1326+
}
1327+
13081328
if (octeon_map_pci_barx(oct, 0, 0))
13091329
return 1;
13101330

0 commit comments

Comments
 (0)