Skip to content

Commit

Permalink
Changes for ARM64
Browse files Browse the repository at this point in the history
  • Loading branch information
fergofrog committed Jul 7, 2018
1 parent c417375 commit 3f9807a
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 14 deletions.
2 changes: 1 addition & 1 deletion EXTERNAL_HEADERS/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ INSTALL_MI_LIST =

INSTALL_MI_DIR = .

INSTALL_KF_MI_LIST = ${KERNEL_FILES}
INSTALL_KF_MI_LIST = ${EXPORT_FILES} ${KERNEL_FILES}

INSTALL_KF_MI_LCL_LIST = ${KERNEL_FILES}

Expand Down
1 change: 1 addition & 0 deletions SETUP/kextsymboltool/kextsymboltool.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ lookup_arch(const char *archstring)
static const NXArchInfo archlist[] = {
{ "x86_64", 0x01000007 /* CPU_TYPE_X86_64 */, 3 /* CPU_SUBTYPE_X86_64_ALL */, NX_LittleEndian, NULL },
{ "x86_64h", 0x01000007 /* CPU_TYPE_X86_64 */, 8 /* CPU_SUBTYPE_X86_64_H */, NX_LittleEndian, NULL },
{ "arm64", 0x0100000c /* CPU_TYPE_ARM64 */, 0 /* CPU_SUBTYPE_ARM64_ALL */, NX_LittleEndian, NULL },
};
unsigned long i;

Expand Down
4 changes: 1 addition & 3 deletions bsd/dev/arm/kern_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ grade_binary(cpu_type_t exectype, cpu_subtype_t execsubtype)
return 8;
}
break;


break;
}
#else /* __arm64__ */

case CPU_TYPE_ARM:
Expand Down
1 change: 1 addition & 0 deletions libkern/conf/files.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

12 changes: 6 additions & 6 deletions makedefs/MakeInc.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ SUPPORTED_SIMULATOR_PLATFORMS := iPhoneSimulator iPhoneNanoSimulator tvSimulator
SUPPORTED_PLATFORMS := MacOSX $(SUPPORTED_SIMULATOR_PLATFORMS) $(SUPPORTED_EMBEDDED_PLATFORMS)

# Platform-specific tools
ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
ifeq ($(EMBEDDED_DEVICE_MAP),)
export EMBEDDED_DEVICE_MAP := $(shell $(XCRUN) -sdk $(SDKROOT) -find embedded_device_map)
endif
EDM_DBPATH ?= $(PLATFORMPATH)/usr/local/standalone/firmware/device_map.db
endif
#ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
#ifeq ($(EMBEDDED_DEVICE_MAP),)
# export EMBEDDED_DEVICE_MAP := $(shell $(XCRUN) -sdk $(SDKROOT) -find embedded_device_map)
#endif
#EDM_DBPATH ?= $(PLATFORMPATH)/usr/local/standalone/firmware/device_map.db
#endif

# Scripts or tools we build ourselves
#
Expand Down
55 changes: 52 additions & 3 deletions makedefs/MakeInc.def
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# Architecture Configuration options
#
SUPPORTED_ARCH_CONFIGS := X86_64 X86_64H
SUPPORTED_ARCH_CONFIGS := X86_64 X86_64H ARM64

#
# Kernel Configuration options
Expand All @@ -22,6 +22,7 @@ SUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE KASAN

SUPPORTED_X86_64_MACHINE_CONFIGS = NONE
SUPPORTED_X86_64H_MACHINE_CONFIGS = NONE
SUPPORTED_ARM64_MACHINE_CONFIGS = NONE


#
Expand Down Expand Up @@ -149,7 +150,8 @@ WARNFLAGS_STD := \
-Wno-used-but-marked-unused \
-Wno-variadic-macros \
-Wno-vla \
-Wno-zero-length-array
-Wno-zero-length-array \
-Wno-zero-as-null-pointer-constant

CWARNFLAGS_STD = \
$(WARNFLAGS_STD) \
Expand Down Expand Up @@ -188,7 +190,7 @@ endef

ARCH_FLAGS_X86_64 = -arch x86_64
ARCH_FLAGS_X86_64H = -arch x86_64h

ARCH_FLAGS_ARM64 = -arch arm64


#
Expand Down Expand Up @@ -228,6 +230,8 @@ CFLAGS_X86_64 = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \

CFLAGS_X86_64H = $(CFLAGS_X86_64)

CFLAGS_ARM64 = -Darm64 -DARM64 -D__arm64__ -D__ARM64__ -DLP64 \
-DCONFIG_EMBEDDED -mkernel -DARM64_BOARD_CONFIG_T8011=1

CFLAGS_RELEASEX86_64 = -O2
CFLAGS_DEVELOPMENTX86_64 = -O2
Expand All @@ -248,6 +252,12 @@ CFLAGS_DEVELOPMENTARM = -O2
CFLAGS_DEBUGARM = -O0
CFLAGS_PROFILEARM = -O2

CFLAGS_RELEASEARM64 = -O2
CFLAGS_DEVELOPMENTARM64 = -O2
CFLAGS_KASANARM64 = $(CFLAGS_DEVELOPMENTARM64)
# No space optimization for the DEBUG kernel for the benefit of gdb:
CFLAGS_DEBUGARM64 = -O0
CFLAGS_PROFILEARM64 = -O2


#
Expand All @@ -264,6 +274,7 @@ ifeq ($(KASAN),1)
BUILD_LTO = 0
KASAN_SHIFT_X86_64=0xdffffe1000000000
KASAN_SHIFT_X86_64H=$(KASAN_SHIFT_X86_64)
KASAN_SHIFT_ARM64=$(KASAN_SHIFT_ARM64)
KASAN_SHIFT=$($(addsuffix $(CURRENT_ARCH_CONFIG),KASAN_SHIFT_))
KASAN_BLACKLIST=$(OBJROOT)/san/kasan-blacklist-$(CURRENT_ARCH_CONFIG_LC)
CFLAGS_GEN += -DKASAN=1 -DKASAN_SHIFT=$(KASAN_SHIFT) -fsanitize=address \
Expand Down Expand Up @@ -314,6 +325,7 @@ SFLAGS_PROFILE =

SFLAGS_X86_64 = $(CFLAGS_X86_64)
SFLAGS_X86_64H = $(CFLAGS_X86_64H)
SFLAGS_ARM64 = $(CFLAGS_ARM64)

SFLAGS = $(SFLAGS_GEN) \
$($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \
Expand Down Expand Up @@ -412,6 +424,7 @@ endif
# Define KERNEL_BASE_OFFSET so known at compile time:
CFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
CFLAGS_X86_64H += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
CFLAGS_ARM64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)

LDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
LDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
Expand All @@ -424,6 +437,41 @@ LDFLAGS_KERNEL_DEVELOPMENTX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H)
LDFLAGS_KERNEL_KASANX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H)
LDFLAGS_KERNEL_PROFILEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H)

LDFLAGS_KERNEL_RELEASEARM64 = \
-Wl,-pie \
-Wl,-static \
-Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \
-Wl,-image_base,$(KERNEL_TEXT_BASE) \
-Wl,-seg_page_size,__TEXT,0x200000 \
-Wl,-sectalign,__HIB,__bootPT,0x1000 \
-Wl,-sectalign,__HIB,__desc,0x1000 \
-Wl,-sectalign,__HIB,__data,0x1000 \
-Wl,-sectalign,__HIB,__text,0x1000 \
-Wl,-sectalign,__HIB,__const,0x1000 \
-Wl,-sectalign,__HIB,__bss,0x1000 \
-Wl,-sectalign,__HIB,__common,0x1000 \
-Wl,-sectalign,__HIB,__llvm_prf_cnts,0x1000 \
-Wl,-sectalign,__HIB,__llvm_prf_names,0x1000 \
-Wl,-sectalign,__HIB,__llvm_prf_data,0x1000 \
-Wl,-sectalign,__HIB,__textcoal_nt,0x1000 \
-Wl,-rename_section,__DATA,__const,__CONST,__constdata \
-Wl,-no_zero_fill_sections \
$(LDFLAGS_NOSTRIP_FLAG)

ifeq ($(KASAN),1)
LDFLAGS_KERNEL_RELEASEARM64 += \
-Wl,-sectalign,__HIB,__cstring,0x1000 \
-Wl,-sectalign,__HIB,__asan_globals,0x1000 \
-Wl,-sectalign,__HIB,__asan_liveness,0x1000 \
-Wl,-sectalign,__HIB,__mod_term_func,0x1000 \
-Wl,-rename_section,__HIB,__mod_init_func,__NULL,__mod_init_func \
-Wl,-rename_section,__HIB,__eh_frame,__NULL,__eh_frame
endif

LDFLAGS_KERNEL_DEBUGARM64 = $(LDFLAGS_KERNEL_RELEASEARM64)
LDFLAGS_KERNEL_DEVELOPMENTARM64 = $(LDFLAGS_KERNEL_RELEASEARM64)
LDFLAGS_KERNEL_KASANARM64 = $(LDFLAGS_KERNEL_RELEASEARM64)
LDFLAGS_KERNEL_PROFILEARM64 = $(LDFLAGS_KERNEL_RELEASEARM64)

LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \
$(LDFLAGS_KERNEL_SDK) \
Expand Down Expand Up @@ -616,6 +664,7 @@ DSYMUTIL_FLAGS_GEN = --minimize

DSYMUTIL_FLAGS_X86_64 = --arch=x86_64
DSYMUTIL_FLAGS_X86_64H = --arch=x86_64h
DSYMUTIL_FLAGS_ARM64 = --arch=arm64

DSYMUTIL_FLAGS = $(DSYMUTIL_FLAGS_GEN) \
$($(addsuffix $(CURRENT_ARCH_CONFIG),DSYMUTIL_FLAGS_))
Expand Down
1 change: 1 addition & 0 deletions makedefs/MakeInc.top
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ endif
override DEFAULT_I386_MACHINE_CONFIG := NONE
override DEFAULT_X86_64_MACHINE_CONFIG := NONE
override DEFAULT_X86_64H_MACHINE_CONFIG := NONE
override DEFAULT_ARM64_MACHINE_CONFIG := NONE


# This is typically never specified (TARGET_CONFIGS is used)
Expand Down
17 changes: 17 additions & 0 deletions osfmk/chud/arm/chud_osfmk_callback_arm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <chud/chud_xnu_private.h>

__private_extern__ void
chudxnu_cpu_signal_handler(void)
{
}

void *
chudxnu_cpu_alloc(boolean_t boot_processor)
{
return NULL;
}

void
chudxnu_cpu_free(void *cp)
{
}
12 changes: 12 additions & 0 deletions osfmk/chud/arm/chud_thread_arm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <mach/mach_types.h>
#include <chud/chud_xnu.h>

__private_extern__
kern_return_t chudxnu_thread_get_callstack64_kperf(
thread_t thread,
uint64_t *callstack,
mach_msg_type_number_t *count,
boolean_t is_user)
{
return KERN_SUCCESS;
}
6 changes: 6 additions & 0 deletions osfmk/chud/arm/chud_xnu_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _ARM64_CHUD_XNU_PRIVATE_H_
#define _ARM64_CHUD_XNU_PRIVATE_H_

extern void chudxnu_cpu_signal_handler(void);

#endif /* _ARM64_CHUD_XNU_PRIVATE_H_ */
3 changes: 3 additions & 0 deletions osfmk/conf/files.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,6 @@ osfmk/corecrypto/ccn/src/ccn_set.c standard

osfmk/arm64/pgtrace.c standard
osfmk/arm64/pgtrace_decoder.c optional config_pgtrace_nonkext

osfmk/chud/arm/chud_osfmk_callback_arm.c standard
osfmk/chud/arm/chud_thread_arm.c standard
1 change: 1 addition & 0 deletions pexpert/pexpert/arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include $(MakeInc_def)

DATAFILES = \
AIC.h \
AMCC.h \
arm64_common.h \
board_config.h \
boot.h \
Expand Down
2 changes: 1 addition & 1 deletion san/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $(OBJROOT)/san/kasan-blacklist-%: $(SOURCE)/kasan-blacklist $(SOURCE)/kasan-blac
@echo "$(ColorH)GENERATING$(Color0) $(ColorLF)$(notdir $@)$(Color0)"
$(_v)sed -e 's,^src:\./,src:'"$(SRCROOT)/," $^ > $@

do_build_setup:: $(OBJROOT)/san/kasan-blacklist-x86_64
do_build_setup:: $(OBJROOT)/san/kasan-blacklist-$(CURRENT_ARCH_CONFIG_LC)


#
Expand Down
7 changes: 7 additions & 0 deletions san/conf/Makefile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
######################################################################
#BEGIN Machine dependent Makefile fragment for arm64
######################################################################

######################################################################
#END Machine dependent Makefile fragment for arm64
######################################################################
5 changes: 5 additions & 0 deletions san/conf/files.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# options

# KASAN
san/kasan-arm64.c standard
san/kasan-test-arm64.s standard

0 comments on commit 3f9807a

Please sign in to comment.