]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
inmates: pci: include feature check in capability lookup
authorHenning Schild <henning.schild@siemens.com>
Fri, 7 Nov 2014 13:46:02 +0000 (14:46 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Fri, 7 Nov 2014 14:01:59 +0000 (15:01 +0100)
Do not look for pci capabilites in devices that do not support them.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates/lib/pci.c
inmates/lib/x86/inmate.h

index 180062dbc1872b432ac3baa849ea1943066993b0..38120e67fd6c34a94a6a09efad107ce847605d35 100644 (file)
@@ -30,6 +30,9 @@ int pci_find_cap(u16 bdf, u16 cap)
 {
        u8 pos = PCI_CFG_CAP_PTR - 1;
 
+       if (!(pci_read_config(bdf, PCI_CFG_STATUS, 2) & PCI_STS_CAPS))
+               return -1;
+
        while (1) {
                pos = pci_read_config(bdf, pos + 1, 1);
                if (pos == 0)
index 33d7cb4f3c90eb01c688cb1eafa13462d440d179..45fd0494dae21b7b0c8403fc72d5afc691a74c10 100644 (file)
@@ -44,6 +44,7 @@
 # define PCI_CMD_INTX_OFF      (1 << 10)
 #define PCI_CFG_STATUS         0x006
 # define PCI_STS_INT           (1 << 3)
+# define PCI_STS_CAPS          (1 << 4)
 #define PCI_CFG_BAR            0x010
 # define PCI_BAR_64BIT         0x4
 #define PCI_CFG_CAP_PTR                0x034