On Dec 9, 2010, at 12:34 AM, Brandon Fliflet wrote:

> I am working on a project that provides a scatter/gather memory like logic 
> for a virtual device. In this usage, the guest driver provides pinned memory 
> that plugs into a PCI memory range such that accesses through that memory 
> range get translated into the physical page provided by the guest driver. For 
> the most part, things are working but there are some issues that make me 
> wonder if something might be wrong with the implementation. To perform this 
> behavior I needed to remap the HC physical page in the MMIO2 range with a new 
> HC physical page (converted from the guest provided pinned memory). As such, 
> we used the following interfaces.
> 
> //
> // Remap page of memory region
> //
> // Inputs are GCPhys and regionOffset (offset from PCI BAR) where only 4K 
> pages are mapped
> rc = PGMPhysGCPhys2HCPhys(pVM, GCPhys, &HCPhys);
> // Error handling
> rc = PGMR3PhysMMIO2SetHCPhys(pVM, pDevIns, 0, regionOffset, HCPhys);
> // Error handling
> 
> Where PGMR3PhysMMIO2SetHCPhys was adapted from PGMR3PhysMMIO2GetHCPhys.  
> Actual code used was in my forum post.
> 
> My questions to the devs here are: Do you forsee any issues with updating the 
> HC physical page of an MMIO2 range? Is there a better way to remap a page in 
> the MMIO2 given that the page is provided by the guest driver?

Changing the host physical address of an MMIO2 page is not enough to make this 
work reliably. For instance take a look at what pgmPhysPageMapCommon in 
VMMAll/PGMAllPhys.cpp does when encountering an MMIO2 page: it calculates the 
ring-3/ring-0 mapping address of a page in an MMIO2 range by pRam->pvR3 + 
offset, i.e. it will access the original page and not the one you want it to. 

What you're trying to do is not something we've modeled into the physical guest 
memory handling due to lack of use cases. What you could try is to copy the 
whole PGMPAGE structure and not just the physical address, that should change 
the page type and avoid the pgmPhysPageMapCommon pitfalls. Only, you need to 
save the original MMIO2 PGMPAGE entries somewhere as you must restore them on 
reset (all memory is replaced by zero pages) and possibly also power off.

-- 

Kind regards / Mit freundlichen Gruessen / Vennlig hilsen,
 bird

--

ORACLE Deutschland B.V. & Co. KG  Knut St. Osmundsen
Werkstrasse 24                    Senior Staff Engineer, VirtualBox
71384 Weinstadt, Germany          mailto:[email protected]

Hauptverwaltung: Riesstr. 25, D-80992 Muenchen
Registergericht: Amtsgericht Muenchen, HRA 95603

Komplementaerin: ORACLE Deutschland Verwaltung B.V.
Rijnzathe 6, 3454PV De Meern, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschaeftsfuehrer: J. Kunz, M. van de Molen, A. van der Ven

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

Reply via email to