É possível executar o código Python no modo de emulação syscall Gem5?

Sep 21 2020

Eu preciso executar algum código Python dentro do Gem5 . Como teste, criei um programa Python chamado hello.pyimprime "Hello World from Python". Eu criei um binário do hello.pyarquivo usando o Pyinstaller . O nome do arquivo binário é hello. Em seguida, tentei executar o Gem5 usando o seguinte comando ./build/X86/gem5.opt --debug-flags=DRAM --debug-file=gem5-helloworld.out ./configs/example/se.py -c ./tests/test-progs/myFile/hello. No entanto, estou recebendo a seguinte mensagem fatal: syscall fchmod (#91) unimplemented.e o Gem5 não está imprimindo o "Hello World from Python". mensagem. Como resolver o problema acima? É possível executar o código Python dentro do Gem5? O Gem5 está imprimindo o seguinte no terminal.

./build/X86/gem5.opt --debug-flags=DRAM --debug-file=gem5-helloworld.out ./configs/example/se.py -c ./tests/test-progs/myFile/hello

warn: CheckedInt already exists in allParams. This may be caused by the Python 2.7 compatibility layer.
warn: Enum already exists in allParams. This may be caused by the Python 2.7 compatibility layer.
warn: ScopedEnum already exists in allParams. This may be caused by the Python 2.7 compatibility layer.
gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.

gem5 version 20.0.0.3
gem5 compiled Aug  5 2020 12:06:57
gem5 started Sep 21 2020 16:31:18
gem5 executing on LAPWF05588, pid 248502
command line: ./build/X86/gem5.opt --debug-flags=DRAM --debug-file=gem5-helloworld.out ./configs/example/se.py -c ./tests/test-progs/myFile/hello

Global frequency set at 1000000000000 ticks per second
warn: No dot file generated. Please install pydot to generate the dot file and pdf.
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (512 Mbytes)
0: system.remote_gdb: listening for remote gdb on port 7000
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
warn: ignoring syscall access(...)
info: Increasing stack size by one page.
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
warn: MOVNTDQ: Ignoring non-temporal hint, modeling as cacheable!
fatal: syscall fchmod (#91) unimplemented.
Memory Usage: 688628 KBytes

Respostas

CiroSantilli Sep 21 2020 at 21:53

Você deve implementar todas as syscalls necessárias ausentes, uma por uma, à medida que são atingidas.

Alguns deles, entretanto, não são fundamentais e funcionarão com ignoreFuncstubs não implementados, basta dar uma olhada rápida na descrição do syscall e tentar adivinhar se é fundamental ou não, por exemplohttps://github.com/gem5/gem5/blob/fa70478413e4650d0058cbfe81fd5ce362101994/src/arch/arm/linux/process.cc#L179

Eu suspeito que isso não será muito difícil. É simplesmente impossível ter certeza sem tentar, tudo depende de quantas syscalls não ignoráveis ​​estão faltando e quão complexo eles são para implementar.

A situação é análoga para Java: rodando programas Java em gem5 (ou qualquer linguagem que não seja C)

Relacionado:

  • https://cirosantilli.com/linux-kernel-module-cheat/#python-gem5-user-mode-simulation
  • gem5 syscall emulation arm C hello world falha com "fatal: syscall gettid (# 224) unimplemented"