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] [day] [month] [year] [list]
Date:   Thu, 06 Apr 2023 17:21:48 -0400
From:   Radu Rendec <rrendec@...hat.com>
To:     Pierre Gondois <pierre.gondois@....com>,
        linux-kernel@...r.kernel.org
Cc:     Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>,
        Sudeep Holla <sudeep.holla@....com>,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2 1/2] cacheinfo: Add arch specific early level
 initializer

Hello Pierre,

On Thu, 2023-04-06 at 10:17 +0200, Pierre Gondois wrote:
> [start]
> > +       unsigned int early_leaves = cache_leaves(cpu);
> >         int ret;
> >   
> >         /* Since early initialization/allocation of the cacheinfo is allowed
> >          * via fetch_cache_info() and this also gets called as CPU hotplug
> >          * callbacks via cacheinfo_cpu_online, the init/alloc can be skipped
> >          * as it will happen only once (the cacheinfo memory is never freed).
> > -        * Just populate the cacheinfo.
> > +        * Just populate the cacheinfo. However, if the cacheinfo has been
> > +        * allocated early through the arch-specific early_cache_level() call,
> > +        * there is a chance the info is wrong (this can happen on arm64). In
> > +        * that case, call init_cache_level() anyway to give the arch-specific
> > +        * code a chance to make things right.
> >          */
> > -       if (per_cpu_cacheinfo(cpu))
> > +       if (per_cpu_cacheinfo(cpu) && !ci_cacheinfo(cpu)->early_arch_info)
> >                 goto populate_leaves;
> >   
> >         if (init_cache_level(cpu) || !cache_leaves(cpu))
> >                 return -ENOENT;
> >   
> > +       if (cache_leaves(cpu) <= early_leaves)
> > +               goto populate_leaves;
> > +
> > +       kfree(per_cpu_cacheinfo(cpu))
> > 
> >         ret = allocate_cache_info(cpu);
> >         if (ret)
> >                 return ret;
> [stop]
> 
> Maybe this would be the occasion to put the code between the start/stop in a separate
> function and remove the 'populate_leaves' label. The code seems correct, but it was
> already a bit complex to read before the patch.

Yes, that makes sense. I will address this (and your other comment
about the braces) and post v3 shortly. Thanks for reviewing the patch
and for the feedback!

After I had sent v2, I realized there was something missing from that
code between start/stop. I think we should also set the early_arch_info
flag back to false to prevent another detection/reallocation in case
detect_cache_attributes() is called again (I'm thinking CPU hotplug).
I will address this as well in v3.

Best regards,
Radu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ