Skip to contentSkip to conversation

Does paging_gva_to_gfn() convert to mfn for PV guests?

DISCUSSION Mike Sun 2 participants 5 messages May 12, 2008 – May 13, 2008

lore
Share & tools
lore

Mike Sun

author
#0 lore raw

Hi,

Does the function "paging_gva_to_gfn()" in xen/include/asm-x86/paging.h translate from guest virtual address to mfns or to pfns in PV guests that are not using fully translated shadow page tables (e.g. dom)?

Thanks,
Mike

#1 lore raw
Quoted 4 lines · Mike Sun

Does the function "paging_gva_to_gfn()" in xen/include/asm-x86/paging.h translate from guest virtual address to mfns or to pfns in PV guests that are not using fully translated shadow page tables (e.g. dom)?

It ought to, as long as they're using *some* kind of paging assistance. For non-HVM guests, that means shadow paging, e.g. log-dirty or 'test' mode.

Tim.

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]
author
#2 lore raw

Hmm... I'm not sure if I'm understanding clearly what you're saying. If I use this function to translate virtual addresses from dom0 (a PV guest without shadow paging). will I get an mfn or a pfn?

My expectation would be that I get an mfn since PV guests without any sort of shadow paging have virt --> machine translations installed in the page tables and do not actually use the p2m table for translation.
Is this correct?

Thanks,
Mike

Quoted 17 lines · Tim Deegan
Quoted 4 lines · Mike Sun

Does the function "paging_gva_to_gfn()" in xen/include/asm-x86/paging.h translate from guest virtual address to mfns or to pfns in PV guests that are not using fully translated shadow page tables (e.g. dom)?

It ought to, as long as they're using *some* kind of paging assistance. For non-HVM guests, that means shadow paging, e.g. log-dirty or 'test' mode.

Tim.

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

#3 lore raw
Quoted 3 lines · Mike Sun

Hmm... I'm not sure if I'm understanding clearly what you're saying. If I use this function to translate virtual addresses from dom0 (a PV guest without shadow paging). will I get an mfn or a pfn?

No. :) The code behind that function relies on data structures which are only maintained if paging assistance (shadow or HAP) is turned on.

Quoted 4 lines

My expectation would be that I get an mfn since PV guests without any sort of shadow paging have virt --> machine translations installed in the page tables and do not actually use the p2m table for translation.
Is this correct?

In the case of PV guests with shadow pagetables turned on (typically this is only while live migration is in progress), then yes, you should get an MFN.

Cheers,

Tim

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]
author
#4 lore raw

Thanks Tim. In that case, is there a function or macro that will translate a guest va from dom0 to mfn in Xen?

I've seen that functions like copy_to_guest will allow Xen to write into a dom0 guest address, but the way it's it's implemented (kernel to userspace copy), seems to require that the current address space in cr3 be the same as the guest process containing that guest address. I want to be able to copy from Xen to a guest address in dom0 regardless of what guest address space is currently loaded in cr3. I was hoping to do the gva --> mfn translation, store the mfn and map that mfn in to Xen on demand when I wanted to do the copy.

Any ideas?

Thanks,
Mike

Quoted 29 lines · Tim Deegan
Quoted 3 lines · Mike Sun

Hmm... I'm not sure if I'm understanding clearly what you're saying. If I use this function to translate virtual addresses from dom0 (a PV guest without shadow paging). will I get an mfn or a pfn?

No. :) The code behind that function relies on data structures which are only maintained if paging assistance (shadow or HAP) is turned on.

Quoted 4 lines

My expectation would be that I get an mfn since PV guests without any sort of shadow paging have virt --> machine translations installed in the page tables and do not actually use the p2m table for translation.
Is this correct?

In the case of PV guests with shadow pagetables turned on (typically this is only while live migration is in progress), then yes, you should get an MFN.

Cheers,

Tim

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]