Skip to content

Commit

Permalink
xnu-4570.20.62
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Dec 10, 2018
1 parent 0a798f6 commit 3d335d2
Show file tree
Hide file tree
Showing 70 changed files with 2,440 additions and 625 deletions.
4 changes: 4 additions & 0 deletions bsd/kern/bsd_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/mman.h>
#include <sys/kasl.h>

#include <security/audit/audit.h>

Expand Down Expand Up @@ -711,6 +712,9 @@ bsd_init(void)
panic("bsd_init: Failed to allocate bsd pageable map");
}

bsd_init_kprintf("calling fpxlog_init\n");
fpxlog_init();

/*
* Initialize buffers and hash links for buffers
*
Expand Down
6 changes: 4 additions & 2 deletions bsd/kern/bsd_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

/* XXX these should be in a common header somwhere, but aren't */
extern int chrtoblk_set(int, int);
extern vm_offset_t kmem_mb_alloc(vm_map_t, int, int);
extern vm_offset_t kmem_mb_alloc(vm_map_t, int, int, kern_return_t *);

/* XXX most of these just exist to export; there's no good header for them*/
void pcb_synch(void);
Expand All @@ -58,7 +58,7 @@ lck_grp_t * devsw_lock_grp;
int dmmin, dmmax, dmtext;

vm_offset_t
kmem_mb_alloc(vm_map_t mbmap, int size, int physContig)
kmem_mb_alloc(vm_map_t mbmap, int size, int physContig, kern_return_t *err)
{
vm_offset_t addr = 0;
kern_return_t kr = KERN_SUCCESS;
Expand All @@ -70,6 +70,8 @@ kmem_mb_alloc(vm_map_t mbmap, int size, int physContig)

if (kr != KERN_SUCCESS)
addr = 0;
if (err)
*err = kr;

return addr;
}
Expand Down
7 changes: 7 additions & 0 deletions bsd/kern/kern_asl.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ kern_asl_msg_va(int level, const char *facility, int num_pairs, va_list vargs, .
/* Print the key-value pairs in ASL format */
vaddlog(fmt, vargs);

/*
* Note: can't use os_log_with_args() here because 'fmt' is
* constructed on the stack i.e. doesn't come from a text
* section. More importantly, the newer logging system
* doesn't grok ASL either.
*/

return (err);
}

Expand Down
11 changes: 5 additions & 6 deletions bsd/kern/kern_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3115,7 +3115,7 @@ posix_spawn(proc_t ap, struct posix_spawn_args *uap, int32_t *retval)
if (error) {
DTRACE_PROC1(exec__failure, int, error);
} else {
DTRACE_PROC(exec__success);
dtrace_thread_didexec(imgp->ip_new_thread);
}
}

Expand All @@ -3124,8 +3124,7 @@ posix_spawn(proc_t ap, struct posix_spawn_args *uap, int32_t *retval)
}
#endif
/*
* exec-success dtrace probe fired, clear bsd_info from
* old task if it did exec.
* clear bsd_info from old task if it did exec.
*/
if (task_did_exec(current_task())) {
set_bsdtask_info(current_task(), NULL);
Expand Down Expand Up @@ -3577,9 +3576,10 @@ __mac_execve(proc_t p, struct __mac_execve_args *uap, int32_t *retval)
}
#endif /* CONFIG_MACF */

DTRACE_PROC(exec__success);

#if CONFIG_DTRACE
dtrace_thread_didexec(imgp->ip_new_thread);

if ((dtrace_proc_waitfor_hook = dtrace_proc_waitfor_exec_ptr) != NULL)
(*dtrace_proc_waitfor_hook)(p);
#endif
Expand All @@ -3594,8 +3594,7 @@ __mac_execve(proc_t p, struct __mac_execve_args *uap, int32_t *retval)
exit_with_error:

/*
* exec-success dtrace probe fired, clear bsd_info from
* old task if it did exec.
* clear bsd_info from old task if it did exec.
*/
if (task_did_exec(current_task())) {
set_bsdtask_info(current_task(), NULL);
Expand Down
37 changes: 37 additions & 0 deletions bsd/kern/kern_ntptime.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#include <security/mac_framework.h>
#endif
#include <IOKit/IOBSD.h>
#include <os/log.h>

typedef int64_t l_fp;
#define L_ADD(v, u) ((v) += (u))
Expand Down Expand Up @@ -216,6 +217,11 @@ static void ntp_loop_update_call(void);
static void refresh_ntp_loop(void);
static void start_ntp_loop(void);

#if DEVELOPMENT || DEBUG
uint32_t g_should_log_clock_adjustments = 0;
SYSCTL_INT(_kern, OID_AUTO, log_clock_adjustments, CTLFLAG_RW | CTLFLAG_LOCKED, &g_should_log_clock_adjustments, 0, "enable kernel clock adjustment logging");
#endif

static bool
ntp_is_time_error(int tsl)
{
Expand Down Expand Up @@ -326,6 +332,12 @@ ntp_adjtime(struct proc *p, struct ntp_adjtime_args *uap, __unused int32_t *retv
if (error)
return (error);

#if DEVELOPEMNT || DEBUG
if (g_should_log_clock_adjustments) {
os_log(OS_LOG_DEFAULT, "%s:BEFORE modes %u offset %ld freq %ld status %d constant %ld time_adjtime %lld\n",
__func__, ntv.modes, ntv.offset, ntv.freq, ntv.status, ntv.constant, time_adjtime);
}
#endif
/*
* Update selected clock variables - only the superuser can
* change anything. Note that there is no error checking here on
Expand Down Expand Up @@ -415,6 +427,13 @@ ntp_adjtime(struct proc *p, struct ntp_adjtime_args *uap, __unused int32_t *retv

ret = ntp_is_time_error(time_status) ? TIME_ERROR : time_state;

#if DEVELOPEMNT || DEBUG
if (g_should_log_clock_adjustments) {
os_log(OS_LOG_DEFAULT, "%s:AFTER offset %lld freq %lld status %d constant %ld time_adjtime %lld\n",
__func__, time_offset, time_freq, time_status, time_constant, time_adjtime);
}
#endif

/*
* Retrieve all clock variables. Note that the TAI offset is
* returned only by ntp_gettime();
Expand Down Expand Up @@ -535,6 +554,18 @@ ntp_update_second(int64_t *adjustment, clock_sec_t secs)
updated = 0;
}

#if DEVELOPEMNT || DEBUG
if (g_should_log_clock_adjustments) {
int64_t nano = (time_adj > 0)? time_adj >> 32 : -((-time_adj) >> 32);
int64_t frac = (time_adj > 0)? ((uint32_t) time_adj) : -((uint32_t) (-time_adj));

os_log(OS_LOG_DEFAULT, "%s:AFTER offset %lld (%lld) freq %lld status %d "
"constant %ld time_adjtime %lld nano %lld frac %lld adj %lld\n",
__func__, time_offset, (time_offset > 0)? time_offset >> 32 : -((-time_offset) >> 32),
time_freq, time_status, time_constant, time_adjtime, nano, frac, time_adj);
}
#endif

*adjustment = time_adj;
}

Expand Down Expand Up @@ -622,6 +653,12 @@ kern_adjtime(struct timeval *delta)
NTP_LOCK(enable);
ltr = time_adjtime;
time_adjtime = ltw;
#if DEVELOPEMNT || DEBUG
if (g_should_log_clock_adjustments) {
os_log(OS_LOG_DEFAULT, "%s:AFTER offset %lld freq %lld status %d constant %ld time_adjtime %lld\n",
__func__, time_offset, time_freq, time_status, time_constant, time_adjtime);
}
#endif
NTP_UNLOCK(enable);

atv.tv_sec = ltr / (int64_t)USEC_PER_SEC;
Expand Down
Loading

0 comments on commit 3d335d2

Please sign in to comment.