Showing posts with label hardware virtualization. Show all posts
Showing posts with label hardware virtualization. Show all posts

Mar 23, 2014

Qemu. Mips cpu virtualization

About MIPS architecture

Download initrd.gz and vmlinux-3.2.0-4-4kc-malta from http://ftp.debian.org/debian/dists/stable/main/installer-mips/current/images/malta/netboot/
# install
qemu-system-mips -M malta -kernel vmlinux-3.2.0-4-4kc-malta -initrd initrd.gz \
 -hda debian74_mips.img  -append "root=/dev/sda1 console=ttyS0" -nographic

# boot
qemu-system-mips -M malta -kernel vmlinux-3.2.0-4-4kc-malta \
 -hda debian74_mips.img -append "root=/dev/sda1 console=ttyS0" -nographic

On guest host:
uname -a
# Linux debianmips 3.2.0-4-4kc-malta #1 Debian 3.2.54-2 mips GNU/Linux

cat /proc/cpuinfo 
# system type  : MIPS Malta
# processor  : 0
# cpu model  : MIPS 24Kc V0.0  FPU V0.0
mips hello world (http://en.wikipedia.org/wiki/MIPS_architecture#MIPS_assembly_language):
00400640 <main>:
#include <stdio.h>

int main() {
  400640: 27bdffe0  addiu sp,sp,-32
  400644: afbf001c  sw ra,28(sp)
  400648: afbe0018  sw s8,24(sp)
  40064c: 03a0f021  move s8,sp
    printf("Hello world!\n");
  400650: 3c020040  lui v0,0x40
  400654: 24440810  addiu a0,v0,2064
  400658: 0c100140  jal 400500 <puts@plt>
  40065c: 00200825  move at,at
    return 0;
  400660: 00001021  move v0,zero
}
  400664: 03c0e821  move sp,s8
  400668: 8fbf001c  lw ra,28(sp)
  40066c: 8fbe0018  lw s8,24(sp)
  400670: 27bd0020  addiu sp,sp,32
  400674: 03e00008  jr ra
  400678: 00200825  move at,at
  40067c: 00200825  move at,at
i386 hello world:
0804840c <main>:
#include <stdio.h>

int main() {
 804840c: 55                    push   ebp
 804840d: 89 e5                 mov    ebp,esp
 804840f: 83 e4 f0              and    esp,0xfffffff0
 8048412: 83 ec 10              sub    esp,0x10
    printf("Hello world!\n");
 8048415: c7 04 24 c0 84 04 08  mov    DWORD PTR [esp],0x80484c0
 804841c: e8 cf fe ff ff        call   80482f0 <puts@plt>
    return 0;
 8048421: b8 00 00 00 00        mov    eax,0x0
}
 8048426: c9                    leave  
 8048427: c3                    ret    
 8048428: 90                    nop
 8048429: 90                    nop
 804842a: 90                    nop
 804842b: 90                    nop
 804842c: 90                    nop
 804842d: 90                    nop
 804842e: 90                    nop
 804842f: 90                    nop
x64 hello world:
00000000004004fd <main>:
#include <stdio.h>

int main() {
  4004fd: 55                    push   rbp
  4004fe: 48 89 e5              mov    rbp,rsp
    printf("Hello world!\n");
  400501: bf a4 05 40 00        mov    edi,0x4005a4
  400506: e8 d5 fe ff ff        call   4003e0 <puts@plt>
    return 0;
  40050b: b8 00 00 00 00        mov    eax,0x0
}
  400510: 5d                    pop    rbp
  400511: c3                    ret    
  400512: 66 2e 0f 1f 84 00 00  nop    WORD PTR cs:[rax+rax*1+0x0]
  400519: 00 00 00 
  40051c: 0f 1f 40 00           nop    DWORD PTR [rax+0x0]

Instructions for other archs with qemu:
https://gmplib.org/~tege/qemu.html