From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLq0w-0001np-Sb for qemu-devel@nongnu.org; Thu, 03 Nov 2011 01:39:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLq0v-0008M2-GO for qemu-devel@nongnu.org; Thu, 03 Nov 2011 01:38:58 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:46679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLq0u-0008ET-Mk for qemu-devel@nongnu.org; Thu, 03 Nov 2011 01:38:57 -0400 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [202.81.31.247]) by e23smtp07.au.ibm.com (8.14.4/8.13.1) with ESMTP id pA35ceo6030306 for ; Thu, 3 Nov 2011 16:38:40 +1100 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pA35Zm7p2404494 for ; Thu, 3 Nov 2011 16:35:48 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pA35cdji032146 for ; Thu, 3 Nov 2011 16:38:39 +1100 Message-ID: <4EB228A9.8090607@linux.vnet.ibm.com> Date: Thu, 03 Nov 2011 13:37:45 +0800 From: shu ming MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Catching system calls and PIDs in Qemu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ricardo Alves Cc: qemu-devel@nongnu.org I don't know how to convert the guest virtual address to a guest physical address. But I believe that the guest virtual address to guest physical address mapping table should belong to the guest OS and stay at guest context. So you should know where is the mapping table in the guest OS by guest physical address before you have a way to do the conversion. After the guest physical address of the table is known, cpu_physical_memory_rw() can be used to walking the table and get the guest physical address of the guest virtual address you want to convert. The time spending on the walk should be non-trival. On 2011-11-3 2:25, Ricardo Alves wrote: > Need Help! > > I am editing the Qemu source code to be able to catch every system call made by the guest OS and which processes do those system calls. > > I catch the system calls in the "void do_interrupt(CPUState *env1)" (op_helper.c) function by accessing the exception index on the cpu environment (env->exception_index == 0x80) and inspecting the system call ID in the eax register. > > The difficulty resides in finding the process that made the system call. Linux uses the thread_info struct to store process information. The method to find this struct location is to apply a mask to the esp register and I would get the struct pointer. In qemu I would just do this -- target_ulong pos = env->regs[R_ESP]& 0xFFFFE000. > > The problem is that I don't know how to access the guest main memory. The qemu function I found to access memory was this one -- void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,int len, int is_write) (exec.c). But as far as I know (I could be wrong) this function receives a guest physical adress and the one I have is a guest virtual adress. Can anybody help me convert this guest virtual adress to a guest physical adress? > > Thank you. > >