All of lore.kernel.org
 help / color / mirror / Atom feed
From: shu ming <shuming@linux.vnet.ibm.com>
To: Ricardo Alves <rdq.alves@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Catching system calls and PIDs in Qemu
Date: Thu, 03 Nov 2011 13:37:45 +0800	[thread overview]
Message-ID: <4EB228A9.8090607@linux.vnet.ibm.com> (raw)
In-Reply-To: <C5E896BE-1FF9-4C82-BA88-2836B2BBEB37@gmail.com>

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.
>
>

      reply	other threads:[~2011-11-03  5:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-02 18:25 [Qemu-devel] Catching system calls and PIDs in Qemu Ricardo Alves
2011-11-03  5:37 ` shu ming [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EB228A9.8090607@linux.vnet.ibm.com \
    --to=shuming@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rdq.alves@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.