Skip to contentSkip to conversation

lib: fdtdec: Couple of fies

PATCH New Keerthy 5 participants 12 messages Dec 21, 2018 – Jan 15, 2019 Library code

lore
Share & tools
lore

Keerthy

author
#0 lore raw

cover lib: fdtdec: Couple of fies

Couple of fixes for fdtdec_get_addr_size and fdtdec_get_addr_size_fixed functions.

Keerthy (2):
lib: fdtdec: fdtdec_get_addr_size_fixed remove checks
lib: fdtdec: fixup fdtdec_get_addr_size

 lib/fdtdec.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/2 lib: fdtdec: fdtdec_get_addr_size_fixed remove checks

With 8 bytes addressing even on 32 bit machines these checks are no longer valid. Remove them.

---
 lib/fdtdec.c | 10 ----------
 1 file changed, 10 deletions(-)
lib/fdtdec.c +0 -10
index 6f8ec0d..18663ce 100644
@@ -95,16 +95,6 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
 
 	debug("%s: %s: ", __func__, prop_name);
 
-	if (na > (sizeof(fdt_addr_t) / sizeof(fdt32_t))) {
-		debug("(na too large for fdt_addr_t type)\n");
-		return FDT_ADDR_T_NONE;
-	}
-
-	if (ns > (sizeof(fdt_size_t) / sizeof(fdt32_t))) {
-		debug("(ns too large for fdt_size_t type)\n");
-		return FDT_ADDR_T_NONE;
-	}
-
 	prop = fdt_getprop(blob, node, prop_name, &len);
 	if (!prop) {
 		debug("(not found)\n");
Signature · 1 line
1.9.1
author
#4 lore raw

PATCH 2/2 lib: fdtdec: fixup fdtdec_get_addr_size

In reply to Keerthy

fix up fdtdec_get_addr_size to use fdtdec_get_addr_size_auto_noparent so that the address cells and size cells are obtained from the parent instead of going by the fixed length.

---
 lib/fdtdec.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
lib/fdtdec.c +2 -5
index 18663ce..11a30e1 100644
@@ -178,11 +178,8 @@ fdt_addr_t fdtdec_get_addr_size_auto_noparent(const void *blob, int node,
 fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
 				const char *prop_name, fdt_size_t *sizep)
 {
-	int ns = sizep ? (sizeof(fdt_size_t) / sizeof(fdt32_t)) : 0;
-
-	return fdtdec_get_addr_size_fixed(blob, node, prop_name, 0,
-					  sizeof(fdt_addr_t) / sizeof(fdt32_t),
-					  ns, sizep, false);
+	return fdtdec_get_addr_size_auto_noparent(blob, node, prop_name, 0,
+						  sizep, false);
 }
 
 fdt_addr_t fdtdec_get_addr(const void *blob, int node, const char *prop_name)
Signature · 1 line
1.9.1
#5 lore raw

PATCH 2/2 lib: fdtdec: fixup fdtdec_get_addr_size

+Stephen

Hi Keethy,

Quoted 4 lines · Keerthy

fix up fdtdec_get_addr_size to use fdtdec_get_addr_size_auto_noparent so that the address cells and size cells are obtained from the parent instead of going by the fixed length.

Why? Can you please expand this?

cc Stephen too.

Regards,
Simon

#6 lore raw

PATCH 2/2 lib: fdtdec: fixup fdtdec_get_addr_size

In reply to Keerthy
Quoted 3 lines · Keerthy

fix up fdtdec_get_addr_size to use fdtdec_get_addr_size_auto_noparent so that the address cells and size cells are obtained from the parent instead of going by the fixed length.

This patch makes perfect sense to me. However, I am worried about the potential existence of code that assumes the current fixed-size logic; in the past when fixing similar issues like this we've often run into code that was use "get addr" functions when it should have been using "get u32" functions and similar, which then broke when we fixed the implementation to do the right thing. I guess we should still apply the patch, and fix up any fallout as it appears.

#7 lore raw

PATCH 2/2 lib: fdtdec: fixup fdtdec_get_addr_size

Quoted 3 lines · Keerthy

fix up fdtdec_get_addr_size to use fdtdec_get_addr_size_auto_noparent so that the address cells and size cells are obtained from the parent instead of going by the fixed length.

This patch makes perfect sense to me. However, I am worried about the potential existence of code that assumes the current fixed-size logic; in the past when fixing similar issues like this we've often run into code that was use "get addr" functions when it should have been using "get u32" functions and similar, which then broke when we fixed the implementation to do the right thing. I guess we should still apply the patch, and fix up any fallout as it appears.

Applied to u-boot-dm/next, thanks!

author
#8 lore raw

PATCH 2/2 lib: fdtdec: fixup fdtdec_get_addr_size

Quoted 5 lines · sjg at google.com
Quoted 3 lines · Keerthy

fix up fdtdec_get_addr_size to use fdtdec_get_addr_size_auto_noparent so that the address cells and size cells are obtained from the parent instead of going by the fixed length.

Quoted 7 lines

This patch makes perfect sense to me. However, I am worried about the potential existence of code that assumes the current fixed-size logic; in the past when fixing similar issues like this we've often run into code that was use "get addr" functions when it should have been using "get u32" functions and similar, which then broke when we fixed the implementation to do the right thing. I guess we should still apply the patch, and fix up any fallout as it appears.

Thanks Simon!

Quoted 3 lines

Applied to u-boot-dm/next, thanks!

#9 lore raw

PATCH 2/2 lib: fdtdec: fixup fdtdec_get_addr_size

Hi Keerthy,

Quoted 17 lines · Keerthy
Quoted 5 lines · sjg at google.com
Quoted 3 lines · Keerthy

fix up fdtdec_get_addr_size to use fdtdec_get_addr_size_auto_noparent so that the address cells and size cells are obtained from the parent instead of going by the fixed length.

Quoted 7 lines

This patch makes perfect sense to me. However, I am worried about the potential existence of code that assumes the current fixed-size logic; in the past when fixing similar issues like this we've often run into code that was use "get addr" functions when it should have been using "get u32" functions and similar, which then broke when we fixed the implementation to do the right thing. I guess we should still apply the patch, and fix up any fallout as it appears.

Quoted 1 line

Thanks Simon!

Unfortunately this breaks the tests (make qcheck). Can you please take a look?

Regards,
Simon

#10 lore raw

PATCH 2/2 lib: fdtdec: fixup fdtdec_get_addr_size

Quoted 20 lines · Simon Glass

Hi Keerthy,

Quoted 17 lines · Keerthy
Quoted 12 lines · sjg at google.com
Quoted 3 lines · Keerthy

fix up fdtdec_get_addr_size to use fdtdec_get_addr_size_auto_noparent so that the address cells and size cells are obtained from the parent instead of going by the fixed length.

This patch makes perfect sense to me. However, I am worried about the potential existence of code that assumes the current fixed-size logic; in the past when fixing similar issues like this we've often run into code that was use "get addr" functions when it should have been using "get u32" functions and similar, which then broke when we fixed the implementation to do the right thing. I guess we should still apply the patch, and fix up any fallout as it appears.

Quoted 3 lines
Quoted 1 line

Thanks Simon!

Unfortunately this breaks the tests (make qcheck). Can you please take a look?

Simon,

Can you paste the logs? I am at u-boot master tip and my qcheck seems to err out.
https://pastebin.ubuntu.com/p/7Q53TMqxMQ/

Regards,
Keerthy

Quoted 4 lines

Regards,
Simon

#11 lore raw

PATCH 2/2 lib: fdtdec: fixup fdtdec_get_addr_size

Hi Keerthy,

Quoted 26 lines · KEERTHY
Quoted 22 lines · Simon Glass

Hi Keerthy,

Quoted 18 lines · Keerthy
Quoted 5 lines · sjg at google.com
Quoted 3 lines · Keerthy

fix up fdtdec_get_addr_size to use fdtdec_get_addr_size_auto_noparent so that the address cells and size cells are obtained from the parent instead of going by the fixed length.

Quoted 7 lines

This patch makes perfect sense to me. However, I am worried about the potential existence of code that assumes the current fixed-size logic; in the past when fixing similar issues like this we've often run into code that was use "get addr" functions when it should have been using "get u32" functions and similar, which then broke when we fixed the implementation to do the right thing. I guess we should still apply the patch, and fix up any fallout as it appears.

Thanks Simon!

Quoted 8 lines
Quoted 1 line

Unfortunately this breaks the tests (make qcheck). Can you please take a look?

Simon,

Can you paste the logs? I am at u-boot master tip and my qcheck seems to err out.
https://pastebin.ubuntu.com/p/7Q53TMqxMQ/

You should get the tests running. In this case see README.sandbox. Otherwise any patch you send may break U-Boot.

Regards,
Simon