I am trying to run an application which uses pagemap in gem5 FS mode. But I am not able to use pagemap in gem5. It throws below error -
"assert(pagemap>=0) failed"
The line of code is:
int pagemap = open("/proc/self/pagemap", O_RDONLY);
assert(pagemap >= 0);
Also, If I try to run my application on gem5 terminal with sudo ,it throws error-
sudo command not found
How can I use sudo in gem5 ??
These problems are not gem5 specific, but rather image / Linux specific, and would likely happen on any simulator or real hardware. So I recommend that you remove gem5 from the equation completely, and ask a Linux or image specific question next time, saying exactly what image your are using, kernel configs, and provide a minimal C example that reproduces the problem: this will greatly improve the probability that you will get help.
I have just done
open("/proc/self/pagemap", O_RDONLY)
successfully with: this program and on thisfs.py
setup on aarch64, see also these comments.If
/proc/<pid>/pagemap
is not present for any file, do the following:ensure that procfs is mounted on
/proc
. This is normally done with anfstab
entry of type:but your init script needs to use
fstab
as well.Alternatively, you can mount
proc
manually with:you will likely want to ensure that
/sys
and/dev
are mounted as well.grep the kernel to see if there is some config controlling the file creation.
These kinds of things are often easy to find without knowing anything about the kernel.
If I do:
to find the
pagemap
string, which is likely the creation point, on v4.18 this leads me tofs/proc/base.c
, which contains:so make sure
CONFIG_PROC_PAGE_MONITOR
is set.sudo
: most embedded / simulator images don't have it, you just login as root directly and can do anything by default without it. This can be seen by the conventional#
in the prompt instead of$
.