* [PATCH] of: fdt: fix memory range check
@ 2014-09-23 9:59 ` Srinivas Kandagatla
0 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2014-09-23 9:59 UTC (permalink / raw)
To: Grant Likely, devicetree; +Cc: Rob Herring, linux-kernel, Srinivas Kandagatla
In cases where board has below memory DT node
memory{
device_type = "memory";
reg = <0x80000000 0x80000000>;
};
Check on the memory range in fdt.c will always fail because it is
comparing MAX_PHYS_ADDR with base + size, in fact it should compare
it with base + size - 1.
This issue was originally noticed on Qualcomm IFC6410 board.
Without this patch kernel shows up noticed unnecessary warnings
[ 0.000000] Machine model: Qualcomm APQ8064/IFC6410
[ 0.000000] Ignoring memory range 0xffffffff - 0x100000000
[ 0.000000] cma: Reserved 64 MiB at ab800000
as a result the size get reduced to 0x7fffffff which looks wrong.
This patch fixes the check involved in generating this warning and
as a result it also fixes the wrong size calculation.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/of/fdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 79cb831..3f5736c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -937,7 +937,7 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
return;
}
- if (base + size > MAX_PHYS_ADDR) {
+ if (base + size - 1 > MAX_PHYS_ADDR) {
pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
ULONG_MAX, base + size);
size = MAX_PHYS_ADDR - base;
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] of: fdt: fix memory range check
@ 2014-09-23 9:59 ` Srinivas Kandagatla
0 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2014-09-23 9:59 UTC (permalink / raw)
To: Grant Likely, devicetree-u79uwXL29TY76Z2rM5mHXA
Cc: Rob Herring, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Srinivas Kandagatla
In cases where board has below memory DT node
memory{
device_type = "memory";
reg = <0x80000000 0x80000000>;
};
Check on the memory range in fdt.c will always fail because it is
comparing MAX_PHYS_ADDR with base + size, in fact it should compare
it with base + size - 1.
This issue was originally noticed on Qualcomm IFC6410 board.
Without this patch kernel shows up noticed unnecessary warnings
[ 0.000000] Machine model: Qualcomm APQ8064/IFC6410
[ 0.000000] Ignoring memory range 0xffffffff - 0x100000000
[ 0.000000] cma: Reserved 64 MiB at ab800000
as a result the size get reduced to 0x7fffffff which looks wrong.
This patch fixes the check involved in generating this warning and
as a result it also fixes the wrong size calculation.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
drivers/of/fdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 79cb831..3f5736c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -937,7 +937,7 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
return;
}
- if (base + size > MAX_PHYS_ADDR) {
+ if (base + size - 1 > MAX_PHYS_ADDR) {
pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
ULONG_MAX, base + size);
size = MAX_PHYS_ADDR - base;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] of: fdt: fix memory range check
2014-09-23 9:59 ` Srinivas Kandagatla
@ 2014-09-24 14:38 ` Grant Likely
-1 siblings, 0 replies; 5+ messages in thread
From: Grant Likely @ 2014-09-24 14:38 UTC (permalink / raw)
To: Srinivas Kandagatla, devicetree
Cc: Rob Herring, linux-kernel, Srinivas Kandagatla
On Tue, 23 Sep 2014 10:59:09 +0100, Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote:
> In cases where board has below memory DT node
>
> memory{
> device_type = "memory";
> reg = <0x80000000 0x80000000>;
> };
>
> Check on the memory range in fdt.c will always fail because it is
> comparing MAX_PHYS_ADDR with base + size, in fact it should compare
> it with base + size - 1.
>
> This issue was originally noticed on Qualcomm IFC6410 board.
> Without this patch kernel shows up noticed unnecessary warnings
>
> [ 0.000000] Machine model: Qualcomm APQ8064/IFC6410
> [ 0.000000] Ignoring memory range 0xffffffff - 0x100000000
> [ 0.000000] cma: Reserved 64 MiB at ab800000
>
> as a result the size get reduced to 0x7fffffff which looks wrong.
>
> This patch fixes the check involved in generating this warning and
> as a result it also fixes the wrong size calculation.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> drivers/of/fdt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 79cb831..3f5736c 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -937,7 +937,7 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
> return;
> }
>
> - if (base + size > MAX_PHYS_ADDR) {
> + if (base + size - 1 > MAX_PHYS_ADDR) {
> pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
> ULONG_MAX, base + size);
> size = MAX_PHYS_ADDR - base;
By that logic, the above two lines need to be repaired also:
pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
MAX_PHYS_ADDR + 1, base + size);
size = MAX_PHYS_ADDR - base + 1;
I've fixed it up and applied, thanks.
g.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] of: fdt: fix memory range check
@ 2014-09-24 14:38 ` Grant Likely
0 siblings, 0 replies; 5+ messages in thread
From: Grant Likely @ 2014-09-24 14:38 UTC (permalink / raw)
To: devicetree; +Cc: Rob Herring, linux-kernel, Srinivas Kandagatla
On Tue, 23 Sep 2014 10:59:09 +0100, Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote:
> In cases where board has below memory DT node
>
> memory{
> device_type = "memory";
> reg = <0x80000000 0x80000000>;
> };
>
> Check on the memory range in fdt.c will always fail because it is
> comparing MAX_PHYS_ADDR with base + size, in fact it should compare
> it with base + size - 1.
>
> This issue was originally noticed on Qualcomm IFC6410 board.
> Without this patch kernel shows up noticed unnecessary warnings
>
> [ 0.000000] Machine model: Qualcomm APQ8064/IFC6410
> [ 0.000000] Ignoring memory range 0xffffffff - 0x100000000
> [ 0.000000] cma: Reserved 64 MiB at ab800000
>
> as a result the size get reduced to 0x7fffffff which looks wrong.
>
> This patch fixes the check involved in generating this warning and
> as a result it also fixes the wrong size calculation.
>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> drivers/of/fdt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 79cb831..3f5736c 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -937,7 +937,7 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
> return;
> }
>
> - if (base + size > MAX_PHYS_ADDR) {
> + if (base + size - 1 > MAX_PHYS_ADDR) {
> pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
> ULONG_MAX, base + size);
> size = MAX_PHYS_ADDR - base;
By that logic, the above two lines need to be repaired also:
pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
MAX_PHYS_ADDR + 1, base + size);
size = MAX_PHYS_ADDR - base + 1;
I've fixed it up and applied, thanks.
g.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] of: fdt: fix memory range check
2014-09-24 14:38 ` Grant Likely
(?)
@ 2014-09-24 14:51 ` Srinivas Kandagatla
-1 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2014-09-24 14:51 UTC (permalink / raw)
To: Grant Likely, devicetree; +Cc: Rob Herring, linux-kernel
On 24/09/14 15:38, Grant Likely wrote:
>> --- a/drivers/of/fdt.c
>> >+++ b/drivers/of/fdt.c
>> >@@ -937,7 +937,7 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
>> > return;
>> > }
>> >
>> >- if (base + size > MAX_PHYS_ADDR) {
>> >+ if (base + size - 1 > MAX_PHYS_ADDR) {
>> > pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
>> > ULONG_MAX, base + size);
>> > size = MAX_PHYS_ADDR - base;
> By that logic, the above two lines need to be repaired also:
Thanks for fixing this too.
>
> pr_warning("Ignoring memory range 0x%lx - 0x%llx\n",
> MAX_PHYS_ADDR + 1, base + size);
I think the first argument should be printed in 0x%llx format as there
would be a 32bit overflow for MAX_PHYS_ADDR + 1.
> size = MAX_PHYS_ADDR - base + 1;
>
> I've fixed it up and applied, thanks.
--srini
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-24 14:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-23 9:59 [PATCH] of: fdt: fix memory range check Srinivas Kandagatla
2014-09-23 9:59 ` Srinivas Kandagatla
2014-09-24 14:38 ` Grant Likely
2014-09-24 14:38 ` Grant Likely
2014-09-24 14:51 ` Srinivas Kandagatla
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.