Skip to contentSkip to conversation

pc: Fix e820 fw_cfg for big endian

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pc: Fix e820 fw_cfg for big endian

---

Compile tested only. Only current user is kvm, no cross-arch users.

 hw/pc.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
hw/pc.c +7 -7
index 0264e3d..cc8ec14 100644
@@ -467,19 +467,19 @@ static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val)
 
 int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)
 {
-    int index = e820_table.count;
+    int index = le32_to_cpu(e820_table.count);
     struct e820_entry *entry;
 
     if (index >= E820_NR_ENTRIES)
         return -EBUSY;
-    entry = &e820_table.entry[index];
+    entry = &e820_table.entry[index++];
 
-    entry->address = address;
-    entry->length = length;
-    entry->type = type;
+    entry->address = cpu_to_le64(address);
+    entry->length = cpu_to_le64(length);
+    entry->type = cpu_to_le32(type);
 
-    e820_table.count++;
-    return e820_table.count;
+    e820_table.count = cpu_to_le32(index);
+    return index;
 }
 
 static void *bochs_bios_init(void)
#1 lore raw
Quoted 7 lines · Alex Williamson

---

Compile tested only. Only current user is kvm, no cross-arch users.

 hw/pc.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

Patch looks fine to me, but are there any systems out there using e820 on big endian hardware?

Jes

#2 lore raw
Quoted 11 lines · Jes Sorensen
Quoted 7 lines · Alex Williamson

---

Compile tested only. Only current user is kvm, no cross-arch users.

hw/pc.c | 14 +++++++-------

1 files changed, 7 insertions(+), 7 deletions(-)

Patch looks fine to me, but are there any systems out there using e820 on big endian hardware?

This fixes things when host endianness is big endian.

Alex

#3 lore raw
Quoted 9 lines · Alexander Graf
Quoted 6 lines · Jes Sorensen
Quoted 5 lines · Alex Williamson

---

Compile tested only. Only current user is kvm, no cross-arch users.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

hw/pc.c | 14 +++++++-------

1 files changed, 7 insertions(+), 7 deletions(-)

Patch looks fine to me, but are there any systems out there using e820 on big endian hardware?

This fixes things when host endianness is big endian.

Ah right, then it's all fine :)

Cheers,
Jes

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

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 42 lines

---

Compile tested only. Only current user is kvm, no cross-arch users.

  hw/pc.c |   14 +++++++-------
  1 files changed, 7 insertions(+), 7 deletions(-)
hw/pc.c +7 -7
index 0264e3d..cc8ec14 100644
@@ -467,19 +467,19 @@ static void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val)
 
  int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)
  {
-    int index = e820_table.count;
+    int index = le32_to_cpu(e820_table.count);
      struct e820_entry *entry;
 
      if (index>= E820_NR_ENTRIES)
          return -EBUSY;
-    entry =&e820_table.entry[index];
+    entry =&e820_table.entry[index++];
 
-    entry->address = address;
-    entry->length = length;
-    entry->type = type;
+    entry->address = cpu_to_le64(address);
+    entry->length = cpu_to_le64(length);
+    entry->type = cpu_to_le32(type);
 
-    e820_table.count++;
-    return e820_table.count;
+    e820_table.count = cpu_to_le32(index);
+    return index;
  }
 
  static void *bochs_bios_init(void)