-
-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virt_to_phys_user to print a physical address for a mmap #146
Comments
Hi Balaji, So you want to do a mmap and then get its physical address is that right? But are you trying to the the physical address from:
by searching for If so, I'm not sure that can work, since using |
So, even though it does not have any corresponding virtual address. Writing to vaddr will reflect in the /dev/mem |
Yes, I think this is what happens when using the |
Thank you for your swift replies. |
You mean the mmap size as in |
In many examples that mmap a physical memory I have seen the size was page_size in general. for instance here ptr=mmap(NULL,page_size,PROT_READ,MAP_SHARED,fd,(addr & ~(page_size-1))); So, I was wondering if there is a limitation for mmaping physical memory. |
Hi,
Thanks a lot for the codes that you are sharing. It is helping me to understand Linux better. 🐧
(All these experiments are on Ubuntu VM)
I have used linux-kernel-module-cheat/userland/virt_to_phys_user.c to print a physical address of a variable like this
and I get some reasonable values for virtual address, page frame number and physical address as
virtual address , Page frame no, physical address
0x55e451c272a0, 0x3d4a27, 0x3d4a272a0
But when I use it for a mmap I am getting 0 as physical address.
(for this I have compiled the kernel 5.9 with enabling CMA and making CONFIG_STRICT_DEVMEM=n
dmesg | cma
[ 0.068544] cma: Reserved 64 MiB at 0x000000021bc00000
)
virtual address , Page frame no, physical address
0x7fd5fffb3000, 0x0, 0x0
Does this program needs some modification for mmap's physical address ? or is there something I am missing ?
The text was updated successfully, but these errors were encountered: