[Lguest] [patch] introduce lgread_ulong/lgwrite_ulong for pointer read/write

Avi Kivity avi at qumranet.com
Wed Sep 26 01:07:55 EST 2007


Jes Sorensen wrote:
> Hi,
>
> We cannot use lgread_u32/lgwrite_u32 in page_tables.c given pointers
> aren't meant to be 32 bit :-)
>
> This patch introduces _ulong versions as an alternative and makes the
> page_tables.c code use those instead - should improve portability.

page table entries are not "unsigned long" -- they have no relation to 
the machine word size.  On i386 they can be 32-bit or 64-bit, on x86_64 
they can only be 64-bit.  Since lguest doesn't support pae, unsigned 
long happens to match, but this is incidental.

I suggest lgread_pte/lgwrite_pte that take type lgpte_t and map to 
lg{read,write}_u{32,64} using #ifdefs.

(btw, if lguest wants to support pae and smp on i386, it needs to use 
atomic 64-bit writes, like kvm, so lgwrite_pte might be different from 
lgwrite_64).

-- 
Any sufficiently difficult bug is indistinguishable from a feature.




More information about the Lguest mailing list