Skip to contentSkip to conversation

dtc: fix endian issue when reading blobs

PATCH In review Michael Neuling 2 participants 3 messages Jul 7, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dtc: fix endian issue when reading blobs

The reserve mem regions are screwy if you read a blob on x86. I'm guessing there may be a few more of these lurking in the code.

---
This now gives clean diffs between running on big and little endian machines.

 flattree.c |    2 ++
 1 file changed, 2 insertions(+)
flattree.c +2 -0
Index: dtc/flattree.c
===================================================================
@@ -619,6 +619,8 @@ static struct reserve_info *flat_read_me
 	p = inb->ptr;
 	while (1) {
 		flat_read_chunk(inb, &re, sizeof(re));
+		re.address  = cpu_to_be64(re.address);
+		re.size = cpu_to_be64(re.size);
 		if (re.size == 0)
 			break;
 
#1 lore raw

The reserve mem regions are screwy if you read a blob on x86. I'm guessing there may be a few more of these lurking in the code.

---
Oops.. wrong way around.. thanks Milton.

 flattree.c |    2 ++
 1 file changed, 2 insertions(+)
flattree.c +2 -0
Index: dtc/flattree.c
===================================================================
@@ -619,6 +619,8 @@ static struct reserve_info *flat_read_me
 	p = inb->ptr;
 	while (1) {
 		flat_read_chunk(inb, &re, sizeof(re));
+		re.address  = be64_to_cpu(re.address);
+		re.size = be64_to_cpu(re.size);
 		if (re.size == 0)
 			break;
 
#2 lore raw

So, like, the other day Michael Neuling mumbled:

Quoted 10 lines

The reserve mem regions are screwy if you read a blob on x86. I'm guessing there may be a few more of these lurking in the code.

---
Oops.. wrong way around.. thanks Milton.

 flattree.c |    2 ++
 1 file changed, 2 insertions(+)

Your wish has been granted.

Thanks!

jdl