From 7231fd77a76af504b64032b9e3fa1f3ada887c3e Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Thu, 13 Oct 2011 09:44:41 +0000 Subject: I'm sick and tired of people doing misalgned reads and writes to PCI config space and not noticing because they only test on amd64. So enforce alignment there as well, at least for a little while such that we find those bugs and force people to fix them. --- sys/arch/amd64/pci/pci_machdep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/arch/amd64/pci/pci_machdep.c b/sys/arch/amd64/pci/pci_machdep.c index b5452961351..13a3aa85e3c 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.51 2011/06/18 17:28:18 kettenis Exp $ */ +/* $OpenBSD: pci_machdep.c,v 1.52 2011/10/13 09:44:40 kettenis Exp $ */ /* $NetBSD: pci_machdep.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -269,6 +269,8 @@ pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) pcireg_t data; int bus; + KASSERT((reg & 0x3) == 0); + if (pci_mcfg_addr && reg >= PCI_CONFIG_SPACE_SIZE) { pci_decompose_tag(pc, tag, &bus, NULL, NULL); if (bus >= pci_mcfg_min_bus && bus <= pci_mcfg_max_bus) { @@ -293,6 +295,8 @@ pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data) { int bus; + KASSERT((reg & 0x3) == 0); + if (pci_mcfg_addr && reg >= PCI_CONFIG_SPACE_SIZE) { pci_decompose_tag(pc, tag, &bus, NULL, NULL); if (bus >= pci_mcfg_min_bus && bus <= pci_mcfg_max_bus) { -- cgit v1.2.3