tomaka/redshirt

Rework pci-interface so that one can take ownership of devices

Closed this issue · 1 comments

cc #283 which is similar (PCI being the x86 equivalent of device trees)

Rather than using the PCI interface to query the list of devices, then freely access the hardware, devices should instead ask the PCI interface to take ownership of a specific PCI device.

After that, the driver could only access memory mapping or wait for an interrupt corresponding to the device they "own".

Of course the PCI interface handler would consequently only allow one owner per device.

What I had in mind when opening this issue is moving towards sandboxing drivers of PCI devices.

In practice, however, it is extremely common to have to pass pointers to physical memory to PCI devices so that they can directly read/write RAM.
It is not really possible to prevent a malicious driver to send a bad pointer to a device and let the (non-malicious) hardware device overwrite portions of RAM chosen by the driver.
The idea of sandboxing is therefore not achievable.

However it is I think still important to have this "device locking" system in place in order to prevent two drivers from handling the same device, and also for debugging purposes to know which devices are being handled by which process, and which devices are missing a driver.