main.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. .. _user-mode:
  2. QEMU User space emulator
  3. ========================
  4. Supported Operating Systems
  5. ---------------------------
  6. The following OS are supported in user space emulation:
  7. - Linux (referred as qemu-linux-user)
  8. - BSD (referred as qemu-bsd-user)
  9. Features
  10. --------
  11. QEMU user space emulation has the following notable features:
  12. **System call translation:**
  13. QEMU includes a generic system call translator. This means that the
  14. parameters of the system calls can be converted to fix endianness and
  15. 32/64-bit mismatches between hosts and targets. IOCTLs can be
  16. converted too.
  17. **POSIX signal handling:**
  18. QEMU can redirect to the running program all signals coming from the
  19. host (such as ``SIGALRM``), as well as synthesize signals from
  20. virtual CPU exceptions (for example ``SIGFPE`` when the program
  21. executes a division by zero).
  22. QEMU relies on the host kernel to emulate most signal system calls,
  23. for example to emulate the signal mask. On Linux, QEMU supports both
  24. normal and real-time signals.
  25. **Threading:**
  26. On Linux, QEMU can emulate the ``clone`` syscall and create a real
  27. host thread (with a separate virtual CPU) for each emulated thread.
  28. Note that not all targets currently emulate atomic operations
  29. correctly. x86 and Arm use a global lock in order to preserve their
  30. semantics.
  31. QEMU was conceived so that ultimately it can emulate itself. Although it
  32. is not very useful, it is an important test to show the power of the
  33. emulator.
  34. .. _linux-user-mode:
  35. Linux User space emulator
  36. -------------------------
  37. Command line options
  38. ~~~~~~~~~~~~~~~~~~~~
  39. ::
  40. qemu-i386 [-h] [-d] [-L path] [-s size] [-cpu model] [-g endpoint] [-B offset] [-R size] program [arguments...]
  41. ``-h``
  42. Print the help
  43. ``-L path``
  44. Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
  45. ``-s size``
  46. Set the x86 stack size in bytes (default=524288)
  47. ``-cpu model``
  48. Select CPU model (-cpu help for list and additional feature
  49. selection)
  50. ``-E var=value``
  51. Set environment var to value.
  52. ``-U var``
  53. Remove var from the environment.
  54. ``-B offset``
  55. Offset guest address by the specified number of bytes. This is useful
  56. when the address region required by guest applications is reserved on
  57. the host. This option is currently only supported on some hosts.
  58. ``-R size``
  59. Pre-allocate a guest virtual address space of the given size (in
  60. bytes). \"G\", \"M\", and \"k\" suffixes may be used when specifying
  61. the size.
  62. Debug options:
  63. ``-d item1,...``
  64. Activate logging of the specified items (use '-d help' for a list of
  65. log items)
  66. ``-g endpoint``
  67. Wait gdb connection to a port (e.g., ``1234``) or a unix socket (e.g.,
  68. ``/tmp/qemu.sock``).
  69. If a unix socket path contains single ``%d`` placeholder (e.g.,
  70. ``/tmp/qemu-%d.sock``), it is replaced by the emulator PID, which is useful
  71. when passing this option via the ``QEMU_GDB`` environment variable to a
  72. multi-process application.
  73. If the endpoint address is followed by ``,suspend=n`` (e.g.,
  74. ``1234,suspend=n``), then the emulated program starts without waiting for a
  75. connection, which can be established at any later point in time.
  76. ``-one-insn-per-tb``
  77. Run the emulation with one guest instruction per translation block.
  78. This slows down emulation a lot, but can be useful in some situations,
  79. such as when trying to analyse the logs produced by the ``-d`` option.
  80. Environment variables:
  81. QEMU_STRACE
  82. Print system calls and arguments similar to the 'strace' program
  83. (NOTE: the actual 'strace' program will not work because the user
  84. space emulator hasn't implemented ptrace). At the moment this is
  85. incomplete. All system calls that don't have a specific argument
  86. format are printed with information for six arguments. Many
  87. flag-style arguments don't have decoders and will show up as numbers.
  88. Other binaries
  89. ~~~~~~~~~~~~~~
  90. - user mode (Alpha)
  91. * ``qemu-alpha`` TODO.
  92. - user mode (Arm)
  93. * ``qemu-armeb`` TODO.
  94. * ``qemu-arm`` is also capable of running Arm \"Angel\" semihosted ELF
  95. binaries (as implemented by the arm-elf and arm-eabi Newlib/GDB
  96. configurations), and arm-uclinux bFLT format binaries.
  97. - user mode (ColdFire)
  98. - user mode (M68K)
  99. * ``qemu-m68k`` is capable of running semihosted binaries using the BDM
  100. (m5xxx-ram-hosted.ld) or m68k-sim (sim.ld) syscall interfaces, and
  101. coldfire uClinux bFLT format binaries.
  102. The binary format is detected automatically.
  103. - user mode (i386)
  104. * ``qemu-i386`` TODO.
  105. * ``qemu-x86_64`` TODO.
  106. - user mode (Microblaze)
  107. * ``qemu-microblaze`` TODO.
  108. - user mode (MIPS)
  109. * ``qemu-mips`` executes 32-bit big endian MIPS binaries (MIPS O32 ABI).
  110. * ``qemu-mipsel`` executes 32-bit little endian MIPS binaries (MIPS O32 ABI).
  111. * ``qemu-mips64`` executes 64-bit big endian MIPS binaries (MIPS N64 ABI).
  112. * ``qemu-mips64el`` executes 64-bit little endian MIPS binaries (MIPS N64
  113. ABI).
  114. * ``qemu-mipsn32`` executes 32-bit big endian MIPS binaries (MIPS N32 ABI).
  115. * ``qemu-mipsn32el`` executes 32-bit little endian MIPS binaries (MIPS N32
  116. ABI).
  117. - user mode (PowerPC)
  118. * ``qemu-ppc64`` TODO.
  119. * ``qemu-ppc`` TODO.
  120. - user mode (SH4)
  121. * ``qemu-sh4eb`` TODO.
  122. * ``qemu-sh4`` TODO.
  123. - user mode (SPARC)
  124. * ``qemu-sparc`` can execute Sparc32 binaries (Sparc32 CPU, 32 bit ABI).
  125. * ``qemu-sparc32plus`` can execute Sparc32 and SPARC32PLUS binaries
  126. (Sparc64 CPU, 32 bit ABI).
  127. * ``qemu-sparc64`` can execute some Sparc64 (Sparc64 CPU, 64 bit ABI) and
  128. SPARC32PLUS binaries (Sparc64 CPU, 32 bit ABI).
  129. .. _bsd-user-mode:
  130. BSD User space emulator
  131. -----------------------
  132. BSD Status
  133. ~~~~~~~~~~
  134. - target Sparc64 on Sparc64: Some trivial programs work.
  135. Quick Start
  136. ~~~~~~~~~~~
  137. In order to launch a BSD process, QEMU needs the process executable
  138. itself and all the target dynamic libraries used by it.
  139. - On Sparc64, you can just try to launch any process by using the
  140. native libraries::
  141. qemu-sparc64 /bin/ls
  142. Command line options
  143. ~~~~~~~~~~~~~~~~~~~~
  144. ::
  145. qemu-sparc64 [-h] [-d] [-L path] [-s size] [-bsd type] program [arguments...]
  146. ``-h``
  147. Print the help
  148. ``-L path``
  149. Set the library root path (default=/)
  150. ``-s size``
  151. Set the stack size in bytes (default=524288)
  152. ``-ignore-environment``
  153. Start with an empty environment. Without this option, the initial
  154. environment is a copy of the caller's environment.
  155. ``-E var=value``
  156. Set environment var to value.
  157. ``-U var``
  158. Remove var from the environment.
  159. ``-bsd type``
  160. Set the type of the emulated BSD Operating system. Valid values are
  161. FreeBSD, NetBSD and OpenBSD (default).
  162. Debug options:
  163. ``-d item1,...``
  164. Activate logging of the specified items (use '-d help' for a list of
  165. log items)
  166. ``-p pagesize``
  167. Act as if the host page size was 'pagesize' bytes
  168. ``-one-insn-per-tb``
  169. Run the emulation with one guest instruction per translation block.
  170. This slows down emulation a lot, but can be useful in some situations,
  171. such as when trying to analyse the logs produced by the ``-d`` option.