Skip to contentSkip to conversation

x86/asm: Add support for MOVDIR64B instruction

PATCH In review Kirill A. Shutemov 5 participants 6 messages Jul 30, 2019 – Aug 1, 2019 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/asm: Add support for MOVDIR64B instruction

Add support for a new instruction MOVDIR64B. The instruction moves 64-bytes as direct-store with 64-byte write atomicity from source memory address to destination memory address.

MOVDIR64B requires the destination address to be 64-byte aligned. No alignment restriction is enforced for source operand.

See Intel Software Developer’s Manual for more information on the instruction.

---

Several upcoming patchsets will make use of the helper.

---
 arch/x86/include/asm/special_insns.h | 7 +++++++
 1 file changed, 7 insertions(+)
arch/x86/include/asm/special_insns.h +7 -0
index 219be88a59d2..059e7bd331d2 100644
@@ -248,6 +248,13 @@ static inline void clwb(volatile void *__p)
 
 #define nop() asm volatile ("nop")
 
+static inline void movdir64b(void *dst, const void *src)
+{
+	/* movdir64b [rdx], rax */
+	asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"
+			: "=m" (*(char *)dst)
+			: "d" (src), "a" (dst));
+}
 
 #endif /* __KERNEL__ */
 
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kirill A. Shutemov

Add support for a new instruction MOVDIR64B. The instruction moves 64-bytes as direct-store with 64-byte write atomicity from source memory address to destination memory address.

MOVDIR64B requires the destination address to be 64-byte aligned. No alignment restriction is enforced for source operand.

See Intel Software Developer’s Manual for more information on the instruction.

Quoted 26 lines

---

Several upcoming patchsets will make use of the helper.

---
  arch/x86/include/asm/special_insns.h | 7 +++++++
  1 file changed, 7 insertions(+)
arch/x86/include/asm/special_insns.h +7 -0
index 219be88a59d2..059e7bd331d2 100644
@@ -248,6 +248,13 @@ static inline void clwb(volatile void *__p)
 
  #define nop() asm volatile ("nop")
 
+static inline void movdir64b(void *dst, const void *src)
+{
+	/* movdir64b [rdx], rax */
+	asm volatile(".byte 0x66, 0x0f, 0x38, 0xf8, 0x02"
+			: "=m" (*(char *)dst)
+			: "d" (src), "a" (dst));
+}
 
  #endif /* __KERNEL__ */
 
maintainer
#2 lore raw
In reply to Kirill A. Shutemov
Quoted 7 lines · Kirill A. Shutemov

Add support for a new instruction MOVDIR64B. The instruction moves 64-bytes as direct-store with 64-byte write atomicity from source memory address to destination memory address.

MOVDIR64B requires the destination address to be 64-byte aligned. No alignment restriction is enforced for source operand.

Quoted 7 lines

See Intel Software Developer’s Manual for more information on the instruction.

---

Several upcoming patchsets will make use of the helper.

... so why aren't you sending it together with its first user?

Signature · 5 lines
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
#3 lore raw
Quoted 11 lines · Borislav Petkov
Quoted 10 lines · Kirill A. Shutemov

Add support for a new instruction MOVDIR64B. The instruction moves 64-bytes as direct-store with 64-byte write atomicity from source memory address to destination memory address.

MOVDIR64B requires the destination address to be 64-byte aligned. No alignment restriction is enforced for source operand.

See Intel Software Developer’s Manual for more information on the instruction.

Quoted 6 lines
Quoted 4 lines

---

Several upcoming patchsets will make use of the helper.

... so why aren't you sending it together with its first user?

We are not yet sure which patchset will hit upstream first. I thought it would be logistically easier to get the patch upstream on its own.

But if you prefer the patch to be submitted along with the first user, we can definately do this.

Jing, are you okay with this?

Signature · 1 line
 Kirill A. Shutemov
#4 lore raw
In reply to Borislav Petkov
Quoted 4 lines · Borislav Petkov
Quoted 1 line · Kirill A. Shutemov

Several upcoming patchsets will make use of the helper.

... so why aren't you sending it together with its first user?

Just to get another of the non-controversial bits out of the way before the main course arrives.

Note that the CPUFEATURE bit for MOVDIR64B already went upstream in v4.20:

ace6485a0326 ("x86/cpufeatures: Enumerate MOVDIR64B instruction")

-Tony

maintainer
#5 lore raw
Quoted 2 lines · Tony

Just to get another of the non-controversial bits out of the way before the main course arrives.

Let's submit functions together with their respective users pls. Like we always do.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.