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:   Wed, 18 Oct 2023 20:26:55 +0200
From:   Uros Bizjak <ubizjak@...il.com>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     Nadav Amit <namit@...are.com>,
        "the arch/x86 maintainers" <x86@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Andy Lutomirski <luto@...nel.org>,
        Brian Gerst <brgerst@...il.com>,
        Denys Vlasenko <dvlasenk@...hat.com>,
        "H . Peter Anvin" <hpa@...or.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>
Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr()

On Wed, Oct 18, 2023 at 8:16 PM Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> On Wed, 18 Oct 2023 at 11:08, Uros Bizjak <ubizjak@...il.com> wrote:
> >
> > But loads from non-const memory work like the above.
>
> Yes, I'm certainly ok with the move to use plain loads from __seg_gs
> for the percpu accesses. If they didn't honor the memory clobber, we
> could never use it at all.
>
> I was just saying that the 'const' alias trick isn't useful for
> anything else than 'current', because everything else needs to at
> least honor our existing barriers.

FYI, smp_processor_id() is implemented as:

#define __smp_processor_id() __this_cpu_read(pcpu_hot.cpu_number)

where __this_* forces volatile access which disables CSE.

*If* the variable is really stable, then it should use __raw_cpu_read.
Both, __raw_* and __this_* were recently (tip/percpu branch)
implemented for SEG_SUPPORT as:

#define __raw_cpu_read(qual, pcp)                    \
({                                    \
    *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp));        \
})

where "qual" can be volatile. To enable smp_processor_id()
optimization, it just needs to be moved from __this to __raw accessor.

> (And yes, there's the other user of this_cpu_read_stable() -
> 'top_of_stack', but as mentioned that doesn't really matter).

Uros.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ