Hello Chia,

Sorry for the late reply.

Let me first explain the situation. When gem5 boots up your image, there is
a specific path that it takes to communicate with it. For example, unlike
you, gem5 logs into the image as "root", then it should operate starting
from this point. So, you need to configure the "root" on the image so that
it takes whatever you pass in the script and handles this for you. Luckily,
this is partially set up for you, which is represented in the m5 installed
on the image. The m5 has a set of commands, each is used to carry out a
specific task, such as resetting your stats, taking snapshots, or even
exiting your simulation.

What we care about here is the "m5 readfile", which reads the lines
included in the rcs script you pass to the image when you run gem5 on your
host machine. Thus, you need to configure the root user on the image in a
way that makes it anticipate a script is passed to the m5, read it, then
execute it. Check out this file:
https://github.com/gem5/gem5/blob/stable/configs/boot/hack_back_ckpt.rcS

If you append the content of this file to the /root/.bashrc, it is going to
take a checkpoint right after the boot (assuming you run the image from
scratch NOT restoring a checkpoint). Then, when you restore the checkpoint,
it is going to run "m5 readfile" and then redirect the content of your
script to a temporary script file on the image then execute it.

Try it, and let me know.

Thanks.

--

*Best,Abdelrahman Hussein*
MSc. Student -- Graduate RA/TA
School of Computing Sciences
Simon Fraser University, Canada


On Thu, Jul 14, 2022 at 11:58 AM Chia Jen Cheng <chia...@bu.edu> wrote:

> Hi Abdelrahman,
>
> I downloaded my image from the gem5 guest binaries
> https://www.gem5.org/documentation/general_docs/fullsystem/guest_binaries
> and mounted it using gem5img.py, which I think corresponds to the 2nd
> option listed on the gem5 website.
>
> Here is the last bulk of /root/.bashrc:
>
> # enable color support of ls and also add handy aliases
> if [ -x /usr/bin/dircolors ]; then
>     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval
> "$(dircolors -b)"
>     alias ls='ls --color=auto'
>     #alias dir='dir --color=auto'
>     #alias vdir='vdir --color=auto'
>
>     alias grep='grep --color=auto'
>     alias fgrep='fgrep --color=auto'
>     alias egrep='egrep --color=auto'
> fi
>
> # some more ls aliases
> alias ll='ls -alF'
> alias la='ls -A'
> alias l='ls -CF'
>
> # Alias definitions.
> # You may want to put all your additions into a separate file like
> # ~/.bash_aliases, instead of adding them here directly.
> # See /usr/share/doc/bash-doc/examples in the bash-doc package.
>
> if [ -f ~/.bash_aliases ]; then
>     . ~/.bash_aliases
> fi
>
> # enable programmable completion features (you don't need to enable
> # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
> # sources /etc/bash.bashrc).
> #if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
> #    . /etc/bash_completion
> #fi
>
> Best regards,
> Chia Jen
>
> On Thu, Jul 14, 2022 at 12:29 PM Abdelrahman S. Hussein <
> abdelrahman.sob...@gmail.com> wrote:
>
>> Would you please walk me through the steps that you followed to build the
>> image itself? Also, there is a script file that gets appended to the
>> /root/.bashrc during building the image (assuming that you have followed
>> the steps on gem5 website).
>>
>> You can access the image using QEMU to modify it. The username is gem5
>> and the password is from 1 to 5. When you do, try to cat /root/.bashrc and
>> show me the last bulk of lines that were added to this file. You should be
>> able to recognize if they are related to gem5 since they are going to
>> contain m5 or something.
>>
>> One last comment, "m5 exit" just halts your entire simulation, so
>> probably having it in the first line of your script is another problem.
>> However, this is NOT the cause of the current behavior you are seeing now.
>> Mainly, the problem is that the /root/.bashrc includes different commands
>> from what should be there to read the rcs script you pass as an argument to
>> the gem5. This is why I am asking you to share it with me.
>>
>> qemu-system-x86_64 -enable-kvm -hda YOUR_IMAGE_NAME -boot d -m 8000 -net
>> user,hostfwd=tcp::10022-:22 -net nic
>>
>> This should open a QEMU terminal to your image. Otherwise, if nothing
>> appears, check your terminal for something that says that it is running.
>> The machine can be SSHed to on localhost with port number 10022.
>>
>>
>> --
>>
>> *Best,Abdelrahman Hussein*
>>
>>
>> On Thu, Jul 14, 2022 at 8:48 AM Chia Jen Cheng <chia...@bu.edu> wrote:
>>
>>> Hi Abdelrahman,
>>>
>>> Thank you for your help. When I tried that combination of inputs, the
>>> segmentation fault disappeared. However, the m5 terminal did not display
>>> the output of my executable and froze indefinitely.
>>>
>>> There are no error messages on my local terminal, and this is what I see
>>> on the m5 terminal.
>>>
>>> Trying 127.0.0.1...
>>> Connected to localhost.
>>> Escape character is '^]'.
>>> ==== m5 terminal: Terminal 0 ====
>>>
>>> Here is the content of my rcS script.
>>>
>>> /sbin/m5 exit
>>> echo "This works!"
>>> /book_info.out
>>>
>>> Best regards,
>>> Chia Jen
>>>
>>> On Thu, Jul 14, 2022 at 7:08 AM Abdelrahman S. Hussein <
>>> abdelrahman.sob...@gmail.com> wrote:
>>>
>>>> You need to tweak your command(s) a little. Basically, when you take a
>>>> snapshot with a certain CPU and you restore it with a different CPU, your
>>>> restoration command has to reflect both.
>>>>
>>>> Add the following to your command line when restoring (This solved the
>>>> problem with me):
>>>>
>>>> --restore-with-cpu=${CPU_Restore_TYPE}CPU
>>>> --cpu-type=${CPU_Restore_TYPE}CPU such that, you pass the CPU type
>>>> that you need.
>>>>
>>>> Keep me posted. I will be glad to help!
>>>>
>>>> --
>>>>
>>>> *Best,Abdelrahman Hussein*
>>>>
>>>>
>>>> On Tue, Jul 12, 2022 at 9:51 AM Chia Jen Cheng <chia...@bu.edu> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I am unable to restore simulations from checkpoints in Full System
>>>>> mode with ARM. I ran my simulations with the following bash commands in 
>>>>> one
>>>>> script.
>>>>>
>>>>> $CURR_DIR/build/ARM/gem5.opt configs/secure_mem/fs/unified_secure.py
>>>>> --kernel $KERNEL_PATH --mem-size 4GB --cpu-type AtomicSimpleCPU --caches
>>>>> --disk $DISK_PATH --script=$BOOTSCRIPT_PATH --checkpoint-at-end
>>>>> $CURR_DIR/build/ARM/gem5.opt configs/secure_mem/fs/unified_secure.py
>>>>> --kernel $KERNEL_PATH --mem-size 4GB --cpu-type DerivO3CPU --caches --disk
>>>>> $DISK_PATH --script=$BOOTSCRIPT_PATH --checkpoint-restore=1
>>>>>
>>>>> It seems that the first line was executed correctly. The cpt.* file
>>>>> was created in m5out, but gem5 could not restore it from the checkpoint.
>>>>> This is the error message I received.
>>>>>
>>>>> gem5 Simulator System.  http://gem5.org
>>>>> gem5 is copyrighted software; use the --copyright option for details.
>>>>>
>>>>> gem5 version 21.2.1.1
>>>>> gem5 compiled Jul 10 2022 21:16:20
>>>>> gem5 started Jul 12 2022 12:38:00
>>>>> gem5 executing on chiajen, pid 3141
>>>>> command line: /home/chiajen/gem5/build/ARM/gem5.opt
>>>>> configs/secure_mem/fs/unified_secure.py --kernel
>>>>> /home/chiajen/gem5/dist/binaries/vmlinux.arm64 --secure 1 --mem-size 4GB
>>>>> --cpu-type AtomicSimpleCPU --caches --disk
>>>>> /home/chiajen/gem5/dist/disks/ubuntu-18.04-arm64-docker.img
>>>>> --script=/home/chiajen/gem5/bootscripts/fs_checkpoint.rcS
>>>>> --checkpoint-at-end
>>>>>
>>>>> warn: iobus.master is deprecated. `master` is now called
>>>>> `mem_side_ports`
>>>>> warn: membus.slave is deprecated. `slave` is now called
>>>>> `cpu_side_ports`
>>>>> Global frequency set at 1000000000000 ticks per second
>>>>> build/ARM/mem/mem_interface.cc:792: warn: DRAM device capacity (8192
>>>>> Mbytes) does not match the address range assigned (4096 Mbytes)
>>>>> build/ARM/sim/kernel_workload.cc:46: info: kernel located at:
>>>>> /home/chiajen/gem5/dist/binaries/vmlinux.arm64
>>>>> system.vncserver: Listening for connections on port 5900
>>>>> system.terminal: Listening for connections on port 3456
>>>>> system.realview.uart1.device: Listening for connections on port 3457
>>>>> system.realview.uart2.device: Listening for connections on port 3458
>>>>> system.realview.uart3.device: Listening for connections on port 3459
>>>>> 0: system.remote_gdb: listening for remote gdb on port 7000
>>>>> build/ARM/arch/arm/fs_workload.cc:121: info: Using bootloader at
>>>>> address 0x10
>>>>> build/ARM/arch/arm/fs_workload.cc:139: info: Using kernel entry
>>>>> physical address at 0x80080000
>>>>> build/ARM/arch/arm/linux/fs_workload.cc:96: info: Loading DTB file:
>>>>> m5out/system.dtb at address 0x88000000
>>>>> **** REAL SIMULATION ****
>>>>> build/ARM/dev/arm/energy_ctrl.cc:252: warn: Existing EnergyCtrl, but
>>>>> no enabled DVFSHandler found.
>>>>> build/ARM/sim/simulate.cc:194: info: Entering event queue @ 0.
>>>>> Starting simulation...
>>>>> build/ARM/dev/arm/rv_ctrl.cc:176: warn: SCReg: Access to unknown
>>>>> device dcc0:site0:pos0:fn7:dev0
>>>>> build/ARM/arch/arm/insts/pseudo.cc:172: warn: instruction 'csdb'
>>>>> unimplemented
>>>>> build/ARM/dev/arm/rv_ctrl.cc:122: warn: Tried to read RealView I/O at
>>>>> offset 0x60 that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:122: warn: Tried to read RealView I/O at
>>>>> offset 0x48 that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:198: warn: Tried to write RVIO at offset
>>>>> 0xa8 (data 0) that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:122: warn: Tried to read RealView I/O at
>>>>> offset 0x8 that doesn't exist
>>>>> build/ARM/dev/arm/rv_ctrl.cc:122: warn: Tried to read RealView I/O at
>>>>> offset 0x48 that doesn't exist
>>>>> build/ARM/dev/arm/energy_ctrl.cc:77: warn: EnergyCtrl: Disabled
>>>>> handler, ignoring read from reg 0
>>>>> Exiting @ tick 434950318500 because m5_exit instruction encountered
>>>>> Writing checkpoint
>>>>> gem5 Simulator System.  http://gem5.org
>>>>> gem5 is copyrighted software; use the --copyright option for details.
>>>>>
>>>>> gem5 version 21.2.1.1
>>>>> gem5 compiled Jul 10 2022 21:16:20
>>>>> gem5 started Jul 12 2022 12:40:49
>>>>> gem5 executing on chiajen, pid 3170
>>>>> command line: /home/chiajen/gem5/build/ARM/gem5.opt
>>>>> configs/secure_mem/fs/unified_secure.py --kernel
>>>>> /home/chiajen/gem5/dist/binaries/vmlinux.arm64 --secure 1 --mem-size 4GB
>>>>> --cpu-type DerivO3CPU --caches --disk
>>>>> /home/chiajen/gem5/dist/disks/ubuntu-18.04-arm64-docker.img
>>>>> --script=/home/chiajen/gem5/bootscripts/fs_checkpoint.rcS
>>>>> --checkpoint-restore=1
>>>>>
>>>>> warn: iobus.master is deprecated. `master` is now called
>>>>> `mem_side_ports`
>>>>> warn: membus.slave is deprecated. `slave` is now called
>>>>> `cpu_side_ports`
>>>>> Global frequency set at 1000000000000 ticks per second
>>>>> build/ARM/mem/mem_interface.cc:792: warn: DRAM device capacity (8192
>>>>> Mbytes) does not match the address range assigned (4096 Mbytes)
>>>>> build/ARM/sim/kernel_workload.cc:46: info: kernel located at:
>>>>> /home/chiajen/gem5/dist/binaries/vmlinux.arm64
>>>>> system.vncserver: Listening for connections on port 5900
>>>>> system.terminal: Listening for connections on port 3456
>>>>> system.realview.uart1.device: Listening for connections on port 3457
>>>>> system.realview.uart2.device: Listening for connections on port 3458
>>>>> system.realview.uart3.device: Listening for connections on port 3459
>>>>> gem5 has encountered a segmentation fault!
>>>>>
>>>>> --- BEGIN LIBC BACKTRACE ---
>>>>> /home/chiajen/gem5/build/ARM/gem5.opt(+0x7ba92c)[0xaaaadf71a92c]
>>>>> /home/chiajen/gem5/build/ARM/gem5.opt(+0x7d9054)[0xaaaadf739054]
>>>>> linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0xffff9bd937dc]
>>>>> /home/chiajen/gem5/build/ARM/gem5.opt(+0x5d2700)[0xaaaadf532700]
>>>>> /home/chiajen/gem5/build/ARM/gem5.opt(+0x5ae8c8)[0xaaaadf50e8c8]
>>>>> /home/chiajen/gem5/build/ARM/gem5.opt(+0x20b0be4)[0xaaaae1010be4]
>>>>> /home/chiajen/gem5/build/ARM/gem5.opt(+0x20b646c)[0xaaaae101646c]
>>>>> /home/chiajen/gem5/build/ARM/gem5.opt(+0x4d0ae8)[0xaaaadf430ae8]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0x1229f4)[0xffff9b8929f4]
>>>>>
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(_PyObject_MakeTpCall+0x8c)[0xffff9b84e840]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0xe0898)[0xffff9b850898]
>>>>>
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x89f0)[0xffff9b7e91e0]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0x1b76d4)[0xffff9b9276d4]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0xe0848)[0xffff9b850848]
>>>>>
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x89f0)[0xffff9b7e91e0]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0x1b76d4)[0xffff9b9276d4]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0xe0848)[0xffff9b850848]
>>>>>
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x89f0)[0xffff9b7e91e0]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0x1b76d4)[0xffff9b9276d4]
>>>>>
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x89f0)[0xffff9b7e91e0]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0x1b76d4)[0xffff9b9276d4]
>>>>>
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x89f0)[0xffff9b7e91e0]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0x1b76d4)[0xffff9b9276d4]
>>>>>
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(PyEval_EvalCode+0xa4)[0xffff9b922438]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0x1b29e4)[0xffff9b9229e4]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0x1282d8)[0xffff9b8982d8]
>>>>>
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x5d68)[0xffff9b7e6558]
>>>>> /lib/aarch64-linux-gnu/libpython3.10.so.1.0(+0x1b76d4)[0xffff9b9276d4]
>>>>> /home/chiajen/gem5/build/ARM/gem5.opt(+0x51aaf8)[0xaaaadf47aaf8]
>>>>> /home/chiajen/gem5/build/ARM/gem5.opt(+0x45c4b4)[0xaaaadf3bc4b4]
>>>>> /lib/aarch64-linux-gnu/libc.so.6(+0x273fc)[0xffff9adf73fc]
>>>>>
>>>>> /lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98)[0xffff9adf74cc]
>>>>> --- END LIBC BACKTRACE ---
>>>>> bash_scripts/fs_MEE.sh: line 10:  3170 Segmentation fault      (core
>>>>> dumped) $CURR_DIR/build/ARM/gem5.opt
>>>>> configs/secure_mem/fs/unified_secure.py --kernel $KERNEL_PATH --secure 1
>>>>> --mem-size 4GB --cpu-type DerivO3CPU --caches --disk $DISK_PATH
>>>>> --script=$BOOTSCRIPT_PATH --checkpoint-restore=1
>>>>>
>>>>> This problem does not occur when both CPU types are atomic. I also
>>>>> experimented with different input options. One that gave a different 
>>>>> result
>>>>> is the following.
>>>>>
>>>>> $CURR_DIR/build/ARM/gem5.opt configs/secure_mem/fs/unified_secure.py
>>>>> --kernel $KERNEL_PATH --secure 1 --mem-size 4GB --cpu-type $CPU_TYPE
>>>>> --caches --disk $DISK_PATH --script=$BOOTSCRIPT_PATH --checkpoint-at-end
>>>>> $CURR_DIR/build/ARM/gem5.opt configs/secure_mem/fs/unified_secure.py
>>>>> --kernel $KERNEL_PATH --secure 1 --mem-size 4GB --cpu-type DerivO3CPU
>>>>> --restore-with-cpu DerivO3CPU --caches --disk $DISK_PATH
>>>>> --script=$BOOTSCRIPT_PATH --checkpoint-restore=1
>>>>>
>>>>> In this case, I received no error messages, but the program stops and
>>>>> does not produce any outputs.
>>>>>
>>>>> **** REAL SIMULATION ****
>>>>> build/ARM/dev/arm/energy_ctrl.cc:252: warn: Existing EnergyCtrl, but
>>>>> no enabled DVFSHandler found.
>>>>> build/ARM/sim/simulate.cc:194: info: Entering event queue @
>>>>> 414294840500.  Starting simulation...
>>>>> build/ARM/arch/arm/insts/pseudo.cc:172: warn: instruction 'csdb'
>>>>> unimplemented
>>>>> 500822322500: system.terminal: attach terminal 0
>>>>> 518383741500: system.terminal: detach terminal 0
>>>>>
>>>>> I ran “telnet localhost 3456” in a separate terminal, and this was
>>>>> what I saw.
>>>>>
>>>>> Trying 127.0.0.1...
>>>>> Connected to localhost.
>>>>> Escape character is '^]'.
>>>>> ==== m5 terminal: Terminal 0 ====
>>>>>
>>>>> Any help is appreciated.
>>>>>
>>>>> Best regards,
>>>>> Chia Jen Cheng
>>>>> _______________________________________________
>>>>> gem5-users mailing list -- gem5-users@gem5.org
>>>>> To unsubscribe send an email to gem5-users-le...@gem5.org
>>>>>
>>>> _______________________________________________
>>>> gem5-users mailing list -- gem5-users@gem5.org
>>>> To unsubscribe send an email to gem5-users-le...@gem5.org
>>>>
>>> _______________________________________________
>>> gem5-users mailing list -- gem5-users@gem5.org
>>> To unsubscribe send an email to gem5-users-le...@gem5.org
>>>
>> _______________________________________________
>> gem5-users mailing list -- gem5-users@gem5.org
>> To unsubscribe send an email to gem5-users-le...@gem5.org
>>
> _______________________________________________
> gem5-users mailing list -- gem5-users@gem5.org
> To unsubscribe send an email to gem5-users-le...@gem5.org
>
_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org

Reply via email to