On Feb 13, 2010, at 5:46 AM, [email protected] wrote:

> Greetings,
> 
> I have a question regarding how to translate between different types of 
> memory addresses in VirtualBox. I am looking for ways to translate from:
> 
> * Guest Virtual Address ---> Guest Physical Address
-> PGMPhysGCPtr2GCPhys

> * Guest Physical ---> Guest Virtual
-> No API for this. 

The simple implementation of this translation would be to scan all known guest 
page tables, which would probably be extremely slow. We could maybe speed it up 
a bit by first checking the shadowed page table backrefs for the guest physical 
page, but the shadowed page tables lack information about their relation to 
virtual addresses (they can be mapped into several paging hierarchies) and the 
information we find there might easily be outdated or for a different memory 
context. This kind of operation might make sense as a debugger command, maybe. 
But like everything else there, it'll be added when we need it do debug 
something.

> * Guest Virtual ---> Host Physical
-> PGMPhysGCPtr2HCPhys

> * Guest Physical ---> Host Physical
-> PGMPhysGCPhys2HCPhys

For completeness: 

* Guest Physical ---> Host Virtual
-> PGMPhysGCPhys2CCPtr or PGMPhysGCPhys2CCPtrReadOnly; release with 
PGMPhysReleasePageMappingLock.

* Guest Virtual ---> Host Virtual
-> PGMPhysGCPtr2CCPtr or PGMPhysGCPtr2CCPtrReadOnly; release with 
PGMPhysReleasePageMappingLock.

* Host Virtual ---> *  or   Host Physical ---> *;
-> No working APIs for these transformation because or unwanted complexity.  
Again, might be useful in the debugger (there are non-working APIs for some of 
these).

> I looked through the VirtualBox code, and its is not completely clear to me. 
> If you could provide examples and function names to use, it would be great. 
> Your advice is much appreciated.
> 
> P.S. When I run a Linux guest system and translate some guest virtual 
> addresses to guest physical addresses inside the guest, I sometimes get 
> physical address which exceeds the maximum amount of VM memory -- could this 
> be due to the fact that what I am really seeing is host physical address and 
> not guest physical?

You will never see host physical addresses from within the guest. 

--

Kind regards / Mit freundlichen Gruessen / Vennlig hilsen,
  Knut

--

Sun Microsystems GmbH        Knut St. Osmundsen
Werkstrasse 24               Senior Staff Engineer, VirtualBox
71384 Weinstadt, Germany     mailto:[email protected]

==================================================
Sitz der Gesellschaft: Sun Microsystems GmbH,
Sonnenallee 1, D-85551 Kirchheim-Heimstetten
Amtsgericht Muenchen: HRB 161028
Gesch?ftsf?hrer: Thomas Schroeder, Wolfgang Engels
Vorsitzender des Aufsichtsrates: Martin Haering
==================================================


_______________________________________________
vbox-dev mailing list
[email protected]
http://vbox.innotek.de/mailman/listinfo/vbox-dev

Reply via email to