The Page Fault Process After Address Access in Arm-Linux
# Address Access Example Taking the access to the user-space **virtual address** 0x0000007000003000 as an example, consider the following code. ```C #include <sys/mman.h> #include <stdio.h> int main() { unsigned long long *x = (unsigned long long)0x0000007000003000; int *p = (int*)mmap(0x0000007000003000, sizeof(unsigned long long) * 10, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); printf("before write, x = %llu\n", *x); *x = 1; printf("after write, x = %llu\n", *x); } ``` If the user-space virtual address `0x0000007000003000` is not mapped in advance via mmap with read and write permissions, a `Segmentation fault (core dumped)` will occur, because `0x0000007000003000` is not managed as a vma (virtual memory area) allocated through mmap or brk in the process's virtual address space, and thus the virtual address is not accessible at this point. The output after compilation is as follows. ``` before write, x = 0 after write, x = 1 ``` As can be seen, a new value was successfully written to the user-space virtual address `0x0000007000003000`.