Commit 1eb20527c88ff596e761574e6615c8f2272882b8
1 parent
e3e86d56
update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@283 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
268 additions
and
40 deletions
Changelog
| ... | ... | @@ -4,6 +4,7 @@ version 0.4: |
| 4 | 4 | - fixed signal handling for correct dosemu DPMI emulation |
| 5 | 5 | - fast x86 MMU emulation with mmap() |
| 6 | 6 | - fixed popl (%esp) case |
| 7 | + - Linux kernel can be executed by QEMU with the 'vl' command. | |
| 7 | 8 | |
| 8 | 9 | version 0.3: |
| 9 | 10 | |
| ... | ... | @@ -17,10 +18,10 @@ version 0.3: |
| 17 | 18 | |
| 18 | 19 | version 0.2: |
| 19 | 20 | |
| 20 | - - PowerPC disassembly and ELF symbols output (Rusty Russel) | |
| 21 | - - flock support (Rusty Russel) | |
| 22 | - - ugetrlimit support (Rusty Russel) | |
| 23 | - - fstat64 fix (Rusty Russel) | |
| 21 | + - PowerPC disassembly and ELF symbols output (Rusty Russell) | |
| 22 | + - flock support (Rusty Russell) | |
| 23 | + - ugetrlimit support (Rusty Russell) | |
| 24 | + - fstat64 fix (Rusty Russell) | |
| 24 | 25 | - initial Alpha port (Falk Hueffner) |
| 25 | 26 | - initial IA64 port (Matt Wilson) |
| 26 | 27 | - initial Sparc and Sparc64 port (David S. Miller) | ... | ... |
TODO
| 1 | 1 | |
| 2 | +- finish segment ops (call far, ret far, load_seg suppressed) | |
| 2 | 3 | - fix arm fpu rounding (at least for float->integer conversions) |
| 3 | 4 | - fix CCOP optimisation |
| 4 | 5 | - optimize FPU operations (evaluate x87 stack pointer statically) |
| ... | ... | @@ -7,7 +8,6 @@ |
| 7 | 8 | state, find a solution for tb_flush()). |
| 8 | 9 | - add gcc 2.96 test configure (some gcc3 flags are needed) |
| 9 | 10 | - add IPC syscalls |
| 10 | -- submit a patch to fix DOSEMU coopthreads | |
| 11 | 11 | |
| 12 | 12 | lower priority: |
| 13 | 13 | -------------- | ... | ... |
VERSION
qemu-doc.texi
| ... | ... | @@ -11,35 +11,62 @@ |
| 11 | 11 | |
| 12 | 12 | @section Features |
| 13 | 13 | |
| 14 | -QEMU is a FAST! processor emulator. Its purpose is to run Linux executables | |
| 15 | -compiled for one architecture on another. For example, x86 Linux | |
| 16 | -processes can be ran on PowerPC Linux architectures. By using dynamic | |
| 17 | -translation it achieves a reasonnable speed while being easy to port on | |
| 18 | -new host CPUs. Its main goal is to be able to launch the @code{Wine} | |
| 19 | -Windows API emulator (@url{http://www.winehq.org}) or @code{DOSEMU} | |
| 20 | -(@url{http://www.dosemu.org}) on non-x86 CPUs. | |
| 14 | +QEMU is a FAST! processor emulator. By using dynamic translation it | |
| 15 | +achieves a reasonnable speed while being easy to port on new host | |
| 16 | +CPUs. | |
| 17 | + | |
| 18 | +QEMU has two operating modes: | |
| 19 | +@itemize | |
| 20 | +@item User mode emulation. In this mode, QEMU can launch Linux processes | |
| 21 | +compiled for one CPU on another CPU. Linux system calls are converted | |
| 22 | +because of endianness and 32/64 bit mismatches. The Wine Windows API | |
| 23 | +emulator (@url{http://www.winehq.org}) and the DOSEMU DOS emulator | |
| 24 | +(@url{www.dosemu.org}) are the main targets for QEMU. | |
| 25 | + | |
| 26 | +@item Full system emulation. In this mode, QEMU emulates a full | |
| 27 | +system, including a processor and various peripherials. Currently, it | |
| 28 | +is only used to launch an x86 Linux kernel on an x86 Linux system. It | |
| 29 | +enables easier testing and debugging of system code. It can also be | |
| 30 | +used to provide virtual hosting of several virtual PCs on a single | |
| 31 | +server. | |
| 32 | + | |
| 33 | +@end itemize | |
| 34 | + | |
| 35 | +As QEMU requires no host kernel patches to run, it is very safe and | |
| 36 | +easy to use. | |
| 21 | 37 | |
| 22 | 38 | QEMU generic features: |
| 23 | 39 | |
| 24 | 40 | @itemize |
| 25 | 41 | |
| 26 | -@item User space only emulation. | |
| 42 | +@item User space only or full system emulation. | |
| 43 | + | |
| 44 | +@item Using dynamic translation to native code for reasonnable speed. | |
| 27 | 45 | |
| 28 | 46 | @item Working on x86 and PowerPC hosts. Being tested on ARM, Sparc32, Alpha and S390. |
| 29 | 47 | |
| 30 | -@item Using dynamic translation to native code for reasonnable speed. | |
| 48 | +@item Self-modifying code support. | |
| 49 | + | |
| 50 | +@item Precise exception support. | |
| 31 | 51 | |
| 52 | +@item The virtual CPU is a library (@code{libqemu}) which can be used | |
| 53 | +in other projects. | |
| 54 | + | |
| 55 | +@end itemize | |
| 56 | + | |
| 57 | +QEMU user mode emulation features: | |
| 58 | +@itemize | |
| 32 | 59 | @item Generic Linux system call converter, including most ioctls. |
| 33 | 60 | |
| 34 | 61 | @item clone() emulation using native CPU clone() to use Linux scheduler for threads. |
| 35 | 62 | |
| 36 | 63 | @item Accurate signal handling by remapping host signals to target signals. |
| 64 | +@end itemize | |
| 65 | +@end itemize | |
| 37 | 66 | |
| 38 | -@item Self-modifying code support. | |
| 39 | - | |
| 40 | -@item The virtual CPU is a library (@code{libqemu}) which can be used | |
| 41 | -in other projects. | |
| 42 | - | |
| 67 | +QEMU full system emulation features: | |
| 68 | +@itemize | |
| 69 | +@item Using mmap() system calls to simulate the MMU | |
| 43 | 70 | @end itemize |
| 44 | 71 | |
| 45 | 72 | @section x86 emulation |
| ... | ... | @@ -49,11 +76,9 @@ QEMU x86 target features: |
| 49 | 76 | @itemize |
| 50 | 77 | |
| 51 | 78 | @item The virtual x86 CPU supports 16 bit and 32 bit addressing with segmentation. |
| 52 | -User space LDT and GDT are emulated. VM86 mode is also supported to run DOSEMU. | |
| 53 | - | |
| 54 | -@item Precise user space x86 exceptions. | |
| 79 | +LDT/GDT and IDT are emulated. VM86 mode is also supported to run DOSEMU. | |
| 55 | 80 | |
| 56 | -@item Support of host page sizes bigger than 4KB. | |
| 81 | +@item Support of host page sizes bigger than 4KB in user mode emulation. | |
| 57 | 82 | |
| 58 | 83 | @item QEMU can emulate itself on x86. |
| 59 | 84 | |
| ... | ... | @@ -73,12 +98,21 @@ Current QEMU limitations: |
| 73 | 98 | @item IPC syscalls are missing. |
| 74 | 99 | |
| 75 | 100 | @item The x86 segment limits and access rights are not tested at every |
| 76 | -memory access (and will never be to have good performances). | |
| 101 | +memory access. | |
| 77 | 102 | |
| 78 | 103 | @item On non x86 host CPUs, @code{double}s are used instead of the non standard |
| 79 | 104 | 10 byte @code{long double}s of x86 for floating point emulation to get |
| 80 | 105 | maximum performances. |
| 81 | 106 | |
| 107 | +@item Full system emulation only works if no data are mapped above the virtual address | |
| 108 | +0xc0000000 (yet). | |
| 109 | + | |
| 110 | +@item Some priviledged instructions or behaviors are missing. Only the ones | |
| 111 | +needed for proper Linux kernel operation are emulated. | |
| 112 | + | |
| 113 | +@item No memory separation between the kernel and the user processes is done. | |
| 114 | +It will be implemented very soon. | |
| 115 | + | |
| 82 | 116 | @end itemize |
| 83 | 117 | |
| 84 | 118 | @section ARM emulation |
| ... | ... | @@ -94,7 +128,7 @@ generic dynamic code generation architecture of QEMU. |
| 94 | 128 | |
| 95 | 129 | @end itemize |
| 96 | 130 | |
| 97 | -@chapter Invocation | |
| 131 | +@chapter QEMU User space emulation invocation | |
| 98 | 132 | |
| 99 | 133 | @section Quick Start |
| 100 | 134 | |
| ... | ... | @@ -198,27 +232,188 @@ Activate log (logfile=/tmp/qemu.log) |
| 198 | 232 | Act as if the host page size was 'pagesize' bytes |
| 199 | 233 | @end table |
| 200 | 234 | |
| 235 | +@chapter QEMU System emulator invocation | |
| 236 | + | |
| 237 | +@section Quick Start | |
| 238 | + | |
| 239 | +This section explains how to launch a Linux kernel inside QEMU. | |
| 240 | + | |
| 241 | +@enumerate | |
| 242 | +@item | |
| 243 | +Download the archive @file{vl-test-xxx.tar.gz} containing a Linux kernel | |
| 244 | +and an initrd (initial Ram Disk). The archive also contains a | |
| 245 | +precompiled version of @file{vl}, the QEMU System emulator. | |
| 246 | + | |
| 247 | +@item Optional: If you want network support (for example to launch X11 examples), you | |
| 248 | +must copy the script @file{vl-ifup} in @file{/etc} and configure | |
| 249 | +properly @code{sudo} so that the command @code{ifconfig} contained in | |
| 250 | +@file{vl-ifup} can be executed as root. You must verify that your host | |
| 251 | +kernel supports the TUN/TAP network interfaces: the device | |
| 252 | +@file{/dev/net/tun} must be present. | |
| 253 | + | |
| 254 | +When network is enabled, there is a virtual network connection between | |
| 255 | +the host kernel and the emulated kernel. The emulated kernel is seen | |
| 256 | +from the host kernel at IP address 172.20.0.2 and the host kernel is | |
| 257 | +seen from the emulated kernel at IP address 172.20.0.1. | |
| 258 | + | |
| 259 | +@item Launch @code{vl.sh}. You should have the following output: | |
| 260 | + | |
| 261 | +@example | |
| 262 | +> ./vl.sh | |
| 263 | +connected to host network interface: tun0 | |
| 264 | +Uncompressing Linux... Ok, booting the kernel. | |
| 265 | +Linux version 2.4.20 (bellard@voyager) (gcc version 2.95.2 20000220 (Debian GNU/Linux)) #42 Wed Jun 25 14:16:12 CEST 2003 | |
| 266 | +BIOS-provided physical RAM map: | |
| 267 | + BIOS-88: 0000000000000000 - 000000000009f000 (usable) | |
| 268 | + BIOS-88: 0000000000100000 - 0000000002000000 (usable) | |
| 269 | +32MB LOWMEM available. | |
| 270 | +On node 0 totalpages: 8192 | |
| 271 | +zone(0): 4096 pages. | |
| 272 | +zone(1): 4096 pages. | |
| 273 | +zone(2): 0 pages. | |
| 274 | +Kernel command line: root=/dev/ram ramdisk_size=6144 | |
| 275 | +Initializing CPU#0 | |
| 276 | +Detected 501.785 MHz processor. | |
| 277 | +Calibrating delay loop... 973.20 BogoMIPS | |
| 278 | +Memory: 24776k/32768k available (725k kernel code, 7604k reserved, 151k data, 48k init, 0k highmem) | |
| 279 | +Dentry cache hash table entries: 4096 (order: 3, 32768 bytes) | |
| 280 | +Inode cache hash table entries: 2048 (order: 2, 16384 bytes) | |
| 281 | +Mount-cache hash table entries: 512 (order: 0, 4096 bytes) | |
| 282 | +Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes) | |
| 283 | +Page-cache hash table entries: 8192 (order: 3, 32768 bytes) | |
| 284 | +CPU: Intel Pentium Pro stepping 03 | |
| 285 | +Checking 'hlt' instruction... OK. | |
| 286 | +POSIX conformance testing by UNIFIX | |
| 287 | +Linux NET4.0 for Linux 2.4 | |
| 288 | +Based upon Swansea University Computer Society NET3.039 | |
| 289 | +Initializing RT netlink socket | |
| 290 | +apm: BIOS not found. | |
| 291 | +Starting kswapd | |
| 292 | +pty: 256 Unix98 ptys configured | |
| 293 | +Serial driver version 5.05c (2001-07-08) with no serial options enabled | |
| 294 | +ttyS00 at 0x03f8 (irq = 4) is a 16450 | |
| 295 | +ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com) | |
| 296 | +Last modified Nov 1, 2000 by Paul Gortmaker | |
| 297 | +NE*000 ethercard probe at 0x300: 52 54 00 12 34 56 | |
| 298 | +eth0: NE2000 found at 0x300, using IRQ 9. | |
| 299 | +RAMDISK driver initialized: 16 RAM disks of 6144K size 1024 blocksize | |
| 300 | +NET4: Linux TCP/IP 1.0 for NET4.0 | |
| 301 | +IP Protocols: ICMP, UDP, TCP, IGMP | |
| 302 | +IP: routing cache hash table of 512 buckets, 4Kbytes | |
| 303 | +TCP: Hash tables configured (established 2048 bind 2048) | |
| 304 | +NET4: Unix domain sockets 1.0/SMP for Linux NET4.0. | |
| 305 | +RAMDISK: ext2 filesystem found at block 0 | |
| 306 | +RAMDISK: Loading 6144 blocks [1 disk] into ram disk... done. | |
| 307 | +Freeing initrd memory: 6144k freed | |
| 308 | +VFS: Mounted root (ext2 filesystem). | |
| 309 | +Freeing unused kernel memory: 48k freed | |
| 310 | +sh: can't access tty; job control turned off | |
| 311 | +# | |
| 312 | +@end example | |
| 313 | + | |
| 314 | +@item | |
| 315 | +Then you can play with the kernel inside the virtual serial console. You | |
| 316 | +can launch @code{ls} for example. Type @key{Ctrl-a h} to have an help | |
| 317 | +about the keys you can type inside the virtual serial console. In | |
| 318 | +particular @key{Ctrl-a b} is the Magic SysRq key. | |
| 319 | + | |
| 320 | +@item | |
| 321 | +If the network is enabled, launch the script @file{/etc/linuxrc} in the | |
| 322 | +emulator (don't forget the leading dot): | |
| 323 | +@example | |
| 324 | +. /etc/linuxrc | |
| 325 | +@end example | |
| 326 | + | |
| 327 | +Then enable X11 connections on your PC from the emulated Linux: | |
| 328 | +@example | |
| 329 | +xhost +172.20.0.2 | |
| 330 | +@end example | |
| 331 | + | |
| 332 | +You can now launch @file{xterm} or @file{xlogo} and verify that you have | |
| 333 | +a real Virtual Linux system ! | |
| 334 | + | |
| 335 | +@end enumerate | |
| 336 | + | |
| 337 | +NOTE: the example initrd is a modified version of the one made by Kevin | |
| 338 | +Lawton for the plex86 Project (@url{www.plex86.org}). | |
| 339 | + | |
| 340 | +@section Kernel Compilation | |
| 341 | + | |
| 342 | +You can use any Linux kernel within QEMU provided it is mapped at | |
| 343 | +address 0x90000000 (the default is 0xc0000000). You must modify only two | |
| 344 | +lines in the kernel source: | |
| 345 | + | |
| 346 | +In asm/page.h, replace | |
| 347 | +@example | |
| 348 | +#define __PAGE_OFFSET (0xc0000000) | |
| 349 | +@end example | |
| 350 | +by | |
| 351 | +@example | |
| 352 | +#define __PAGE_OFFSET (0x90000000) | |
| 353 | +@end example | |
| 354 | + | |
| 355 | +And in arch/i386/vmlinux.lds, replace | |
| 356 | +@example | |
| 357 | + . = 0xc0000000 + 0x100000; | |
| 358 | +@end example | |
| 359 | +by | |
| 360 | +@example | |
| 361 | + . = 0x90000000 + 0x100000; | |
| 362 | +@end example | |
| 363 | + | |
| 364 | +The file config-2.4.20 gives the configuration of the example kernel. | |
| 365 | + | |
| 366 | +Just type | |
| 367 | +@example | |
| 368 | +make bzImage | |
| 369 | +@end example | |
| 370 | + | |
| 371 | +As you would do to make a real kernel. Then you can use with QEMU | |
| 372 | +exactly the same kernel as you would boot on your PC (in | |
| 373 | +@file{arch/i386/boot/bzImage}). | |
| 374 | + | |
| 375 | +@section PC Emulation | |
| 376 | + | |
| 377 | +QEMU emulates the following PC peripherials: | |
| 378 | + | |
| 379 | +@itemize | |
| 380 | +@item | |
| 381 | +PIC (interrupt controler) | |
| 382 | +@item | |
| 383 | +PIT (timers) | |
| 384 | +@item | |
| 385 | +CMOS memory | |
| 386 | +@item | |
| 387 | +Serial port (port=0x3f8, irq=4) | |
| 388 | +@item | |
| 389 | +NE2000 network adapter (port=0x300, irq=9) | |
| 390 | +@item | |
| 391 | +Dumb VGA (to print the @code{uncompressing Linux kernel} message) | |
| 392 | +@end itemize | |
| 393 | + | |
| 201 | 394 | @chapter QEMU Internals |
| 202 | 395 | |
| 203 | 396 | @section QEMU compared to other emulators |
| 204 | 397 | |
| 205 | -Unlike bochs [3], QEMU emulates only a user space x86 CPU. It means that | |
| 206 | -you cannot launch an operating system with it. The benefit is that it is | |
| 207 | -simpler and faster due to the fact that some of the low level CPU state | |
| 208 | -can be ignored (in particular, no virtual memory needs to be emulated). | |
| 398 | +Like bochs [3], QEMU emulates an x86 CPU. But QEMU is much faster than | |
| 399 | +bochs as it uses dynamic compilation and because it uses the host MMU to | |
| 400 | +simulate the x86 MMU. The downside is that currently the emulation is | |
| 401 | +not as accurate as bochs (for example, you cannot currently run Windows | |
| 402 | +inside QEMU). | |
| 209 | 403 | |
| 210 | 404 | Like Valgrind [2], QEMU does user space emulation and dynamic |
| 211 | 405 | translation. Valgrind is mainly a memory debugger while QEMU has no |
| 212 | -support for it (QEMU could be used to detect out of bound memory accesses | |
| 213 | -as Valgrind, but it has no support to track uninitialised data as | |
| 214 | -Valgrind does). Valgrind dynamic translator generates better code than | |
| 215 | -QEMU (in particular it does register allocation) but it is closely tied | |
| 216 | -to an x86 host and target. | |
| 217 | - | |
| 218 | -EM86 [4] is the closest project to QEMU (and QEMU still uses some of its | |
| 219 | -code, in particular the ELF file loader). EM86 was limited to an alpha | |
| 220 | -host and used a proprietary and slow interpreter (the interpreter part | |
| 221 | -of the FX!32 Digital Win32 code translator [5]). | |
| 406 | +support for it (QEMU could be used to detect out of bound memory | |
| 407 | +accesses as Valgrind, but it has no support to track uninitialised data | |
| 408 | +as Valgrind does). Valgrind dynamic translator generates better code | |
| 409 | +than QEMU (in particular it does register allocation) but it is closely | |
| 410 | +tied to an x86 host and target and has no support for precise exception | |
| 411 | +and system emulation. | |
| 412 | + | |
| 413 | +EM86 [4] is the closest project to user space QEMU (and QEMU still uses | |
| 414 | +some of its code, in particular the ELF file loader). EM86 was limited | |
| 415 | +to an alpha host and used a proprietary and slow interpreter (the | |
| 416 | +interpreter part of the FX!32 Digital Win32 code translator [5]). | |
| 222 | 417 | |
| 223 | 418 | TWIN [6] is a Windows API emulator like Wine. It is less accurate than |
| 224 | 419 | Wine but includes a protected mode x86 interpreter to launch x86 Windows |
| ... | ... | @@ -227,6 +422,20 @@ Windows API is executed natively but it is far more difficult to develop |
| 227 | 422 | because all the data structures and function parameters exchanged |
| 228 | 423 | between the API and the x86 code must be converted. |
| 229 | 424 | |
| 425 | +User mode Linux [7] was the only solution before QEMU to launch a Linux | |
| 426 | +kernel as a process while not needing any host kernel patches. However, | |
| 427 | +user mode Linux requires heavy kernel patches while QEMU accepts | |
| 428 | +unpatched Linux kernels. It would be interesting to compare the | |
| 429 | +performance of the two approaches. | |
| 430 | + | |
| 431 | +The new Plex86 [8] PC virtualizer is done in the same spirit as the QEMU | |
| 432 | +system emulator. It requires a patched Linux kernel to work (you cannot | |
| 433 | +launch the same kernel on your PC), but the patches are really small. As | |
| 434 | +it is a PC virtualizer (no emulation is done except for some priveledged | |
| 435 | +instructions), it has the potential of being faster than QEMU. The | |
| 436 | +downside is that a complicated (and potentially unsafe) kernel patch is | |
| 437 | +needed. | |
| 438 | + | |
| 230 | 439 | @section Portable dynamic translation |
| 231 | 440 | |
| 232 | 441 | QEMU is a dynamic translator. When it first encounters a piece of code, |
| ... | ... | @@ -409,6 +618,16 @@ space conflicts. QEMU solves this problem by being an executable ELF |
| 409 | 618 | shared object as the ld-linux.so ELF interpreter. That way, it can be |
| 410 | 619 | relocated at load time. |
| 411 | 620 | |
| 621 | +@section MMU emulation | |
| 622 | + | |
| 623 | +For system emulation, QEMU uses the mmap() system call to emulate the | |
| 624 | +target CPU MMU. It works as long the emulated OS does not use an area | |
| 625 | +reserved by the host OS (such as the area above 0xc0000000 on x86 | |
| 626 | +Linux). | |
| 627 | + | |
| 628 | +It is planned to add a slower but more precise MMU emulation | |
| 629 | +with a software MMU. | |
| 630 | + | |
| 412 | 631 | @section Bibliography |
| 413 | 632 | |
| 414 | 633 | @table @asis |
| ... | ... | @@ -439,6 +658,14 @@ Chernoff and Ray Hookway. |
| 439 | 658 | @url{http://www.willows.com/}, Windows API library emulation from |
| 440 | 659 | Willows Software. |
| 441 | 660 | |
| 661 | +@item [7] | |
| 662 | +@url{http://user-mode-linux.sourceforge.net/}, | |
| 663 | +The User-mode Linux Kernel. | |
| 664 | + | |
| 665 | +@item [8] | |
| 666 | +@url{http://www.plex86.org/}, | |
| 667 | +The new Plex86 project. | |
| 668 | + | |
| 442 | 669 | @end table |
| 443 | 670 | |
| 444 | 671 | @chapter Regression Tests | ... | ... |