virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* lguest virtio_descriptor structure on 64bit
@ 2007-08-17  8:22 Christian Borntraeger
  2007-08-17 11:13 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Borntraeger @ 2007-08-17  8:22 UTC (permalink / raw)
  To: Rusty Russell; +Cc: virtualization

Hello Rusty,

while playing with your virtio descriptor code, I realized that the desc_pages 
data structure is not 64 bit safe. struct lguest_desc desc[NUM_DESCS] can be 
smaller than a page, as struct lguest_desc is 24 bytes on 64bit systems. Lets 
add a char padding to make the next page really page aligned.

Btw. the new_io_desc.patch does not apply on current git. What base should I 
use?



--- lguest_virtio.c.old	2007-08-17 10:15:05.000000000 +0200
+++ lguest_virtio.c	2007-08-17 10:16:00.000000000 +0200
@@ -31,15 +31,16 @@
 
 struct desc_pages
 {
 	/* Page of descriptors. */
 	struct lguest_desc desc[NUM_DESCS];
+	char pad0[PAGE_SIZE - NUM_DESCS * sizeof(struct lguest_desc)];
 
 	/* Next page: how we tell other side what buffers are available. */
 	unsigned int avail_idx;
 	unsigned int available[NUM_DESCS];
-	char pad[PAGE_SIZE - (NUM_DESCS+1) * sizeof(unsigned int)];
+	char pad1[PAGE_SIZE - (NUM_DESCS+1) * sizeof(unsigned int)];
 
 	/* Third page: how other side tells us what's used. */
 	unsigned int used_idx;
 	struct lguest_used used[NUM_DESCS];
 };

cheers

Christian

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: lguest virtio_descriptor structure on 64bit
  2007-08-17  8:22 lguest virtio_descriptor structure on 64bit Christian Borntraeger
@ 2007-08-17 11:13 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2007-08-17 11:13 UTC (permalink / raw)
  To: Christian Borntraeger; +Cc: virtualization

On Fri, 2007-08-17 at 10:22 +0200, Christian Borntraeger wrote:
> Hello Rusty,
> 
> while playing with your virtio descriptor code, I realized that the desc_pages 
> data structure is not 64 bit safe. struct lguest_desc desc[NUM_DESCS] can be 
> smaller than a page, as struct lguest_desc is 24 bytes on 64bit systems. Lets 
> add a char padding to make the next page really page aligned.

Indeed.  This is something which would need fixing for a non-32 bit
platform.

> Btw. the new_io_desc.patch does not apply on current git. What base should I 
> use?

Unfortunately, the lguest tree is undergoing a significant reshuffle as
files get moved (non-i386 support).  The lguest patch queue as a whole
should apply tho.

Thanks!
Rusty.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-17 11:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-17  8:22 lguest virtio_descriptor structure on 64bit Christian Borntraeger
2007-08-17 11:13 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).