xref: /linux/tools/arch/x86/include/asm/special_insns.h (revision 55a42f78ffd386e01a5404419f8c5ded7db70a21)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TOOLS_ASM_X86_SPECIAL_INSNS_H
3 #define _TOOLS_ASM_X86_SPECIAL_INSNS_H
4 
5 /* The dst parameter must be 64-bytes aligned */
6 static inline void movdir64b(void *dst, const void *src)
7 {
8 	const struct { char _[64]; } *__src = src;
9 	struct { char _[64]; } *__dst = dst;
10 
11 	/*
12 	 * MOVDIR64B %(rdx), rax.
13 	 *
14 	 * Both __src and __dst must be memory constraints in order to tell the
15 	 * compiler that no other memory accesses should be reordered around
16 	 * this one.
17 	 *
18 	 * Also, both must be supplied as lvalues because this tells
19 	 * the compiler what the object is (its size) the instruction accesses.
20 	 * I.e., not the pointers but what they point to, thus the deref'ing '*'.
21 	 */
22 	asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"
23 		     : "+m" (*__dst)
24 		     :  "m" (*__src), "a" (__dst), "d" (__src));
25 }
26 
27 #endif /* _TOOLS_ASM_X86_SPECIAL_INSNS_H */
28