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] Read value of CR3 from DomU VCPU

To: "Nimgaonkar, Satyajeet" <SatyajeetNimgaonkar@xxxxxxxxxx>, Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Subject: Re: [Xen-devel] Read value of CR3 from DomU VCPU
From: Keir Fraser <keir.xen@xxxxxxxxx>
Date: Fri, 06 May 2011 17:57:39 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 06 May 2011 09:59:22 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:user-agent:date:subject:from:to:cc:message-id :thread-topic:thread-index:in-reply-to:mime-version:content-type :content-transfer-encoding; bh=3vjJBwBo1TBrsH1giWAC3PhJus5Pomgw1IyIXqy54zc=; b=la2cSfEy2ssMOFiGt+tZBNTZDZPwWzhy/v4n1KYZ2OmeZvwg0ObtdO49Vt/IicrQKQ zQZwt1Z1400WK/VJsxQe6BJZrJFudg9YiWhIa2wUDsJkHbOcF9/usYWGay6XUaM1iWsk E13CfurXi5ldiZarHRy5jG9RyZIj81Pp9BxnA=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=user-agent:date:subject:from:to:cc:message-id:thread-topic :thread-index:in-reply-to:mime-version:content-type :content-transfer-encoding; b=gzvpPmPFDeew3oCJZm9AOwoenJw2f7Civc9kEqVr198RYv8vhMGDkH6d5mTRnd5gkf Jy0qgZVsIcDOkaUiOBSIAMa546Wfm0f5rvxD/0avAgxIPa543s4/3T1tNp1Ww8JN0nnZ vHBN7PsZsmTT8pOYv1sK5Q3iGgyY7pFGAyGdk=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <12871952FC0E29439F861FA745BCDD850D34A796@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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AQHMCv8uEE6BnjIBzU+ZDp10JZOUgpR/+/PygAALeB8=
Thread-topic: [Xen-devel] Read value of CR3 from DomU VCPU
User-agent: Microsoft-Entourage/12.29.0.110113
On 06/05/2011 17:33, "Nimgaonkar, Satyajeet"
<SatyajeetNimgaonkar@xxxxxxxxxx> wrote:

> Hi Tim,
>            I looked at the xc_translate_foreign_address() in
> tools/libxc/xc_pagetab.c and tried to emulate it. The function below void
> do_jeet1() is a hypercall handler function for my custom hypercall to get the
> value of CR3 from the guest VCPU. But when I try to call this hypercall, my
> machine automatically boots up. Any thoughts?
> 
> void do_jeet1(void){
> 
>    unsigned long pgdaddr;
>    vcpu_guest_context_u ctx;
>    printk ("Successfull Hypercall made to __HYPERVISOR_jeet1\n");
>                  
>    pgdaddr = xen_cr3_to_pfn(ctx.nat->ctrlreg[3]);

How experienced are you with C? This is so very obviously broken
(dereferencing field 'nat' in uninitialised union 'ctx'), it's surprising
gcc didn't warn and thereby fail the build. It's not really the purpose of
this list to school you.

 -- Keir

>    printk ("PGDADDR:%lx\n", pgdaddr);
>                  
> }
> 
> Thanks.
> 
> Regards,
> Jeet
> 
> ________________________________________
> From: Tim Deegan [Tim.Deegan@xxxxxxxxxx]
> Sent: Thursday, May 05, 2011 2:33 AM
> To: Nimgaonkar, Satyajeet
> Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
> Subject: Re: [Xen-devel] Read value of CR3 from DomU VCPU
> 
> At 21:28 +0100 on 04 May (1304544537), Nimgaonkar, Satyajeet wrote:
>> Hi,
>>     I intend to map the DomU kernel memory to the Dom0 using the
>> function xc_map_foreign_range(). For this I need the machine frame
>> number (mfn) for the page I want to map. To get the value of mfn I want
>> to read the value of cr3 from the DomU Vcpu data structure i.e. the
>> value of ctrlreg[3] from a vcpu_guest_context object.
> 
> Look at xc_translate_foreign_address() in tools/libxc/xc_pagetab.c; it
> does VA->MFN translations, including extracting CR3.
> 
> Cheers,
> 
> Tim.
> 
>> Also I have implemented a hypercall and wish to read the cr3 value in the
>> hypercall handler.
>> Can anyone share some information regarding how read the cr3 value. Any code
>> examples would help me significantly.
>> Thanks a lot.
>> 
>> Regards,
>> Jeet
> 
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@xxxxxxxxxxxxxxxxxxx
>> http://lists.xensource.com/xen-devel
> 
> 
> --
> 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



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

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