summaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorCedric Le Goater2013-10-30 14:47:08 +0100
committerBenjamin Herrenschmidt2013-10-31 02:37:28 +0100
commitc81095a465b2c1cd819fb14ee3cd07bc1b377af1 (patch)
treeee9eb8e0c6f30ae8d7c5adf47d12abd1e81fca18 /arch/powerpc
parentpowerpc/nvram: Fix endian issue when reading the NVRAM size (diff)
downloadkernel-qcow2-linux-c81095a465b2c1cd819fb14ee3cd07bc1b377af1.tar.gz
kernel-qcow2-linux-c81095a465b2c1cd819fb14ee3cd07bc1b377af1.tar.xz
kernel-qcow2-linux-c81095a465b2c1cd819fb14ee3cd07bc1b377af1.zip
powerpc/nvram: Fix endian issue when using the partition length
When reading partitions, the length has to be translated from big endian to the endian order of the host. Similarly, when writing partitions, the length needs to be in big endian order. The userspace tool 'nvram' needs a similar fix as it is reading and writing partitions through /dev/nram : http://sourceforge.net/p/powerpc-utils/mailman/message/31571277/ Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/kernel/nvram_64.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 8213ee1eb05a..fd82c289ab1c 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -223,9 +223,13 @@ static int __init nvram_write_header(struct nvram_partition * part)
{
loff_t tmp_index;
int rc;
-
+ struct nvram_header phead;
+
+ memcpy(&phead, &part->header, NVRAM_HEADER_LEN);
+ phead.length = cpu_to_be16(phead.length);
+
tmp_index = part->index;
- rc = ppc_md.nvram_write((char *)&part->header, NVRAM_HEADER_LEN, &tmp_index);
+ rc = ppc_md.nvram_write((char *)&phead, NVRAM_HEADER_LEN, &tmp_index);
return rc;
}
@@ -505,6 +509,8 @@ int __init nvram_scan_partitions(void)
memcpy(&phead, header, NVRAM_HEADER_LEN);
+ phead.length = be16_to_cpu(phead.length);
+
err = 0;
c_sum = nvram_checksum(&phead);
if (c_sum != phead.checksum) {