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/
Home Products Support Community News


Re: [Xen-devel] xen_cr3_to_pfn

To: "Nimgaonkar, Satyajeet" <SatyajeetNimgaonkar@xxxxxxxxxx>
Subject: Re: [Xen-devel] xen_cr3_to_pfn
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Wed, 11 May 2011 09:54:52 +0100
Cc: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Wed, 11 May 2011 01:55:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <12871952FC0E29439F861FA745BCDD850D34C5E4@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
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>
Organization: Citrix Systems, Inc.
References: <12871952FC0E29439F861FA745BCDD850D34C5E4@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Tue, 2011-05-10 at 21:37 +0100, Nimgaonkar, Satyajeet wrote:
> Hi,
>     I am trying to read the value of cr3 from a VCPU assigned to a Dom
> U. I am invoking a custom hypercall and then attempting to read the
> value of cr3 in the hypercall handler. Below is the code of my
> hypercall handler.
> Here I am creating an object of the vcpu_guest_context and trying to
> read the value of ctrlreg[3] using xen_cr3_to_pfn macro. But I am
> getting the value of this (i.e. pgdaddr) as 0. Can anyone please tell
> me what am I doing wrong here.??

You have failed to initialise ctx for one thing.

> I also found a function called read_cr3(). And I am getting some 8 bit
> values for this function e.g. 27ca4000. Does this look right??

What values do you expect cr3 to contain? The contents of the cr3
register is defined by the processor architecture. You need to find
yourself a copy of e.g. "IA-32 Intel Architecture Software Developers
Guide Volume 3: System Programming Guide" (or the AMD equivalent) and
read it. The PDFs are readily available on the manufacturers websites.

I'm afraid that xen-devel is really not the place to be schooled in
basic processor architecture like this.

> Also then what is the difference between read_cr3 and xen_cr3_to_pfn.

Have you not read the code for each function? If you had then I think
the difference would be pretty obvious.


>  I read in some documentation that read_cr3 is not reliable hence use
> xen_cr3_to_pfn. 
> unsigned long CR3;
> unsigned long pgdaddr;
> vcpu_guest_context_t ctx;
> void do_jeet1(void){   
>    printk ("Successfull Hypercall made to __HYPERVISOR_jeet1\n");  
>    CR3 =  read_cr3();
>    pgdaddr = xen_cr3_to_pfn(ctx.ctrlreg[3]);
>    printk ("CR3:%lx\n", CR3);
>    printk ("PGDADDR:%lx\n", pgdaddr);
> } 
> Thanks.
> Regards,
> Jeet

Xen-devel mailing list

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