<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type><!-- flashmail style begin -->
<STYLE type=text/css>
body {border-width:0;margin:0}
img {border:0;margin:0;padding:0}
</STYLE>
<BASE target=_blank><!-- flashmail style end -->
<META name=GENERATOR content="MSHTML 8.00.7601.17514"></HEAD>
<BODY 
style="LINE-HEIGHT: 1.5; BORDER-RIGHT-WIDTH: 0px; MARGIN: 12px; FONT-FAMILY: 微软雅黑; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; COLOR: #000000; FONT-SIZE: 10.5pt; BORDER-LEFT-WIDTH: 0px" 
marginheight="0" marginwidth="0">
<DIV>Dear Eiraku san,</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV dir=ltr align=left>void <BR>get_control_regs(ulong * cr0, ulong * cr3, 
ulong * cr4, u64 * efer){</DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
  <DIV style="MARGIN-RIGHT: 0px" dir=ltr 
  align=left>current->vmctl.read_control_reg (CONTROL_REG_CR0, 
  cr0);<BR>current->vmctl.read_control_reg (CONTROL_REG_CR3, 
  cr3);<BR>current->vmctl.read_control_reg (CONTROL_REG_CR4, 
  cr4);<BR>current->vmctl.read_msr (MSR_IA32_EFER, efer);</DIV></BLOCKQUOTE>
<DIV style="MARGIN-RIGHT: 0px" dir=ltr align=left>}</DIV>
<DIV style="MARGIN-RIGHT: 0px" dir=ltr align=left> </DIV>
<DIV>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.</DIV>
<DIV style="TEXT-INDENT: 2em"> </DIV>
<DIV>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.</DIV>
<DIV style="TEXT-INDENT: 2em"> </DIV>
<DIV>Augustus Liu <<A 
href="mailto:hikkikuma1991@163.com">hikkikuma1991@163.com</A>></DIV>
<DIV> </DIV>
<DIV>
<HR 
style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; HEIGHT: 1px; BORDER-TOP: #c0c0c0 1px solid; BORDER-RIGHT: 0px">
</DIV>
<BLOCKQUOTE 
style="PADDING-LEFT: 0px; FONT-FAMILY: Verdana; MARGIN-LEFT: 0px; FONT-SIZE: 10pt" 
id=ntes-flashmail-quote>
  <DIV><STRONG>发件人:</STRONG>bitvisor-devel-en-request@bitvisor.org</DIV>
  <DIV><STRONG>发送时间:</STRONG>2015-12-09 11:00</DIV>
  <DIV><STRONG>主题:</STRONG>BitVisor-devel-en Digest, Vol 26, Issue 2</DIV>
  <DIV><STRONG>收件人:</STRONG>"bitvisor-devel-en"<bitvisor-devel-en@bitvisor.org></DIV>
  <DIV><STRONG>抄送:</STRONG></DIV>
  <DIV> </DIV>
  <DIV>
  <DIV>Send BitVisor-devel-en mailing list submissions to </DIV>
  <DIV>    bitvisor-devel-en@bitvisor.org </DIV>
  <DIV> </DIV>
  <DIV>To subscribe or unsubscribe via the World Wide Web, visit </DIV>
  <DIV>    https://www.bitvisor.org/mailman/listinfo/bitvisor-devel-en </DIV>
  <DIV>or, via email, send a message with subject or body 'help' to </DIV>
  <DIV>    bitvisor-devel-en-request@bitvisor.org </DIV>
  <DIV> </DIV>
  <DIV>You can reach the person managing the list at </DIV>
  <DIV>    bitvisor-devel-en-owner@bitvisor.org </DIV>
  <DIV> </DIV>
  <DIV>When replying, please edit your Subject line so it is more specific </DIV>
  <DIV>than "Re: Contents of BitVisor-devel-en digest..." </DIV>
  <DIV> </DIV>
  <DIV> </DIV>
  <DIV>Today's Topics: </DIV>
  <DIV> </DIV>
  <DIV>   1. [BitVisor-devel-en:66] Re: How can I convert a gva to gpa? </DIV>
  <DIV>      (Hideki EIRAKU) </DIV>
  <DIV> </DIV>
  <DIV> </DIV>
  <DIV>---------------------------------------------------------------------- </DIV>
  <DIV> </DIV>
  <DIV>Message: 1 </DIV>
  <DIV>Date: Tue, 08 Dec 2015 15:39:09 +0900 (JST) </DIV>
  <DIV>From: Hideki EIRAKU <hdk@igel.co.jp> </DIV>
  <DIV>To: bitvisor-devel-en@bitvisor.org </DIV>
  <DIV>Subject: [BitVisor-devel-en:66] Re: How can I convert a gva to gpa? </DIV>
  <DIV>Message-ID: <20151208.153909.26311979.hdk@igel.co.jp> </DIV>
  <DIV>Content-Type: Text/Plain; charset=us-ascii </DIV>
  <DIV> </DIV>
  <DIV>Hello, </DIV>
  <DIV> </DIV>
  <DIV>From: "hikkikuma1991"<hikkikuma1991@163.com> </DIV>
  <DIV>Subject: [BitVisor-devel-en:65] How can I convert a gva to gpa? </DIV>
  <DIV>Date: Mon, 7 Dec 2015 15:02:34 +0800 </DIV>
  <DIV> </DIV>
  <DIV>> 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. </DIV>
  <DIV> </DIV>
  <DIV>The memdump_gvirt() function in core/debug.c uses the </DIV>
  <DIV>cpu_mmu_get_pte() function to convert virtual address to physical </DIV>
  <DIV>address.  The cpu_mmu_get_pte() function requires register values of </DIV>
  <DIV>cr0, cr3, cr4, and, efer.  Those registers contain information about </DIV>
  <DIV>page tables.  The cpu_mmu_get_pte() function should work properly </DIV>
  <DIV>because it is used by instruction interpretation for real-address mode </DIV>
  <DIV>emulation for old processors like Intel Core 2 Duo. </DIV>
  <DIV> </DIV>
  <DIV>To convert address of current running process or kernel in the guest </DIV>
  <DIV>operating system, use current->vmctl.read_control_reg() and </DIV>
  <DIV>current->vmctl.read_msr() function to get those registers, then use </DIV>
  <DIV>the cpu_mmu_get_pte() function.  Functions such as read_linearaddr_b() </DIV>
  <DIV>in core/cpu_mmu.c use this way. </DIV>
  <DIV> </DIV>
  <DIV>VMMERR_PAGE_NOT_PRESENT means the page is not present.  For example, </DIV>
  <DIV>if the virtual address is zero, usually the page is not present </DIV>
  <DIV>because it is NULL pointer address.  For another example, a page that </DIV>
  <DIV>a process allocated may not be present because of deferred page </DIV>
  <DIV>allocation or swapping. </DIV>
  <DIV> </DIV>
  <DIV>--  </DIV>
  <DIV>Hideki EIRAKU <hdk@igel.co.jp> </DIV>
  <DIV> </DIV>
  <DIV> </DIV>
  <DIV>------------------------------ </DIV>
  <DIV> </DIV>
  <DIV>Subject: Digest Footer </DIV>
  <DIV> </DIV>
  <DIV>_______________________________________________ </DIV>
  <DIV>BitVisor-devel-en mailing list </DIV>
  <DIV>BitVisor-devel-en@bitvisor.org </DIV>
  <DIV>https://www.bitvisor.org/mailman/listinfo/bitvisor-devel-en </DIV>
  <DIV> </DIV>
  <DIV> </DIV>
  <DIV>------------------------------ </DIV>
  <DIV> </DIV>
  <DIV>End of BitVisor-devel-en Digest, Vol 26, Issue 2 </DIV>
  <DIV>************************************************ </DIV></DIV></BLOCKQUOTE></BODY></HTML>