[Lguest] [patch] u32 pointer nightmare .....

Rusty Russell rusty at rustcorp.com.au
Thu Sep 13 21:56:15 EST 2007


On Thu, 2007-09-13 at 13:18 +0200, Jes Sorensen wrote:
> Rusty Russell wrote:
> >> -static u32 *dma2iov(unsigned long dma, struct iovec iov[], unsigned *num)
> >> +static unsigned long *
> >> +dma2iov(unsigned long dma, struct iovec iov[], unsigned *num)
> >>  {
> > 
> > This one really is a u32*, even on 64-bit platforms (it's where we put
> > the length written/read).
> 
> Problem is when you have a struct that has multiple of them in it, you
> can end up with badly aligned fields which needs kernel or firmware
> support to handle - ia64 doesn't handle 64 bit loads on misaligned
> boundaries in hardware :(
>
> Thats why I thought it was better to just stick to long for those and
> get proper alignment at all times.

Well, the alternative is to fix "struct lguest_dma" in lguest_launcher.h
to use an unsigned long:

struct lguest_dma
{
	/* 0 if free to be used, filled by the Host. */
 	u32 used_len;
	unsigned long addr[LGUEST_MAX_DMA_SECTIONS];
	u16 len[LGUEST_MAX_DMA_SECTIONS];
};

Thanks!
Rusty.




More information about the Lguest mailing list