Skip to content

Commit

Permalink
xnu-1228.9.59
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Jun 4, 2017
1 parent e6b06a0 commit 2b9d4bc
Show file tree
Hide file tree
Showing 256 changed files with 7,323 additions and 3,871 deletions.
29 changes: 27 additions & 2 deletions EXTERNAL_HEADERS/mach-o/loader.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
Expand Down Expand Up @@ -192,6 +192,10 @@ struct mach_header_64 {
the static linker does not need to
examine dependent dylibs to see
if any are re-exported */
#define MH_PIE 0x200000 /* When this bit is set, the OS will
load the main executable at a
random address. Only used in
MH_EXECUTE filetypes. */

/*
* The load commands directly follow the mach_header. The total size of all
Expand Down Expand Up @@ -266,6 +270,8 @@ struct load_command {
#define LC_CODE_SIGNATURE 0x1d /* local of code signature */
#define LC_SEGMENT_SPLIT_INFO 0x1e /* local of info to split segments */
#define LC_REEXPORT_DYLIB (0x1f | LC_REQ_DYLD) /* load and re-export dylib */
#define LC_LAZY_LOAD_DYLIB 0x20 /* delay load of dylib until first use */
#define LC_ENCRYPTION_INFO 0x21 /* encrypted segment information */

/*
* A variable length string in a load command is represented by an lc_str
Expand Down Expand Up @@ -448,7 +454,13 @@ struct section_64 { /* for 64-bit architectures */
#define S_INTERPOSING 0xd /* section with only pairs of
function pointers for
interposing */
#define S_16BYTE_LITERALS 0xe /* section with only 16 byte literals */
#define S_16BYTE_LITERALS 0xe /* section with only 16 byte
literals */
#define S_DTRACE_DOF 0xf /* section contains
DTrace Object Format */
#define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10 /* section with only lazy
symbol pointers to lazy
loaded dylibs */
/*
* Constants for the section attributes part of the flags field of a section
* structure.
Expand Down Expand Up @@ -1107,6 +1119,19 @@ struct linkedit_data_command {
uint32_t datasize; /* file size of data in __LINKEDIT segment */
};

/*
* The encryption_info_command contains the file offset and size of an
* of an encrypted segment.
*/
struct encryption_info_command {
uint32_t cmd; /* LC_ENCRYPTION_INFO */
uint32_t cmdsize; /* sizeof(struct encryption_info_command) */
uint32_t cryptoff; /* file offset of encrypted range */
uint32_t cryptsize; /* file size of encrypted range */
uint32_t cryptid; /* which enryption system,
0 means not-encrypted yet */
};

/*
* The symseg_command contains the offset and size of the GNU style
* symbol table information as described in the header file <symseg.h>.
Expand Down
18 changes: 9 additions & 9 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ A. How to build XNU:

By default, architecture defaults to the build machine
architecture, and the kernel configuration is set to build for DEVELOPMENT.
The machine configuration defaults to S5L8900XRB for arm and default for i386 and ppc.
The machine configuration defaults to S5L8900X for arm and default for i386 and ppc.

This will also create a bootable image, mach_kernel, and a kernel binary
with symbols, mach_kernel.sys.

Examples:
/* make a debug kernel for H1 arm board */
make TARGET_CONFIGS="debug arm s5l8900xrb"
make TARGET_CONFIGS="debug arm s5l8900x"

$(OBJROOT)/DEBUG_ARM_S5L8900XRB/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEBUG_ARM_S5L8900XRB/mach_kernel: bootable image
$(OBJROOT)/DEBUG_ARM_S5L8900X/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEBUG_ARM_S5L8900X/mach_kernel: bootable image

/* make debug and development kernels for H1 arm board */
make TARGET_CONFIGS="debug arm s5l8900xrb development arm s5l8900xrb"
make TARGET_CONFIGS="debug arm s5l8900x development arm s5l8900x"

$(OBJROOT)/DEBUG_ARM_S5L8900XRB/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEBUG_ARM_S5L8900XRB/mach_kernel: bootable image
$(OBJROOT)/DEVELOPMENT_ARM/osfmk/DEVELOPMENT/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEVELOPMENT_ARM/mach_kernel: bootable image
$(OBJROOT)/DEBUG_ARM_S5L8900X/osfmk/DEBUG/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEBUG_ARM_S5L8900X/mach_kernel: bootable image
$(OBJROOT)/DEVELOPMENT_ARM_S5L8900X/osfmk/DEVELOPMENT/osfmk.o: pre-linked object for osfmk component
$(OBJROOT)/DEVELOPMENT_ARM_S5L8900X/mach_kernel: bootable image

/* this is all you need to do to build H1 arm with DEVELOPMENT kernel configuration */
make TARGET_CONFIGS="default arm default"
Expand Down
17 changes: 16 additions & 1 deletion bsd/conf/MASTER
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ options CONFIG_SOWUPCALL # SB_UPCALL on sowwakeup # <config_sowupcall>
options CONFIG_FORCE_OUT_IFP # Force IP output to use an interface # <config_force_out_ifp>
options CONFIG_MBUF_NOEXPAND # limit mbuf expansion # <config_mbuf_noexpand>
options CONFIG_MBUF_JUMBO # jumbo cluster pool # <config_mbuf_jumbo>
options CONFIG_IP_EDGEHOLE # Drop tagged packets at EDGE interface # <config_ip_edgehole>

options CONFIG_WORKQUEUE # <config_workqueue>

#
# 4.4 filesystems
Expand Down Expand Up @@ -278,7 +281,7 @@ options CONFIG_VNODES=263168 # <large,xlarge>
options CONFIG_VNODES=263168 # <medium>
options CONFIG_VNODES=10240 # <small>
options CONFIG_VNODES=1024 # <xsmall>
options CONFIG_VNODES=512 # <bsmall>
options CONFIG_VNODES=640 # <bsmall>

options CONFIG_VNODE_FREE_MIN=500 # <large,xlarge>
options CONFIG_VNODE_FREE_MIN=300 # <medium>
Expand Down Expand Up @@ -324,6 +327,11 @@ options CONFIG_NMBCLUSTERS="((1024 * 1024) / MCLBYTES)" # <large,xlarge>
options CONFIG_NMBCLUSTERS="((1024 * 512) / MCLBYTES)" # <medium>
options CONFIG_NMBCLUSTERS="((1024 * 256) / MCLBYTES)" # <bsmall,xsmall,small>

# set maximum space used for packet buffers
#
options CONFIG_USESOCKTHRESHOLD=1 # <large,xlarge,medium>
options CONFIG_USESOCKTHRESHOLD=0 # <bsmall,xsmall,small>

#
# Configure size of TCP hash table
#
Expand Down Expand Up @@ -388,6 +396,13 @@ options CONFIG_NO_KPRINTF_STRINGS # <no_kprintf_str>
#
options CONFIG_EMBEDDED # <config_embedded>

#
# code decryption... used on embedded for app protection
# must be set in all the bsd/conf and osfmk/conf MASTER files
#
options CONFIG_CODE_DECRYPTION # <config_embedded>


#
# Ethernet (ARP)
#
Expand Down
10 changes: 8 additions & 2 deletions bsd/conf/MASTER.i386
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#
# Standard Apple Research Configurations:
# -------- ----- -------- ---------------
# BASE = [ intel mach medium config_dtrace vol pst gdb kernobjc fixpri simple_clock mdebug kernserv driverkit uxpr kernstack ipc_compat ipc_debug compat_43_tty sysv_sem sysv_msg sysv_shm audit panic_info config_imageboot ]
# BASE = [ intel mach medium config_dtrace vol pst gdb kernobjc fixpri simple_clock mdebug kernserv driverkit uxpr kernstack ipc_compat ipc_debug compat_43_tty sysv_sem sysv_msg sysv_shm audit panic_info config_imageboot config_workqueue ]
# FILESYS = [ devfs revfs hfs journaling fdesc config_fse quota namedstreams fifo ffs union cd9660 config_volfs ]
# NETWORKING = [ inet inet6 compat_oldsock mrouting tcpdrop_synfin bpfilter ipdivert netat ipfirewall ipv6firewall ipfw2 dummynet traffic_mgt sendfile netmibs bond vlan gif stf zlib randomipid ifnet_input_chk config_mbuf_jumbo ]
# NFS = [ nfsclient nfsserver ]
Expand All @@ -53,7 +53,7 @@
# PROFILE = [ RELEASE profile ]
# DEBUG = [ BASE NETWORKING NFS VPN FILESYS libdriver_g debug xpr_debug mach_assert ]
#
# EMBEDDED_BASE = [ intel mach bsmall vol pst gdb kernobjc fixpri simple_clock mdebug kernserv driverkit uxpr kernstack ipc_compat ipc_debug compat_43_tty sysv_sem sysv_msg sysv_shm audit panic_info config_imageboot ]
# EMBEDDED_BASE = [ intel mach bsmall vol pst gdb kernobjc fixpri simple_clock mdebug kernserv driverkit uxpr kernstack ipc_compat ipc_debug compat_43_tty sysv_sem sysv_msg sysv_shm audit panic_info config_imageboot config_workqueue ]
# EMBEDDED_FILESYS = [ devfs hfs journaling fdesc fifo ]
# EMBEDDED_NET = [ inet compat_oldsock mrouting tcpdrop_synfin bpfilter config_mbuf_noexpand ]
# EMBEDDED = [ EMBEDDED_BASE EMBEDDED_NET VPN EMBEDDED_FILESYS libdriver no_printf_str no_kprintf_str no_kdebug ]
Expand Down Expand Up @@ -92,6 +92,12 @@ options CONFIG_MACF_SOCKET_SUBSET # MAC socket subest (no labels)
# app-profiling i.e. pre-heating - off?
options CONFIG_APP_PROFILE=0

#
# code decryption... used on i386 for DSMOS
# must be set in all the bsd/conf and osfmk/conf MASTER files
#
options CONFIG_CODE_DECRYPTION

#
# Ipl measurement system
#
Expand Down
2 changes: 1 addition & 1 deletion bsd/conf/MASTER.ppc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
# Standard Apple Research Configurations:
# -------- ----- -------- ---------------
#
# BASE = [ ppc mach medium config_dtrace vol pst gdb noprofiling simple_clock kernstack compat_43_tty sysv_sem sysv_msg sysv_shm audit panic_info config_imageboot ]
# BASE = [ ppc mach medium config_dtrace vol pst gdb noprofiling simple_clock kernstack compat_43_tty sysv_sem sysv_msg sysv_shm audit panic_info config_imageboot config_workqueue ]
# FILESYS = [ devfs revfs hfs journaling fdesc config_fse quota namedstreams fifo ffs union cd9660 config_volfs ]
# NETWORKING = [ inet inet6 compat_oldsock mrouting tcpdrop_synfin bpfilter ipdivert netat ipfirewall ipv6firewall ipfw2 dummynet traffic_mgt sendfile netmibs bond vlan gif stf zlib randomipid ifnet_input_chk ]
# NFS = [ nfsclient nfsserver ]
Expand Down
2 changes: 2 additions & 0 deletions bsd/conf/files
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
OPTIONS/hw_ast optional hw_ast
OPTIONS/hw_footprint optional hw_footprint
OPTIONS/kernserv optional kernserv
OPTIONS/config_ip_edgehole optional config_ip_edgehole
OPTIONS/config_macf optional config_macf
OPTIONS/config_macf_socket_subset optional config_macf_socket_subset
OPTIONS/config_macf_socket optional config_macf_socket
Expand Down Expand Up @@ -262,6 +263,7 @@ bsd/netinet/ip_id.c optional randomipid inet
bsd/netinet/ip_input.c optional inet
bsd/netinet/ip_mroute.c optional mrouting
bsd/netinet/ip_output.c optional inet
bsd/netinet/ip_edgehole.c optional config_ip_edgehole
bsd/netinet/raw_ip.c optional inet
bsd/netinet/tcp_debug.c optional tcpdebug
bsd/netinet/tcp_input.c optional inet
Expand Down
2 changes: 1 addition & 1 deletion bsd/dev/dtrace/dtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -16549,7 +16549,7 @@ dtrace_init( void )
* XXX Warn if state is LAZY_OFF? It won't break anything, but
* makes no sense...
*/
if (!PE_parse_boot_arg("dtrace_dof_mode", &dtrace_dof_mode)) {
if (!PE_parse_boot_argn("dtrace_dof_mode", &dtrace_dof_mode, sizeof (dtrace_dof_mode))) {
dtrace_dof_mode = DTRACE_DOF_MODE_LAZY_ON;
}

Expand Down
2 changes: 1 addition & 1 deletion bsd/dev/dtrace/fbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void
fbt_init( void )
{

PE_parse_boot_arg("DisableFBT", &gDisableFBT);
PE_parse_boot_argn("DisableFBT", &gDisableFBT, sizeof (gDisableFBT));

if (0 == gDisableFBT)
{
Expand Down
8 changes: 1 addition & 7 deletions bsd/dev/i386/fbt_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ static const char * critical_blacklist[] =
"pmap_cpu_high_map_vaddr",
"pmap_cpu_high_shared_remap",
"pmap_cpu_init",
"rdHPET",
"register_cpu_setup_func",
"unregister_cpu_setup_func"
};
Expand Down Expand Up @@ -405,7 +404,7 @@ __fbt_provide_module(void *arg, struct modctl *ctl)
unsigned int i, j;

int gIgnoreFBTBlacklist = 0;
PE_parse_boot_arg("IgnoreFBTBlacklist", &gIgnoreFBTBlacklist);
PE_parse_boot_argn("IgnoreFBTBlacklist", &gIgnoreFBTBlacklist, sizeof (gIgnoreFBTBlacklist));

mh = (struct mach_header *)(ctl->address);
modname = ctl->mod_modname;
Expand Down Expand Up @@ -527,17 +526,12 @@ __fbt_provide_module(void *arg, struct modctl *ctl)
*/
if (strstr(name, "machine_stack_") == name ||
strstr(name, "mapping_") == name ||
strstr(name, "hpet_") == name ||

0 == strcmp(name, "rdHPET") ||
0 == strcmp(name, "HPETInterrupt") ||
0 == strcmp(name, "tmrCvt") ||

strstr(name, "tsc_") == name ||

strstr(name, "pmCPU") == name ||
0 == strcmp(name, "Cstate_table_set") ||
0 == strcmp(name, "pmHPETInterrupt") ||
0 == strcmp(name, "pmKextRegister") ||
0 == strcmp(name, "pmSafeMode") ||
0 == strcmp(name, "pmUnregister") ||
Expand Down
48 changes: 48 additions & 0 deletions bsd/dev/i386/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <i386/cpuid.h>
#include <i386/tsc.h>

static int
hw_cpu_sysctl SYSCTL_HANDLER_ARGS
Expand Down Expand Up @@ -166,6 +167,12 @@ SYSCTL_PROC(_machdep_cpu, OID_AUTO, cores_per_package,
sizeof(uint32_t),
hw_cpu_sysctl, "I", "CPU cores per package");

SYSCTL_PROC(_machdep_cpu, OID_AUTO, microcode_version,
CTLTYPE_INT | CTLFLAG_RD,
(void *)offsetof(i386_cpu_info_t, cpuid_microcode_version),
sizeof(uint32_t),
hw_cpu_sysctl, "I", "Microcode version number");


SYSCTL_NODE(_machdep_cpu, OID_AUTO, mwait, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
"mwait");
Expand Down Expand Up @@ -291,6 +298,34 @@ SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, size,
hw_cpu_sysctl, "I", "Cache size (in Kbytes)");


SYSCTL_NODE(_machdep_cpu, OID_AUTO, tlb, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
"tlb");

SYSCTL_PROC(_machdep_cpu_tlb, OID_AUTO, inst_small,
CTLTYPE_INT | CTLFLAG_RD,
(void *)offsetof(i386_cpu_info_t, cpuid_itlb_small),
sizeof(uint32_t),
hw_cpu_sysctl, "I", "Number of small page instruction TLBs");

SYSCTL_PROC(_machdep_cpu_tlb, OID_AUTO, data_small,
CTLTYPE_INT | CTLFLAG_RD,
(void *)offsetof(i386_cpu_info_t, cpuid_dtlb_small),
sizeof(uint32_t),
hw_cpu_sysctl, "I", "Number of small page data TLBs");

SYSCTL_PROC(_machdep_cpu_tlb, OID_AUTO, inst_large,
CTLTYPE_INT | CTLFLAG_RD,
(void *)offsetof(i386_cpu_info_t, cpuid_itlb_large),
sizeof(uint32_t),
hw_cpu_sysctl, "I", "Number of large page instruction TLBs");

SYSCTL_PROC(_machdep_cpu_tlb, OID_AUTO, data_large,
CTLTYPE_INT | CTLFLAG_RD,
(void *)offsetof(i386_cpu_info_t, cpuid_dtlb_large),
sizeof(uint32_t),
hw_cpu_sysctl, "I", "Number of large page data TLBs");


SYSCTL_NODE(_machdep_cpu, OID_AUTO, address_bits, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
"address_bits");

Expand All @@ -306,6 +341,19 @@ SYSCTL_PROC(_machdep_cpu_address_bits, OID_AUTO, virtual,
sizeof(uint32_t),
hw_cpu_sysctl, "I", "Number of virtual address bits");

SYSCTL_PROC(_machdep_cpu, OID_AUTO, core_count,
CTLTYPE_INT | CTLFLAG_RD,
(void *)offsetof(i386_cpu_info_t, core_count),
sizeof(uint32_t),
hw_cpu_sysctl, "I", "Number of enabled cores per package");

SYSCTL_PROC(_machdep_cpu, OID_AUTO, thread_count,
CTLTYPE_INT | CTLFLAG_RD,
(void *)offsetof(i386_cpu_info_t, thread_count),
sizeof(uint32_t),
hw_cpu_sysctl, "I", "Number of enabled threads per package");


uint64_t pmap_pv_hashlist_walks;
uint64_t pmap_pv_hashlist_cnts;
uint32_t pmap_pv_hashlist_max;
Expand Down
13 changes: 6 additions & 7 deletions bsd/dev/i386/systemcalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ extern void dtrace_systrace_syscall_return(unsigned short, int, int *);
extern void unix_syscall(x86_saved_state_t *);
extern void unix_syscall64(x86_saved_state_t *);
extern void *find_user_regs(thread_t);
extern void throttle_lowpri_io(int *lowpri_window, mount_t v_mount);

extern void x86_toggle_sysenter_arg_store(thread_t thread, boolean_t valid);
extern boolean_t x86_sysenter_arg_store_isvalid(thread_t thread);
Expand Down Expand Up @@ -223,15 +222,15 @@ unix_syscall(x86_saved_state_t *state)
*/
syscall_exit_funnelcheck();
#endif /* DEBUG */
if (uthread->uu_lowpri_window && uthread->v_mount) {
if (uthread->uu_lowpri_window) {
/*
* task is marked as a low priority I/O type
* and the I/O we issued while in this system call
* collided with normal I/O operations... we'll
* delay in order to mitigate the impact of this
* task on the normal operation of the system
*/
throttle_lowpri_io(&uthread->uu_lowpri_window,uthread->v_mount);
throttle_lowpri_io(TRUE);
}
if (code != 180)
KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_END,
Expand Down Expand Up @@ -398,15 +397,15 @@ unix_syscall64(x86_saved_state_t *state)
*/
syscall_exit_funnelcheck();

if (uthread->uu_lowpri_window && uthread->v_mount) {
if (uthread->uu_lowpri_window) {
/*
* task is marked as a low priority I/O type
* and the I/O we issued while in this system call
* collided with normal I/O operations... we'll
* delay in order to mitigate the impact of this
* task on the normal operation of the system
*/
throttle_lowpri_io(&uthread->uu_lowpri_window,uthread->v_mount);
throttle_lowpri_io(TRUE);
}
if (code != 180)
KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_END,
Expand Down Expand Up @@ -533,15 +532,15 @@ unix_syscall_return(int error)
*/
syscall_exit_funnelcheck();

if (uthread->uu_lowpri_window && uthread->v_mount) {
if (uthread->uu_lowpri_window) {
/*
* task is marked as a low priority I/O type
* and the I/O we issued while in this system call
* collided with normal I/O operations... we'll
* delay in order to mitigate the impact of this
* task on the normal operation of the system
*/
throttle_lowpri_io(&uthread->uu_lowpri_window,uthread->v_mount);
throttle_lowpri_io(TRUE);
}
if (code != 180)
KERNEL_DEBUG_CONSTANT(BSDDBG_CODE(DBG_BSD_EXCP_SC, code) | DBG_FUNC_END,
Expand Down
Loading

0 comments on commit 2b9d4bc

Please sign in to comment.