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