[snip]
>All of the monitor structures are mapped into an address
>space spanned by one page table (a 4MByte span).
>This is done for convenience so we can migrate the such structures
>within the address space efficiently and easily, if the guest ever
>requires the use of a linear address within that range.
>Likely we have placed the monitor in a portion of the address space
>in which the guest doesn't use.
... (this and the previous paragraph) hasn't this all been written already
earlier in the text ? If not, I think they should ;)
>Virtualization of non-existent physical guest memory:
>=====================================================
>
>For situations where the guest OS gropes physical memory
>to determine the amount of memory installed, we must handle
>this in such a way that the guest determines that memory
>beyond the amount which we have allocated, does not exist.
>
>One approach would be to make sure that all such accesses
>are covered by protections in the page tables, and result
>in a page fault. We would then have to virtualize the
>access on behalf of the guest, and continue. For writes,
>we would ignore the access, for reads we would return a
>value reprentative of non-existent memory.
>
>The problem with this approach is that it involves heavy
>overhead to handle the execution of such guest code.
Accessing non-existant physical memory is a bug -- shouldn't worry about
this too much... either that or it's a memory probe, which isn't performance
critical.
>A different and more efficient approach would be to find a
>truly unused physical memory region (spanning 1 aligned page)
>in the host, and then map this page-size region into the address
>space wherever the guest page tables point to non-existent physical
>memory. Or for guest code running in non-paged mode, map this page
>to all of the linear address space above the size of physical
>guest memory. Then we could let the guest access such non-existent
>memory from thereon, and it will truly be accessing non-existent
>memory. Any comments/caveats/warnings here?
I have some weird experiences with accessing non-existant physical memory. A
couple of years ago I was writing a memory probe for an OS, which worked by
repeatedly taking a page of physical memory, writing to it, and then reading
back the value. By counting how many times this goes right, you should (in
principle) be able to figure out how much physical memory you have, assuming
that it doesn't have holes in it. Unfortunately, this method failed completely
on my pentium (worked fine on 486 though), where it repeatedly said I have 64MB
of memory though I have only 56MB. After spending a hell of a time on
debugging
it, I found out that a curious thing was going on: though the physical
memeory I
was accessing didn't exist, the CPU was still caching my memory writes; and
when
I read it back, it read the values I had just written out of the cache. The
only way to circumvent this was turning off the cache in CR0...
If we want to emulate this behavior, we need to use "real" nonexistant memory
when the cache is turned on in CR0, and use the pagefault mechanism if it's off.
-- Ramon