2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
5 * Copyright (C) 1990, NeXT, Inc.
7 * File: next/kern_machdep.c
10 * Machine-specific kernel routines.
13 #include <sys/types.h>
14 #include <mach/machine.h>
15 #include <kern/cpu_number.h>
16 #include <machine/exec.h>
19 extern int bootarg_no64exec
; /* bsd_init.c */
20 static cpu_subtype_t
cpu_subtype32(void);
21 #endif /* __arm64__ */
25 * When an arm64 CPU is executing an arm32 binary, we need to map from the
26 * host's 64-bit subtype to the appropriate 32-bit subtype.
31 switch (cpu_subtype()) {
32 case CPU_SUBTYPE_ARM64_V8
:
33 return CPU_SUBTYPE_ARM_V8
;
40 /**********************************************************************
41 * Routine: grade_binary()
43 * Function: Return a relative preference for exectypes and
44 * execsubtypes in fat executable files. The higher the
45 * grade, the higher the preference. A grade of 0 means
47 **********************************************************************/
49 grade_binary(cpu_type_t exectype
, cpu_subtype_t execsubtype
)
52 cpu_subtype_t hostsubtype
= (exectype
& CPU_ARCH_ABI64
) ? cpu_subtype() : cpu_subtype32();
54 cpu_subtype_t hostsubtype
= cpu_subtype();
55 #endif /* __arm64__ */
60 if (bootarg_no64exec
) return 0;
62 switch (hostsubtype
) {
63 case CPU_SUBTYPE_ARM64_V8
:
64 switch (execsubtype
) {
65 case CPU_SUBTYPE_ARM64_V8
:
67 case CPU_SUBTYPE_ARM64_ALL
:
77 switch (hostsubtype
) {
79 * For 32-bit ARMv8, try the ARMv8 slice before falling back to Swift.
81 case CPU_SUBTYPE_ARM_V8
:
82 switch (execsubtype
) {
83 case CPU_SUBTYPE_ARM_V8
:
89 * For Swift and later, we prefer to run a swift slice, but fall back
90 * to v7 as Cortex A9 errata should not apply
93 case CPU_SUBTYPE_ARM_V7S
:
94 switch (execsubtype
) {
95 case CPU_SUBTYPE_ARM_V7S
:
101 * For Cortex A7, accept v7k only due to differing ABI
103 case CPU_SUBTYPE_ARM_V7K
:
104 switch (execsubtype
) {
105 case CPU_SUBTYPE_ARM_V7K
:
111 * For Cortex A9, we prefer the A9 slice, but will run v7 albeit
112 * under the risk of hitting the NEON load/store errata
114 case CPU_SUBTYPE_ARM_V7F
:
115 switch (execsubtype
) {
116 case CPU_SUBTYPE_ARM_V7F
:
122 case CPU_SUBTYPE_ARM_V7
:
123 switch (execsubtype
) {
124 case CPU_SUBTYPE_ARM_V7
:
129 case CPU_SUBTYPE_ARM_V6
:
130 switch (execsubtype
) {
131 case CPU_SUBTYPE_ARM_V6
:
136 case CPU_SUBTYPE_ARM_V5TEJ
:
137 switch (execsubtype
) {
138 case CPU_SUBTYPE_ARM_V5TEJ
:
143 case CPU_SUBTYPE_ARM_V4T
:
144 switch (execsubtype
) {
145 case CPU_SUBTYPE_ARM_V4T
:
147 case CPU_SUBTYPE_ARM_ALL
:
152 case CPU_SUBTYPE_ARM_XSCALE
:
153 switch (execsubtype
) {
154 case CPU_SUBTYPE_ARM_XSCALE
:
156 case CPU_SUBTYPE_ARM_V5TEJ
:
158 case CPU_SUBTYPE_ARM_V4T
:
160 case CPU_SUBTYPE_ARM_ALL
:
165 #endif /* __arm64__ */
172 pie_required(cpu_type_t exectype
, cpu_subtype_t execsubtype
)
178 #endif /* __arm64__ */
181 switch (execsubtype
) {
182 case CPU_SUBTYPE_ARM_V7K
: