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, 6 May 2020 18:00:25 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     Rasmus Villemoes <linux@...musvillemoes.dk>,
        "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Masami Hiramatsu <mhiramat@...nel.org>, bristot@...hat.com,
        Jason Baron <jbaron@...mai.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...nel.org>, Nadav Amit <namit@...are.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Andy Lutomirski <luto@...nel.org>,
        Ard Biesheuvel <ard.biesheuvel@...aro.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        "H.J. Lu" <hjl.tools@...il.com>,
        clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH v4 14/18] static_call: Add static_cond_call()

On Wed, May 06, 2020 at 03:51:28PM +0200, Peter Zijlstra wrote:
> On Tue, May 05, 2020 at 11:13:53AM -0700, Nick Desaulniers wrote:
> > On Tue, May 5, 2020 at 2:36 AM Peter Zijlstra <peterz@...radead.org> wrote:
> > >
> > >
> > > HJ, Nick,
> > >
> > > Any chance any of you can see a way to make your respective compilers
> > > not emit utter junk for this?
> > >
> > > On Mon, May 04, 2020 at 10:14:45PM +0200, Peter Zijlstra wrote:
> > >
> > > > https://godbolt.org/z/SDRG2q
> > 
> > Woah, a godbolt link! Now we're speaking the same language.  What were
> > you expecting?
> 
> Given the output for x86-64 clang (trunk)
> 
> 	bar:                                    # @bar
> 		movl    %edi, .L_x$local(%rip)
> 		retq
> 	ponies:                                 # @ponies
> 		movq    .Lfoo$local(%rip), %rax
> 		testq   %rax, %rax
> 		movl    $__static_call_nop, %ecx
> 		cmovneq %rax, %rcx
> 		jmpq    *%rcx                   # TAILCALL
> 	__static_call_nop:                      # @__static_call_nop
> 		retq
> 	_x:
> 	.L_x$local:
> 		.long   0                       # 0x0
> 
> 	foo:
> 	.Lfoo$local:
> 		.zero   8
> 
> 
> I was hoping for:
> 
> 	bar:                                    # @bar
> 		movl    %edi, .L_x$local(%rip)
> 		retq
> 	ponies:                                 # @ponies
> 		movq    .Lfoo$local(%rip), %rax
> 		testq   %rax, %rax
> 		jz	1f
> 		jmpq    *%rcx                   # TAILCALL

Obviously this then wants to be *%rax.

> 	1:
> 		retq
> 
> That avoids the indirect call (possible retpoline) and does an immediate
> return.
> 
> So it does 2 things different:
> 
>  - it realizes the NULL case is a constant and uses an
>    immediate call and avoids the indirect call/jmp.
> 
>  - it realizes __static_call_nop() is a no-op and avoids the call
>    entirely and does an immediate return.

    IOW, have it inline __static_call_nop().

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ