* Re:[PATCH] memblock: Correct calculation method for overflowing range @size
[not found] <20230324052351.31106-1-jhb_ee@163.com>
@ 2023-03-24 5:56 ` 电子
0 siblings, 0 replies; only message in thread
From: 电子 @ 2023-03-24 5:56 UTC (permalink / raw)
To: rppt; +Cc: akpm, linux-mm, linux-kernel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-24 5:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20230324052351.31106-1-jhb_ee@163.com>
2023-03-24 5:56 ` Re:[PATCH] memblock: Correct calculation method for overflowing range @size 电子
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox