From: Tim Deegan Subject: Re: Why gpa instead of mfn is directed used in emulated nic Date: Fri, 6 Mar 2015 10:39:12 +0100 Message-ID: <20150306093912.GA76636@deinos.phlegethon.org> References: <43fac069.5158.14be7daf917.Coremail.openlui@126.com> <20150305110941.GB85606@deinos.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: openlui Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org At 10:14 +0800 on 06 Mar (1425633255), openlui wrote: > At 2015-03-05 19:09:41, "Tim Deegan" wrote: > >Hi, > > > >At 10:54 +0800 on 05 Mar (1425549262), openlui wrote: > >> 2. From the trace info and qemu-dm's log, it seems that it is "GPA" > >> (Guest Physical Address) instead of "MFN" in the IOREQ's data field > >> received by qemu-dm: > > > >Yes. > Thanks for your reply. > > >> I think qemu-dm/rtl8139 should read/write data from "MFN" address in > >> host memory instaed of GPA, and I find that there isn't hypercall > >> from dom0 to "translate" the gpa to mfn in subsequent xentrace > >> info. Is my understanding is wrong? I would really appreciate your > >> help. > > > >The hypercall that qemu uses to map the guest's memory for reading and > >writing also takes a GFN/GPA. So Qemu doesn't need to know what the > >actual MFN is -- it just does all its operations in GPAs and Xen takes > >care of the translations. > > Could you give some hint about the type of hypercall qemu used to map the guest's memory? I know that there are some xc_map_foreign_xxx interfaces > in libxc which can do the similar work. However, it seems that these interfaces should be given MFN instead of GFN/GPA. That's some unfortunate historical APIs/docs. :( The argument is in fact a GFN in all cases, but for PV guests, which were implemented first, that's == MFN. Basically anything in the tools that deals with HVM guest memory should _always_ be working in GFN/GPA. Cheers, Tim.