linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Dave Jiang' <dave.jiang@intel.com>,
	"vkoul@kernel.org" <vkoul@kernel.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"dan.j.williams@intel.com" <dan.j.williams@intel.com>,
	"tony.luck@intel.com" <tony.luck@intel.com>,
	"jing.lin@intel.com" <jing.lin@intel.com>,
	"ashok.raj@intel.com" <ashok.raj@intel.com>,
	"sanjay.k.kumar@intel.com" <sanjay.k.kumar@intel.com>,
	"fenghua.yu@intel.com" <fenghua.yu@intel.com>,
	"kevin.tian@intel.com" <kevin.tian@intel.com>,
	"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v5 1/5] x86/asm: Carve out a generic movdir64b() helper for general usage
Date: Thu, 24 Sep 2020 08:24:46 +0000	[thread overview]
Message-ID: <a8c81da06df2471296b663d40b186c92@AcuMS.aculab.com> (raw)
In-Reply-To: <160090264332.44288.7575027054245105525.stgit@djiang5-desk3.ch.intel.com>

From: Dave Jiang
> Sent: 24 September 2020 00:11
>
> The MOVDIR64B instruction can be used by other wrapper instructions. Move
> the asm code to special_insns.h and have iosubmit_cmds512() call the
> asm function.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> Reviewed-by: Tony Luck <tony.luck@intel.com>
> ---
>  arch/x86/include/asm/io.h            |   17 +++--------------
>  arch/x86/include/asm/special_insns.h |   19 +++++++++++++++++++
>  2 files changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
> index e1aa17a468a8..d726459d08e5 100644
> --- a/arch/x86/include/asm/io.h
> +++ b/arch/x86/include/asm/io.h
...
> diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
> index 59a3e13204c3..2a5abd27bb86 100644
> --- a/arch/x86/include/asm/special_insns.h
> +++ b/arch/x86/include/asm/special_insns.h
> @@ -234,6 +234,25 @@ static inline void clwb(volatile void *__p)
> 
>  #define nop() asm volatile ("nop")
> 
> +/* The dst parameter must be 64-bytes aligned */
> +static inline void movdir64b(void *dst, const void *src)
> +{
> +	/*
> +	 * 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" (*(struct { char _[64];} **)src), "a" (__dst)
> +		     : "memory");
> +}
> +
>  #endif /* __KERNEL__ */

You've lost the "d" (src).
You don't need the 'memory' clobber, just:

static inline void movdir64b(void *dst, const void *src)
{
	/*
	 * 64 bytes from dst are marked as modified for completeness.
	 * Since the writes bypass the cache later reads may return
	 * old data anyway.
	 */
	/* MOVDIR64B [rdx], rax */
	asm volatile (".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"
	     : "=m" ((struct { char _[64];} *)dst),
	     : "m" ((struct { char _[64];} *)src), "d" (src), "a" (dst));
}

I've checked that the "m" constraint on src does force (at least one
version of) gcc to actually write to the supplied buffer.

	David

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

  parent reply	other threads:[~2020-09-24  8:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <160090233730.44288.4446779116422752486.stgit@djiang5-desk3.ch.intel.com>
2020-09-23 23:10 ` [PATCH v5 3/5] dmaengine: idxd: Add shared workqueue support Dave Jiang
2020-09-23 23:11 ` [PATCH v5 4/5] dmaengine: idxd: Clean up descriptors with fault error Dave Jiang
2020-09-23 23:11 ` [PATCH v5 5/5] dmaengine: idxd: Add ABI documentation for shared wq Dave Jiang
     [not found] ` <160090264332.44288.7575027054245105525.stgit@djiang5-desk3.ch.intel.com>
2020-09-24  8:24   ` David Laight [this message]
2020-09-24 10:15     ` [PATCH v5 1/5] x86/asm: Carve out a generic movdir64b() helper for general usage Borislav Petkov
2020-09-24 10:42       ` David Laight
2020-09-24 11:02         ` Borislav Petkov
2020-09-24 11:25           ` David Laight
2020-09-24 14:07       ` Michael Matz
2020-09-24 13:07   ` Borislav Petkov
2020-09-24 13:27     ` David Laight
2020-09-24 15:07     ` Dave Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8c81da06df2471296b663d40b186c92@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=ashok.raj@intel.com \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fenghua.yu@intel.com \
    --cc=jing.lin@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=sanjay.k.kumar@intel.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).