[BitVisor-devel-en:69] Re: How can I convert a gva to gpa?
hikkikuma1991
hikkikuma1991 at 163.com
Fri Dec 18 13:04:46 JST 2015
Dear Eiraku san,
Thank you very much. I can convert a gva to hpa now, and I can dump the memory region of a process' or kernel's gva address. My source code is very similar with the core/debug.c just added a function to read cr3~efer registers.
void
get_control_regs(ulong * cr0, ulong * cr3, ulong * cr4, u64 * efer){
current->vmctl.read_control_reg (CONTROL_REG_CR0, cr0);
current->vmctl.read_control_reg (CONTROL_REG_CR3, cr3);
current->vmctl.read_control_reg (CONTROL_REG_CR4, cr4);
current->vmctl.read_msr (MSR_IA32_EFER, efer);
}
But there is a little trick, that is the value of cr3 is the vcpu's current state, which means if u are running a process A, and A has invoked get_control_regs() to get cr3, then the cr3's value is process A's page directory's gpa address. If u want to convert process B's gva, it should not work.
And I have another question, is there anyone can answer me? How to pause bitvisor and resume it? I need to pause vm for consistent memory access although it seems work good if I don't pause vm. But I still need some help or knowledge of pausing and resuming the bitvisor.
Augustus Liu <hikkikuma1991 at 163.com>
发件人:bitvisor-devel-en-request at bitvisor.org
发送时间:2015-12-09 11:00
主题:BitVisor-devel-en Digest, Vol 26, Issue 2
收件人:"bitvisor-devel-en"<bitvisor-devel-en at bitvisor.org>
抄送:
Send BitVisor-devel-en mailing list submissions to
bitvisor-devel-en at bitvisor.org
To subscribe or unsubscribe via the World Wide Web, visit
https://www.bitvisor.org/mailman/listinfo/bitvisor-devel-en
or, via email, send a message with subject or body 'help' to
bitvisor-devel-en-request at bitvisor.org
You can reach the person managing the list at
bitvisor-devel-en-owner at bitvisor.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of BitVisor-devel-en digest..."
Today's Topics:
1. [BitVisor-devel-en:66] Re: How can I convert a gva to gpa?
(Hideki EIRAKU)
----------------------------------------------------------------------
Message: 1
Date: Tue, 08 Dec 2015 15:39:09 +0900 (JST)
From: Hideki EIRAKU <hdk at igel.co.jp>
To: bitvisor-devel-en at bitvisor.org
Subject: [BitVisor-devel-en:66] Re: How can I convert a gva to gpa?
Message-ID: <20151208.153909.26311979.hdk at igel.co.jp>
Content-Type: Text/Plain; charset=us-ascii
Hello,
From: "hikkikuma1991"<hikkikuma1991 at 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 at igel.co.jp>
------------------------------
Subject: Digest Footer
_______________________________________________
BitVisor-devel-en mailing list
BitVisor-devel-en at bitvisor.org
https://www.bitvisor.org/mailman/listinfo/bitvisor-devel-en
------------------------------
End of BitVisor-devel-en Digest, Vol 26, Issue 2
************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.bitvisor.org/archives/bitvisor-devel-en/attachments/20151218/92774c20/attachment.html>
More information about the BitVisor-devel-en
mailing list