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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6n4x75ounp3uvpy46ezejoyhteelkodq3ailpqcpheimeoqjpz@hr57al3q2ok2>
Date: Tue, 18 Mar 2025 15:29:34 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: David Laight <david.laight.linux@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>, x86@...nel.org, 
	linux-kernel@...r.kernel.org, Peter Zijlstra <peterz@...radead.org>, 
	Borislav Petkov <bp@...en8.de>, "H. Peter Anvin" <hpa@...or.com>, 
	Uros Bizjak <ubizjak@...il.com>, Andrew Cooper <andrew.cooper3@...rix.com>, 
	Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH 14/20] x86/barrier: Use alternative_io() in 32-bit
 barrier functions

On Tue, Mar 18, 2025 at 10:06:05PM +0000, David Laight wrote:
> > > So with:
> > > #define __asm_call(qual, alt, out, in, clobber) \
> > > 	asm("zzz", ARG out, ARG in, ARG clobber)
> > > 
> > > __asm_call(qual, ALT(), \
> > > 		([var] "+m" (__my_cpu_var(_var)), "+a" (old__.low),	\
> > > 		    "+d" (old__.high)),					\
> > > 		("b" (new__.low), "c" (new__.high), "S" (&(_var))),	\
> > > 		("memory"));
> > > 
> > > would get expanded the same as the line below.  
> > 
> > Interesting idea, though I still prefer the self-documenting ASM_OUTPUT
> > / ASM_INPUT / ASM_CLOBBER macros which are self-documenting and make it
> > easier to read and visually distinguish the constraint lists.
> 
> Except that non of this really makes it easier to get out/in in the correct
> order or to use the right constraints.

At least it's still no worse than asm() itself in that respect.

> So are you just adding 'syntactic sugar' for no real gain?

Some wrappers need to modify their constraint lists, so the sugar does
have a functional purpose.  The new alternative_io() (or whatever it
will be called) interface will especially be needed for the followup to
this patch set which introduces asm_call() to try to fix an
ASM_CALL_CONSTRAINT mess.

> Looking back at one of the changes:
> -#define mb() asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "mfence", \
> -				      X86_FEATURE_XMM2) ::: "memory", "cc")
> +#define mb() alternative_io("lock addl $0,-4(%%esp)",			\
> +			    "mfence", X86_FEATURE_XMM2,			\
> +			    ARG(),					\
> +			    ARG(),					\
> +			    ARG("memory", "cc")) 
> 
> is it really an improvement?

The motivation here is to use the alternative*() wrappers whenever
possible.  It helps achieve consistent behaviors and also removes the
ugly nested ALTERNATIVE() macro.

In fact, the change in your example actually improves code generation:
it changes the asm() to asm_inline() which prevents GCC from doing crazy
things due to the exploded size of the asm string.

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ