Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 460
Richard Keller Avatar asked Sep 12 '25 10:09

Richard Keller


1 Answers

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
like image 72
user568109 Avatar answered Sep 16 '25 08:09

user568109