Andi Kleen | bd61643 | 2008-01-30 13:32:38 +0100 | [diff] [blame] | 1 | #ifndef _ASM_NOPS_H |
| 2 | #define _ASM_NOPS_H 1 |
| 3 | |
| 4 | /* Define nops for use with alternative() */ |
| 5 | |
H. Peter Anvin | 4cd2095 | 2008-02-18 23:24:33 -0800 | [diff] [blame] | 6 | /* generic versions from gas |
| 7 | 1: nop |
Mikael Pettersson | 5d570cb | 2008-03-11 16:43:31 +0100 | [diff] [blame] | 8 | the following instructions are NOT nops in 64-bit mode, |
| 9 | for 64-bit mode use K8 or P6 nops instead |
H. Peter Anvin | 4cd2095 | 2008-02-18 23:24:33 -0800 | [diff] [blame] | 10 | 2: movl %esi,%esi |
| 11 | 3: leal 0x00(%esi),%esi |
| 12 | 4: leal 0x00(,%esi,1),%esi |
| 13 | 6: leal 0x00000000(%esi),%esi |
| 14 | 7: leal 0x00000000(,%esi,1),%esi |
| 15 | */ |
| 16 | #define GENERIC_NOP1 ".byte 0x90\n" |
| 17 | #define GENERIC_NOP2 ".byte 0x89,0xf6\n" |
| 18 | #define GENERIC_NOP3 ".byte 0x8d,0x76,0x00\n" |
| 19 | #define GENERIC_NOP4 ".byte 0x8d,0x74,0x26,0x00\n" |
| 20 | #define GENERIC_NOP5 GENERIC_NOP1 GENERIC_NOP4 |
| 21 | #define GENERIC_NOP6 ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n" |
| 22 | #define GENERIC_NOP7 ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n" |
| 23 | #define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7 |
Andi Kleen | bd61643 | 2008-01-30 13:32:38 +0100 | [diff] [blame] | 24 | |
H. Peter Anvin | 4cd2095 | 2008-02-18 23:24:33 -0800 | [diff] [blame] | 25 | /* Opteron 64bit nops |
| 26 | 1: nop |
| 27 | 2: osp nop |
| 28 | 3: osp osp nop |
| 29 | 4: osp osp osp nop |
| 30 | */ |
Andi Kleen | bd61643 | 2008-01-30 13:32:38 +0100 | [diff] [blame] | 31 | #define K8_NOP1 GENERIC_NOP1 |
| 32 | #define K8_NOP2 ".byte 0x66,0x90\n" |
| 33 | #define K8_NOP3 ".byte 0x66,0x66,0x90\n" |
| 34 | #define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n" |
| 35 | #define K8_NOP5 K8_NOP3 K8_NOP2 |
| 36 | #define K8_NOP6 K8_NOP3 K8_NOP3 |
| 37 | #define K8_NOP7 K8_NOP4 K8_NOP3 |
| 38 | #define K8_NOP8 K8_NOP4 K8_NOP4 |
| 39 | |
H. Peter Anvin | 4cd2095 | 2008-02-18 23:24:33 -0800 | [diff] [blame] | 40 | /* K7 nops |
| 41 | uses eax dependencies (arbitary choice) |
| 42 | 1: nop |
| 43 | 2: movl %eax,%eax |
| 44 | 3: leal (,%eax,1),%eax |
| 45 | 4: leal 0x00(,%eax,1),%eax |
| 46 | 6: leal 0x00000000(%eax),%eax |
| 47 | 7: leal 0x00000000(,%eax,1),%eax |
| 48 | */ |
| 49 | #define K7_NOP1 GENERIC_NOP1 |
Andi Kleen | bd61643 | 2008-01-30 13:32:38 +0100 | [diff] [blame] | 50 | #define K7_NOP2 ".byte 0x8b,0xc0\n" |
| 51 | #define K7_NOP3 ".byte 0x8d,0x04,0x20\n" |
| 52 | #define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n" |
| 53 | #define K7_NOP5 K7_NOP4 ASM_NOP1 |
| 54 | #define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n" |
H. Peter Anvin | 4cd2095 | 2008-02-18 23:24:33 -0800 | [diff] [blame] | 55 | #define K7_NOP7 ".byte 0x8D,0x04,0x05,0,0,0,0\n" |
| 56 | #define K7_NOP8 K7_NOP7 ASM_NOP1 |
Andi Kleen | bd61643 | 2008-01-30 13:32:38 +0100 | [diff] [blame] | 57 | |
H. Peter Anvin | 4cd2095 | 2008-02-18 23:24:33 -0800 | [diff] [blame] | 58 | /* P6 nops |
| 59 | uses eax dependencies (Intel-recommended choice) |
| 60 | 1: nop |
| 61 | 2: osp nop |
| 62 | 3: nopl (%eax) |
| 63 | 4: nopl 0x00(%eax) |
| 64 | 5: nopl 0x00(%eax,%eax,1) |
| 65 | 6: osp nopl 0x00(%eax,%eax,1) |
| 66 | 7: nopl 0x00000000(%eax) |
| 67 | 8: nopl 0x00000000(%eax,%eax,1) |
| 68 | */ |
Andi Kleen | bd61643 | 2008-01-30 13:32:38 +0100 | [diff] [blame] | 69 | #define P6_NOP1 GENERIC_NOP1 |
| 70 | #define P6_NOP2 ".byte 0x66,0x90\n" |
| 71 | #define P6_NOP3 ".byte 0x0f,0x1f,0x00\n" |
| 72 | #define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n" |
| 73 | #define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n" |
| 74 | #define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n" |
| 75 | #define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n" |
| 76 | #define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n" |
| 77 | |
Suresh Siddha | 871de93 | 2008-04-07 11:56:34 -0700 | [diff] [blame] | 78 | #if defined(CONFIG_MK7) |
Andi Kleen | bd61643 | 2008-01-30 13:32:38 +0100 | [diff] [blame] | 79 | #define ASM_NOP1 K7_NOP1 |
| 80 | #define ASM_NOP2 K7_NOP2 |
| 81 | #define ASM_NOP3 K7_NOP3 |
| 82 | #define ASM_NOP4 K7_NOP4 |
| 83 | #define ASM_NOP5 K7_NOP5 |
| 84 | #define ASM_NOP6 K7_NOP6 |
| 85 | #define ASM_NOP7 K7_NOP7 |
| 86 | #define ASM_NOP8 K7_NOP8 |
H. Peter Anvin | 7343b3b | 2008-02-14 14:52:05 -0800 | [diff] [blame] | 87 | #elif defined(CONFIG_X86_P6_NOP) |
Andi Kleen | bd61643 | 2008-01-30 13:32:38 +0100 | [diff] [blame] | 88 | #define ASM_NOP1 P6_NOP1 |
| 89 | #define ASM_NOP2 P6_NOP2 |
| 90 | #define ASM_NOP3 P6_NOP3 |
| 91 | #define ASM_NOP4 P6_NOP4 |
| 92 | #define ASM_NOP5 P6_NOP5 |
| 93 | #define ASM_NOP6 P6_NOP6 |
| 94 | #define ASM_NOP7 P6_NOP7 |
| 95 | #define ASM_NOP8 P6_NOP8 |
Suresh Siddha | 871de93 | 2008-04-07 11:56:34 -0700 | [diff] [blame] | 96 | #elif defined(CONFIG_X86_64) |
| 97 | #define ASM_NOP1 K8_NOP1 |
| 98 | #define ASM_NOP2 K8_NOP2 |
| 99 | #define ASM_NOP3 K8_NOP3 |
| 100 | #define ASM_NOP4 K8_NOP4 |
| 101 | #define ASM_NOP5 K8_NOP5 |
| 102 | #define ASM_NOP6 K8_NOP6 |
| 103 | #define ASM_NOP7 K8_NOP7 |
| 104 | #define ASM_NOP8 K8_NOP8 |
Andi Kleen | bd61643 | 2008-01-30 13:32:38 +0100 | [diff] [blame] | 105 | #else |
| 106 | #define ASM_NOP1 GENERIC_NOP1 |
| 107 | #define ASM_NOP2 GENERIC_NOP2 |
| 108 | #define ASM_NOP3 GENERIC_NOP3 |
| 109 | #define ASM_NOP4 GENERIC_NOP4 |
| 110 | #define ASM_NOP5 GENERIC_NOP5 |
| 111 | #define ASM_NOP6 GENERIC_NOP6 |
| 112 | #define ASM_NOP7 GENERIC_NOP7 |
| 113 | #define ASM_NOP8 GENERIC_NOP8 |
| 114 | #endif |
| 115 | |
| 116 | #define ASM_NOP_MAX 8 |
| 117 | |
| 118 | #endif |