Tuesday, April 26, 2011

MIPS: non-virtualizable architecture (Part 1)

MIPS is a wonderful architecture. But when it was design virtualization wasn't much in the air. As a result, this architecture isn't compleletly virtualizable. It isn't as notorious as x86.

One requirement for virtualization is the access priviledges to syste registers. MIPS does provide this. All system registers are in CP0. Any access from user space will falt. Modification access to TLBs will also fault. Then what is the problem?

The problem is with the way virtual address space is laid out. For 32 bit architecture 4 GB virtual address space is available. MIPS specification reserve upper 2 GB for kernel/supervisor mode. Any access to 3rd GB in kernel mode will go untranslated by MMU. The last 4th GB will go via MMU but is only usable in kernel mode.

For running a guest, only first 2 GB is available. Both guest and its userspace programs can only have 2GB of virtual address space.
Linux assumes many things about address space layout. It is linked in kseg0. Kmap addresses are present in Kseg2. For these and other reasons, an unmodified Linux guest cannot run on MIPS architecture. There will be modifications required. But don't propose the modifications up to the level of "hypercalls".