Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.2.2.3
      1  1.2.2.2    martin /* $NetBSD: asm.h,v 1.2.2.3 2020/04/21 18:42:02 martin 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.2.2.3    martin #if defined(_KERNEL_OPT)
      7  1.2.2.3    martin #include "opt_cpuoptions.h"
      8  1.2.2.3    martin #endif
      9  1.2.2.3    martin 
     10      1.1      matt #include <arm/asm.h>
     11      1.1      matt 
     12  1.2.2.2    martin #ifdef __aarch64__
     13  1.2.2.2    martin 
     14  1.2.2.2    martin #ifdef __ASSEMBLER__
     15  1.2.2.2    martin .macro	adrl 	reg, addr
     16  1.2.2.2    martin 	adrp	\reg, \addr
     17  1.2.2.2    martin 	add	\reg, \reg, #:lo12:\addr
     18  1.2.2.2    martin .endm
     19  1.2.2.2    martin #endif
     20  1.2.2.2    martin 
     21  1.2.2.1  christos #define	fp	x29
     22  1.2.2.1  christos #define	lr	x30
     23  1.2.2.1  christos 
     24  1.2.2.2    martin /*
     25  1.2.2.2    martin  * Add a speculation barrier after the 'eret'.
     26  1.2.2.2    martin  * Some aarch64 cpus speculatively execute instructions after 'eret',
     27  1.2.2.2    martin  * and this potentiates side-channel attacks.
     28  1.2.2.2    martin  */
     29  1.2.2.2    martin #define	ERET	\
     30  1.2.2.2    martin 	eret; dsb sy; isb
     31  1.2.2.2    martin 
     32  1.2.2.3    martin /*
     33  1.2.2.3    martin  * ARMv8 options to be made available for the compiler to use. Should be
     34  1.2.2.3    martin  * inserted at the beginning of the ASM files that need them.
     35  1.2.2.3    martin  *
     36  1.2.2.3    martin  * For now the only option is PAC, needed for the compiler to recognize
     37  1.2.2.3    martin  * the key registers.
     38  1.2.2.3    martin  */
     39  1.2.2.3    martin #ifdef ARMV83_PAC
     40  1.2.2.3    martin #define ARMV8_DEFINE_OPTIONS	\
     41  1.2.2.3    martin 	.arch armv8.3-a+pac
     42  1.2.2.3    martin #else
     43  1.2.2.3    martin #define ARMV8_DEFINE_OPTIONS	/* nothing */
     44  1.2.2.3    martin #endif
     45  1.2.2.3    martin 
     46  1.2.2.2    martin #endif
     47  1.2.2.2    martin 
     48      1.1      matt #endif /* !_AARCH64_ASM_H_ */
     49