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]
Date:   Wed, 23 Sep 2020 16:00:45 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Dave Jiang' <dave.jiang@...el.com>, Borislav Petkov <bp@...en8.de>
CC:     "vkoul@...nel.org" <vkoul@...nel.org>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "dan.j.williams@...el.com" <dan.j.williams@...el.com>,
        "tony.luck@...el.com" <tony.luck@...el.com>,
        "jing.lin@...el.com" <jing.lin@...el.com>,
        "ashok.raj@...el.com" <ashok.raj@...el.com>,
        "sanjay.k.kumar@...el.com" <sanjay.k.kumar@...el.com>,
        "fenghua.yu@...el.com" <fenghua.yu@...el.com>,
        "kevin.tian@...el.com" <kevin.tian@...el.com>,
        "dmaengine@...r.kernel.org" <dmaengine@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v4 1/5] x86/asm: move the raw asm in iosubmit_cmds512() to
 special_insns.h

From: Dave Jiang
> Sent: 23 September 2020 16:43
...
> >
> > On Thu, Sep 17, 2020 at 02:15:16PM -0700, Dave Jiang wrote:
> >> diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
> >> index 59a3e13204c3..7bc8e714f37e 100644
> >> --- a/arch/x86/include/asm/special_insns.h
> >> +++ b/arch/x86/include/asm/special_insns.h
> >> @@ -234,6 +234,23 @@ static inline void clwb(volatile void *__p)
> >>
> >>   #define nop() asm volatile ("nop")
> >>
> >> +static inline void movdir64b(void *__dst, const void *src)
> >
> > Make __dst be the function local variable name and keep "dst", i.e.,
> > without the underscores, the function parameter name.
> 
> Ok will fix
> 
> >
> >> +	/*
> >> +	 * Note that this isn't an "on-stack copy", just definition of "dst"
> >> +	 * as a pointer to 64-bytes of stuff that is going to be overwritten.
> >> +	 * In the MOVDIR64B case that may be needed as you can use the
> >> +	 * MOVDIR64B instruction to copy arbitrary memory around. This trick
> >> +	 * lets the compiler know how much gets clobbered.
> >> +	 */
> >> +	volatile struct { char _[64]; } *dst = __dst;
> >> +
> >> +	/* MOVDIR64B [rdx], rax */
> >> +	asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"
> >> +		     : "=m" (dst)
> >> +		     : "d" (src), "a" (dst));
> >> +}

Since 'dst' needs to be 64byte aligned it isn't clear that 'void *'
is the right type for 'dst'.
At least add a comment.

Your asm constraints are also just wrong.

There is no real point specifying "=m" (dst) as an output.
The write rather bypasses the cache and the caller better
know what they are doing.

OTOH you'd better add "m" ((struct { char _[64];} *)src) as
an input constraint.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ