1/* 2 * CDDL HEADER START 3 * 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 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25/* 26 * Copyright 2019 Joyent, Inc. 27 */ 28 29#include <sys/asm_linkage.h> 30#include <sys/regset.h> 31 32#include "assym.h" 33 34 ENTRY_NP(dtrace_getfp) 35 movq %rbp, %rax 36 ret 37 SET_SIZE(dtrace_getfp) 38 39 40 ENTRY_NP(dtrace_getvmreg) 41 42 movq %rdi, %rdx 43 vmread %rdx, %rax 44 ret 45 46 SET_SIZE(dtrace_getvmreg) 47 48 49 ENTRY(dtrace_cas32) 50 movl %esi, %eax 51 lock 52 cmpxchgl %edx, (%rdi) 53 ret 54 SET_SIZE(dtrace_cas32) 55 56 ENTRY(dtrace_casptr) 57 movq %rsi, %rax 58 lock 59 cmpxchgq %rdx, (%rdi) 60 ret 61 SET_SIZE(dtrace_casptr) 62 63 ENTRY(dtrace_caller) 64 movq $-1, %rax 65 ret 66 SET_SIZE(dtrace_caller) 67 68 ENTRY(dtrace_copy) 69 pushq %rbp 70 call smap_disable 71 movq %rsp, %rbp 72 73 xchgq %rdi, %rsi /* make %rsi source, %rdi dest */ 74 movq %rdx, %rcx /* load count */ 75 repz /* repeat for count ... */ 76 smovb /* move from %ds:rsi to %ed:rdi */ 77 call smap_enable 78 leave 79 ret 80 SET_SIZE(dtrace_copy) 81 82 ENTRY(dtrace_copystr) 83 pushq %rbp 84 movq %rsp, %rbp 85 call smap_disable 860: 87 movb (%rdi), %al /* load from source */ 88 movb %al, (%rsi) /* store to destination */ 89 addq $1, %rdi /* increment source pointer */ 90 addq $1, %rsi /* increment destination pointer */ 91 subq $1, %rdx /* decrement remaining count */ 92 cmpb $0, %al 93 je 2f 94 testq $0xfff, %rdx /* test if count is 4k-aligned */ 95 jnz 1f /* if not, continue with copying */ 96 testq $CPU_DTRACE_BADADDR, (%rcx) /* load and test dtrace flags */ 97 jnz 2f 981: 99 cmpq $0, %rdx 100 jne 0b 1012: 102 call smap_enable 103 leave 104 ret 105 106 SET_SIZE(dtrace_copystr) 107 108 ENTRY(dtrace_fulword) 109 call smap_disable 110 movq (%rdi), %rax 111 call smap_enable 112 ret 113 SET_SIZE(dtrace_fulword) 114 115 ENTRY(dtrace_fuword8_nocheck) 116 call smap_disable 117 xorq %rax, %rax 118 movb (%rdi), %al 119 call smap_enable 120 ret 121 SET_SIZE(dtrace_fuword8_nocheck) 122 123 ENTRY(dtrace_fuword16_nocheck) 124 call smap_disable 125 xorq %rax, %rax 126 movw (%rdi), %ax 127 call smap_enable 128 ret 129 SET_SIZE(dtrace_fuword16_nocheck) 130 131 ENTRY(dtrace_fuword32_nocheck) 132 call smap_disable 133 xorq %rax, %rax 134 movl (%rdi), %eax 135 call smap_enable 136 ret 137 SET_SIZE(dtrace_fuword32_nocheck) 138 139 ENTRY(dtrace_fuword64_nocheck) 140 call smap_disable 141 movq (%rdi), %rax 142 call smap_enable 143 ret 144 SET_SIZE(dtrace_fuword64_nocheck) 145 146 ENTRY(dtrace_probe_error) 147 pushq %rbp 148 movq %rsp, %rbp 149 subq $0x8, %rsp 150 movq %r9, (%rsp) 151 movq %r8, %r9 152 movq %rcx, %r8 153 movq %rdx, %rcx 154 movq %rsi, %rdx 155 movq %rdi, %rsi 156 movl dtrace_probeid_error(%rip), %edi 157 call dtrace_probe 158 addq $0x8, %rsp 159 leave 160 ret 161 SET_SIZE(dtrace_probe_error) 162 163