From: Michal Hocko <mhocko@kernel.org>
To: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
Cc: linux-snps-arc@lists.infradead.org, Vineet.Gupta1@synopsys.com,
Alexey.Brodkin@synopsys.com, linux-kernel@vger.kernel.org
Subject: Re: [RFC] ARC: mm: Restrict definition of pfn_valid() macro for CONFIG_FLATMEM
Date: Wed, 30 Nov 2016 10:16:37 +0100 [thread overview]
Message-ID: <20161130091637.GC18437@dhcp22.suse.cz> (raw)
In-Reply-To: <1480433346-18054-1-git-send-email-yuriy.kolerov@synopsys.com>
On Tue 29-11-16 18:29:06, Yuriy Kolerov wrote:
> Despite the fact that subtraction of unsigned integers is a defined
> behaviour however such operations can lead to unexpected results. Thus
> it is better to check both left and right boundaries to avoid potential
> bugs as it done in the generic page.h.
Why and which code would use an out of range pfn? Why other arches do
not need to care?
>
> Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
> ---
> arch/arc/include/asm/page.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
> index 296c342..81cfc6c7 100644
> --- a/arch/arc/include/asm/page.h
> +++ b/arch/arc/include/asm/page.h
> @@ -88,7 +88,7 @@ typedef pte_t * pgtable_t;
> #define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_LINK_BASE)
>
> #ifdef CONFIG_FLATMEM
> -#define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
> +#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
> #endif
>
> /*
> --
> 2.7.4
>
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2016-11-30 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-29 15:29 Yuriy Kolerov
2016-11-30 9:16 ` Michal Hocko [this message]
2016-11-30 14:21 ` Yuriy Kolerov
2016-11-30 16:55 ` Vineet Gupta
2016-12-02 14:14 ` Yuriy Kolerov
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=20161130091637.GC18437@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=Alexey.Brodkin@synopsys.com \
--cc=Vineet.Gupta1@synopsys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=yuriy.kolerov@synopsys.com \
/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
Powered by JetHome