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]
Message-ID: <Z9frKMLYnhZI0MDD@gmail.com>
Date: Mon, 17 Mar 2025 10:28:08 +0100
From: Ingo Molnar <mingo@...nel.org>
To: Borislav Petkov <bp@...en8.de>
Cc: Uros Bizjak <ubizjak@...il.com>, x86@...nel.org,
	linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH] x86/asm: Use asm_inline() instead of asm() in
 __untagged_addr()


* Ingo Molnar <mingo@...nel.org> wrote:

> But GCC cannot always do proper inlining decisions due to our 
> complicated ALTERNATIVE macro constructs confusing the GCC inliner:
> 
>   > > ALTERNATIVE macro that expands to several pseudo directives causes 
>   > > instruction length estimate to count more than 20 instructions.
>                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Note how the asm_inline() compiler feature was added by GCC at the 
> kernel community's request to address such issues. (!)
> 
> So for those reasons, in my book, eliminating a function call for 
> really simple single instruction inlines is an unconditional 
> improvement that doesn't require futile performance measurements - it 
> 'only' requires assembly level code generation analysis in the 
> changelog.

Note that at least in part this is a weakness of GCC: the compiler 
isn't looking at the asm() closely enough and the 20 instructions count 
vastly overestimates the true footprint of these statements.

Yet GCC is also giving us a tool: "asm __inline", which tells the 
compiler that this piece of asm() statement is small. A tool that was 
created at the request of the kernel community's complaints about this 
issue. :-/

asm_inline() is functionally similar to __force_inline - which we 
regularly apply if it has code generation benefits.

So I really don't see the harm in these patches - they have benefits in 
terms of GCC code generation quality, documentation and performance:

 - It documents small asm() statements by annotating them asm_inline().

 - It sometimes avoids function call overhead, improving performance.

And because single-function inlining changes are next to impossible to 
measure in practice in most cases, I'd suggest we skip the performance 
measurement requirement if the code generation advantages on a recent 
GCC version are unambiguous.

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ