Skip to contentSkip to conversation

kexec/fs2dt : Fix endianess issue with initrd base and size

PATCH Applied Laurent Dufour 2 participants 2 messages Apr 11, 2014 – Apr 14, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kexec/fs2dt : Fix endianess issue with initrd base and size

The initrd values exposed in the device tree of the kexeced kernel must be encoded in Big Endian format.

Without this patch, kexeced LE kernel are expected to panic when dealing with the initrd image.

---
 kexec/fs2dt.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kexec/fs2dt.c +5 -4
index 5e6b98d..2a90979 100644
@@ -531,7 +531,7 @@ static void putnode(void)
 	/* Add initrd entries to the second kernel */
 	if (initrd_base && initrd_size && !strcmp(basename,"chosen/")) {
 		int len = 8;
-		unsigned long long initrd_end;
+		uint64_t bevalue;
 
 		dt_reserve(&dt, 12); /* both props, of 6 words ea. */
 		*dt++ = cpu_to_be32(3);
@@ -539,7 +539,8 @@ static void putnode(void)
 		*dt++ = cpu_to_be32(propnum("linux,initrd-start"));
 		pad_structure_block(len);
 
-		memcpy(dt,&initrd_base,len);
+		bevalue = cpu_to_be64(initrd_base);
+		memcpy(dt, &bevalue, len);
 		dt += (len + 3)/4;
 
 		len = 8;
@@ -547,10 +548,10 @@ static void putnode(void)
 		*dt++ = cpu_to_be32(len);
 		*dt++ = cpu_to_be32(propnum("linux,initrd-end"));
 
-		initrd_end = initrd_base + initrd_size;
+		bevalue = cpu_to_be64(initrd_base + initrd_size);
 		pad_structure_block(len);
 
-		memcpy(dt,&initrd_end,len);
+		memcpy(dt, &bevalue, len);
 		dt += (len + 3)/4;
 
 		reserve(initrd_base, initrd_size);

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Applied
#1 lore raw
Quoted 7 lines · Laurent Dufour

The initrd values exposed in the device tree of the kexeced kernel must be encoded in Big Endian format.

Without this patch, kexeced LE kernel are expected to panic when dealing with the initrd image.

Thanks, applied.

Quoted 31 lines
---
 kexec/fs2dt.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kexec/fs2dt.c +3 -2
index 5e6b98d..2a90979 100644
@@ -531,7 +531,7 @@ static void putnode(void)
 	/* Add initrd entries to the second kernel */
 	if (initrd_base && initrd_size && !strcmp(basename,"chosen/")) {
 		int len = 8;
-		unsigned long long initrd_end;
+		uint64_t bevalue;
 
 		dt_reserve(&dt, 12); /* both props, of 6 words ea. */
 		*dt++ = cpu_to_be32(3);
@@ -539,7 +539,8 @@ static void putnode(void)
 		*dt++ = cpu_to_be32(propnum("linux,initrd-start"));
 		pad_structure_block(len);
 
-		memcpy(dt,&initrd_base,len);
+		bevalue = cpu_to_be64(initrd_base);
+		memcpy(dt, &bevalue, len);
 		dt += (len + 3)/4;
 
 		len = 8;
@@ -547,10 +548,10 @@ static void putnode(void)
 		*dt++ = cpu_to_be32(len);
 		*dt++ = cpu_to_be32(propnum("linux,initrd-end"));

kexec/fs2dt.c static void putnode(void) · line 557

Quoted 10 lines
kexec/fs2dt.c +2 -2
 
-		initrd_end = initrd_base + initrd_size;
+		bevalue = cpu_to_be64(initrd_base + initrd_size);
 		pad_structure_block(len);
 
-		memcpy(dt,&initrd_end,len);
+		memcpy(dt, &bevalue, len);
 		dt += (len + 3)/4;
 
 		reserve(initrd_base, initrd_size);

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec