summaryrefslogtreecommitdiff
path: root/src/openbsd_pci.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@herrb.eu>2012-06-02 13:05:10 +0200
committerMatthieu Herrb <matthieu@herrb.eu>2018-11-25 19:19:55 +0100
commitdf1dc905f044d113db76f852550de7e0cd13b5b3 (patch)
tree485b53dd31eec525c5ad0ce7fcae19db93b09ba4 /src/openbsd_pci.c
parent87786ac519ad2b3c34e746809c371eaee5752e5e (diff)
Add support for X server privilege separation to pci_legacy_open_io()
With privilege separation the X server enables legacy i/o port access during the early privileged initialization. Other calls should be no-op. Makes X server 1.12 happy with privilege separation. ok miod@
Diffstat (limited to 'src/openbsd_pci.c')
-rw-r--r--src/openbsd_pci.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/openbsd_pci.c b/src/openbsd_pci.c
index c73ce70..60bc659 100644
--- a/src/openbsd_pci.c
+++ b/src/openbsd_pci.c
@@ -428,51 +428,48 @@ pci_device_openbsd_probe(struct pci_device *device)
#include <machine/pio.h>
#endif
+static struct pci_io_handle *legacy_io_handle = NULL;
+
static struct pci_io_handle *
pci_device_openbsd_open_legacy_io(struct pci_io_handle *ret,
struct pci_device *dev, pciaddr_t base, pciaddr_t size)
{
-#if 0
#if defined(__i386__)
struct i386_iopl_args ia;
+#elif defined(__amd64__)
+ struct amd64_iopl_args ia;
+#endif
+ /* With X server privilege separation, i/o access is
+ enabled early and never disabled, allow recursive,
+ privilege-less calls */
+ if (legacy_io_handle != NULL) {
+ ret->base = legacy_io_handle->base;
+ ret->size = legacy_io_handle->size;
+ ret->memory = legacy_io_handle->memory;
+ ret->is_legacy = 1;
+ return ret;
+ }
+#if defined(__i386__)
ia.iopl = 1;
if (sysarch(I386_IOPL, &ia))
return NULL;
-
- ret->base = base;
- ret->size = size;
- ret->is_legacy = 1;
- return ret;
#elif defined(__amd64__)
- struct amd64_iopl_args ia;
-
ia.iopl = 1;
if (sysarch(AMD64_IOPL, &ia))
return NULL;
-
- ret->base = base;
- ret->size = size;
- ret->is_legacy = 1;
- return ret;
#elif defined(PCI_MAGIC_IO_RANGE)
ret->memory = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
aperturefd, PCI_MAGIC_IO_RANGE + base);
if (ret->memory == MAP_FAILED)
return NULL;
-
- ret->base = base;
- ret->size = size;
- ret->is_legacy = 1;
- return ret;
#else
return NULL;
#endif
-#else
ret->base = base;
ret->size = size;
+ legacy_io_handle = ret;
return ret;
-#endif
}
static uint32_t