lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 28 Dec 2020 11:36:19 -0800
From:   Roman Gushchin <guro@...com>
To:     Mike Rapoport <rppt@...nel.org>
CC:     Andrew Morton <akpm@...ux-foundation.org>, <linux-mm@...ck.org>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Rik van Riel <riel@...riel.com>,
        Michal Hocko <mhocko@...nel.org>,
        <linux-kernel@...r.kernel.org>, <kernel-team@...com>
Subject: Re: [PATCH v2 1/2] mm: cma: allocate cma areas bottom-up

On Thu, Dec 24, 2020 at 12:10:39AM +0200, Mike Rapoport wrote:
> On Wed, Dec 23, 2020 at 08:35:37AM -0800, Roman Gushchin wrote:
> > On Tue, Dec 22, 2020 at 08:06:06PM -0800, Andrew Morton wrote:
> > > On Mon, 21 Dec 2020 09:05:51 -0800 Roman Gushchin <guro@...com> wrote:
> > > 
> > > > Subject: [PATCH v3 1/2] mm: cma: allocate cma areas bottom-up
> > > 
> > > i386 allmodconfig:
> > > 
> > > In file included from ./include/vdso/const.h:5,
> > >                  from ./include/linux/const.h:4,
> > >                  from ./include/linux/bits.h:5,
> > >                  from ./include/linux/bitops.h:6,
> > >                  from ./include/linux/kernel.h:11,
> > >                  from ./include/asm-generic/bug.h:20,
> > >                  from ./arch/x86/include/asm/bug.h:93,
> > >                  from ./include/linux/bug.h:5,
> > >                  from ./include/linux/mmdebug.h:5,
> > >                  from ./include/linux/mm.h:9,
> > >                  from ./include/linux/memblock.h:13,
> > >                  from mm/cma.c:24:
> > > mm/cma.c: In function ‘cma_declare_contiguous_nid’:
> > > ./include/uapi/linux/const.h:20:19: warning: conversion from ‘long long unsigned int’ to ‘phys_addr_t’ {aka ‘unsigned int’} changes value from ‘4294967296’ to ‘0’ [-Woverflow]
> > >  #define __AC(X,Y) (X##Y)
> > >                    ^~~~~~
> > > ./include/uapi/linux/const.h:21:18: note: in expansion of macro ‘__AC’
> > >  #define _AC(X,Y) __AC(X,Y)
> > >                   ^~~~
> > > ./include/linux/sizes.h:46:18: note: in expansion of macro ‘_AC’
> > >  #define SZ_4G    _AC(0x100000000, ULL)
> > >                   ^~~
> > > mm/cma.c:349:53: note: in expansion of macro ‘SZ_4G’
> > >     addr = memblock_alloc_range_nid(size, alignment, SZ_4G,
> > >                                                      ^~~~~
> > > 
> > 
> > I thought that (!memblock_bottom_up() && memblock_end >= SZ_4G + size)
> > can't be true on a 32-bit platform, so the whole if clause can be compiled out.
> > Maybe it's because memblock_end can be equal to SZ_4G and if the size == 0...
> > 
> > I have no better idea than wrapping everything into
> > #if BITS_PER_LONG > 32
> > #endif.
> 
> 32-bit systems can have more than 32 bit in the physical address.
> I think a better option would be to use CONFIG_PHYS_ADDR_T_64BIT

I agree. An updated fixup below.

Andrew, can you, please, replace the previous fixup with this one?

Thanks!

--

diff --git a/mm/cma.c b/mm/cma.c
index 4fe74c9d83b0..0ba69cd16aeb 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -344,12 +344,14 @@ int __init cma_declare_contiguous_nid(phys_addr_t base,
                 * Avoid using first 4GB to not interfere with constrained zones
                 * like DMA/DMA32.
                 */
+#ifdef CONFIG_PHYS_ADDR_T_64BIT
                if (!memblock_bottom_up() && memblock_end >= SZ_4G + size) {
                        memblock_set_bottom_up(true);
                        addr = memblock_alloc_range_nid(size, alignment, SZ_4G,
                                                        limit, nid, true);
                        memblock_set_bottom_up(false);
                }
+#endif
 
                if (!addr) {
                        addr = memblock_alloc_range_nid(size, alignment, base,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ