Skip to content

Commit 396a343

Browse files
tlfalconozbenh
authored andcommitted
powerpc: Fix endianness of flash_block_list in rtas_flash
The function rtas_flash_firmware passes the address of a data structure, flash_block_list, when making the update-flash-64-and-reboot rtas call. While the endianness of the address is handled correctly, the endianness of the data is not. This patch ensures that the data in flash_block_list is big endian when passed to rtas on little endian hosts. Signed-off-by: Thomas Falcon <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent fa952c5 commit 396a343

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/powerpc/kernel/rtas_flash.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,17 +611,19 @@ static void rtas_flash_firmware(int reboot_type)
611611
for (f = flist; f; f = next) {
612612
/* Translate data addrs to absolute */
613613
for (i = 0; i < f->num_blocks; i++) {
614-
f->blocks[i].data = (char *)__pa(f->blocks[i].data);
614+
f->blocks[i].data = (char *)cpu_to_be64(__pa(f->blocks[i].data));
615615
image_size += f->blocks[i].length;
616+
f->blocks[i].length = cpu_to_be64(f->blocks[i].length);
616617
}
617618
next = f->next;
618619
/* Don't translate NULL pointer for last entry */
619620
if (f->next)
620-
f->next = (struct flash_block_list *)__pa(f->next);
621+
f->next = (struct flash_block_list *)cpu_to_be64(__pa(f->next));
621622
else
622623
f->next = NULL;
623624
/* make num_blocks into the version/length field */
624625
f->num_blocks = (FLASH_BLOCK_LIST_VERSION << 56) | ((f->num_blocks+1)*16);
626+
f->num_blocks = cpu_to_be64(f->num_blocks);
625627
}
626628

627629
printk(KERN_ALERT "FLASH: flash image is %ld bytes\n", image_size);

0 commit comments

Comments
 (0)