diff mbox

[for-1.6] fw_cfg: the I/O port variant expects little-endian

Message ID 1375014954-31916-2-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini July 28, 2013, 12:35 p.m. UTC
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.

Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/nvram/fw_cfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Cave-Ayland July 29, 2013, 11:44 a.m. UTC | #1
On 28/07/13 13:35, Paolo Bonzini wrote:

> 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.
>
> Reported-by: Mark Cave-Ayland<mark.cave-ayland@ilande.co.uk>
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   hw/nvram/fw_cfg.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 0a35015..d0820e5 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -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!

Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.
Paolo Bonzini Aug. 5, 2013, 4:21 p.m. UTC | #2
On 07/28/2013 02:35 PM, Paolo Bonzini wrote:
> 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.
>
> Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   hw/nvram/fw_cfg.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 0a35015..d0820e5 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -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.
Laszlo Ersek Aug. 5, 2013, 5:19 p.m. UTC | #3
On 08/05/13 18:21, Paolo Bonzini wrote:
> On 07/28/2013 02:35 PM, Paolo Bonzini wrote:
>> 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.
>>
>> Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   hw/nvram/fw_cfg.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
>> index 0a35015..d0820e5 100644
>> --- a/hw/nvram/fw_cfg.c
>> +++ b/hw/nvram/fw_cfg.c
>> @@ -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.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Anthony Liguori Aug. 14, 2013, 4:29 p.m. UTC | #4
Applied.  Thanks.

Regards,

Anthony Liguori
diff mbox

Patch

diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 0a35015..d0820e5 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -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,
 };