pc: Fix e820 fw_cfg for big endian
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
@@ -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 )
Quoted 7 lines · Alex Williamson
Signed-off-by Alex Williamson <[email protected]>---
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
Quoted 11 lines · Jes Sorensen
Quoted 7 lines · Alex Williamson
Signed-off-by Alex Williamson <[email protected]>---
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
Quoted 9 lines · Alexander Graf
Quoted 6 lines · Jes Sorensen
Quoted 5 lines · Alex Williamson
Signed-off-by Alex Williamson <[email protected]>---
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
Anthony Liguori
AppliedQuoted 2 lines · Alex Williamson
Signed-off-by Alex Williamson<[email protected]>
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@@ -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 )