x86: introduce NOP9 forms
authorJan Beulich <jbeulich@suse.com>
Wed, 20 Dec 2017 09:03:20 +0000 (10:03 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 20 Dec 2017 09:03:20 +0000 (10:03 +0100)
Both Intel and AMD recommend an operand-size-override-prefixed long NOP
form for covering 9 bytes, so introduce this and use it in p6_nops[] to
allow further reducing the number of NOPs needed when covering larger
ranges.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/alternative.c
xen/include/asm-x86/nops.h

index af7b42f9a6afa6c88373ca83fb91934df49be91f..ee18e6ce5b9c7a5be861d40d574080e8338f3b1a 100644 (file)
@@ -37,7 +37,8 @@ static const unsigned char k8nops[] init_or_livepatch_const = {
     K8_NOP5,
     K8_NOP6,
     K8_NOP7,
-    K8_NOP8
+    K8_NOP8,
+    K8_NOP9,
 };
 static const unsigned char * const k8_nops[ASM_NOP_MAX+1] init_or_livepatch_constrel = {
     NULL,
@@ -48,7 +49,8 @@ static const unsigned char * const k8_nops[ASM_NOP_MAX+1] init_or_livepatch_cons
     k8nops + 1 + 2 + 3 + 4,
     k8nops + 1 + 2 + 3 + 4 + 5,
     k8nops + 1 + 2 + 3 + 4 + 5 + 6,
-    k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7
+    k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
+    k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8,
 };
 #endif
 
@@ -61,7 +63,8 @@ static const unsigned char p6nops[] init_or_livepatch_const = {
     P6_NOP5,
     P6_NOP6,
     P6_NOP7,
-    P6_NOP8
+    P6_NOP8,
+    P6_NOP9,
 };
 static const unsigned char * const p6_nops[ASM_NOP_MAX+1] init_or_livepatch_constrel = {
     NULL,
@@ -72,7 +75,8 @@ static const unsigned char * const p6_nops[ASM_NOP_MAX+1] init_or_livepatch_cons
     p6nops + 1 + 2 + 3 + 4,
     p6nops + 1 + 2 + 3 + 4 + 5,
     p6nops + 1 + 2 + 3 + 4 + 5 + 6,
-    p6nops + 1 + 2 + 3 + 4 + 5 + 6 + 7
+    p6nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
+    p6nops + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8,
 };
 #endif
 
index 9a6a4e116431265953b55928d352bb5016eca725..dda9d202c8820835816d6229e366e2b07d2da4d2 100644 (file)
@@ -22,6 +22,7 @@
 #define K8_NOP6 K8_NOP3,K8_NOP3
 #define K8_NOP7 K8_NOP4,K8_NOP3
 #define K8_NOP8 K8_NOP4,K8_NOP4
+#define K8_NOP9 K8_NOP3,K8_NOP3,K8_NOP3
 
 /*
  * P6 nops
@@ -34,6 +35,7 @@
  * 6: osp nopl 0x00(%eax,%eax,1)
  * 7: nopl 0x00000000(%eax)
  * 8: nopl 0x00000000(%eax,%eax,1)
+ * 9: nopw 0x00000000(%eax,%eax,1)
  *    Note: All the above are assumed to be a single instruction.
  *          There is kernel code that depends on this.
  */
@@ -45,6 +47,7 @@
 #define P6_NOP6 0x66,0x0f,0x1f,0x44,0x00,0
 #define P6_NOP7 0x0f,0x1f,0x80,0,0,0,0
 #define P6_NOP8 0x0f,0x1f,0x84,0x00,0,0,0,0
+#define P6_NOP9 0x66,0x0f,0x1f,0x84,0x00,0,0,0,0
 
 #ifdef __ASSEMBLY__
 #define _ASM_MK_NOP(x) .byte x
@@ -60,7 +63,8 @@
 #define ASM_NOP6 _ASM_MK_NOP(K8_NOP6)
 #define ASM_NOP7 _ASM_MK_NOP(K8_NOP7)
 #define ASM_NOP8 _ASM_MK_NOP(K8_NOP8)
+#define ASM_NOP9 _ASM_MK_NOP(K8_NOP9)
 
-#define ASM_NOP_MAX 8
+#define ASM_NOP_MAX 9
 
 #endif /* __X86_ASM_NOPS_H__ */