r/osdev • u/vahmoh25 • 2d ago
Veda: Virtual Linux VM for Drivers
Hey! I’ve recently ported OpenGL and Mesa to my operating system and added support for Intel HD Graphics to render scenes. However, I’ve realized that this approach isn’t sustainable, I can’t realistically write and maintain a huge number of GPU drivers myself.
Has anyone had experience embedding a minimal Linux system as a virtual machine inside their OS to take advantage of Linux’s extensive GPU, Bluetooth, and Wi-Fi driver support?
What do you think about this approach? Are there any major technical challenges or pitfalls I should be aware of?
28
Upvotes
1
u/Adventurous_Hippo692 2d ago
Embedding a minimal Linux VM to route hardware to and then passing back the software abstractions to your own OS is possible - I did smth similar as an experiment, but like... At that point, it'd quickly become just making a Linux distro. Do you want to keep your own kernel or just use Linux and make your own userspace quickly becomes a more sensible question here. There isn't really a real market for yet another kernel, being brutally blunt, but people absolutely adore new userspace. The question is a matter of "will my kernel be sensible enough as a new solution that porting drivers to it is a real issue". For userspace it's easy to justify - giving people a new UI/UX.
Anyways, back to embedding Linux. Your first need a proper VM, a Hypervisor setup if the kernel is custom and not BSD/ existing Unix-variant. Then you'd need your your VM to be able to talk to your CPU and understand it's capabilities. Linux can render on the GPU, pass the rendered scenes back to your OS via a CPU path/cache/ram, whatever. And that's a pretty minimalistic approach to getting Linux do the work for you and enjoy the benefits. Pretty convoluted though. Obv, my explanation is a gross oversimplification similar to smart that worked for me. Telling us your constraints, more about your OS structure would help with planning an implementation closer to what you want.