From: jonathan.austin@arm.com (Jonathan Austin)
To: linux-arm-kernel@lists.infradead.org
Subject: Why the region area don't decrease 1 in function sanity_check_meminfo?
Date: Fri, 10 Aug 2012 18:43:56 +0100 [thread overview]
Message-ID: <5025485C.80407@arm.com> (raw)
In-Reply-To: <20120810153705.GZ18957@n2100.arm.linux.org.uk>
Hi Russell,
On 10/08/12 16:37, Russell King - ARM Linux wrote:
>> With !HIGHMEM, sanity_check_meminfo checks for banks that completely or
>> partially overlap the vmalloc region. The check for partial overlap checks
>> __va(bank->start + bank->size) > vmalloc_min, but the last address of the
>> bank is (bank->start + bank->size -1).
>
> Erm.
>
> Let's say you have a bank at 0x80000000, which maps to 0xc0000000 virtual.
> This is 512MB in size (so it's last byte address is 0x9fffffff). That
> places it at at 0xdfffffff. Now, let's say vmalloc_min is 0xe0000000.
>
> "bank->start + bank->size" would be 0xa0000000, right ?
>
> So, "__va(bank->start + bank->size)" would be 0xe0000000.
Yep, except in our (hypothetical?) case below...
>
> And "0xe0000000 > vmalloc_min" would be false.
>
Yup... My commit message is wrong. Sorry. The linear case is fine...
>> However, theoretically, if using using SPARSEMEM in a situation where the
>> physical to virtual address conversion is not monotonic increasing, the
>> incorrect test could result in a bank not being truncated when it should be.
>
> Right, so what you're actually talking about is a non-linear translation
> by __va() and friends. In that case, what you actually need is:
>
> (__va(bank->start + bank->size - 1) + 1) > vmalloc_min
> or
> __va(bank->start + bank->size - 1) >= vmalloc_min
>
> and not
>
> __va(bank->start + bank->size - 1) > vmalloc_min
>
Agreed. I prefer the second form, and there seems to be a precedent for
">=" further up in sanity_check_meminfo, too.
If you think it is worth fixing for this case, I'll make the fixes,
ensure the commit message is !wrong and submit this to the patch-system.
Jonny
prev parent reply other threads:[~2012-08-10 17:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-24 10:54 Why the region area don't decrease 1 in function sanity_check_meminfo? 湛振波
2012-07-25 7:50 ` 湛振波
2012-08-10 15:14 ` Jonathan Austin
2012-08-10 15:37 ` Russell King - ARM Linux
2012-08-10 17:43 ` Jonathan Austin [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=5025485C.80407@arm.com \
--to=jonathan.austin@arm.com \
--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).