[<prev] [next>] [day] [month] [year] [list]
Message-ID: <072d5479-17e0-4224-b0e8-e2f710f8dfba@p183>
Date: Mon, 15 Jul 2024 08:06:33 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] x86/asm: simplify some inline assembly with pointers to array
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@...il.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)
Powered by blists - more mailing lists