Skip to contentSkip to conversation

machine address

DISCUSSION HANNAS YAYA Issa 3 participants 4 messages Mar 30, 2015 – Apr 9, 2015

lore
Share & tools
lore
#0 lore raw

Hi
When there is a page fault the trapper of the page fault in the hypervisor is do_page_fault in xen/arch/x86/traps.c right? in this funcion i found a method read_cr2() which return the virtual adrress of the page who generate the page fault. My question is : is it possible to get the machine address of the page table entry for this virtual address?

Thank you

HANNAS

#1 lore raw
Quoted 3 lines · HANNAS YAYA Issa

Hi
When there is a page fault the trapper of the page fault in the hypervisor is do_page_fault in xen/arch/x86/traps.c right?

That's for PV guests. For HVM guests, the page fault causes a VMEXIT, which will be handled in xen/arch/x86/hvm/vmx/vmx.c:vmx_vmexit_handler() (on Intel).

Quoted 4 lines

in this funcion i found a method read_cr2() which return the virtual adrress of the page who generate the page fault.
My question is : is it possible to get the machine address of the page table entry for this virtual address?

In general the way you have to do that is to use the virtual address to walk the guest's pagetables (exactly the same way the hardware would do on a TLB miss).

For HVM guests (or PV guests in shadow mode) there's already code to do walk for you in xen/arch/x86/mm/guest_walk.c:guest_walk(). You can see how it's called from the HAP code and the shadow code if you want.

I don't immediately see a walker for PV guests.

-George

#2 lore raw

Ok. thank you

Quoted 26 lines · George Dunlap
Quoted 3 lines · HANNAS YAYA Issa

Hi
When there is a page fault the trapper of the page fault in the hypervisor is do_page_fault in xen/arch/x86/traps.c right?

That's for PV guests. For HVM guests, the page fault causes a VMEXIT, which will be handled in xen/arch/x86/hvm/vmx/vmx.c:vmx_vmexit_handler() (on Intel).

Quoted 4 lines

in this funcion i found a method read_cr2() which return the virtual adrress of the page who generate the page fault.
My question is : is it possible to get the machine address of the page table entry for this virtual address?

In general the way you have to do that is to use the virtual address to walk the guest's pagetables (exactly the same way the hardware would do on a TLB miss).

For HVM guests (or PV guests in shadow mode) there's already code to do walk for you in xen/arch/x86/mm/guest_walk.c:guest_walk(). You can see how it's called from the HAP code and the shadow code if you want.

I don't immediately see a walker for PV guests.

-George

#3 lore raw
In reply to George Dunlap
Quoted 19 lines · George Dunlap
Quoted 3 lines · HANNAS YAYA Issa

Hi
When there is a page fault the trapper of the page fault in the hypervisor is do_page_fault in xen/arch/x86/traps.c right?

That's for PV guests. For HVM guests, the page fault causes a VMEXIT, which will be handled in xen/arch/x86/hvm/vmx/vmx.c:vmx_vmexit_handler() (on Intel).

Quoted 4 lines

in this funcion i found a method read_cr2() which return the virtual adrress of the page who generate the page fault.
My question is : is it possible to get the machine address of the page table entry for this virtual address?

In general the way you have to do that is to use the virtual address to walk the guest's pagetables (exactly the same way the hardware would do on a TLB miss).

Quoted 5 lines

For HVM guests (or PV guests in shadow mode) there's already code to do walk for you in xen/arch/x86/mm/guest_walk.c:guest_walk(). You can see how it's called from the HAP code and the shadow code if you want.

I don't immediately see a walker for PV guests.

There one in __page_fault_type(). You can also use the linear pagetable mappings, if you know what you're doing -- see, e.g., guest_map_l1e() which does something very like this.

Cheers,

Tim.