* Read value of CR3 from DomU VCPU
@ 2011-05-04 20:28 Nimgaonkar, Satyajeet
2011-05-05 8:33 ` Tim Deegan
0 siblings, 1 reply; 4+ messages in thread
From: Nimgaonkar, Satyajeet @ 2011-05-04 20:28 UTC (permalink / raw)
To: xen-devel@lists.xensource.com
[-- Attachment #1.1: Type: text/plain, Size: 574 bytes --]
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. 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
[-- Attachment #1.2: Type: text/html, Size: 2398 bytes --]
[-- Attachment #2: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Read value of CR3 from DomU VCPU
2011-05-04 20:28 Read value of CR3 from DomU VCPU Nimgaonkar, Satyajeet
@ 2011-05-05 8:33 ` Tim Deegan
2011-05-06 16:33 ` Nimgaonkar, Satyajeet
0 siblings, 1 reply; 4+ messages in thread
From: Tim Deegan @ 2011-05-05 8:33 UTC (permalink / raw)
To: Nimgaonkar, Satyajeet; +Cc: xen-devel@lists.xensource.com
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@lists.xensource.com
> http://lists.xensource.com/xen-devel
--
Tim Deegan <Tim.Deegan@citrix.com>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Read value of CR3 from DomU VCPU
2011-05-05 8:33 ` Tim Deegan
@ 2011-05-06 16:33 ` Nimgaonkar, Satyajeet
2011-05-06 16:57 ` Keir Fraser
0 siblings, 1 reply; 4+ messages in thread
From: Nimgaonkar, Satyajeet @ 2011-05-06 16:33 UTC (permalink / raw)
To: Tim Deegan; +Cc: xen-devel@lists.xensource.com
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]);
printk ("PGDADDR:%lx\n", pgdaddr);
}
Thanks.
Regards,
Jeet
________________________________________
From: Tim Deegan [Tim.Deegan@citrix.com]
Sent: Thursday, May 05, 2011 2:33 AM
To: Nimgaonkar, Satyajeet
Cc: xen-devel@lists.xensource.com
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@lists.xensource.com
> http://lists.xensource.com/xen-devel
--
Tim Deegan <Tim.Deegan@citrix.com>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Read value of CR3 from DomU VCPU
2011-05-06 16:33 ` Nimgaonkar, Satyajeet
@ 2011-05-06 16:57 ` Keir Fraser
0 siblings, 0 replies; 4+ messages in thread
From: Keir Fraser @ 2011-05-06 16:57 UTC (permalink / raw)
To: Nimgaonkar, Satyajeet, Tim Deegan; +Cc: xen-devel@lists.xensource.com
On 06/05/2011 17:33, "Nimgaonkar, Satyajeet"
<SatyajeetNimgaonkar@my.unt.edu> 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@citrix.com]
> Sent: Thursday, May 05, 2011 2:33 AM
> To: Nimgaonkar, Satyajeet
> Cc: xen-devel@lists.xensource.com
> 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@lists.xensource.com
>> http://lists.xensource.com/xen-devel
>
>
> --
> Tim Deegan <Tim.Deegan@citrix.com>
> Principal Software Engineer, Xen Platform Team
> Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-06 16:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 20:28 Read value of CR3 from DomU VCPU Nimgaonkar, Satyajeet
2011-05-05 8:33 ` Tim Deegan
2011-05-06 16:33 ` Nimgaonkar, Satyajeet
2011-05-06 16:57 ` Keir Fraser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).