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: <d9d6b9db-dcdb-4024-a14a-bdcbe6afe00a@p183>
Date: Fri, 7 Mar 2025 19:15:42 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Ingo Molnar <mingo@...nel.org>
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
	dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] x86/asm: delete dummy variables in movdir64b()

On Fri, Mar 07, 2025 at 12:49:26PM +0100, Ingo Molnar wrote:
> 
> * Alexey Dobriyan <adobriyan@...il.com> wrote:
> 
> > Cast to pointer-to-array instead.
> > 
> > Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
> > ---
> >  arch/x86/include/asm/special_insns.h | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
> > index d349aa0f0a83..b24c6c945c38 100644
> > --- a/arch/x86/include/asm/special_insns.h
> > +++ b/arch/x86/include/asm/special_insns.h
> > @@ -215,13 +215,10 @@ static __always_inline void serialize(void)
> >  /* The dst parameter must be 64-bytes aligned */
> >  static inline void movdir64b(void *dst, const void *src)
> >  {
> > -	const struct { char _[64]; } *__src = src;
> > -	struct { char _[64]; } *__dst = dst;
> > -
> >  	/*
> >  	 * MOVDIR64B %(rdx), rax.
> >  	 *
> > -	 * Both __src and __dst must be memory constraints in order to tell the
> > +	 * Both src and dst must be memory constraints in order to tell the
> >  	 * compiler that no other memory accesses should be reordered around
> >  	 * this one.
> >  	 *
> > @@ -230,8 +227,8 @@ static inline void movdir64b(void *dst, const void *src)
> >  	 * I.e., not the pointers but what they point to, thus the deref'ing '*'.
> >  	 */
> >  	asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"
> > -		     : "+m" (*__dst)
> > -		     :  "m" (*__src), "a" (__dst), "d" (__src));
> > +		     : "+m" (*(char(*)[64])dst)
> > +		     :  "m" (*(const char(*)[64])src), "a" (dst), "d" (src));
> 
> In what world is putting type casts inside asm() statements an 
> improvement to the code?

In the same world where creating distracting variable whose only purpose
is to make a cast is considered not good.

Notice the cast is shorter, there is not "struct", so it is positive in
both vertical and horizontal directions.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ