Skip to contentSkip to conversation

pc: e820 qemu_cfg tables need to be packed

PATCH RESEND Applied Alex Williamson 3 participants 4 messages Nov 5, 2010 – Nov 16, 2010

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 pc: e820 qemu_cfg tables need to be packed

We can't let the compiler define the alignment for qemu_cfg data.

---

 hw/pc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/pc.c +2 -2
index 69b13bf..0264e3d 100644
@@ -75,12 +75,12 @@ struct e820_entry {
     uint64_t address;
     uint64_t length;
     uint32_t type;
-};
+} __attribute((__packed__, __aligned__(4)));
 
 struct e820_table {
     uint32_t count;
     struct e820_entry entry[E820_NR_ENTRIES];
-};
+} __attribute((__packed__, __aligned__(4)));
 
 static struct e820_table e820_table;
 
#1 lore raw
Quoted 1 line · Alex Williamson

We can't let the compiler define the alignment for qemu_cfg data.

Actually, whole e820_table implementation seems to be buggy. The structure may not be passed directly to fw_cfg interface without endianness conversions, otherwise the emulation will not work on big endian host.

#2 lore raw
Quoted 8 lines · Blue Swirl
Quoted 1 line · Alex Williamson

We can't let the compiler define the alignment for qemu_cfg data.

Actually, whole e820_table implementation seems to be buggy. The structure may not be passed directly to fw_cfg interface without endianness conversions, otherwise the emulation will not work on big endian host.

I sent a patch for this a couple days ago:

http://lists.nongnu.org/archive/html/qemu-devel/2010-11/msg00481.html

I think that resolves your concern. Thanks,

Alex

#3 lore raw
In reply to Alex Williamson
Quoted 4 lines · Alex Williamson

We can't let the compiler define the alignment for qemu_cfg data.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 28 lines

---

  hw/pc.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
hw/pc.c +2 -2
index 69b13bf..0264e3d 100644
@@ -75,12 +75,12 @@ struct e820_entry {
      uint64_t address;
      uint64_t length;
      uint32_t type;
-};
+} __attribute((__packed__, __aligned__(4)));
 
  struct e820_table {
      uint32_t count;
      struct e820_entry entry[E820_NR_ENTRIES];
-};
+} __attribute((__packed__, __aligned__(4)));
 
  static struct e820_table e820_table;