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: <CAHk-=wia9vFmyCJPkYg0vvegF8eojLy+DxVtpfoDv-UHoWKfqQ@mail.gmail.com>
Date:   Wed, 18 Oct 2023 14:10:53 -0700
From:   Linus Torvalds <torvalds@...ux-foundation.org>
To:     Uros Bizjak <ubizjak@...il.com>
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, 18 Oct 2023 at 13:52, Uros Bizjak <ubizjak@...il.com> wrote:
>
> FYI: This is the reason RMW instructions in percpu.h are not (blindly)
> converted to C ops.  They will remain in their (volatile or not) asm
> form because of the above reason, and due to the fact that they don't
> combine with anything.

Well, also because converting them to C would be HORRIBYL BUGGY.

They absolutely have to be a single instruction. We have architectures
that can't do rmw instructions, and then they have to do lots of extra
horrid crud (disable interrupts or whatever) to make a percpu 'add' be
a valid thing.


> Actually, RMW insns are better written in asm, while simple "mov"
> should be converted to (volatile or not) memory access.

No.

This remat issue has convinced me that the *only* thing that should be
converted to a memory access is the "stable" case (which in practice
is mainly just 'current').

Because if you make them 'volatile' memory instructions, then the
simple "mov" inline asm is simply better. It still allows CSE on the
asm (in the "raw" form).

And if you make them memory instructions _without_ the 'volatile', the
memory access is simply buggy until we have some 'nomaterialize'
model.

So the *only* situation where a memory access is better is that
'stable' case. In all other cases they are the same or strictly worse
than 'asm'.

               Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ