Subject: Re: Why not track our xsrc with X11R6.6 from X.org?
To: NetBSD-current Discussion List <current-users@NetBSD.ORG>
From: Nathan J. Williams <nathanw@MIT.EDU>
List: current-users
Date: 07/17/2001 10:09:31
woods@weird.com (Greg A. Woods) writes:

> > Something like "What kind of bus is this on? What is the
> > bus-specific information (TC/SBus/PCI device ID, and so on)? For some
> > buses, "What address ranges can I map?". 
> 
> this is where it goes from being merely ugly to being down-right horrid
> and gross.  it grates against my very nerves!  and its very in-elegant
> too -- now we've got user-land code apparently duplicating much of the
> low-level hardware probing and mapping done initially by the kernel!

The part of the XFree86 approach that bothers me is that it scans the
entire universe of PCI busses itself, looking for a video card. That
is duplicated effort, and it's also a pretty dangerous operation. What
I'm suggesting is that you give X access to /dev/wsvideo or something,
and wsvideo says "Hi, I'm a PCI card, vendor xxxx, product yyyy,
revision z". 

> At the very worst couldn't there be a common interface defined such that
> a virtual device driver (or sysctl, or /kern file, or whatever) could
> provide all the necessary details in some mostly portable manner?

Right, I think that's what I'm lobbying for (Nobody ever replied the
last time I brought this up, a couple of years ago).

The reason I suspect XFree86 took the approach that they did was that
they run on several operating systems (believe it or not!) that they
don't control, and requiring priveleged access and performing *very*
low-level bus scans was something that they could do, whereas asking
multiple OS vendors to implement a new, common, interface is a
tedious, panful, and often fruitless battle.

> > This also doesn't even touch the (hardware-based) issue that the
> > implementation of accelerated video cards with DMA engines, and the
> > lack of page-based protection in any computer's bus/memory DMA
> > interface, implies that any code that can touch the video system in a
> > useful way has full priveleges to touch the entire system.
> 
> Why?  Is it just because of brain-dead hardware design, or lazy driver
> design, or is it simply impossible to fix properly?  Why can't the
> driver be in control of (and thus vetting) the DMA operations?

It's related to the above bit about a bazillion different cards; the
kernel would have to know about the exact register set and semantics
of DMA for each of them. It would also require crossing the protection
boundary for every such operation, which wouldn't just be sub-optimal
performance; it would be downright abysmal.

(I'm curious if Microsoft's DirectX addresses this issue at all; I
suspect that it doesn't.)

> Performance isn't everything!  Surely we can have decent performance
> with the kernel still in control of the dangerous bits with sharp
> corners!

You might think so, but history disagrees. Unfortunately, like many
other power tools, modern graphics cards are built so that the sharp
edges are the useful bits.

        - Nathan