4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2017 Joyent, Inc.
25 */
26
27 #ifndef _SYS_ASM_MISC_H
28 #define _SYS_ASM_MISC_H
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #ifdef _ASM /* The remainder of this file is only for assembly files */
35
36 /* Load reg with pointer to per-CPU structure */
37 #if defined(__amd64)
38 #define LOADCPU(reg) \
39 movq %gs:CPU_SELF, reg;
40 #else
41 #define LOADCPU(reg) \
42 movl %gs:CPU_SELF, reg;
43 #endif
44
45 #define RET_INSTR 0xc3
46 #define NOP_INSTR 0x90
47 #define STI_INSTR 0xfb
48 #define JMP_INSTR 0x00eb
49
50
51 #if defined(__i386)
52
53 #define _HOT_PATCH_PROLOG \
54 push %ebp; \
55 mov %esp, %ebp; \
56 push %ebx; \
57 push %esi; \
58 push %edi
59
60 #define _HOT_PATCH(srcaddr, dstaddr, size) \
61 movl $srcaddr, %esi; \
62 movl $dstaddr, %edi; \
63 movl $size, %ebx; \
64 0: pushl $1; \
65 /*CSTYLED*/ \
66 movzbl (%esi), %eax; \
67 pushl %eax; \
68 pushl %edi; \
69 call hot_patch_kernel_text; \
70 addl $12, %esp; \
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2019 Joyent, Inc.
25 */
26
27 #ifndef _SYS_ASM_MISC_H
28 #define _SYS_ASM_MISC_H
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #define RET_INSTR 0xc3
35 #define NOP_INSTR 0x90
36 #define STI_INSTR 0xfb
37 #define JMP_INSTR 0x00eb
38
39 #ifdef _ASM /* The remainder of this file is only for assembly files */
40
41 /* Load reg with pointer to per-CPU structure */
42 #if defined(__amd64)
43 #define LOADCPU(reg) \
44 movq %gs:CPU_SELF, reg;
45 #else
46 #define LOADCPU(reg) \
47 movl %gs:CPU_SELF, reg;
48 #endif
49
50 #if defined(__i386)
51
52 #define _HOT_PATCH_PROLOG \
53 push %ebp; \
54 mov %esp, %ebp; \
55 push %ebx; \
56 push %esi; \
57 push %edi
58
59 #define _HOT_PATCH(srcaddr, dstaddr, size) \
60 movl $srcaddr, %esi; \
61 movl $dstaddr, %edi; \
62 movl $size, %ebx; \
63 0: pushl $1; \
64 /*CSTYLED*/ \
65 movzbl (%esi), %eax; \
66 pushl %eax; \
67 pushl %edi; \
68 call hot_patch_kernel_text; \
69 addl $12, %esp; \
|