low level VM for test boxes
Posted: Mon May 25, 2009 5:27 pm
I came up with this idea while in another thread, but it was kind of out of place.
Wouldn't it be useful if there was a way that you could test someone else's OS project on a real machine without any fear of it crashing and somehow destroying your data/hardware? I think it would be a good idea to write a very small piece of code that works as a simple VM for privileged instructions, and is itself run on the bare hardware, acting as a "gatekeeper" for ports. The real kernel would probably be run in ring 1, and all privileged calls would be trapped to the VM. It would be configured at compile/assemble time to either reject or accept certain actions, but would never emulate anything. A bit of self-modifying code could be used to handle all privileged instructions with one handler too .
There would be three main advantages of this over something like VMware or Bochs. First off, it is several orders of magnitude smaller and simpler, and would need no operating system support. Second, all hardware for the VM would be *real* hardware, so drivers for real devices could be written and tested. Plus, the processor is real as well, so things can be realistically tested on different machines - that's the whole reason for testing on real machines anyway. Third, it would run at almost completely native speeds, except for the privileged instructions, which would take a dozen or so extra clock cycles.
Additionally, it could also have a built in default IDT and GDT that would trap faults even before the kernel sets up its own handlers. This would be handy for debugging early stages of kernel development, both on real hardware and within a full virtual machine.
Does this seem like a useful and, more importantly, feasible idea?
Wouldn't it be useful if there was a way that you could test someone else's OS project on a real machine without any fear of it crashing and somehow destroying your data/hardware? I think it would be a good idea to write a very small piece of code that works as a simple VM for privileged instructions, and is itself run on the bare hardware, acting as a "gatekeeper" for ports. The real kernel would probably be run in ring 1, and all privileged calls would be trapped to the VM. It would be configured at compile/assemble time to either reject or accept certain actions, but would never emulate anything. A bit of self-modifying code could be used to handle all privileged instructions with one handler too .
There would be three main advantages of this over something like VMware or Bochs. First off, it is several orders of magnitude smaller and simpler, and would need no operating system support. Second, all hardware for the VM would be *real* hardware, so drivers for real devices could be written and tested. Plus, the processor is real as well, so things can be realistically tested on different machines - that's the whole reason for testing on real machines anyway. Third, it would run at almost completely native speeds, except for the privileged instructions, which would take a dozen or so extra clock cycles.
Additionally, it could also have a built in default IDT and GDT that would trap faults even before the kernel sets up its own handlers. This would be handy for debugging early stages of kernel development, both on real hardware and within a full virtual machine.
Does this seem like a useful and, more importantly, feasible idea?