ios.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ===========
  2. iOS Support
  3. ===========
  4. To run qemu on the iOS platform, some modifications were required. Most of the
  5. modifications are conditioned on the ``CONFIG_IOS`` and ``CONFIG_IOS_JIT``
  6. configuration variables.
  7. Build support
  8. -------------
  9. For the code to compile, certain changes in the block driver and the slirp
  10. driver had to be made. There is no ``system()`` call, so code requiring it had
  11. to be disabled.
  12. ``ucontext`` support is broken on iOS. The implementation from ``libucontext``
  13. is used instead.
  14. Because ``fork()`` is not allowed on iOS apps, the option to build qemu and the
  15. utilities as shared libraries is added. Note that because qemu does not perform
  16. resource cleanup in most cases (open files, allocated memory, etc), it is
  17. advisable that the user implements a proxy layer for syscalls so resources can
  18. be kept track by the app that uses qemu as a shared library.
  19. JIT support
  20. -----------
  21. On iOS, allocating RWX pages require special entitlements not usually granted to
  22. apps. However, it is possible to use `bulletproof JIT`_ with a development
  23. certificate. This means that we need to allocate one chunk of memory with RX
  24. permissions and then mirror map the same memory with RW permissions. We generate
  25. code to the mirror mapping and execute the original mapping.
  26. With ``CONFIG_IOS_JIT`` defined, we store inside the TCG context the difference
  27. between the two mappings. Then, we make sure that any writes to JIT memory is
  28. done to the pointer + the difference (in order to get a pointer to the mirror
  29. mapped space). Additionally, we make sure to flush the data cache before we
  30. invalidate the instruction cache so the changes are seen in both mappings.
  31. .. _bulletproof JIT: https://www.blackhat.com/docs/us-16/materials/us-16-Krstic.pdf