allocating unmapped physical pages

I want to be able to allocate memory in Windows to return to Xen so that
Xen can use it in other VM’s. On the Xen side of things, I just need to
pass it some PFN’s. On the Windows side of things, the only way I know
how to do this would be to allocate NonPagedPool memory and get the PFN
via MmGetPhysicalAddress (if just allocating a page at a time) or create
an MDL and get the PFN’s from that. Xen doesn’t need a virtual address
though, and I think that allocating NonPagedPool is a bit of a waste of
resources and would probably come unstuck pretty quickly).

The sort of magnitudes I’m talking about here are that a system might
boot up with 3G of memory, and then Xen may ask my drivers to return 1G
of memory, or possibly more. If my understanding is correct, there is no
way I’m going to get away with allocating 1G of memory from
NonPagedPool.

I think I could allocate the memory from PagedPool, and then lock it
into place in physical memory, but would that have the same
shortcomings? I don’t know a great deal about memory management, but I
assume that there is a page table entry involved in doing that mapping,
which is otherwise unnecessary… could they get used up?

Any suggestions?

Thanks

James

Please ignore my ramblings below. MmAllocatePagesForMdl is what I want.

Thanks

James

-----Original Message-----
From: James Harper
Sent: Monday, 8 June 2009 13:44
To: Windows System Software Devs Interest List
Subject: allocating unmapped physical pages

I want to be able to allocate memory in Windows to return to Xen so
that Xen
can use it in other VM’s. On the Xen side of things, I just need to
pass it
some PFN’s. On the Windows side of things, the only way I know how to
do this
would be to allocate NonPagedPool memory and get the PFN via
MmGetPhysicalAddress (if just allocating a page at a time) or create
an MDL
and get the PFN’s from that. Xen doesn’t need a virtual address
though, and I
think that allocating NonPagedPool is a bit of a waste of resources
and would
probably come unstuck pretty quickly).

The sort of magnitudes I’m talking about here are that a system might
boot up
with 3G of memory, and then Xen may ask my drivers to return 1G of
memory, or
possibly more. If my understanding is correct, there is no way I’m
going to
get away with allocating 1G of memory from NonPagedPool.

I think I could allocate the memory from PagedPool, and then lock it
into
place in physical memory, but would that have the same shortcomings? I
don’t
know a great deal about memory management, but I assume that there is
a page
table entry involved in doing that mapping, which is otherwise
unnecessary…
could they get used up?

Any suggestions?

Thanks

James

>The sort of magnitudes I’m talking about here are that a system might

boot up with 3G of memory, and then Xen may ask my drivers to return 1G
of memory, or possibly more. If my understanding is correct, there is no
way I’m going to get away with allocating 1G of memory from
NonPagedPool.

Can MmAllocatePagesForMdl help?


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com