diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-06-02 21:01:52 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-06-02 21:01:52 +0000 |
commit | 654fb9534c038074367ad419ac62effc1d14bbaa (patch) | |
tree | b61ad754b3405ca354d647aff58a9d22414dcc3e /sys/arch/amd64/pci | |
parent | d685c43035cf813cd4208fdf9e9d1a3cef47392c (diff) |
Fix two issues in the MSI-X code. First, actually read the MSI-X capability
register. Second, correctly decode the table sizefromits contents.
First issue pointed out by David Hill (with the help of clang). Second
issue spotted after seeing a diff from Christiano Hasbaert.
Diffstat (limited to 'sys/arch/amd64/pci')
-rw-r--r-- | sys/arch/amd64/pci/pci_machdep.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/arch/amd64/pci/pci_machdep.c b/sys/arch/amd64/pci/pci_machdep.c index 2d18122d2ef..19983b0a22e 100644 --- a/sys/arch/amd64/pci/pci_machdep.c +++ b/sys/arch/amd64/pci/pci_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.c,v 1.64 2016/05/14 20:22:41 kettenis Exp $ */ +/* $OpenBSD: pci_machdep.c,v 1.65 2016/06/02 21:01:51 kettenis Exp $ */ /* $NetBSD: pci_machdep.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -456,7 +456,7 @@ msix_addroute(struct pic *pic, struct cpu_info *ci, int pin, int vec, int type) table = pci_conf_read(pc, tag, off + PCI_MSIX_TABLE); bir = (table & PCI_MSIX_TABLE_BIR); offset = (table & PCI_MSIX_TABLE_OFF); - tblsz = (reg & PCI_MSIX_MC_TBLSZ) + 1; + tblsz = PCI_MSIX_MC_TBLSZ(reg) + 1; bir = PCI_MAPREG_START + bir * 4; if (pci_mem_find(pc, tag, bir, &base, NULL, NULL) || @@ -496,7 +496,7 @@ msix_delroute(struct pic *pic, struct cpu_info *ci, int pin, int vec, int type) table = pci_conf_read(pc, tag, off + PCI_MSIX_TABLE); bir = (table & PCI_MSIX_TABLE_BIR); offset = (table & PCI_MSIX_TABLE_OFF); - tblsz = (reg & PCI_MSIX_MC_TBLSZ) + 1; + tblsz = PCI_MSIX_MC_TBLSZ(reg) + 1; bir = PCI_MAPREG_START + bir * 4; if (pci_mem_find(pc, tag, bir, &base, NULL, NULL) || @@ -520,10 +520,10 @@ pci_intr_map_msix(struct pci_attach_args *pa, int vec, pci_intr_handle_t *ihp) KASSERT(PCI_MSIX_VEC(vec) == vec); if ((pa->pa_flags & PCI_FLAGS_MSI_ENABLED) == 0 || mp_busses == NULL || - pci_get_capability(pc, tag, PCI_CAP_MSIX, NULL, NULL) == 0) + pci_get_capability(pc, tag, PCI_CAP_MSIX, NULL, ®) == 0) return 1; - if (vec > (reg & PCI_MSIX_MC_TBLSZ)) + if (vec > PCI_MSIX_MC_TBLSZ(reg)) return 1; ihp->tag = PCI_MSIX_PIN(tag, vec); |