Skip to contentSkip to conversation

fw_cfg: the I/O port variant expects little-endian

PATCH Applied Paolo Bonzini 4 participants 5 messages Jul 28, 2013 – Aug 14, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fw_cfg: the I/O port variant expects little-endian

The I/O port variant of fw_cfg is used by sparc64, which is a big-endian machine. Firmware swaps bytes before sending them to fw_cfg, so we need to unswap them in the device.

This is only used on sparc64 and on (little-endian) x86, so it does not affect any other target. 32-bit Sparc and PPC all use memory-mapped fw_cfg.

---
 hw/nvram/fw_cfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/nvram/fw_cfg.c +1 -1
index 0a35015..d0820e5 100644
@@ -324,7 +324,7 @@ static const MemoryRegionOps fw_cfg_data_mem_ops = {
 static const MemoryRegionOps fw_cfg_comb_mem_ops = {
     .read = fw_cfg_comb_read,
     .write = fw_cfg_comb_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
     .valid.accepts = fw_cfg_comb_valid,
 };
 
Signature · 1 line
1.8.1.4
Tested-by on v1 1/1
#1 lore raw
Quoted 18 lines · Paolo Bonzini

The I/O port variant of fw_cfg is used by sparc64, which is a big-endian machine. Firmware swaps bytes before sending them to fw_cfg, so we need to unswap them in the device.

This is only used on sparc64 and on (little-endian) x86, so it does not affect any other target. 32-bit Sparc and PPC all use memory-mapped fw_cfg.

---
  hw/nvram/fw_cfg.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/nvram/fw_cfg.c +0 -0
index 0a35015..d0820e5 100644

hw/nvram/fw_cfg.c static const MemoryRegionOps fw_cfg_data_mem_ops = { · line 329

Quoted 7 lines
hw/nvram/fw_cfg.c +1 -1
@@ -324,7 +324,7 @@ static const MemoryRegionOps fw_cfg_data_mem_ops = {
  static const MemoryRegionOps fw_cfg_comb_mem_ops = {
      .read = fw_cfg_comb_read,
      .write = fw_cfg_comb_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
      .valid.accepts = fw_cfg_comb_valid,
  };

Hi Paolo,

I can confirm that this fixes SPARC64 boot for me - thanks!

ATB,

Mark.

#2 lore raw

[Qemu-devel] PING for-1.6 Re: [PATCH for-1.6] fw_cfg: the I/O port variant expects little-endian

In reply to Paolo Bonzini
Quoted 19 lines · Paolo Bonzini

The I/O port variant of fw_cfg is used by sparc64, which is a big-endian machine. Firmware swaps bytes before sending them to fw_cfg, so we need to unswap them in the device.

This is only used on sparc64 and on (little-endian) x86, so it does not affect any other target. 32-bit Sparc and PPC all use memory-mapped fw_cfg.

---
  hw/nvram/fw_cfg.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/nvram/fw_cfg.c +0 -0
index 0a35015..d0820e5 100644

hw/nvram/fw_cfg.c static const MemoryRegionOps fw_cfg_data_mem_ops = { · line 330

Quoted 8 lines
hw/nvram/fw_cfg.c +1 -1
@@ -324,7 +324,7 @@ static const MemoryRegionOps fw_cfg_data_mem_ops = {
  static const MemoryRegionOps fw_cfg_comb_mem_ops = {
      .read = fw_cfg_comb_read,
      .write = fw_cfg_comb_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
      .valid.accepts = fw_cfg_comb_valid,
  };
 

Ping.

Reviewed-by
#3 lore raw

Re: [Qemu-devel] PING for-1.6 Re: [PATCH for-1.6] fw_cfg: the I/O port variant expects little-endian

Quoted 17 lines · Paolo Bonzini
Quoted 16 lines · Paolo Bonzini

The I/O port variant of fw_cfg is used by sparc64, which is a big-endian machine.
Firmware swaps bytes before sending them to fw_cfg, so we need to unswap them in
the device.

This is only used on sparc64 and on (little-endian) x86, so it does not affect
any other target. 32-bit Sparc and PPC all use memory-mapped fw_cfg.

---
  hw/nvram/fw_cfg.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines
Quoted 6 lines
hw/nvram/fw_cfg.c +0 -0
index 0a35015..d0820e5 100644

hw/nvram/fw_cfg.c static const MemoryRegionOps fw_cfg_data_mem_ops = { · line 330

Quoted 8 lines
hw/nvram/fw_cfg.c +1 -1
@@ -324,7 +324,7 @@ static const MemoryRegionOps fw_cfg_data_mem_ops = {
  static const MemoryRegionOps fw_cfg_comb_mem_ops = {
      .read = fw_cfg_comb_read,
      .write = fw_cfg_comb_write,
-    .endianness = DEVICE_NATIVE_ENDIAN,
+    .endianness = DEVICE_LITTLE_ENDIAN,
      .valid.accepts = fw_cfg_comb_valid,
  };
 

Ping.

Not sure if you were asking for a review, but the patch and the argument in the commit msg look sane to me.