Missing syscalls in gem5 ARM

2019-03-02 00:39发布

问题:

I am having the following error in gem5. This happens in ARM only. With X86 I see some syscalls being ignored but none causing a fatal error.

tomas@ubuntu:~/gem5$ ./build/ARM/gem5.opt configs/example/arm/starter_se.py ../tests_gem5/hello
gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.

gem5 compiled Jul  9 2018 17:09:01
gem5 started Jul  9 2018 18:07:37
gem5 executing on ubuntu, pid 5064
command line: ./build/ARM/gem5.opt configs/example/arm/starter_se.py ../tests_gem5/hello

info: 1. command and arguments: ['../tests_gem5/hello']
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (1024 Mbytes)
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (1024 Mbytes)
0: system.remote_gdb: listening for remote gdb on port 7000
info: Entering event queue @ 0.  Starting simulation...
fatal: syscall openat (#322) unimplemented.
Memory Usage: 2246296 KBytes

I found this answer in gem5's FAQ. But now it shows this error:

warn: ignoring syscall openat(...)
FATAL: kernel too old
warn: ignoring syscall rt_sigprocmask(...)
      (further warnings will be suppressed)
fatal: syscall gettid (#224) unimplemented.

I am compiling in Ubuntu 18.04 using this:

arm-linux-gnueabi-gcc hello.c -o hello -static -DUNIX

Has anyone found a way to compile a simple hello world, targeting ARM, that doesn't use syscalls not supported by gem5? There are pre-compiled examples so there must be a way.

回答1:

update: x86, arm and aarch64 C hello world is working on Ubuntu 18.04 pre-packaged toolchain, see: How to compile and run an executable in gem5 syscall emulation mode with se.py?

"FATAL: kernel too old" has been previously asked at: How to solve "FATAL: kernel too old" when running gem5 in syscall emulation SE mode?

As explained in that page, that message comes from a glibc sanity check, and ct-ng is the sanest approach to overcome it.

As for the unimplemented syscalls, I don't know why x86 ignores them and arm blows up, but it should be easy to grep that up in the source if you give the x86 syscall ignored message.

But the blow up behavior does seem sensible: how can you expect your program to work properly when it tries to run an unimplemented syscall?

Most syscalls are unimplemented in both archs as can be seen at:

  • https://github.com/gem5/gem5/blob/5de8ca95506a5f15bfbfdd2ca9babd282a882d1f/src/arch/arm/linux/process.cc#L123
  • https://github.com/gem5/gem5/blob/5de8ca95506a5f15bfbfdd2ca9babd282a882d1f/src/arch/x86/linux/process.cc#L222

So, I only see two sensible solutions:

  • implement the syscall, which is easy for most of them, and send gem5 a patch
    • have a look if other archs implement it by grepping, sometimes another arch has already implemented it and you just need to write things up
    • you could also try to ignore the syscall, TODO: is there a good way in ARM? But you have to be pretty sure that it won't matter.
  • give up on syscall emulation and just use full system which is saner: When to use full system FS vs syscall emulation SE with userland programs in gem5?


回答2:

uclibc is the answer for compiling for gem5. It doesn't use a bunch of syscalls that glibc uses and that gem5 doesn't have implemented. So using crosstool-ng and arm-unknown-linux-uclibcgnueabi solved the issue.