1 1.9 maxv /* $NetBSD: asm.h,v 1.9 2020/08/02 06:58:16 maxv Exp $ */ 2 1.1 matt 3 1.1 matt #ifndef _AARCH64_ASM_H_ 4 1.1 matt #define _AARCH64_ASM_H_ 5 1.1 matt 6 1.7 maxv #if defined(_KERNEL_OPT) 7 1.7 maxv #include "opt_cpuoptions.h" 8 1.7 maxv #endif 9 1.7 maxv 10 1.1 matt #include <arm/asm.h> 11 1.1 matt 12 1.4 joerg #ifdef __aarch64__ 13 1.6 skrll 14 1.6 skrll #ifdef __ASSEMBLER__ 15 1.6 skrll .macro adrl reg, addr 16 1.6 skrll adrp \reg, \addr 17 1.6 skrll add \reg, \reg, #:lo12:\addr 18 1.6 skrll .endm 19 1.6 skrll #endif 20 1.6 skrll 21 1.3 christos #define fp x29 22 1.3 christos #define lr x30 23 1.5 ryo 24 1.5 ryo /* 25 1.5 ryo * Add a speculation barrier after the 'eret'. 26 1.5 ryo * Some aarch64 cpus speculatively execute instructions after 'eret', 27 1.5 ryo * and this potentiates side-channel attacks. 28 1.5 ryo */ 29 1.5 ryo #define ERET \ 30 1.5 ryo eret; dsb sy; isb 31 1.5 ryo 32 1.7 maxv /* 33 1.7 maxv * ARMv8 options to be made available for the compiler to use. Should be 34 1.7 maxv * inserted at the beginning of the ASM files that need them. 35 1.7 maxv * 36 1.9 maxv * The options are: 37 1.9 maxv * - PAN, needed for the compiler to recognize the PAN register. 38 1.9 maxv * - PAC, needed for the compiler to recognize the key registers. 39 1.7 maxv */ 40 1.7 maxv #ifdef ARMV83_PAC 41 1.7 maxv #define ARMV8_DEFINE_OPTIONS \ 42 1.8 ryo .arch armv8.3-a 43 1.9 maxv #elif defined(ARMV81_PAN) 44 1.9 maxv #define ARMV8_DEFINE_OPTIONS \ 45 1.9 maxv .arch armv8.1-a 46 1.7 maxv #else 47 1.7 maxv #define ARMV8_DEFINE_OPTIONS /* nothing */ 48 1.7 maxv #endif 49 1.7 maxv 50 1.4 joerg #endif 51 1.3 christos 52 1.1 matt #endif /* !_AARCH64_ASM_H_ */ 53