qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Get host virtual address corresponding to guest physica


From: Blue Swirl
Subject: Re: [Qemu-devel] Get host virtual address corresponding to guest physical address?
Date: Sat, 25 Aug 2012 08:02:25 +0000

On Fri, Aug 24, 2012 at 3:14 AM, 陳韋任 (Wei-Ren Chen)
<address@hidden> wrote:
> Hi all,
>
>   I would like to know if there is a function in QEMU which converts
> a guest physical address into corresponding host virtual address. I
> guess cpu_physical_memory_map (exec.c) can do the job, but I have a
> few questions.
>
>   1. I am running x86 guest on a x86_64 host and using the cod below
>      to get the host virtual address, I am not sure what value of len
>      should be.
>
>         static inline void *gpa2hva(target_phys_addr_t addr)
>         {
>             target_phys_addr_t len = 4;
>             return cpu_physical_memory_map(addr, &len, 0);
>         }
>
>   2. There is a function "cpu_physical_memory_unmap", the comment
>      of it says,
>
>        Unmaps a memory region previously mapped by cpu_physical_memory_map().
>
>      That makes me not sure if I use cpu_physical_memory_map correctly,
>      does it do what I want to do?

I'd suppose the functions should be used like this:

ptr = cpu_physical_memory_map(addr, &len, 0);
/* code that uses ptr */
...
/* no need to use ptr anymore */
cpu_physical_memory_unmap(ptr, len, 0, len);
/* ptr may no longer be assumed to be valid */

>
> Regards,
> chenwj
>
> --
> Wei-Ren Chen (陳韋任)
> Computer Systems Lab, Institute of Information Science,
> Academia Sinica, Taiwan (R.O.C.)
> Tel:886-2-2788-3799 #1667
> Homepage: http://people.cs.nctu.edu.tw/~chenwj
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]