diff mbox

sh4: Fix initramfs initialization for endiannes-mismatched targets

Message ID 1439389236-22158-1-git-send-email-linux@roeck-us.net
State New
Headers show

Commit Message

Guenter Roeck Aug. 12, 2015, 2:20 p.m. UTC
If host and target endianness does not match, loding an initramfs does not work.
Fix by writing boot parameters with appropriate endianness conversion.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 hw/sh4/r2d.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Aurelien Jarno Aug. 17, 2015, 8:46 p.m. UTC | #1
On 2015-08-12 07:20, Guenter Roeck wrote:
> If host and target endianness does not match, loding an initramfs does not work.
> Fix by writing boot parameters with appropriate endianness conversion.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  hw/sh4/r2d.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
> index 5e22ed7..3b0b2ec 100644
> --- a/hw/sh4/r2d.c
> +++ b/hw/sh4/r2d.c
> @@ -338,9 +338,9 @@ static void r2d_init(MachineState *machine)
>          }
>  
>          /* initialization which should be done by firmware */
> -        boot_params.loader_type = 1;
> -        boot_params.initrd_start = INITRD_LOAD_OFFSET;
> -        boot_params.initrd_size = initrd_size;
> +        boot_params.loader_type = tswap32(1);
> +        boot_params.initrd_start = tswap32(INITRD_LOAD_OFFSET);
> +        boot_params.initrd_size = tswap32(initrd_size);
>      }
>  
>      if (kernel_cmdline) {

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>

Good catch. I have added it to my sh4-next queue:

http://git.aurel32.net/?p=qemu.git;a=shortlog;h=refs/heads/sh4-next
diff mbox

Patch

diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 5e22ed7..3b0b2ec 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -338,9 +338,9 @@  static void r2d_init(MachineState *machine)
         }
 
         /* initialization which should be done by firmware */
-        boot_params.loader_type = 1;
-        boot_params.initrd_start = INITRD_LOAD_OFFSET;
-        boot_params.initrd_size = initrd_size;
+        boot_params.loader_type = tswap32(1);
+        boot_params.initrd_start = tswap32(INITRD_LOAD_OFFSET);
+        boot_params.initrd_size = tswap32(initrd_size);
     }
 
     if (kernel_cmdline) {