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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#define _ASM 28#define _LOCORE 29 30#include <sys/cpuvar_defs.h> 31#include <sys/dtrace.h> 32#include <sys/elf_common.h> 33 34#include <machine/armreg.h> 35#include <machine/asm.h> 36 37#include "assym.inc" 38 39/* 40void dtrace_membar_producer(void) 41*/ 42ENTRY(dtrace_membar_producer) 43 RET 44END(dtrace_membar_producer) 45 46/* 47void dtrace_membar_consumer(void) 48*/ 49ENTRY(dtrace_membar_consumer) 50 RET 51END(dtrace_membar_consumer) 52 53/* 54dtrace_icookie_t dtrace_interrupt_disable(void) 55*/ 56ENTRY(dtrace_interrupt_disable) 57 mrs x0, daif 58 msr daifset, #2 59 RET 60END(dtrace_interrupt_disable) 61 62/* 63void dtrace_interrupt_enable(dtrace_icookie_t cookie) 64*/ 65ENTRY(dtrace_interrupt_enable) 66 msr daif, x0 67 RET 68END(dtrace_interrupt_enable) 69/* 70uint8_t 71dtrace_fuword8_nocheck(void *addr) 72*/ 73ENTRY(dtrace_fuword8_nocheck) 74 ldtrb w0, [x0] 75 RET 76END(dtrace_fuword8_nocheck) 77 78/* 79uint16_t 80dtrace_fuword16_nocheck(void *addr) 81*/ 82ENTRY(dtrace_fuword16_nocheck) 83 ldtrh w0, [x0] 84 RET 85END(dtrace_fuword16_nocheck) 86 87/* 88uint32_t 89dtrace_fuword32_nocheck(void *addr) 90*/ 91ENTRY(dtrace_fuword32_nocheck) 92 ldtr w0, [x0] 93 RET 94END(dtrace_fuword32_nocheck) 95 96/* 97uint64_t 98dtrace_fuword64_nocheck(void *addr) 99*/ 100ENTRY(dtrace_fuword64_nocheck) 101 ldtr x0, [x0] 102 RET 103END(dtrace_fuword64_nocheck) 104 105/* 106void 107dtrace_copyin_pan(uintptr_t uaddr, uintptr_t kaddr, size_t size) 108*/ 109ENTRY(dtrace_copyin_pan) 110 cbz x2, 2f /* If len == 0 then skip loop */ 1111: 112 mvn x4, xzr /* Set all bits */ 113 ldtrb w4, [x0] /* Load from uaddr or raise data abort */ 114 add x0, x0, #1 115 lsr x3, x4, #32 /* Extract zero-extended high bits */ 116 cbnz x3, 2f /* If high bits != 0 then break */ 117 strb w4, [x1], #1 /* Store in kaddr */ 118 sub x2, x2, #1 /* len-- */ 119 cbnz x2, 1b 1202: 121 RET 122END(dtrace_copyin_pan) 123 124/* 125void 126dtrace_copyinstr_pan(uintptr_t uaddr, uintptr_t kaddr, size_t size) 127*/ 128ENTRY(dtrace_copyinstr_pan) 129 cbz x2, 2f /* If len == 0 then skip loop */ 1301: 131 mvn x4, xzr /* Set all bits */ 132 ldtrb w4, [x0] /* Load from uaddr or raise data abort */ 133 add x0, x0, #1 134 lsr x3, x4, #32 /* Extract zero-extended high bits */ 135 cbnz x3, 2f /* If high bits != 0 then break */ 136 strb w4, [x1], #1 /* Store in kaddr */ 137 cbz w4, 2f /* If == 0 then break */ 138 sub x2, x2, #1 /* len-- */ 139 cbnz x2, 1b 1402: 141 RET 142END(dtrace_copyinstr_pan) 143 144/* 145void 146dtrace_copyout_pan(uintptr_t kaddr, uintptr_t uaddr, size_t size, 147 volatile uint16_t *flags) 148*/ 149ENTRY(dtrace_copyout_pan) 150 cbz x2, 4f /* If len == 0 then skip loop */ 151 ldrb w4, [x0], #1 /* Load from kaddr */ 152 sttrb w4, [x1] /* Store in uaddr or raise data abort */ 153 b 2f /* Check fault */ 1541: 155 ldrb w4, [x0], #1 /* Load from kaddr */ 156 sttrb w4, [x1] /* Store in uaddr or raise data abort */ 157 tst x1, #0xfff /* uaddr & 2^12-1 */ 158 bne 3f /* If not 4k aligned then skip check */ 1592: 160 ldrh w5, [x3] /* Load cpu flags */ 161 tst w5, #CPU_DTRACE_BADADDR 162 bne 4f /* If flags&CPU_DTRACE_BADADDR != 0 then break */ 1633: 164 add x1, x1, #1 /* uaddr++ */ 165 sub x2, x2, #1 /* len-- */ 166 cbnz x2, 1b 1674: 168 RET 169END(dtrace_copyout_pan) 170 171 172/* 173void 174dtrace_copyoutstr_pan(uintptr_t kaddr, uintptr_t uaddr, size_t size, 175 volatile uint16_t *flags) 176*/ 177ENTRY(dtrace_copyoutstr_pan) 178 cbz x2, 4f /* If len == 0 then skip loop */ 179 ldrb w4, [x0], #1 /* Load from kaddr */ 180 sttrb w4, [x1] /* Store in uaddr or raise data abort */ 181 b 2f /* Check fault */ 1821: 183 ldrb w4, [x0], #1 /* Load from kaddr */ 184 sttrb w4, [x1] /* Store in uaddr or raise data abort */ 185 tst x1, #0xfff /* uaddr & 2^12-1 */ 186 bne 3f /* If not 4k aligned then skip check */ 1872: 188 ldrh w5, [x3] /* Load cpu flags */ 189 tst w5, #CPU_DTRACE_BADADDR 190 bne 4f /* If flags&CPU_DTRACE_BADADDR != 0 then break */ 1913: 192 cbz w4, 4f /* If == 0 then break */ 193 add x1, x1, #1 /* uaddr++ */ 194 sub x2, x2, #1 /* len-- */ 195 cbnz x2, 1b 1964: 197 RET 198END(dtrace_copyoutstr_pan) 199 200/* 201uintptr_t 202dtrace_caller(int aframes) 203*/ 204ENTRY(dtrace_caller) 205 mov x0, #-1 206 RET 207END(dtrace_caller) 208 209/* 210uint32_t 211dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new) 212*/ 213ENTRY(dtrace_cas32) 2141: ldxr w3, [x0] /* Load target */ 215 cmp w3, w1 /* Check if *target == cmp */ 216 bne 2f /* No, return */ 217 stxr w12, w2, [x0] /* Store new to target */ 218 cbnz w12, 1b /* Try again if store not succeed */ 2192: mov w0, w3 /* Return the value loaded from target */ 220 RET 221END(dtrace_cas32) 222 223/* 224void * 225dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new) 226*/ 227ENTRY(dtrace_casptr) 2281: ldxr x3, [x0] /* Load target */ 229 cmp x3, x1 /* Check if *target == cmp */ 230 bne 2f /* No, return */ 231 stxr w12, x2, [x0] /* Store new to target */ 232 cbnz w12, 1b /* Try again if store not succeed */ 2332: mov x0, x3 /* Return the value loaded from target */ 234 RET 235END(dtrace_casptr) 236 237GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) 238