summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2012-06-02 13:05:10 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2012-06-02 13:05:10 +0000
commit1f45c4a88e0e84466cf6133c972d4e940144d264 (patch)
treec4b97865da347e4762be93604c79a0c486a073c0 /lib
parent88bb6e71aee93f203568b7a6860e90c6c2801462 (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 'lib')
-rw-r--r--lib/libpciaccess/src/openbsd_pci.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/libpciaccess/src/openbsd_pci.c b/lib/libpciaccess/src/openbsd_pci.c
index 53c2f6007..edcf1f530 100644
--- a/lib/libpciaccess/src/openbsd_pci.c
+++ b/lib/libpciaccess/src/openbsd_pci.c
@@ -281,7 +281,7 @@ pci_device_openbsd_write(struct pci_device *dev, const void *data,
return errno;
offset += 4;
- data = (char *)data + 4;
+ data = (const char *)data + 4;
size -= 4;
*bytes_written += 4;
}
@@ -400,42 +400,47 @@ 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 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;
+ return ret;
+ }
+#if defined(__i386__)
ia.iopl = 1;
if (sysarch(I386_IOPL, &ia))
return NULL;
-
- ret->base = base;
- ret->size = size;
- 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;
- 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;
- return ret;
#else
return NULL;
#endif
+ ret->base = base;
+ ret->size = size;
+ legacy_io_handle = ret;
+ return ret;
}
static uint32_t