Skip to content

Commit

Permalink
xnu-3248.20.55
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Jun 4, 2017
1 parent cac3355 commit 30f610b
Show file tree
Hide file tree
Showing 150 changed files with 4,115 additions and 906 deletions.
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,25 @@ installsrc:
pax -rw . $(SRCROOT)

else ifeq ($(RC_ProjectName),xnu_quick_test)
# This rule should be removed once rdar://22820602 is complete.
default: install

installhdrs:

install: xnu_tests

clean:

installsrc:
pax -rw . $(SRCROOT)

else ifeq ($(RC_ProjectName),xnu_tests)

default: install

installhdrs:

install: xnu_quick_test
install: xnu_tests

clean:

Expand Down Expand Up @@ -237,11 +250,11 @@ installhdrs_libkdd install_libkdd:
"SDKROOT=$(SDKROOT)"


# "xnu_quick_test" and "testbots" are targets that can be invoked via a standalone
# "make xnu_quick_test" or via buildit/XBS with the RC_ProjectName=xnu_quick_test.
# "xnu_tests" and "testbots" are targets that can be invoked via a standalone
# "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests.
# Define the target here in the outermost scope of the initial Makefile

xnu_quick_test:
xnu_tests xnu_quick_test:
$(MAKE) -C $(SRCROOT)/tools/tests \
SRCROOT=$(SRCROOT)/tools/tests

Expand Down
7 changes: 6 additions & 1 deletion bsd/dev/i386/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <sys/sysctl.h>
#include <i386/cpuid.h>
#include <i386/tsc.h>
#include <i386/rtclock_protos.h>
#include <i386/machine_routines.h>
#include <i386/pal_routines.h>
#include <i386/ucode.h>
Expand Down Expand Up @@ -758,7 +759,11 @@ SYSCTL_QUAD(_machdep_tsc, OID_AUTO, frequency,

extern uint32_t deep_idle_rebase;
SYSCTL_UINT(_machdep_tsc, OID_AUTO, deep_idle_rebase,
CTLFLAG_RW|CTLFLAG_KERN|CTLFLAG_LOCKED, &deep_idle_rebase, 0, "");
CTLFLAG_RD|CTLFLAG_LOCKED, &deep_idle_rebase, 0, "");
SYSCTL_QUAD(_machdep_tsc, OID_AUTO, at_boot,
CTLFLAG_RD|CTLFLAG_LOCKED, &tsc_at_boot, "");
SYSCTL_QUAD(_machdep_tsc, OID_AUTO, rebase_abs_time,
CTLFLAG_RD|CTLFLAG_LOCKED, &tsc_rebase_abs_time, "");

SYSCTL_NODE(_machdep_tsc, OID_AUTO, nanotime,
CTLFLAG_RD|CTLFLAG_LOCKED, NULL, "TSC to ns conversion");
Expand Down
15 changes: 13 additions & 2 deletions bsd/hfs/hfs_hotfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -1709,8 +1709,10 @@ hfs_recording_init(struct hfsmount *hfsmp)
}
cnid = filep->fileID;

/* Skip over journal files. */
if (cnid == hfsmp->hfs_jnlfileid || cnid == hfsmp->hfs_jnlinfoblkid) {
/* Skip over journal files and the hotfiles B-Tree file. */
if (cnid == hfsmp->hfs_jnlfileid
|| cnid == hfsmp->hfs_jnlinfoblkid
|| cnid == VTOC(hfsmp->hfc_filevp)->c_fileid) {
continue;
}
/*
Expand Down Expand Up @@ -2865,6 +2867,15 @@ hotfiles_evict(struct hfsmount *hfsmp, vfs_context_t ctx)
stage = HFC_ADOPTION;
break;
}

// Jump straight to delete for some files...
if (key->fileID == VTOC(hfsmp->hfc_filevp)->c_fileid
|| key->fileID == hfsmp->hfs_jnlfileid
|| key->fileID == hfsmp->hfs_jnlinfoblkid
|| key->fileID < kHFSFirstUserCatalogNodeID) {
goto delete;
}

/*
* Aquire the vnode for this file.
*/
Expand Down
69 changes: 30 additions & 39 deletions bsd/hfs/hfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2847,6 +2847,26 @@ hfs_getmountpoint(struct vnode *vp, struct hfsmount **hfsmpp)
// XXXdbg
#include <sys/filedesc.h>

static hfsmount_t *hfs_mount_from_cwd(vfs_context_t ctx)
{
vnode_t vp = vfs_context_cwd(ctx);

if (!vp)
return NULL;

/*
* We could use vnode_tag, but it is probably more future proof to
* compare fstypename.
*/
char fstypename[MFSNAMELEN];
vnode_vfsname(vp, fstypename);

if (strcmp(fstypename, "hfs"))
return NULL;

return VTOHFS(vp);
}

/*
* HFS filesystem related variables.
*/
Expand Down Expand Up @@ -2930,7 +2950,6 @@ hfs_sysctl(int *name, __unused u_int namelen, user_addr_t oldp, size_t *oldlenp,

} else if (name[0] == HFS_ENABLE_JOURNALING) {
// make the file system journaled...
vnode_t vp = vfs_context_cwd(context);
vnode_t jvp;
ExtendedVCB *vcb;
struct cat_attr jnl_attr;
Expand All @@ -2952,10 +2971,11 @@ hfs_sysctl(int *name, __unused u_int namelen, user_addr_t oldp, size_t *oldlenp,
if (!kauth_cred_issuser(kauth_cred_get())) {
return (EPERM);
}
if (vp == NULLVP)
return EINVAL;

hfsmp = VTOHFS(vp);
hfsmp = hfs_mount_from_cwd(context);
if (!hfsmp)
return EINVAL;

if (hfsmp->hfs_flags & HFS_READ_ONLY) {
return EROFS;
}
Expand All @@ -2965,7 +2985,7 @@ hfs_sysctl(int *name, __unused u_int namelen, user_addr_t oldp, size_t *oldlenp,
}

if (hfsmp->jnl) {
printf("hfs: volume @ mp %p is already journaled!\n", vnode_mount(vp));
printf("hfs: volume %s is already journaled!\n", hfsmp->vcbVN);
return EAGAIN;
}
vcb = HFSTOVCB(hfsmp);
Expand Down Expand Up @@ -3145,16 +3165,15 @@ hfs_sysctl(int *name, __unused u_int namelen, user_addr_t oldp, size_t *oldlenp,
return 0;
} else if (name[0] == HFS_DISABLE_JOURNALING) {
// clear the journaling bit
vnode_t vp = vfs_context_cwd(context);


/* Only root can disable journaling */
if (!kauth_cred_issuser(kauth_cred_get())) {
return (EPERM);
}
if (vp == NULLVP)
return EINVAL;

hfsmp = VTOHFS(vp);
hfsmp = hfs_mount_from_cwd(context);
if (!hfsmp)
return EINVAL;

/*
* Disabling journaling is disallowed on volumes with directory hard links
Expand All @@ -3165,7 +3184,7 @@ hfs_sysctl(int *name, __unused u_int namelen, user_addr_t oldp, size_t *oldlenp,
return EPERM;
}

printf("hfs: disabling journaling for mount @ %p\n", vnode_mount(vp));
printf("hfs: disabling journaling for %s\n", hfsmp->vcbVN);

hfs_lock_global (hfsmp, HFS_EXCLUSIVE_LOCK);

Expand Down Expand Up @@ -3197,34 +3216,6 @@ hfs_sysctl(int *name, __unused u_int namelen, user_addr_t oldp, size_t *oldlenp,
fsid.val[1] = (int32_t)vfs_typenum(HFSTOVFS(hfsmp));
vfs_event_signal(&fsid, VQ_UPDATE, (intptr_t)NULL);
}
return 0;
} else if (name[0] == HFS_GET_JOURNAL_INFO) {
vnode_t vp = vfs_context_cwd(context);
off_t jnl_start, jnl_size;

if (vp == NULLVP)
return EINVAL;

/* 64-bit processes won't work with this sysctl -- can't fit a pointer into an int! */
if (proc_is64bit(current_proc()))
return EINVAL;

hfsmp = VTOHFS(vp);
if (hfsmp->jnl == NULL) {
jnl_start = 0;
jnl_size = 0;
} else {
jnl_start = hfs_blk_to_bytes(hfsmp->jnl_start, HFSTOVCB(hfsmp)->blockSize) + HFSTOVCB(hfsmp)->hfsPlusIOPosOffset;
jnl_size = hfsmp->jnl_size;
}

if ((error = copyout((caddr_t)&jnl_start, CAST_USER_ADDR_T(name[1]), sizeof(off_t))) != 0) {
return error;
}
if ((error = copyout((caddr_t)&jnl_size, CAST_USER_ADDR_T(name[2]), sizeof(off_t))) != 0) {
return error;
}

return 0;
} else if (name[0] == HFS_SET_PKG_EXTENSIONS) {

Expand Down
5 changes: 3 additions & 2 deletions bsd/hfs/hfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2823,8 +2823,9 @@ int hfs_move_data(cnode_t *from_cp, cnode_t *to_cp,
// Update to_cp's resource data if it has it
filefork_t *to_rfork = to_cp->c_rsrcfork;
if (to_rfork) {
to_rfork->ff_invalidranges = from_rfork->ff_invalidranges;
to_rfork->ff_data = from_rfork->ff_data;
TAILQ_SWAP(&to_rfork->ff_invalidranges,
&from_rfork->ff_invalidranges, rl_entry, rl_link);
to_rfork->ff_data = from_rfork->ff_data;

// Deal with ubc_setsize
hfs_rsrc_setsize(to_cp);
Expand Down
4 changes: 4 additions & 0 deletions bsd/kern/bsd_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ extern int (*mountroot)(void);
lck_grp_t * proc_lck_grp;
lck_grp_t * proc_slock_grp;
lck_grp_t * proc_fdmlock_grp;
lck_grp_t * proc_ucred_mlock_grp;
lck_grp_t * proc_mlock_grp;
lck_grp_attr_t * proc_lck_grp_attr;
lck_attr_t * proc_lck_attr;
Expand Down Expand Up @@ -452,6 +453,7 @@ bsd_init(void)
#if CONFIG_FINE_LOCK_GROUPS
proc_slock_grp = lck_grp_alloc_init("proc-slock", proc_lck_grp_attr);
proc_fdmlock_grp = lck_grp_alloc_init("proc-fdmlock", proc_lck_grp_attr);
proc_ucred_mlock_grp = lck_grp_alloc_init("proc-ucred-mlock", proc_lck_grp_attr);
proc_mlock_grp = lck_grp_alloc_init("proc-mlock", proc_lck_grp_attr);
#endif
/* Allocate proc lock attribute */
Expand All @@ -467,12 +469,14 @@ bsd_init(void)
proc_klist_mlock = lck_mtx_alloc_init(proc_mlock_grp, proc_lck_attr);
lck_mtx_init(&kernproc->p_mlock, proc_mlock_grp, proc_lck_attr);
lck_mtx_init(&kernproc->p_fdmlock, proc_fdmlock_grp, proc_lck_attr);
lck_mtx_init(&kernproc->p_ucred_mlock, proc_ucred_mlock_grp, proc_lck_attr);
lck_spin_init(&kernproc->p_slock, proc_slock_grp, proc_lck_attr);
#else
proc_list_mlock = lck_mtx_alloc_init(proc_lck_grp, proc_lck_attr);
proc_klist_mlock = lck_mtx_alloc_init(proc_lck_grp, proc_lck_attr);
lck_mtx_init(&kernproc->p_mlock, proc_lck_grp, proc_lck_attr);
lck_mtx_init(&kernproc->p_fdmlock, proc_lck_grp, proc_lck_attr);
lck_mtx_init(&kernproc->p_ucred_mlock, proc_lck_grp, proc_lck_attr);
lck_spin_init(&kernproc->p_slock, proc_lck_grp, proc_lck_attr);
#endif

Expand Down
55 changes: 1 addition & 54 deletions bsd/kern/kdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ int kdbg_readcurcpumap(user_addr_t, size_t *);
int kdbg_readthrmap(user_addr_t, size_t *, vnode_t, vfs_context_t);
int kdbg_readthrmap_v3(user_addr_t, size_t *, int);
int kdbg_readcurthrmap(user_addr_t, size_t *);
int kdbg_getreg(kd_regtype *);
int kdbg_setreg(kd_regtype *);
int kdbg_setrtcdec(kd_regtype *);
int kdbg_setpidex(kd_regtype *);
Expand Down Expand Up @@ -2290,50 +2289,6 @@ kdbg_setreg(kd_regtype * kdr)
return(ret);
}

int
kdbg_getreg(__unused kd_regtype * kdr)
{
#if 0
int i,j, ret=0;
unsigned int val_1, val_2, val;

switch (kdr->type) {
case KDBG_CLASSTYPE :
val_1 = (kdr->value1 & 0xff);
val_2 = val_1 + 1;
kdlog_beg = (val_1<<24);
kdlog_end = (val_2<<24);
kd_ctrl_page.kdebug_flags &= (unsigned int)~KDBG_CKTYPES;
kd_ctrl_page.kdebug_flags |= (KDBG_RANGECHECK | KDBG_CLASSTYPE);
break;
case KDBG_SUBCLSTYPE :
val_1 = (kdr->value1 & 0xff);
val_2 = (kdr->value2 & 0xff);
val = val_2 + 1;
kdlog_beg = ((val_1<<24) | (val_2 << 16));
kdlog_end = ((val_1<<24) | (val << 16));
kd_ctrl_page.kdebug_flags &= (unsigned int)~KDBG_CKTYPES;
kd_ctrl_page.kdebug_flags |= (KDBG_RANGECHECK | KDBG_SUBCLSTYPE);
break;
case KDBG_RANGETYPE :
kdlog_beg = (kdr->value1);
kdlog_end = (kdr->value2);
kd_ctrl_page.kdebug_flags &= (unsigned int)~KDBG_CKTYPES;
kd_ctrl_page.kdebug_flags |= (KDBG_RANGECHECK | KDBG_RANGETYPE);
break;
case KDBG_TYPENONE :
kd_ctrl_page.kdebug_flags &= (unsigned int)~KDBG_CKTYPES;
kdlog_beg = 0;
kdlog_end = 0;
break;
default :
ret = EINVAL;
break;
}
#endif /* 0 */
return(EINVAL);
}

static int
kdbg_write_to_vnode(caddr_t buffer, size_t size, vnode_t vp, vfs_context_t ctx, off_t file_offset)
{
Expand Down Expand Up @@ -3206,16 +3161,8 @@ kdbg_control(int *name, u_int namelen, user_addr_t where, size_t *sizep)
ret = kdbg_setreg(&kd_Reg);
break;
case KERN_KDGETREG:
if (size < sizeof(kd_regtype)) {
ret = EINVAL;
break;
}
ret = kdbg_getreg(&kd_Reg);
if (copyout(&kd_Reg, where, sizeof(kd_regtype))) {
ret = EINVAL;
}
kdbg_disable_bg_trace();

ret = EINVAL;
break;
case KERN_KDREADTR:
ret = kdbg_read(where, sizep, NULL, NULL, RAW_VERSION1);
Expand Down
Loading

0 comments on commit 30f610b

Please sign in to comment.