mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] x86/asm: simplify some inline assembly with pointers to array
Date: Mon, 15 Jul 2024 08:06:33 +0300	[thread overview]
Message-ID: <072d5479-17e0-4224-b0e8-e2f710f8dfba@p183> (raw)

Use pointer to array in memory operands instead of dummy variables
to save LOC.

The patterns are:

	"=m" (*(T(*)[N])ptr)
	"+m" (*(T(*)[N])ptr)
and
	"m" (*(const T(*)[N])ptr)

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 arch/x86/include/asm/special_insns.h |   21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

--- a/arch/x86/include/asm/special_insns.h
+++ b/arch/x86/include/asm/special_insns.h
@@ -188,17 +188,15 @@ static inline void clflushopt(volatile void *__p)
 		       "+m" (*(volatile char __force *)__p));
 }
 
-static inline void clwb(volatile void *__p)
+static inline void clwb(volatile void *p)
 {
-	volatile struct { char x[64]; } *p = __p;
-
 	asm volatile(ALTERNATIVE_2(
 		".byte 0x3e; clflush (%[pax])",
 		".byte 0x66; clflush (%[pax])", /* clflushopt (%%rax) */
 		X86_FEATURE_CLFLUSHOPT,
 		".byte 0x66, 0x0f, 0xae, 0x30",  /* clwb (%%rax) */
 		X86_FEATURE_CLWB)
-		: [p] "+m" (*p)
+		: [p] "+m" (*(volatile char(*)[64])p)
 		: [pax] "a" (p));
 }
 
@@ -226,13 +224,10 @@ static 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.
 	 *
@@ -241,8 +236,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));
 }
 
 static inline void movdir64b_io(void __iomem *dst, const void *src)
@@ -271,8 +266,6 @@ static inline void movdir64b_io(void __iomem *dst, const void *src)
  */
 static inline int enqcmds(void __iomem *dst, const void *src)
 {
-	const struct { char _[64]; } *__src = src;
-	struct { char _[64]; } __iomem *__dst = dst;
 	bool zf;
 
 	/*
@@ -282,8 +275,8 @@ static inline int enqcmds(void __iomem *dst, const void *src)
 	 */
 	asm volatile(".byte 0xf3, 0x0f, 0x38, 0xf8, 0x02, 0x66, 0x90"
 		     CC_SET(z)
-		     : CC_OUT(z) (zf), "+m" (*__dst)
-		     : "m" (*__src), "a" (__dst), "d" (__src));
+		     : CC_OUT(z) (zf), "+m" (*(char __iomem(*)[64])dst)
+		     : "m" (*(const char(*)[64])src), "a" (dst), "d" (src));
 
 	/* Submission failure is indicated via EFLAGS.ZF=1 */
 	if (zf)

                 reply	other threads:[~2024-07-15  5:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=072d5479-17e0-4224-b0e8-e2f710f8dfba@p183 \
    --to=adobriyan@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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

all inboxes | Powered by JetHome®