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:

  • ARM Instruction Set
  • MIPS Instruction Set
  • 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 :

  • http://www.linux-mips.org/wiki/Main_Page
  • Porting Linux kernel 2.6 to new MIPS board
  • http://developer.mips.com/linux/
  • For ARM :

  • http://www.arm.com/community/software-enablement/linux.php
  • http://www.arm.linux.org.uk/docs/kerncomp.php

  • 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:

  • MIPS
  • H8 (μClinux)
  • 68k/Coldfire (μClinux)

  • As I said in the comments, I would balance three aspects:

  • simple instruction set (few instruction formats, few opcodes: anything NOT like x86)
  • documentation: widely available. This means potentially discard some simple architectures to concentrate on widely supported ones (for example, x86 wins here, but you also find a lot of material on RISC and especially MIPS from academia). Or go for something Open, like OpenRisc
  • ease of use in "kernel mode". In privileged, kernel mode there is a whole new world of registers, instructions and internals to consider. And do not forget that a processor comes with a bus too, and simple processors may have very complex buses! And you will need to emulate that as well. OR, you may go for User mode Linux, if you are happy with it.
  • 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

    上一篇: 在指令集翻译器/仿真器中解码线程

    下一篇: 可以虚拟化并运行Linux内核的最简单的架构