From: 电子 <jhb_ee@163.com>
To: rppt@kernel.org
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re:[PATCH] memblock: Correct calculation method for overflowing range @size
Date: Fri, 24 Mar 2023 13:56:42 +0800 (CST) [thread overview]
Message-ID: <2032a48e.3206.1871230d3bb.Coremail.jhb_ee@163.com> (raw)
In-Reply-To: <20230324052351.31106-1-jhb_ee@163.com>
Sorry, the size here may be calculated according to this formula, cancel this patch
At 2023-03-24 13:23:51, "Hongbin Ji" <jhb_ee@163.com> wrote:
>When memblock users to specify range where @base + @size overflows
>and automatically cap it at maximum, The new size should be
>PHYS_ADDR_MAX - @base + 1.
>
>Assuming that base is 0, PHYS_ADDR_MAX is 0xff, which is 255 in decimal,
>then @size should be 256 instead of 255
>
>Signed-off-by: Hongbin Ji <jhb_ee@163.com>
>---
> mm/memblock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/mm/memblock.c b/mm/memblock.c
>index 25fd0626a9e7..f1683d1dae65 100644
>--- a/mm/memblock.c
>+++ b/mm/memblock.c
>@@ -169,7 +169,7 @@ static enum memblock_flags __init_memblock choose_memblock_flags(void)
> /* adjust *@size so that (@base + *@size) doesn't overflow, return new size */
> static inline phys_addr_t memblock_cap_size(phys_addr_t base, phys_addr_t *size)
> {
>- return *size = min(*size, PHYS_ADDR_MAX - base);
>+ return *size = min(*size, PHYS_ADDR_MAX - base + 1);
> }
>
> /*
>--
>2.34.1
parent reply other threads:[~2023-03-24 5:57 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20230324052351.31106-1-jhb_ee@163.com>]
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=2032a48e.3206.1871230d3bb.Coremail.jhb_ee@163.com \
--to=jhb_ee@163.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.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