cirosantilli2 / issues

Hello! If you have anything to say to me, feel free to open an issue, and I will reply. For gem5 issues, prefer asking on Stack Overflow or the mailing list: https://www.gem5.org/mailing_lists/ or: https://github.com/cirosantilli2/gem5-issues
1 stars 0 forks source link

How does gem5 run my own code in fs mode? #23

Open Yujie-Cui opened 1 year ago

Yujie-Cui commented 1 year ago

Hi,

I'm trying to use the full system to do some experiments.

I used the boot-exit image and vmlinux-5.4.49 provided by this website(https://gem5art.readthedocs.io/en/latest/tutorials/boot-tutorial.html

I first tried using the terminal script that comes with gem5.

In one of the terminals I execute:

/build/X86/gem5.opt    
  configs/example/fs.py  \
 --kernel=../../full_system_image/binaries/vmlinux-4.19.83  \
 --disk-image=../../full_system_image/disks/boot-exit.img  "

I execute in another terminal:

util/term/m5term localhost 3456

After that, I successfully entered, although I waited for dozens of minutes.

I can enter commands normally.

0af27f81fba0c89d17509956654bc28

. But i want to run my program. I don't want to have to enter the terminal every time, that would be too slow.

For boot-exit images:

  1. I added/root/init.sh instruction at the end of /root/.bashrc file. In this way, the init.sh script will be executed every time the system is entered.
  2. The content of the init.sh file is:
    m5 readfile > /tmp/run.sh
    /bin/sh /tmp/run.sh
    m5 exit
  3. I added run_hello.sh and hello executable files (output hello, world) in the /root directory.
  4. The content of the run_hello.sh file is:
    m5 resetstats
    /root/hello > /tmp/hello.out
    m5 dumpstats

I executed the following command:

/usr/local/src/gem5/build/X86/gem5.opt --debug-flags=CacheAll --debug-file=/usr/local/src/gem5/runScripts/attack_spectre/trace2.out /usr/local/src/gem5/configs/example/fs.py --kernel=../../full_system_image/binaries/vmlinux-4.19.83 --disk-image=../../full_system_image/disks/boot-exit.img --l1d_replacement=LRU --mem-size=4GB --l1d_size=32kB --l1d_assoc=8 --l1i_size=32kB --l1i_assoc=4 --l2_assoc=16 --l2_size=2MB --caches --l2cache --cpu-type=DerivO3CPU --script=/root/run_hello.sh

image

The process will always be stuck here.

It seems to keep waiting for a terminal connection.

If I don't connect, it just waits until. When I connect(util/term/m5term localhost 3456), it will show that there is a terminal connected.

When I type m5 exit in the connected terminal, it ends on both sides.

What should I do to run my code without connecting to a terminal?

thank you very much! ! !

cirosantilli2 commented 1 year ago

Hi Yujie,

I'm sorry I don't have enough time to properly review exactly how your setup is failing, but I recommend the two following approaches:

Yujie-Cui commented 1 year ago

thank you very much!!! You've helped me with several questions. I really appreciate it. I didn't know that I could use QEMU to run images. It is always stuck when running with gem5. I tried what you wrote.
I found that it was the image problem. I have successfully run fs mode. And I successfully generated checkpoint. But I still have some confusion.

The following is my command to generate checkpoint.

/usr/local/src/gem5/build/X86/gem5.opt /usr/local/src/gem5/configs/example/fs.py --kernel=/usr/local/src/gem5/full_system_image/binaries/vmlinux-
4.19.83 --disk-image=/usr/local/src/gem5/full_system_image/disks/boot-exit.img --checkpoint-dir=/usr/local/src/gem5/runScripts/attack_spectre/fs_
mode/../checkpoint/fs_checkpoint_simple --script=/home/gem5/run.sh
  1. When I only use -- restore_ with_ CPU option, I must use AtomicSimpleCPU. Otherwise, segment error will be reported directly. When I use -- restore_ with_ CPU and -- cpu_ Type at the same time, if the two options are inconsistent, segment errors will occur directly. When the two options are the same, I can use other CPU types. I also see your answer here(https://stackoverflow.com/questions/49011096/how-to-switch-cpu-models-in-gem5-after-restoring-a-checkpoint-and-then-observe-t). But I still don't understand the difference between the two options. Here are the commands I ran successfully.

/usr/local/src/gem5/build/X86/gem5.opt /usr/local/src/gem5/configs/example/fs.py --kernel=/usr/local/src/gem5/full_system_image/binaries/vmlinux-4.19.83 --disk-image=/usr/local/src/gem5/full_system_image/disks/gem5-boot.img --checkpoint-dir=/usr/local/src/gem5/runScripts/attack_spectre/fs_mode/../checkpoint/fs_checkpoint_simple --checkpoint-restore=1 --l1d_size=32kB --restore-with-cpu=DerivO3CPU --cpu-type=DerivO3CPU --l1d_assoc=8 --l1i_size=32kB --l1i_assoc=4 --l2_assoc=16 --l2_size=2MB --caches --l2cache --script=/home/gem5/run.sh

  1. How can I get the output value of my program in fs mode? If I run in se mode, the results will be output after running. But I found that under fs mode, the output is not redirected into the file.

Really Thanks!!!