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]
Message-ID: <CAGsJ_4xOSjmA5c_b2M+_EM9eZkna7ePTV=MSvgOrt-VYvPEO3g@mail.gmail.com>
Date: Wed, 20 Mar 2024 12:22:56 +1300
From: Barry Song <21cnbao@...il.com>
To: Guenter Roeck <linux@...ck-us.net>
Cc: chris@...kel.net, jcmvbkbc@...il.com, akpm@...ux-foundation.org, 
	linux-kernel@...r.kernel.org, willy@...radead.org, dennis@...nel.org, 
	alexghiti@...osinc.com, Barry Song <v-songbaohua@...o.com>, 
	Huacai Chen <chenhuacai@...ngson.cn>, Herbert Xu <herbert@...dor.apana.org.au>, 
	kernel test robot <lkp@...el.com>
Subject: Re: [PATCH v2] xtensa: remove redundant flush_dcache_page and
 ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE macros

On Wed, Mar 20, 2024 at 3:18 AM Guenter Roeck <linux@...ck-us.net> wrote:
>
> On 3/18/24 18:27, Barry Song wrote:
> > On Tue, Mar 19, 2024 at 2:09 PM Barry Song <21cnbao@...il.com> wrote:
> >>
> >> From: Barry Song <v-songbaohua@...o.com>
> >>
> >> xtensa's flush_dcache_page() can be a no-op sometimes. There is a
> >> generic implementation for this case in include/asm-generic/
> >> cacheflush.h.
> >>   #ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
> >>   static inline void flush_dcache_page(struct page *page)
> >>   {
> >>   }
> >>
> >>   #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
> >>   #endif
> >>
> >> So remove the superfluous flush_dcache_page() definition, which also
> >> helps silence potential build warnings complaining the page variable
> >> passed to flush_dcache_page() is not used.
> >>
> >>     In file included from crypto/scompress.c:12:
> >>     include/crypto/scatterwalk.h: In function 'scatterwalk_pagedone':
> >>     include/crypto/scatterwalk.h:76:30: warning: variable 'page' set but not used [-Wunused-but-set-variable]
> >>        76 |                 struct page *page;
> >>           |                              ^~~~
> >>     crypto/scompress.c: In function 'scomp_acomp_comp_decomp':
> >>>> crypto/scompress.c:174:38: warning: unused variable 'dst_page' [-Wunused-variable]
> >>       174 |                         struct page *dst_page = sg_page(req->dst);
> >>           |
> >>
> >> The issue was originally reported on LoongArch by kernel test
> >> robot (Huacai fixed it on LoongArch), then reported by Guenter
> >> and me on xtensa.
> >>
> >> This patch also removes lots of redundant macros which have
> >> been defined by asm-generic/cacheflush.h.
> >>
> >> Cc: Huacai Chen <chenhuacai@...ngson.cn>
> >> Cc: Herbert Xu <herbert@...dor.apana.org.au>
> >> Reported-by: kernel test robot <lkp@...el.com>
> >> Closes: https://lore.kernel.org/oe-kbuild-all/202403091614.NeUw5zcv-lkp@intel.com/
> >> Reported-by: Barry Song <v-songbaohua@...o.com>
> >> Closes: https://lore.kernel.org/all/CAGsJ_4yDk1+axbte7FKQEwD7X2oxUCFrEc9M5YOS1BobfDFXPA@mail.gmail.com/
> >> Reported-by: Guenter Roeck <linux@...ck-us.net>
> >
> > Hi Guenter,
> > I am not a xtensa guy, so I will need your help for a full test. if
> > turns out it is a too big(ambitious)
>
> I sent a Tested-by: tag to your patch. As far as my testing goes, it works fine,
> and I added your patch to my "testing" branch (which tries to be buildable
> and testable for all architectures).

Thank you very much, Guenter. It would be nice if xtensa can leverage
the common cacheflush.h just like other architectures.

>
> > fix, a minimal fix might be:
> >
>
> FWIW, I think a minimal fix would have been to mark the variable as __maybe_unused,

I am not quite sure we want this as the point is that drivers should
be independent of
architectural differences.

The driver code, for itself, seems quite innocent,

struct page *dst_page = sg_page(req->dst);

for (i = 0; i < nr_pages; i++)
            flush_dcache_page(dst_page + i);

The only problem is that xtensa's flush_dcache_page is a macro and
doesn't use the "page"
parameter.
if we re-use the inline function in common cacheflush.h, it won't be a problem.

> but as others have pointed out it would be nice if there would be a guidance
> about optional API functions like this one that specifies if it may be
> implemented as macro and, if so, how it has to handle unused variables.

I agree. personally I like this and will have a go in
Documentation/process/coding-style.rst
and see others' opinions.

>
> Thanks,
> Guenter

Thanks
Barry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ