qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] What's the proper type of guest pde address, target_ulo


From: Peter Maydell
Subject: Re: [Qemu-devel] What's the proper type of guest pde address, target_ulong or target_phys_addr_t?
Date: Fri, 24 Aug 2012 08:09:59 +0100

On 24 August 2012 04:34, 陳韋任 (Wei-Ren Chen) <address@hidden> wrote:
> Hi all,
>
>   When I read cpu_get_phys_page_debug (target-i386/helper.c), I found
> the type of pde_addr and pte_addr might be not correct. See below,
>
> ---
> target_phys_addr_t cpu_get_phys_page_debug(CPUX86State *env, target_ulong 
> addr)
> {
>     target_ulong pde_addr, pte_addr;
>
>     ...
>
>     pde_addr = ((pdpe & ~0xfff & ~(PG_NX_MASK | PG_HI_USER_MASK)) +
>                 (((addr >> 21) & 0x1ff) << 3)) & env->a20_mask;
>     pde = ldq_phys(pde_addr);
>
>     ...
> }
> ---
>
> HACKING says target_ulong is for guest virtual address and target_phys_addr_t
> is for guest physical address. IIUC, pde_addr and pte_addr should be the
> guest physical address for guest page table and guest page respectively,
> right? If no one object, I'll send a patch which replaces target_ulong
> with target_phys_addr_t.

In principle, yes, but you need to check the code carefully to make
sure your type change doesn't change any of the results. (Or if it
does, you then need to confirm against the specs that this was a bug
that is being fixed, not a new one being introduced). The thing you have
to remember is that for the 32 bit x86 cores guest physical addresses
are only 32 bits but target_phys_addr_t is still a 64 bit type.
It may be we're deliberately (mis)using target_ulong to get the
right behaviour on both 32 and 64 bit cores.

-- PMM



reply via email to

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