Questions tagged [mmap]

mmap is a POSIX-compliant Unix system call that maps files or devices into memory.

mmap() creates a new mapping in the virtual address space of the calling process.

https://en.wikipedia.org/wiki/Mmap

1936 questions
0
votes
1 answer

Accessing physical address space using mmap in Linux: passing the correct arguments to mmap

I need to access and write to some physical addresses in my RAM. I was looking at this answer and the definition of mmap. If addr is NULL, then the kernel chooses the (page-aligned) address at which to create the mapping; this is the most portable…
acevans
  • 13
  • 4
0
votes
1 answer

Using mmap with C++ and dynamic containers

I am trying to use mmap for mapping and sharing data between processes on my device. My target is an embedded device running Embedded Linux My processes are implemented using C++, and using containers such as std::list and std::map. Obviously the…
Engineer999
  • 3,683
  • 6
  • 33
  • 71
0
votes
2 answers

Calling mmap from specific address

How to read mmap function from specific address, if knew it (0x6A6F7444)? I tried: mmap(0x6A6F7444, 100, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0) But it doen't works. Compile says: warning: passing argument 1 of ‘munmap’ makes…
Restman
  • 95
  • 1
  • 8
0
votes
0 answers

In linux, how to capture all network interface traffic without packet loss?

I am working on a program which can monitor all traffic in a hypervisor, the hypervisor contain many virtual hosts. I want to record all traffic from each network card(include physical network interface and virtual host's tap interface) in the…
0
votes
1 answer

Why is mmap in python so slow?

I've got a 1GB binary example file which I load into memory. When running a benchmark on python 3.7 and windows, mmap loses severly in terms of performance against readinto. The following code runs a benchmark. The first routine uses simple…
codie
  • 343
  • 4
  • 12
0
votes
2 answers

accessing mmap region using structure pointer

Its possible that if I access memory map of a file, via pointer of a structure type which has hole, it may not map the structure elements to correct data. For eg. #include #include #include #include…
Karun
  • 447
  • 5
  • 17
0
votes
0 answers

If I mmap a memory region with no access bits set, does mlockall still force it to be backed by physical memory?

By default Linux doesn't actually back the pages allocated with mmap with any physical memory until the first time they are accessed. However you can force it to do so preemptively by calling mlockall(MCL_CURRENT | MCL_FUTURE). It is a common…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
0
votes
0 answers

MAP_SHARED_VALIDATE with LEGACY_MAP_MASK produce EINVAL error in mmap( )

I read that MAP_SHARED_VALIDATE will return EOPNOTSUPP and mmap() would fail when there are unknown flags but, when I use the LEGACY_MAP_MASK (All are valid flags), the mmap( ) is failing. #define LEGACY_MAP_MASK (MAP_SHARED \ | MAP_PRIVATE…
Paul
  • 331
  • 2
  • 7
0
votes
1 answer

How to count cache-misses in mmap-ed memory (using eBPF)?

I would like to get timeseries t0, misses ... tN, misses where tN is a timestamp (second-resolution) and misses is a number of times the kernel made disk-IO for my PID to load missing page of the mmap()-ed memory region when process did access to…
pavelkolodin
  • 2,859
  • 3
  • 31
  • 74
0
votes
1 answer

Shared memory using mmap

I'm trying to understand how does mmap works in relation to shared memory. Does the MAP_SHARED flag disables Copy-on-Write? Because if so, any malicious process could alter shared libraries. Thanks.
Programmer
  • 119
  • 1
  • 8
0
votes
1 answer

How to use mmap like malloc?

I'm trying to allocate memory for 10x of my list struct then use it for my linked list but I keep getting a segmentation fault. Valgrind ==3806== Invalid write of size 4 ==3806== at 0x4005FD: main (comp.c:14) ==3806== Address 0xffffffffffffffff…
Unknows player
  • 97
  • 1
  • 1
  • 5
0
votes
0 answers

Reading physical memory with /dev/mem

I am trying to figure out how to directly read any location in physical memory on a Power9 processor using /dev/mem. The following is the code that I have used to that end. FILE* fp; int _fdmem; int *map = NULL; const char memDevice[] =…
Jerry9013
  • 1
  • 2
0
votes
1 answer

Scan list (text, treating as bytes-like) and append if item not already present (Python)

I am trying to append jpg file paths to a pre-existing text list if the path is not already present. I am also trying to treat the list as bytes-like to be a little more efficient. I was able to use the following bit of code to create and append a…
Solebay Sharp
  • 519
  • 7
  • 24
0
votes
1 answer

Prefetch with file backed mmap in c

I am writing some performance critical code (i.e. in a very tight loop and indicated by profiling) whose logic is basically (the_key is a parameter and mmap_base is the base address of a memory mapped file): while (current_item && (struct my_struct…
user12986714
  • 741
  • 2
  • 8
  • 19
0
votes
1 answer

mprotect PROT_EXEC on noexec partition

I tried mmap-ing (more specifically dlopen fails on mmap) a file from disk partition that was mounted with the noexec flag and it resulted in failed to map segment from shared object How does the kernel know once the file is mapped to memory if…
user282909
  • 115
  • 1
  • 7