Linux Kernel To Have Stable Userspace Drive
liquidat writes "Linus Torvalds has included patches into the mainline tree which implement a stable userspace driver API into the Linux kernel. The stable driver API was already announced a year ago by Greg Kroah-Hartman. The last patch to Linus' tree included the new API elements. The idea is to make life easier for driver developers: 'This interface allows the ability to write the majority of a driver in userspace with only a very small shell of a driver in the kernel itself. It uses a char device and sysfs to interact with a userspace process to process interrupts and control memory accesses.'"
A stable kernel api for drivers is what linux needs as proprietary driver writers make poor quality and buggy implementations. While this is not a kernel one its a good compromise as proprietary drivers are here to stay as much as it would be great if we had free gnu ones inside the kernel.
I wonder if it would be easy to port it to windows and macosx? IT would be cool for hardware makers to have a driver that works with all operating systems with minimal effort in porting. Costs are one of the issues besides the difficulty in porting windows drivers to linux which many makers do not bother doing.
http://saveie6.com/
Perhaps in ten years time Linux will be a microkernel
http://michaelsmith.id.au
Wouldn't implementing this in userspace drastically lack in performance compared to kernelspace drivers?
So I immediately thought of a spaceship running Linux... I mean, could it really be otherwise?
The lack of a stable userspace driver api was that last thing stopping soccer moms and grandmothers from running Linux on the desktop.
My sarcasm is so extreme, I think what I said above may have actually been true.
You already don't.
Look at things like debian's module-assistant.
/* FUCK - The F-word is here so that you can grep for it */
Don't leave your mind so open that your brain falls out. Don't close it so much that you cut off the blood.
Maybe this path will ultimately bring proprietary drivers to Linux in force, but I think Linus has made the right decision. We should start looking for other ways to convince companies to write open, GPL drivers.
In Soviet America the banks rob you!
QNX has had user space drivers along somewhat similar lines for many years. In QNX, all the drivers are in user space, which makes for a much smaller kernel. Here's a simplified article on QNX driver writing.
The Linux approach has the problem that Linux doesn't have the message passing primitives that QNX does. So there's a special purpose mechanism to hook up these new user-space drivers to the I/O system calls. In QNX, "open", "close", "read", and "write" are actually C library functions that call MsgSend to do the work. (System V IPC isn't really suitable; it's asynchronous, which means a few extra scheduler events for every message pass when you try to use it for something that works like a subroutine call. Long story.)
Unfortunately, on x86 hardware, you can't protect the system from a user level driver and still give the driver direct hardware access. IBM VM mainframes get this right, but x86 does not. On the other hand, you can have channel drivers for the various types of x86 channels (SCSI, FireWire, USB, etc.) and make other drivers work through them.
User-level drivers cost you at least one extra memory copy of the data. That's not too bad in practice. I did a FireWire video camera driver for QNX, and when transmitting 640x480 24 bit images at 15fps, it took about 3% of a Pentium 4 CPU.
If this brings us closer to using (possibly unreliable) windows drivers, a major reason for using windows will be gone.
I wonder if this compromise is worth it. I'd much rather have stable kernel drivers than unstable userspace drivers.
If a driver is buggy and in userspace, its possible that the system could recover from the error, however you could still end up in some unstable state that would potentially end up requiring a reboot (depending on the driver in question).
Also, there is a higher cost of running a driver in userspace (ring 3) than kernel space (ring 0). As mentioned by the article, high traffic drivers (requiring DMA) are not supported.
The reasoning for this seems to be due to unstable proprietary kernel drivers. IMO, the solution to solving this problem is driver signing and certification. Don't use a driver unless its been signed and certified.
Just because some code controls a piece of hardware doesn't mean that a runaway pointer in it should cause a panic or even corrupt files by messing up filesystem buffers. This will also enable device drivers to make use of all available userspace libraries, with sophisticated algorithms that would never be used if all code had to be written from scratch and non-pagable.
FWIW, not trying to troll, but thought I would point out that this feature is one of Vista's improvements over XP, and simultaneously the primary reason why Vista's compatibility isn't that great right now, and thus the primary reason why many people don't switch to Vista yet. Most of the hardware vendors have to make big changes to their drivers in order to accommodate this, especially nvidia who has to make about 4 different user space drivers (one for d3d, one for opengl, and an SLI version of both of those.) This is a good thing to have for both security and stability reasons, and I was waiting for when somebody would add this to the Linux kernel.
Linux has the advantage in that with Linux you can use both the old "kernel only" drivers, and the user space drivers at the same time. Vista could have done this as well, however Microsoft felt that if they allowed this to happen, then most hardware vendors would be lazy and continue to use their old kernel mode drivers, thus defeating the purpose. And to be honest, I agree with them. Linux doesn't need this on the other hand, as eventually somebody who is interested will make these kinds of changes to all of the open source drivers anyways as needed, which can't really happen because most windows drivers are binary only, so Linux can more or less take the "phased change" approach.
Disclaimer: I use both Vista and Linux (gentoo is my preferred distribution,) and am not afraid to say that I don't hate either of them, and rather like both of them.
Careful with names containing L slashdot.org/~AiphaWolf_HK slashdot.org/~AlphaWoif_HK slashdot.org/~AiphaWoif_HK
I think someone needs a nap. =)
It's not offtopic, dumbass. It's orthogonal.
I thought all you need are the kernel headers and you just compile (not recompile) the module alone.
"Thanks for all the money you paid to us. We've used it to buy off ISO among other things" -Microsoft
From TFA there is no DMA access to kernelspace. So other than keyboards and mice I don't see how this can be practical for anything, other than embedded applications as the article alludes to.
Take the cheese to sickbay, the doctor should see it as soon as possible - B'Elanna Torres, "Learning Curve"
2.6.20 ? dude !!!
:p
:D :D The lists are full of different proposals and attempts over different times, but it's really nice to see that this thing finally got rolling, this may open a lot of closed-source drivers for usage for linux people (a lot of those fancy windows toys).
;)
I know i'm hopelessy outdated and my machine shows:
martin@hope ~ $ uname -a
Linux hope 2.6.21-gentoo-r4 #1 Sat Jul 21 22:18:42 EEST 2007 i686 AMD Turion(tm) 64 Mobile Technology MT-30 AuthenticAMD GNU/Linux
Remove that gentoo notice quickly from your slashdot sig. A man using kernel 0.0.02 versions old is a stable version pimp not a gentoo roller...
As for the article
Userspace drivers are not really a new groundbreaking idea now are they
Thumbs up Linus
I'd tell you the chances of this story being a dupe, but you wouldn't like it.
well i remember Linus comparing microkernels to 'masturbating' sometime back. It seems as h/w continues to grow in power and several other factors contributing, pushing more stuff to userspace will now look a better idea after all.
Which led me to the conclusion that this patch set is worthless. It allows remapping of memory-mapped I/Os to a userspace app, and allows a thread to "wait" on an interrupt. Both are nice ideas, and it would be very easy to implement a nice serial port driver with the new APIs. (As any kernel hacker knows, serial port is one of the simplest device drivers; it's easy.)
The new API is completely useless for binary-only drivers. I/Os / IRQs are enough for extremely simple devices - these are, after all, the primitives for talking to hardware. But if this were all a driver needed, don't you think Nvidia / ATI would have used this model for shim drivers a long time ago? Simple things like DMA and PCI configuration access are not present - but to be fair, those are implementable with these primitives. Reality check: real world drivers are a lot more complicated. What is impossible is fast thread switching, kernel synchronization primitives, access to the network stack (wireless!), ring-0 CPU instructions, real-time timing access, and the huge reduction in context switches / cache flushes that comes from running within the kernel (moving code to user-mode increases latency by a factor of 3, roughly). Kiss the lag-free desktop goodbye as hard drive latency skyrockets, watch your 3D framerate drop by 70%, see your webcam stutter into unusability.
The kinds of drivers this API can support are the simplistic ones, the kind that are already GPLed and are already in the kernel, the 80% of devices in this world Linux has always had good support for. The kinds of drivers this API cannot support are 3D graphics, high-performance disk or networking, wireless networking, latency-sensitive USB or Firewire, the virtual devices (VMware, KVM, Xen, even /dev/tty) - notice that most of the devices Linux supports poorly (and all the common binary-only drivers) fall into this list.
To be fair, the official (e.g. from Linus) announcements I've seen only claim this interface is useful for embedded devices (which tend to code for a specific kernel, and not get updated). No official announcement claims the new API will help binary-only drivers. It's just the OSS-zealot crowd making unwarranted assumptions. Yes, this is the bad news: the stable userspace driver API will do nothing to solve binary-only driver dilemmas. Sorry.
A witty [sig] proves nothing. --Voltaire
You've not needed to RECOM-FUCKING-PILE the kernel for a new driver for well over 10 years now... I think modules were added back in 1993 or so. The only people who've been recompiling kernels in the last decade are either (a) unaware of modules or (b) building a statically linked kernel for a niche app. Or perhaps some vendor was too clueless to supply a driver as a module.
Oolite: Elite-like game. For Mac, Linux and Windows
> (...)'nonstandard' hardware that likes direct IO, like disk-arrays.
Which is, as far as I know, scarcely used in a small business situation, or even a home user one. And in this kind of situation, you have system administrators - I know, I'm one of those - who are PAID to do this kind of job.
Not that recompiling a kernel really requires high level expertise, mind you.
Anyway, isn't the solution to petition your favorite vendor to provide the relevant driver with a convenient licence so that it can be incorporated in the kernel?
--
Arkan
Since this is GPL then neither MS or Apple would dare touch it. If it was BSD then it might be possible that Apple might adopt it but they are not going to put something into their kernel that they don't own. The same goes for MS with the added difficulty of their operating system not being POSIX compliant.
This is why I am prefer BSD license over GPL. Though, I am sure the majority of the readers on here would disagree with me. Anytime I look at open software I always check if there is a BSD licensed equivalent as compared to GPL. Just in case I want to develop it into a commercial application and all. That way I don't have to distribute a license that passes rights onto the users. I can simply take the BSD license version make my modifications and slap a (C) on it. I know the GPL advocates would argue that is what makes GPL good, keeping people like me from doing just that but Apple and MS are people like me. That is why Darwin was derived from BSD not because they were so hot on the Mach kernel but because of it's license. If MS ever goes to a POSIX based UNIX type OS with a Windows GUI, just like Apple did, they would do the same thing but they wouldn't be nice enough to maintain an open source version like Apple has done with Darwin.
My 2 cents and change!
Nick Powers
Encryption: I may not agree with what you say, but I will defend your right to encrypt it...
> Linux should absolutely never become a microkernel
Religion notwithstanding, it will become microkernel-like, because a monolithic kernel just doesn't scale. It's as simple as that.
Monolithic kernels don't scale as the number of CPUs rises, nor as the number of drivers and other logical components goes up.
Because of the need to scale, in time Linux will partition itself into independent subsystems, and slowly but surely will become a microkernel-type design, because the alternative to that would be to suffer astronomic bug rates from combinatorial complexity explosion and very poor performance from CPU contention compared to a decoupled, decentralized design.
That microkernel future is 100% inevitable, because fighting growth is like trying to sweep back the tide. In due course, the debate will just fade away, and engineering will take over. And engineers always decouple.
"The question of whether machines can think is no more interesting than [] whether submarines can swim" - Dijkstra
I think someone needs to install git! 2.6.20? psssh.
This seems to be an on-going trend in the kernel: FUSE, libusb, libraw1394 and ALSA all (to a certain extent) export what were traditionally kernel-bound services/drivers to user-space, while leaving the minimum necessary kernel-side mechanism, such as VFS redirection, and low-level I/O and interrupt handling. However they all do this in different ways according to the needs of the hardware. So while a generic API may be a good for unusual pieces of hardware, might it not be a good idea to develop application-specific subsystems that hook the kernel's existing ABIs (as used by current kernel-space drivers)? For example, we could have something specific for networking devices that does all the necessary set-up on the kernel side (establishing device name, wireless extensions, etc.) and communicates with a user-space driver (a bit like ALSA), which could be anything from a specific Free-Software driver to a proprietary modem driver or a wrapper for something like NDIS. Similarly with network protocols, although this might look more like FUSE.
It would be great if dists would support an ABI and produce some dist neutral packaging system that allowed drivers to be installed / uninstalled easily by mere mortals no matter what dist they had.
Linux esperto 2.6.22-8-generic #1 SMP Thu Jul 12 15:59:45 GMT 2007 i686 GNU/Linux Ubuntu user, One who only compile when he need it.
Are doomed.
There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
I'm pretty sure I've HURD of this userland driver idea before.
The Christian religion has been and still is the principal enemy of moral progress in the world. -- Bertrand Russell
A microkernel. What, like this? :-)
Stick Men
I agree with the closed driver thing, i strongly believe that many companies are never going to GPL their drivers, or even open source them at all, and user space drivers solves the majority of that problem.
Sometimes there may be a performance hit but it will be worth the stability and the (hopefully) easier installation and removal of drivers.
Am I missing something here?
Let's take a wireless cards for example. There are many companies that know how to make wireless cards, so how does locking down the driver prevent cloning of a particular card?
It's because without knowledge of how the driver communicates with the card, the best a knock-off competitor could do is to make a functionally similar card with a driver of its own. They can NOT make a card that will work with the same drivers as the original one. (i.e. is "pin compatible").
This gives the manufacturer with existing market share a big advantage, because if a competitor comes along later and says "look, ours does the same thing!" then the OEM or embedded systems engineer (people who buy thousands of these things) will say "yes the specs are similar but it doesn't work with our supported drivers. It's not worth it to us to qualify a new driver even if we can save a few cents per unit."
However, there is a secondary concern that knowledge of the driver interface actually helps a lot for someone to learn how to implement a competing technology even if it doesn't use the same driver. It's not like the data sheets just say "the magic numbers are 0x5724 and 0x3217 etc." You actually need to reveal quite a lot about how the device works in order for someone to be able to write a driver for it.
The demand for linux drivers needs to reach the point at which a given manufacturer perceives that whatever IP they might expose by releasing Linux drivers is less of an impact than losing out on those sales. We are almost certainly at that point already, but most manufacturers don't realize it.
Wow, the kernel's been mainlining drivers without my knowledge? This is serious...
Userspace drivers are not really a new groundbreaking idea now are they
I can make a case for deja-vu 1968: SDS Sigma 7 BPM.
I'm a Programmer. That's one level above Software Engineer and one level below Engineer.
Surely this has security implications - know that you can always become root but with this someone could craft a driver that does evil things and spread it around.
M-
...or applying patches for the scheduler and what not...
Money is the root of all evil?
The only reason that you would have to recompile the kernel to add major drivers would be if the default kernel didn't have the driver you needed compiled as a module. But that generally only happens with pretty uncommon hardware as most everything is compiled as a module in Linux kernels anymore. You might have to change your modprobe scripts to load the new hardware's modules at bootup, but that's about it. And if you have a new driver that's not in the kernel tree (like ATi/NVIDIA and VMware drivers), the worst you have to do is compile it against the kernel, not recompile the whole kernel.
There are other reasons one has to recompile a kernel, but drivers aren't generally one of them, unless you count moving from a single-core box to an SMP one and needing to enable SMP. But even that's rare as most distributors have only an SMP kernel and no UP kernel now.
Just "gittin-r-done," day after day.
The kernel won't help you do DMA nicely, but it can't stop you. Anything with control over a PCI device can set off a DMA operation, which the PCI device will then perform. PCI DMA is done from the device, not the motherboard.
This is a massive security hole. One of these drivers can use DMA to read your kernel memory. It can then send this over the network. It can look for data structures in the kernel, then DMA some code and function pointers into the kernel. It's trivial to take control of the system.
2.6.22-8? Ubuntu is cutting edge considering the latest is 2.6.22-1
http://www.kernel.org/pub/linux/kernel/v2.6/
Yes, and no. Ubuntu gutsy is in alfa.;)
Some of those are simple data transfer interfaces. Most of those have drivers available at this point, either through reverse-engineering efforts or through actual drivers. Some of those are more complicated (it wouldn't surprise me if much of the printer logic is in software at this point, for example).
The same basic economic forces are pushing a lot of them. Software has to be written once and can be copied forever. CPU cycles, RAM, and bytes are cheap. Why not push more into software, and write all your hardware control as "driver" code?
You can divide drivers into three basic categories - drivers that are provided closed-source at best, drivers that are provided open-source by the manufacturer, and drivers that the manufacturer doesn't need to bother providing open-source because they're so fucking simple. A significant amount of the above falls into the latter category. And some doesn't. Shrug.
Breaking Into the Industry - A development log about starting a game studio.
"Yes, and no. Ubuntu gutsy is in alfa.;)"
it's alfalfa not alfa.
Ubuntu = 2.6.22.0 Ubuntu rev 8
Kernel.org = 2.6.22.1
Different, but thanks for playing the Smartass Game! You lose, play again soon!
The preceding comment is my own, and in no way construes an opinon of the Emperor of Mankind.
...I see a first post modded "Redundant". Is there some kind of tradition around here that I'm not aware of?
Schematics are nice, but there is a small problem though - I doubt that your house is big enough for the schematics of the north bridge, never mind the processor...
Excuse me, but please get off my Pennisetum Clandestinum, eh!
Money is the root of all evil?
Those "high priests" also tend to know a hell of a lot more about kernels in general and the Linux kernel specifically than a random layperson, or even a highly experienced coder. It would do you good to learn from them. Perhaps instead of bull-doggedly trying to push your patch, perhaps you should figure out what they specifically objected to (they don't randomly object to all patches, as the kernel does keep being developed and having patches applied), figure out why, and fix it. Either by explaining to them (with evidence!) why they are wrong, and you better be DAMN sure you're right, or more likely by fixing the problems with you patch. Do you expect the engineers at Ferrari to take your suggestion on what cam to put in their engine, even if you're a fast car enthusiast? Why would you think the Linux kernel keepers are any less elite in their skills and knowledge?
My blog. Good stuff (when I remember to update it). Read it.
Show me a Fortune 500 (or even 1000, let's get crazy) company that uses ZFS in a critical space. ZFS isn't relevant (yet) compared to Linux.
My blog. Good stuff (when I remember to update it). Read it.
But what happens if you do this right? Sure, most single drives can't handle that kind of throughput right now, but scalability and future-proofing are important. There's no point in having a mechanism which is OK for today but useless three weeks from now.
It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
Say hi to the HP DeskJets that use PPA (the cheap ones). Their logic is basically composed of an MC68K CPU with enough RAM to hold one print sweep and control the motors. The protocol literally includes commands for advancing the paper a certain amount and sweeping the cartridge (with raw print dot data).
No you don't get how things work around here, when Microsoft does something it is bad. When Linus does something similar it is good.
Well he already caught up to and surpassed a 37 year old operating system. Actually, user mode drivers seem to be new to VISTA, although I think there is something similar in earlier NT kernels.
Its called cross pollination btw. I'd like Linus to go stealing all the good ideas from the non unix OSes.
--- Justin Dearing http://www.justaprogrammer.net/ We're just programmers.
Umm... I dunno. Maybe Sun Microsystems, which sits at #187?
ZFS was released way back in late 2005. Solaris is still pretty popular in the Fortune 500. I would imagine at least a few of those customers are using ZFS, even if they're only to try to stretch a storage budget that just isn't big enough for EMC this quarter.
In practice, where are you going to get a fully capable IOMMU?
The one on AMD64 chips, intended to be just an AGP-GART, does not protect the full address space.
Intel has documented the functionality of an IOMMU for the Linux kernel developers, but makes no mention of actual or even proposed chipsets with the feature.
To protect devices from being used to attack other devices, they can't share busses as is normal for standard PCI. You need one IOMMU per bus.
In other news, MINUX developers have recently announced that MINUX has been rewritten to now focus on having all the device drivers in Kernel Land. Andy Tanenbaum made the decision to make MINUX become LINUX when he was bitten by a raccoon in his garbage can that he was sleeping in outside.
Is this similar to the way video drivers in vista have been moved into user space? At least according to microsoft- this will actually speed up the drivers if implemented right, as opposed to slowing it down. Something about the cpu switching from protected mode to user mode or something. I do not know the details. If someone does- please contribute.
Always happy to play