Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH v2] port/xen: map memory directly in privcmd PRIVCMD_MMAPBATCH



>>>>> "Roger" == Roger Pau Monne <roger.pau%citrix.com@localhost> writes:

    Roger> Cherry G.Mathew wrote:
    >>>>>>> "Roger" == Roger Pau Monne<roger.pau%citrix.com@localhost> writes:
    >> 
    Roger> Cherry G.Mathew wrote:
    >> >>>>>>> "Roger" == Roger Pau Monne<roger.pau%citrix.com@localhost> 
writes:
    >> >>
    Roger> Cherry G.Mathew wrote:
    >> >> >>>>>>> "Roger" == Roger Pau Monne<roger.pau%citrix.com@localhost>
    >> writes: >> >> I'm still missing something here, but I think
    >> something is not >> >> right here. I *think* qemu or NetBSD is
    >> mixing up the guest's >> >> gmfns (pfns) and dom0 mfns here.
    >> >>  >>
    >> >> >> - qemu queries the hypervisor for the guest pfn (aka gmfn)
    >> >> via:>> [1] xc_get_hvm_param(xen_xc, xen_domid,>> >>
    >> HVM_PARAM_IOREQ_PFN,&ioreq_pfn);
    >> >>
    Roger> With this call we get a set of gfns of the guest.
    >> >>
    >> >> what are "gfns" ? Are they mfns (ie; the fns go into the page
    >> >> tables) or gmfns (what the guest *thinks* goes into page
    >> tables) >> ?
    >> 
    Roger> They are gmfns.
    >> 
    >> Ok, that makes a *lot* of sense now :-)
    >> 
    >> But it doesn't answer my question of how pmap_kenter_ma() works,
    >> since it's entering a mfn into the pmap VA. Where does this
    >> gmfn->mfn (or
    P-> M) translation take place ?

    Roger> This translation is done by the hypervisor.

I'm not so sure. 

Could you point me to code ? The mfn we get inside the ioctl is an mfn
*post* translation. pmap_enter_ma() just maps that into the qemu VA.

Ok, I see it now:
This is done from within pmap.c:pmap_enter_ma()

#if defined(XEN)
                if (domid != DOMID_SELF) {
                        /* pmap_pte_cas with error handling */
                        int s = splvm();
                        if (opte != *ptep) {
                                splx(s);
                                continue;
                        }
                        error = xpq_update_foreign(
                            vtomach((vaddr_t)ptep), npte, domid);
                        splx(s);
                        if (error) {
                                if (ptp != NULL && ptp->wire_count <= 1)
                            {
                                        pmap_free_ptp(pmap, ptp, va,
                            ptes, pdes);
                                }
                                pmap_unmap_ptes(pmap, pmap2);
                                goto out;
                        }
                        break;
                }
#endif /* defined(XEN) */

So what's happening is that for HVM, pfn == gmfn != mfn, 
for PV pfn != gmfn == mfn.

In the case of HVM, the hypervisor does the extra translation via the
guest's p2m table, and it is this p2m table that gets switched from
under during the fault.

Roger, Many thanks for taking the trouble to explain!

Waiting for your final patches.
-- 
Cherry


Home | Main Index | Thread Index | Old Index