This is an old revision of the document!


While Qemu user mode is fairly well supported on Linux it lacks a lot of code to support this feature on FreeBSD. This page tracks the latest work being done to add the missing code to add support for some of the more popular CPU architectures. If you are interested in helping please contact sson@. The code repositories are currently located at: https://github.com/staceyson/qemu-devel-1.2.0.git and https://github.com/staceyson/qemu-devel-1.4.0.git.

Feature/Bug Description Notes Status/Who
ARM arch Missing some ARM dependent bits. sigframe and sigreturn trampoline, thread startup in new_thread_start(), maybe some sysarch() stuff, set_mcontext/get_mcontext, etc. {set, get}_mcontext() sigtramp do_sigreturn() sysarch()
MIPS arch mips64 is done. Missing some mips32 dependent bits.
SPARC64 arch Missing SPARC64 dependent bits. demand?
PPC/PPC64 arch Missing PPC/PPC64 dependent bits.
thread cancel SIGTHR is used by underlining thread code in QEMU May use a different sig number for the emulated SIGTHR Done.
sysctl()/getrlimit() Sysctl's KERN_USRSTACK, KERN_PS_STRINGS, and getrlimit(RLIMIT_STACK..) need to return emulator addresses and stack size Increasing stack size with setrlimit() is problematic so it is not supported. Done
Special sysctl(mib[0]=0, mib[1]=3) The return returned data for the special sysctl() to convert a name (e.g. “kern.smu.cpus”) to its mib/oid is not properly byte swapped for mixed endian host/target. Handle the special case for swapping. Done.
Missing sockopt options see bsd-user/syscall.c do_getsockopt()/do_setsockopt()
ioctl commands More ioctl commands need to be added. See bsd-user/freebsd/ioctls.h Added sys/filio.h ioctl's.
_umtx_op() This code needs to be reviewed and maybe improved.
Code cleanup FreeBSD dependent code needs to go in bsd-user/FreeBSD. ARCH dependent code needs to go into bsd-user/arm, etc. bsd-user/syscall.c and bsd-user/syscall_defs.h need lots of love.
NetBSD/OpenBSD Broken by FreeBSD port. Need to be fixed as part of code cleanup.
Dynamically linked executables Currently I have only been testing with statically linked executables. The code is mostly there for dynamically linked executables. Done
execve() hack In the execve() syscall shim check the target executable's ELF header for e_machine=EM_MIPS, e_ident=ELFCLASS64|ELFOSABI_FREEBSD, etc. and automatically insert “qemu-mips64” as the path and the path in front of the argv list. fexecve() is a problem. Passing the FD to new qemu-mips64 instance might be a good work-around. Done
sysctl() for mmap_min_addr The guest_base command-line option tried to open “/proc/sys/vm/mmap_min_addr” to determine the minimum virtual address (main.c). This needs to be replaced with the proper sysctl.
“sysconf pages: Cannot allocate memory” During “Finding dependencies in ports build we get “sysconf pages: Cannot allocate memory”. Most likely a sysctl() problem. sysconf(_SC_PHYS_PAGES) is failing on arm arch. This is a 32-bit target on a 64-bit host issue. Workaround: Run on 32-bit host.
sysctl() returning struct Some sysctl() oid's return structs such as KERN_CLOCKRATE, KERN_VNODE, KERN_PROC, KERN_FILE, KERN_BOOTTIME, etc. Maybe do something like ioctl() with sysctl() using thunk.
interrupted read() SIGINT during a blocked read() results in a core dump. Most likely due to ERESTART not being properly handled after do_freebsd_syscall() in main.c.
Perl 5.16 regression test failures The following perl 5.16 regression tests fail (that don't fail on host): op/magic.t (Failed test 90 - at op/magic.t line 319), op/pack.t (segmentation fault after test 4392), op/sigsystem.t (Failed test 4 - Reaped the right process. at op/sigsystem.t line 42-43), ../cpan/ExtUtils-MakeMaker/t/fixin.t (Failed test 'switch retained' at line 77 & Failed test 'switch retained' at line 96), ../ext/POSIX/t/posix.t (Failed (TODO) test 'read to array element' at line 64 got undef expected 'perl') Bug fixes: 5a3b8a0f1e, 71c890d48c, 94db009c17, 6a1eccb851, f85dca9064 sson@
'uname -m' and 'uname -p' uname(1) will return the host arch instead of the target arch. Some port configure scripts will use this information. It gets it from sysctl: hw.machine & hw.machine_arch done.
Performance: init_paths() For dynamically linked target binaries, initpaths() walks a bunch of directory paths on start up. It might be good to create a cache file or figure a better way or something.
Thr (parent) exit seg fault Running the attached program results in ”<jemalloc>: contrib/jemalloc/include/jemalloc/internal/arena.h:942: Failed assertion: “arena_mapbits_allocated_get(chunk, pageind) != 0” (in target code) and then seg fault in gen_intermediate_code() in qemu-mips64. The tb doesn't seem valid. Looks like thread is still running after main() has exited? bug fix for the case of the parent exiting before child thread. done.
The (child) exit seg fault When the child thread exits it seg faults in arena_chunk_dirty_insert() (jemalloc). The call path of the child is as follows: pthread_exit() → _malloc_thread_cleanup() → jemalloc_tcache_tsd_cleanup_wrapper() → … → arena_chunk_dirty_insert()
Syscall(s) Notes Status/Who
ktimer_*() Needed?
acl_*()/extattr_*() extattr_'s and acl's are needed by tar, etc. Done.
cpuset_*()
rctl_*() Needed?
sctp_*()
kld*()/mod*()
quota*()
jail*() Would be difficult to emulate.
cap_*() Would be difficult to emulate.
_mac*() Needed?
sendfile()
ptrace() Would be difficult to emulate.
utrace() Needed?
freebsd6_*()
setsockopt()/getsockopt() Missing some options. see bsd-user/syscall.c do_getsockopt()/do_setsockopt()
ioctl() Only tty(4) currently supported. Need more ioctl commands. See bsd-user/freebsd/ioctl.h
rtprio_thread() Done
swapcontext() setcontext()/getcontext() are done so this should be easy.
thr_create() Not sure if it is used. All the code I have seen uses thr_new()
fexecve() Done.

FreeBSD Qemu User Mode HowTo

  • qemuusermodetodo.1365090976.txt.gz
  • Last modified: 2013/04/04 15:56
  • by StaceySon