Simplest possible architecture that can be virtualized and run the Linux kernel
I've been inspired by Fabrice Bellard's implementation of an x86 virtual machine in Javascript, and I'd like to try writing the simplest possible virtual machine that is capable of running the Linux kernel. This is a purely educational endeavour, with no purpose other than understanding and sharing the code that makes this possible.
Having glanced over the x86 specification, I suspect that I might be throwing myself into the deep end by trying to write a virtual machine that is capable of emulating the complete x86 instruction set. Instead, I'm looking for a simpler architecture that I can attempt to emulate.
I've read through this question which asks how to emulate the x86 architecture, and the answer suggests starting with something simpler, like the ARM architecture. My question is more specific: what is the simplest possible architecture that I can attempt to emulate which will be able to run the Linux kernel?
I'm interested in fully emulating the entire machine, not simply passing instructions back to the host machine (which, for example, would be possible if I were writing an x86 emulator). I have a decent amount of 16-bit assembly knowledge, and some operating systems theory background, so this should be well within reach with enough work.
Simplest possible architecture will be from point-of-view of ease of implementation. Since you are building an emulator that fully emulates the machine, whichever has simplest Instruction Set Design/Architecture will be suitable. RISC architectures no doubt are better. But choosing an architecture that is not widely used is also not good, if you need support few would be able to help you. Writing a simulator is no piece of cake. I would say either go for ARM or MIPS, both are popular:
Also you must know that Fabrice Bellard's javascript virtual machine uses 32-bit x86 compatible CPU, something which is supported by Linux natively. You would have to port linux kernel (use toolchains) for ARM or MIPS yourself. See links on how to use the linux kernel
For MIPS :
For ARM :
The list of architectures supported by Linux kernel:
http://en.wikipedia.org/wiki/List_of_Linux_supported_architectures
The "simplest possible" is somewhat subjective, but here are what I think are less complicated ones from that list:
As I said in the comments, I would balance three aspects:
In the end, I would suggest something "old": reasonably simple, especially in privileged mode, well studied and documented. For example, the original MIPS, the Motorola 68k family, or something close to the original RISC (http://en.wikipedia.org/wiki/Berkeley_RISC), if there is a Linux variant for it!
链接地址: http://www.djcxy.com/p/50562.html上一篇: 在指令集翻译器/仿真器中解码线程