diff --git a/pkg/nvpci/config.go b/pkg/nvpci/config.go index 5c4fc7f..5373a0f 100644 --- a/pkg/nvpci/config.go +++ b/pkg/nvpci/config.go @@ -27,6 +27,8 @@ const ( pciCfgSpaceStandardSize = 256 pciCfgSpaceExtendedSize = 4096 pciCapabilityListPointer = 0x34 + pciStatusCapabilityList = 0x10 + pciStatusBytePosition = 0x06 ) // ConfigSpace PCI configuration space (standard extended) file path @@ -85,6 +87,11 @@ func (cs *configSpaceIO) GetPCICapabilities() (*PCICapabilities, error) { make(map[uint16]*PCIExtendedCapability), } + support := cs.Read8(pciStatusBytePosition) & pciStatusCapabilityList + if support == 0 { + return nil, fmt.Errorf("pci device does not support capability list") + } + soffset := cs.Read8(pciCapabilityListPointer) if int(soffset) >= cs.Len() { return nil, fmt.Errorf("capability list pointer out of bounds") diff --git a/pkg/nvpci/mock.go b/pkg/nvpci/mock.go index 60d57ae..7448d0d 100644 --- a/pkg/nvpci/mock.go +++ b/pkg/nvpci/mock.go @@ -108,6 +108,7 @@ func (m *MockNvpci) AddMockA100(address string, numaNode int) error { data := bytes.New(&_data) data.Write16(0, pciNvidiaVendorID) data.Write16(2, uint16(0x20bf)) + data.Write8(pciStatusBytePosition, pciStatusCapabilityList) _, err = config.Write(*data.Raw()) if err != nil { return err