Ignore PCI MEM64 ranges over 4GB, since this 32-bit kernel can't use them;
authormiod <miod@openbsd.org>
Tue, 10 Oct 2023 18:40:34 +0000 (18:40 +0000)
committermiod <miod@openbsd.org>
Tue, 10 Oct 2023 18:40:34 +0000 (18:40 +0000)
this prevents a DIAGNOSTIC panic when running in qemu without option
"-M virt,highmem=off".

Reported by and ok jsg@

sys/arch/armv7/vexpress/pciecam.c

index 63d5813..c011a4e 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: pciecam.c,v 1.5 2021/10/24 17:52:28 mpi Exp $ */
+/* $OpenBSD: pciecam.c,v 1.6 2023/10/10 18:40:34 miod Exp $ */
 /*
  * Copyright (c) 2013,2017 Patrick Wildt <patrick@blueri.se>
  *
@@ -28,6 +28,7 @@
 #include <dev/pci/pcivar.h>
 
 #include <dev/ofw/fdt.h>
+#include <dev/ofw/ofw_pci.h>
 #include <dev/ofw/openfirm.h>
 
 /* Assembling ECAM Configuration Address */
@@ -195,14 +196,21 @@ pciecam_attach(struct device *parent, struct device *self, void *aux)
            M_DEVBUF, NULL, 0, EX_NOWAIT | EX_FILLED);
 
        for (i = 0; i < nranges; i++) {
-               if (sc->sc_pciranges[i].flags >> 24 == 0)
-                       continue;
-               if (sc->sc_pciranges[i].flags >> 24 == 1)
+               switch (sc->sc_pciranges[i].flags & OFW_PCI_PHYS_HI_SPACEMASK) {
+               case OFW_PCI_PHYS_HI_SPACE_IO:
                        extent_free(sc->sc_ioex, sc->sc_pciranges[i].pci_base,
                            sc->sc_pciranges[i].size, EX_NOWAIT);
-               else
+                       break;
+               case OFW_PCI_PHYS_HI_SPACE_MEM64:
+                       if (sc->sc_pciranges[i].pci_base +
+                           sc->sc_pciranges[i].size >= (1ULL << 32))
+                               break;
+                       /* FALLTHROUGH */
+               case OFW_PCI_PHYS_HI_SPACE_MEM32:
                        extent_free(sc->sc_memex, sc->sc_pciranges[i].pci_base,
                            sc->sc_pciranges[i].size, EX_NOWAIT);
+                       break;
+               }
        }
 
        memcpy(&sc->sc_bus, sc->sc_iot, sizeof(sc->sc_bus));