WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Difference between vmalloc_to_pfn and virt_to_pfn

To: Srujan Kotikela <ksrujandas@xxxxxxxxx>
Subject: Re: [Xen-devel] Difference between vmalloc_to_pfn and virt_to_pfn
From: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Date: Wed, 29 Jun 2011 09:35:27 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 29 Jun 2011 01:36:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <BANLkTikj8F-Aeh01+Z-_gZtd-RRHf-AT2w@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <BANLkTikj8F-Aeh01+Z-_gZtd-RRHf-AT2w@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.21 (2010-09-15)
Hi,

At 12:32 -0500 on 28 Jun (1309264366), Srujan Kotikela wrote:
> I was trying to convert a virtual adrress in a HVM guest to the MFN.

If you just want to access the memory, hvm_copy_{to,from}_guest_virt
should do it.  If not, you should be able to use bits of it to do the
translation you need.

> I tried using *vmalloc_to_pfn(virt_address)* and then passed the resulting
> pfn to VMM through a hypercall. Inside the VMM I tried calling
> gfn_to_mfn(pfn) with pfn receieved from hypercall. This function always gave
> me INVALID_MFN error (~0UL).
> 
> When I replaced the vmalloc_to_pfn with *virt_to_pfn(virt_address)* I am
> getting some MFN value returned by gfn_to_mfn. Just to make sure, I passed
> the value to gmfn_to_mfn and I am getting the same value as returned by
> gfn_to_mfn.

gmfn_to_mfn is a simple wrapper around gfn_to_mfn, so they usually
give the same answer, even if it's not the one you want. 

> Now my questions:
> 
> 1. What is the difference between vmalloc_to_pfn and virt_to_pfn (apart from
> the fact that one is linux kernel function and the other is xen function) ?

I don't know about the linux functions, but the xen one virt_to_mfn (not
virt_to_pfn) translates _xen_ virtual addresses to MFNs so it's no use
for a HVM guest virtual address.

> 2. Is there a way to verify/conform whether the MFN is correct ?

The surest way is to map it and check the contents.

Tim.

-- 
Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>