Re: [PATCH RFC V4 09/10] x86/jump_label: use GENERIC_NOP5_ATOMIC instead of jmp5 +0

Jeremy Fitzhardinge
2011-10-13T18:21:53Z

On 10/13/2011 08:40 AM, H. Peter Anvin wrote:
> On 10/12/2011 05:08 PM, Jeremy Fitzhardinge wrote:
>> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
>>
>> GENERIC_NOP5_ATOMIC should make a better nop.
>>
> On 32 bits, yes. On 64 bits you should use P6_NOP5_ATOMIC.

Something like this?

From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Date: Thu, 13 Oct 2011 09:55:25 -0700
Subject: [PATCH] x86/nop: we can use P6 as generic NOP on 64-bit

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

diff --git a/arch/x86/include/asm/nops.h b/arch/x86/include/asm/nops.h
index 405b403..f9fead9 100644
--- a/arch/x86/include/asm/nops.h
+++ b/arch/x86/include/asm/nops.h
@@ -19,15 +19,15 @@
6: leal 0x00000000(%esi),%esi
7: leal 0x00000000(,%esi,1),%esi
*/
-#define GENERIC_NOP1 0x90
-#define GENERIC_NOP2 0x89,0xf6
-#define GENERIC_NOP3 0x8d,0x76,0x00
-#define GENERIC_NOP4 0x8d,0x74,0x26,0x00
-#define GENERIC_NOP5 GENERIC_NOP1,GENERIC_NOP4
-#define GENERIC_NOP6 0x8d,0xb6,0x00,0x00,0x00,0x00
-#define GENERIC_NOP7 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00
-#define GENERIC_NOP8 GENERIC_NOP1,GENERIC_NOP7
-#define GENERIC_NOP5_ATOMIC NOP_DS_PREFIX,GENERIC_NOP4
+#define GAS_NOP1 0x90
+#define GAS_NOP2 0x89,0xf6
+#define GAS_NOP3 0x8d,0x76,0x00
+#define GAS_NOP4 0x8d,0x74,0x26,0x00
+#define GAS_NOP5 GENERIC_NOP1,GENERIC_NOP4
+#define GAS_NOP6 0x8d,0xb6,0x00,0x00,0x00,0x00
+#define GAS_NOP7 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00
+#define GAS_NOP8 GENERIC_NOP1,GENERIC_NOP7
+#define GAS_NOP5_ATOMIC NOP_DS_PREFIX,GENERIC_NOP4

/* Opteron 64bit nops
1: nop
@@ -87,6 +87,28 @@
#define P6_NOP8 0x0f,0x1f,0x84,0x00,0,0,0,0
#define P6_NOP5_ATOMIC P6_NOP5

+#ifdef CONFIG_X86_32
+#define GENERIC_NOP1 GAS_NOP1
+#define GENERIC_NOP2 GAS_NOP2
+#define GENERIC_NOP3 GAS_NOP3
+#define GENERIC_NOP4 GAS_NOP4
+#define GENERIC_NOP5 GAS_NOP5
+#define GENERIC_NOP6 GAS_NOP6
+#define GENERIC_NOP7 GAS_NOP7
+#define GENERIC_NOP8 GAS_NOP8
+#define GENERIC_NOP5_ATOMIC GAS_NOP5_ATOMIC
+#else
+#define GENERIC_NOP1 P6_NOP1
+#define GENERIC_NOP2 P6_NOP2
+#define GENERIC_NOP3 P6_NOP3
+#define GENERIC_NOP4 P6_NOP4
+#define GENERIC_NOP5 P6_NOP5
+#define GENERIC_NOP6 P6_NOP6
+#define GENERIC_NOP7 P6_NOP7
+#define GENERIC_NOP8 P6_NOP8
+#define GENERIC_NOP5_ATOMIC P6_NOP5_ATOMIC
+#endif
+
#define _ASM_MK_NOP(x) ".byte " __stringify(x) "\n"

#if defined(CONFIG_MK7)