linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: olof@lixom.net (Olof Johansson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v16 9/9] of: fdt: fix memory address be truncated
Date: Sun, 24 Aug 2014 11:27:47 -0700	[thread overview]
Message-ID: <20140824182747.GC11563@localhost> (raw)
In-Reply-To: <1407121088-4151-10-git-send-email-haojian.zhuang@linaro.org>

On Mon, Aug 04, 2014 at 10:58:08AM +0800, Haojian Zhuang wrote:
> early_init_dt_add_memory_arch() accepts base & size parameters as u64
> type. memblock_add() accepts base & size parameters as phys_addr_t type.
> But phys_addr_t isn't equal to u64. In 32-bit system, phys_addr_t is
> 32-bit long. If 64-bit memory address is specified in DTS file, it'll be
> truncated into 32-bit address.
> 
> So create two values to store base & size first as phys_addr_t type.
> Then compare them with u64 base & u64 size. If they don't match, discard
> them.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> ---
>  drivers/of/fdt.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index c4cddf0..10d5382 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -878,6 +878,8 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
>  void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
>  {
>  	const u64 phys_offset = __pa(PAGE_OFFSET);
> +	phys_addr_t mbase, msize;
> +
>  	base &= PAGE_MASK;
>  	size &= PAGE_MASK;
>  	if (base + size < phys_offset) {
> @@ -885,6 +887,14 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
>  			   base, base + size);
>  		return;
>  	}
> +	/* phys_addr_t may not be equal to u64 */
> +	mbase = base;
> +	msize = size;
> +	if ((mbase != base) || (msize != size)) {
> +		pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
> +			   base, base + size);
> +		return;

Actually, you can do better than this -- you can still use the part that fits in 32 bits even
if not all of it does.


-Olof

      reply	other threads:[~2014-08-24 18:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04  2:57 [PATCH v16 0/9] enable HiP04 SoC Haojian Zhuang
2014-08-04  2:58 ` [PATCH v16 1/9] ARM: mcpm: support 4 clusters Haojian Zhuang
2014-08-04  2:58 ` [PATCH v16 2/9] ARM: hisi: enable MCPM implementation Haojian Zhuang
2014-08-04 22:43   ` Nicolas Pitre
2014-08-05  0:07     ` Haojian Zhuang
2014-08-05  1:02       ` Nicolas Pitre
2014-08-05  1:18         ` Haojian Zhuang
2014-08-05  1:32           ` Nicolas Pitre
2014-08-05  1:38             ` Haojian Zhuang
2014-08-05  2:01               ` Nicolas Pitre
2014-08-05  2:05                 ` Haojian Zhuang
2014-08-04  2:58 ` [PATCH v16 3/9] ARM: hisi: enable HiP04 Haojian Zhuang
2014-08-04  2:58 ` [PATCH v16 4/9] document: dt: add the binding on HiP04 Haojian Zhuang
2014-08-04  2:58 ` [PATCH v16 5/9] ARM: dts: add hip04 dts Haojian Zhuang
2014-08-04  2:58 ` [PATCH v16 6/9] ARM: config: enable hisilicon hip04 Haojian Zhuang
2014-08-04  2:58 ` [PATCH v16 7/9] ARM: debug: add HiP04 debug uart Haojian Zhuang
2014-08-04  2:58 ` [PATCH v16 8/9] irq: enable hip04 irq chip Haojian Zhuang
2014-08-06 15:26   ` Andre Przywara
2014-08-07  5:26     ` Haojian Zhuang
2014-08-04  2:58 ` [PATCH v16 9/9] of: fdt: fix memory address be truncated Haojian Zhuang
2014-08-24 18:27   ` Olof Johansson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140824182747.GC11563@localhost \
    --to=olof@lixom.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).