Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_NOPS_H
3#define _ASM_X86_NOPS_H
4
5#include <asm/asm.h>
6
7/*
8 * Define nops for use with alternative() and for tracing.
9 */
10
11#ifndef CONFIG_64BIT
12
13/*
14 * Generic 32bit nops from GAS:
15 *
16 * 1: nop
17 * 2: movl %esi,%esi
18 * 3: leal 0x0(%esi),%esi
19 * 4: leal 0x0(%esi,%eiz,1),%esi
20 * 5: leal %ds:0x0(%esi,%eiz,1),%esi
21 * 6: leal 0x0(%esi),%esi
22 * 7: leal 0x0(%esi,%eiz,1),%esi
23 * 8: leal %ds:0x0(%esi,%eiz,1),%esi
24 *
25 * Except 5 and 8, which are DS prefixed 4 and 7 resp, where GAS would emit 2
26 * nop instructions.
27 */
28#define BYTES_NOP1 0x90
29#define BYTES_NOP2 0x89,0xf6
30#define BYTES_NOP3 0x8d,0x76,0x00
31#define BYTES_NOP4 0x8d,0x74,0x26,0x00
32#define BYTES_NOP5 0x3e,BYTES_NOP4
33#define BYTES_NOP6 0x8d,0xb6,0x00,0x00,0x00,0x00
34#define BYTES_NOP7 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00
35#define BYTES_NOP8 0x3e,BYTES_NOP7
36
37#else
38
39/*
40 * Generic 64bit nops from GAS:
41 *
42 * 1: nop
43 * 2: osp nop
44 * 3: nopl (%eax)
45 * 4: nopl 0x00(%eax)
46 * 5: nopl 0x00(%eax,%eax,1)
47 * 6: osp nopl 0x00(%eax,%eax,1)
48 * 7: nopl 0x00000000(%eax)
49 * 8: nopl 0x00000000(%eax,%eax,1)
50 */
51#define BYTES_NOP1 0x90
52#define BYTES_NOP2 0x66,BYTES_NOP1
53#define BYTES_NOP3 0x0f,0x1f,0x00
54#define BYTES_NOP4 0x0f,0x1f,0x40,0x00
55#define BYTES_NOP5 0x0f,0x1f,0x44,0x00,0x00
56#define BYTES_NOP6 0x66,BYTES_NOP5
57#define BYTES_NOP7 0x0f,0x1f,0x80,0x00,0x00,0x00,0x00
58#define BYTES_NOP8 0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00
59
60#endif /* CONFIG_64BIT */
61
62#define ASM_NOP1 _ASM_BYTES(BYTES_NOP1)
63#define ASM_NOP2 _ASM_BYTES(BYTES_NOP2)
64#define ASM_NOP3 _ASM_BYTES(BYTES_NOP3)
65#define ASM_NOP4 _ASM_BYTES(BYTES_NOP4)
66#define ASM_NOP5 _ASM_BYTES(BYTES_NOP5)
67#define ASM_NOP6 _ASM_BYTES(BYTES_NOP6)
68#define ASM_NOP7 _ASM_BYTES(BYTES_NOP7)
69#define ASM_NOP8 _ASM_BYTES(BYTES_NOP8)
70
71#define ASM_NOP_MAX 8
72
73#ifndef __ASSEMBLY__
74extern const unsigned char * const x86_nops[];
75#endif
76
77#endif /* _ASM_X86_NOPS_H */