[BitVisor-devel-en:66] Re: How can I convert a gva to gpa?

Hideki EIRAKU hdk at igel.co.jp
Tue Dec 8 15:39:09 JST 2015


Hello,

From: "hikkikuma1991"<hikkikuma1991 ¡÷ 163.com>
Subject: [BitVisor-devel-en:65] How can I convert a gva to gpa?
Date: Mon, 7 Dec 2015 15:02:34 +0800

> But I met a problem when I  tried to convert guest virtual address to guest physics address. I copied the void memdump_gvirt(u64 gvirt) fuction in "process/debug.c", but it always returned a VMMERR_PAGE_NOT_PRESENT value to me, so I want to know is this func really works, or how could I use the func to convert a gva? And if it doesn't work, would you mind giving me some advices to finish this func? By the way, my enviroment is bitvisor 1.3 with 64bit Ubuntu 12.04.

The memdump_gvirt() function in core/debug.c uses the
cpu_mmu_get_pte() function to convert virtual address to physical
address.  The cpu_mmu_get_pte() function requires register values of
cr0, cr3, cr4, and, efer.  Those registers contain information about
page tables.  The cpu_mmu_get_pte() function should work properly
because it is used by instruction interpretation for real-address mode
emulation for old processors like Intel Core 2 Duo.

To convert address of current running process or kernel in the guest
operating system, use current->vmctl.read_control_reg() and
current->vmctl.read_msr() function to get those registers, then use
the cpu_mmu_get_pte() function.  Functions such as read_linearaddr_b()
in core/cpu_mmu.c use this way.

VMMERR_PAGE_NOT_PRESENT means the page is not present.  For example,
if the virtual address is zero, usually the page is not present
because it is NULL pointer address.  For another example, a page that
a process allocated may not be present because of deferred page
allocation or swapping.

-- 
Hideki EIRAKU <hdk ¡÷ igel.co.jp>


More information about the BitVisor-devel-en mailing list