VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.0/crypto/arm_arch.h@ 100832

Last change on this file since 100832 was 99366, checked in by vboxsync, 23 months ago

openssl-3.1.0: Applied and adjusted our OpenSSL changes to 3.0.7. bugref:10418

File size: 6.6 KB
Line 
1/*
2 * Copyright 2011-2022 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef OSSL_CRYPTO_ARM_ARCH_H
11# define OSSL_CRYPTO_ARM_ARCH_H
12
13# if !defined(__ARM_ARCH__)
14# if defined(__CC_ARM)
15# define __ARM_ARCH__ __TARGET_ARCH_ARM
16# if defined(__BIG_ENDIAN)
17# define __ARMEB__
18# else
19# define __ARMEL__
20# endif
21# elif defined(__GNUC__)
22# if defined(__aarch64__)
23# define __ARM_ARCH__ 8
24 /*
25 * Why doesn't gcc define __ARM_ARCH__? Instead it defines
26 * bunch of below macros. See all_architectures[] table in
27 * gcc/config/arm/arm.c. On a side note it defines
28 * __ARMEL__/__ARMEB__ for little-/big-endian.
29 */
30# elif defined(__ARM_ARCH)
31# define __ARM_ARCH__ __ARM_ARCH
32# elif defined(__ARM_ARCH_8A__)
33# define __ARM_ARCH__ 8
34# elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
35 defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \
36 defined(__ARM_ARCH_7EM__)
37# define __ARM_ARCH__ 7
38# elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
39 defined(__ARM_ARCH_6K__)|| defined(__ARM_ARCH_6M__) || \
40 defined(__ARM_ARCH_6Z__)|| defined(__ARM_ARCH_6ZK__) || \
41 defined(__ARM_ARCH_6T2__)
42# define __ARM_ARCH__ 6
43# elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
44 defined(__ARM_ARCH_5E__)|| defined(__ARM_ARCH_5TE__) || \
45 defined(__ARM_ARCH_5TEJ__)
46# define __ARM_ARCH__ 5
47# elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
48# define __ARM_ARCH__ 4
49# else
50# error "unsupported ARM architecture"
51# endif
52# endif
53# endif
54
55# if !defined(__ARM_MAX_ARCH__)
56# define __ARM_MAX_ARCH__ __ARM_ARCH__
57# endif
58
59# if __ARM_MAX_ARCH__<__ARM_ARCH__
60# error "__ARM_MAX_ARCH__ can't be less than __ARM_ARCH__"
61# elif __ARM_MAX_ARCH__!=__ARM_ARCH__
62# if __ARM_ARCH__<7 && __ARM_MAX_ARCH__>=7 && defined(__ARMEB__)
63# error "can't build universal big-endian binary"
64# endif
65# endif
66
67# ifndef __ASSEMBLER__
68extern unsigned int OPENSSL_armcap_P;
69extern unsigned int OPENSSL_arm_midr;
70extern unsigned int OPENSSL_armv8_rsa_neonized;
71# endif
72
73# define ARMV7_NEON (1<<0)
74# define ARMV7_TICK (1<<1)
75# define ARMV8_AES (1<<2)
76# define ARMV8_SHA1 (1<<3)
77# define ARMV8_SHA256 (1<<4)
78# define ARMV8_PMULL (1<<5)
79# define ARMV8_SHA512 (1<<6)
80# define ARMV8_CPUID (1<<7)
81# define ARMV8_RNG (1<<8)
82# define ARMV8_SM3 (1<<9)
83# define ARMV8_SM4 (1<<10)
84# define ARMV8_SHA3 (1<<11)
85# define ARMV8_UNROLL8_EOR3 (1<<12)
86# define ARMV8_SVE (1<<13)
87# define ARMV8_SVE2 (1<<14)
88
89/*
90 * MIDR_EL1 system register
91 *
92 * 63___ _ ___32_31___ _ ___24_23_____20_19_____16_15__ _ __4_3_______0
93 * | | | | | | |
94 * |RES0 | Implementer | Variant | Arch | PartNum |Revision|
95 * |____ _ _____|_____ _ _____|_________|_______ _|____ _ ___|________|
96 *
97 */
98
99# define ARM_CPU_IMP_ARM 0x41
100
101# define ARM_CPU_PART_CORTEX_A72 0xD08
102# define ARM_CPU_PART_N1 0xD0C
103# define ARM_CPU_PART_V1 0xD40
104# define ARM_CPU_PART_N2 0xD49
105
106# define MIDR_PARTNUM_SHIFT 4
107# define MIDR_PARTNUM_MASK (0xfffU << MIDR_PARTNUM_SHIFT)
108# define MIDR_PARTNUM(midr) \
109 (((midr) & MIDR_PARTNUM_MASK) >> MIDR_PARTNUM_SHIFT)
110
111# define MIDR_IMPLEMENTER_SHIFT 24
112# define MIDR_IMPLEMENTER_MASK (0xffU << MIDR_IMPLEMENTER_SHIFT)
113# define MIDR_IMPLEMENTER(midr) \
114 (((midr) & MIDR_IMPLEMENTER_MASK) >> MIDR_IMPLEMENTER_SHIFT)
115
116# define MIDR_ARCHITECTURE_SHIFT 16
117# define MIDR_ARCHITECTURE_MASK (0xfU << MIDR_ARCHITECTURE_SHIFT)
118# define MIDR_ARCHITECTURE(midr) \
119 (((midr) & MIDR_ARCHITECTURE_MASK) >> MIDR_ARCHITECTURE_SHIFT)
120
121# define MIDR_CPU_MODEL_MASK \
122 (MIDR_IMPLEMENTER_MASK | \
123 MIDR_PARTNUM_MASK | \
124 MIDR_ARCHITECTURE_MASK)
125
126# define MIDR_CPU_MODEL(imp, partnum) \
127 (((imp) << MIDR_IMPLEMENTER_SHIFT) | \
128 (0xfU << MIDR_ARCHITECTURE_SHIFT) | \
129 ((partnum) << MIDR_PARTNUM_SHIFT))
130
131# define MIDR_IS_CPU_MODEL(midr, imp, partnum) \
132 (((midr) & MIDR_CPU_MODEL_MASK) == MIDR_CPU_MODEL(imp, partnum))
133
134#if defined(__ASSEMBLER__)
135
136 /*
137 * Support macros for
138 * - Armv8.3-A Pointer Authentication and
139 * - Armv8.5-A Branch Target Identification
140 * features which require emitting a .note.gnu.property section with the
141 * appropriate architecture-dependent feature bits set.
142 * Read more: "ELF for the Arm® 64-bit Architecture"
143 */
144
145# if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
146# define GNU_PROPERTY_AARCH64_BTI (1 << 0) /* Has Branch Target Identification */
147# define AARCH64_VALID_CALL_TARGET hint #34 /* BTI 'c' */
148# else
149# define GNU_PROPERTY_AARCH64_BTI 0 /* No Branch Target Identification */
150# define AARCH64_VALID_CALL_TARGET
151# endif
152
153# if defined(__ARM_FEATURE_PAC_DEFAULT) && \
154 (__ARM_FEATURE_PAC_DEFAULT & 1) == 1 /* Signed with A-key */
155# define GNU_PROPERTY_AARCH64_POINTER_AUTH \
156 (1 << 1) /* Has Pointer Authentication */
157# define AARCH64_SIGN_LINK_REGISTER hint #25 /* PACIASP */
158# define AARCH64_VALIDATE_LINK_REGISTER hint #29 /* AUTIASP */
159# elif defined(__ARM_FEATURE_PAC_DEFAULT) && \
160 (__ARM_FEATURE_PAC_DEFAULT & 2) == 2 /* Signed with B-key */
161# define GNU_PROPERTY_AARCH64_POINTER_AUTH \
162 (1 << 1) /* Has Pointer Authentication */
163# define AARCH64_SIGN_LINK_REGISTER hint #27 /* PACIBSP */
164# define AARCH64_VALIDATE_LINK_REGISTER hint #31 /* AUTIBSP */
165# else
166# define GNU_PROPERTY_AARCH64_POINTER_AUTH 0 /* No Pointer Authentication */
167# if GNU_PROPERTY_AARCH64_BTI != 0
168# define AARCH64_SIGN_LINK_REGISTER AARCH64_VALID_CALL_TARGET
169# else
170# define AARCH64_SIGN_LINK_REGISTER
171# endif
172# define AARCH64_VALIDATE_LINK_REGISTER
173# endif
174
175# if GNU_PROPERTY_AARCH64_POINTER_AUTH != 0 || GNU_PROPERTY_AARCH64_BTI != 0
176 .pushsection .note.gnu.property, "a";
177 .balign 8;
178 .long 4;
179 .long 0x10;
180 .long 0x5;
181 .asciz "GNU";
182 .long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
183 .long 4;
184 .long (GNU_PROPERTY_AARCH64_POINTER_AUTH | GNU_PROPERTY_AARCH64_BTI);
185 .long 0;
186 .popsection;
187# endif
188
189# endif /* defined __ASSEMBLER__ */
190
191# define IS_CPU_SUPPORT_UNROLL8_EOR3() \
192 (OPENSSL_armcap_P & ARMV8_UNROLL8_EOR3)
193
194#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette