Reserve physical page
Hello everyone, I am wondering whether it is possible to reserve a particular physical page in the kernel. The GFP pages can start from _any_ location, and i cannot find a way to specify a starting pfn. I need a few dozen pages to store a bitmap starting at a particular physical page frame number. Perhaps i am trying to do this wrong? I am trying to establish a (one-way) communication between KVM and a guest VM, by assuming that if KVM knows the physical address in the VM , it can access that bitmap. Thanks !
Hello everyone, I am wondering whether it is possible to reserve a particular physical page in the kernel. The GFP pages can start from _any_ location, and i cannot find a way to specify a starting pfn. I need a few dozen pages to store a bitmap starting at a particular physical page frame number. Perhaps i am trying to do this wrong? I am trying to establish a (one-way) communication between KVM and a guest VM, by assuming that if KVM knows the physical address in the VM , it can access that bitmap.
you can covert pa to pfn to struct page (there are some macros in the kernel that does this, you grep the kernel source for it) and directly set the PG_reserved flag of that struct page. thanks, thayumanavar
On Sat, Aug 6, 2011 at 11:35 PM, Thayumanavar S <thayumker@gmail.com> wrote:
Hello everyone, I am wondering whether it is possible to reserve a particular physical page in the kernel. The GFP pages can start from _any_ location, and i cannot find a way to specify a starting pfn. I need a few dozen pages to store a bitmap starting at a particular physical page frame number. Perhaps i am trying to do this wrong? I am trying to establish a (one-way) communication between KVM and a guest VM, by assuming that if KVM knows the physical address in the VM , it can access that bitmap.
you can covert pa to pfn to struct page (there are some macros in the kernel that does this, you grep the kernel source for it) and directly set the PG_reserved flag of that struct page.
Ok. But in this case i have to ensure that the pfn is not mapped by the kernel, right? Will scanning mem_map to find such a pfn help? I'm wondering if there are regions which are typically 'free' which i can reserve and use. Thanks for the reply,
Ok. But in this case i have to ensure that the pfn is not mapped by the kernel, right? Will scanning mem_map to find such a pfn help? I'm wondering if there are regions which are typically 'free' which i can reserve and use. Either you can look at memblock_reserve or reserve_bootmem. (this may solve your problem). or you alloc_page api which return a struct page, you SetPageReserved and use page_to_pfn to get the pfn number.
thanks, thayumanavar s.
On Sat, Aug 6, 2011 at 11:36 AM, Prateek Sharma <prateek3.14@gmail.com> wrote:
Hello everyone, I am wondering whether it is possible to reserve a particular physical page in the kernel. The GFP pages can start from _any_ location, and i cannot find a way to specify a starting pfn. I need a few dozen pages to store a bitmap starting at a particular physical page frame number. Perhaps i am trying to do this wrong? I am trying to establish a (one-way) communication between KVM and a guest VM, by assuming that if KVM knows the physical address in the VM , it can access that bitmap.
Thanks !
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Prateek! I'm not completely sure, but why don't you hide needed page from kernel? I mean, you can provide kernel with memory layout configuration through mem= boot option. You can, for instance, use mem=32768K@0K,mem=32764K@32772K, i.e. you tell to kernel there is a gap (starting at 32768K from 0x0 in 4K size) in memory layout. Later, you can use this gap via ioremap call.
On Sun, Aug 7, 2011 at 9:27 PM, Vladimir Murzin <murzin.v@gmail.com> wrote:
On Sat, Aug 6, 2011 at 11:36 AM, Prateek Sharma <prateek3.14@gmail.com> wrote:
Hello everyone, I am wondering whether it is possible to reserve a particular physical page in the kernel. The GFP pages can start from _any_ location, and i cannot find a way to specify a starting pfn. I need a few dozen pages to store a bitmap starting at a particular physical page frame number. Perhaps i am trying to do this wrong? I am trying to establish a (one-way) communication between KVM and a guest VM, by assuming that if KVM knows the physical address in the VM , it can access that bitmap.
Thanks !
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Prateek!
I'm not completely sure, but why don't you hide needed page from kernel? I mean, you can provide kernel with memory layout configuration through mem= boot option. You can, for instance, use mem=32768K@0K,mem=32764K@32772K, i.e. you tell to kernel there is a gap (starting at 32768K from 0x0 in 4K size) in memory layout. Later, you can use this gap via ioremap call.
This looks like it will work. Thank you! I will try this and report how this little experiment went. Thanks again,
participants (3)
-
Prateek Sharma -
Thayumanavar S -
Vladimir Murzin