Có thể chạy mã Python trong chế độ mô phỏng syscall Gem5 không?
Tôi cần chạy một số mã Python bên trong Gem5 . Để thử nghiệm, tôi đã tạo một chương trình Python có tên là hello.pynó in "Hello World from Python." Tôi đã tạo tệp nhị phân của hello.pytệp bằng cách sử dụng Pyinstaller . Tên tệp nhị phân là hello. Tiếp theo, tôi đã thử chạy Gem5 bằng cách sử dụng lệnh sau ./build/X86/gem5.opt --debug-flags=DRAM --debug-file=gem5-helloworld.out ./configs/example/se.py -c ./tests/test-progs/myFile/hello. Tuy nhiên, tôi nhận được thông báo sau fatal: syscall fchmod (#91) unimplemented.và Gem5 không in "Hello World from Python." thông điệp. Làm thế nào để giải quyết vấn đề trên? Có thể chạy mã Python bên trong Gem5 không? Gem5 đang in nội dung sau trong thiết bị đầu cuối.
./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
Trả lời
Bạn phải triển khai lần lượt tất cả các cuộc gọi tổng hợp bắt buộc bị thiếu khi chúng bị tấn công.
Tuy nhiên, một số trong số chúng không phải là cơ bản và sẽ hoạt động với các sơ ignoreFunckhai chưa hoàn thiện, chỉ cần xem nhanh mô tả syscall và cố gắng đoán xem nó có phải là cơ bản hay không, ví dụ:https://github.com/gem5/gem5/blob/fa70478413e4650d0058cbfe81fd5ce362101994/src/arch/arm/linux/process.cc#L179
Tôi nghi ngờ điều này sẽ không quá khó. Không thể chắc chắn nếu không thử, tất cả phụ thuộc vào việc thiếu bao nhiêu syscalls không thể bỏ qua và mức độ phức tạp để triển khai chúng.
Tình huống tương tự đối với Java: Chạy các chương trình Java trong gem5 (hoặc bất kỳ ngôn ngữ nào không phải là C)
Có liên quan:
- https://cirosantilli.com/linux-kernel-module-cheat/#python-gem5-user-mode-simulation
- nhánh mô phỏng syscall của gem5 C xin chào thế giới không thành công với "death: syscall gettid (# 224) unimplemented"