Skip to content

Commit

Permalink
xnu-3247.10.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Darwin authored and das committed Jun 4, 2017
1 parent dd3bee7 commit cac3355
Show file tree
Hide file tree
Showing 33 changed files with 269 additions and 159 deletions.
50 changes: 0 additions & 50 deletions .gitignore

This file was deleted.

15 changes: 15 additions & 0 deletions bsd/dev/i386/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,21 @@ SYSCTL_PROC(_machdep_cpu, OID_AUTO, ucupdate,
CTLTYPE_INT | CTLFLAG_WR | CTLFLAG_LOCKED, 0, 0,
cpu_ucode_update, "S", "Microcode update interface");

SYSCTL_NODE(_machdep_cpu, OID_AUTO, tsc_ccc, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
"TSC/CCC frequency information");

SYSCTL_PROC(_machdep_cpu_tsc_ccc, OID_AUTO, numerator,
CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
(void *)offsetof(i386_cpu_info_t, cpuid_tsc_leaf.numerator),
sizeof(uint32_t),
i386_cpu_info, "I", "Numerator of TSC/CCC ratio");

SYSCTL_PROC(_machdep_cpu_tsc_ccc, OID_AUTO, denominator,
CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
(void *)offsetof(i386_cpu_info_t, cpuid_tsc_leaf.denominator),
sizeof(uint32_t),
i386_cpu_info, "I", "Denominator of TSC/CCC ratio");

static const uint32_t apic_timer_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_TIMER_INTERRUPT);
static const uint32_t apic_IPI_vector = (LAPIC_DEFAULT_INTERRUPT_BASE + LAPIC_INTERPROCESSOR_INTERRUPT);

Expand Down
3 changes: 2 additions & 1 deletion bsd/dev/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ void dev_kmem_init(void)
{
uint32_t kmem;

if (PE_parse_boot_argn("kmem", &kmem, sizeof (kmem))) {
if (PE_i_can_has_debugger(NULL) &&
PE_parse_boot_argn("kmem", &kmem, sizeof (kmem))) {
if (kmem & 0x1) {
dev_kmem_enabled = TRUE;
}
Expand Down
23 changes: 23 additions & 0 deletions bsd/hfs/hfs_hotfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -2534,6 +2534,29 @@ hotfiles_adopt(struct hfsmount *hfsmp, vfs_context_t ctx)
continue; /* entry is too big, just carry on with the next guy */
}

//
// If a file is not an autocandidate (i.e. it's a user-tagged file desirous of
// being hotfile cached) but it is already bigger than 4 megs, don't bother
// hotfile caching it. Note that if a user tagged file starts small, gets
// adopted and then grows over time we will allow it to grow bigger than 4 megs
// which is intentional for things like the Mail or Photos database files which
// grow slowly over time and benefit from being on the FastDevice.
//
if ((hfsmp->hfs_flags & HFS_CS_HOTFILE_PIN) &&
!(VTOC(vp)->c_attr.ca_recflags & kHFSAutoCandidateMask) &&
(VTOC(vp)->c_attr.ca_recflags & kHFSFastDevCandidateMask) &&
(unsigned int)fileblocks > ((4*1024*1024) / (uint64_t)HFSTOVCB(hfsmp)->blockSize)) {

vnode_clearfastdevicecandidate(vp); // turn off the fast-dev-candidate flag so we don't keep trying to cache it.

hfs_unlock(VTOC(vp));
vnode_put(vp);
listp->hfl_hotfile[i].hf_temperature = 0;
listp->hfl_next++;
listp->hfl_totalblocks -= listp->hfl_hotfile[i].hf_blocks;
continue; /* entry is too big, just carry on with the next guy */
}

if (fileblocks > hfs_hotfile_cur_freeblks(hfsmp)) {
//
// No room for this file. Although eviction should have made space
Expand Down
13 changes: 9 additions & 4 deletions bsd/hfs/hfscommon/Misc/FileExtentMapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,14 +889,19 @@ should_pin_blocks(hfsmount_t *hfsmp, FCB *fcb)
// it was an automatically added file and this function is intended
// to pin new blocks being added to user-generated content.
//
// If a file is marked FastDevPinned or FastDevCandidate it is an
// existing pinned file or a new file that should be pinned.
//
if (fcb->ff_cp->c_attr.ca_recflags & kHFSAutoCandidateMask) {
return 0;
}

if ((fcb->ff_cp->c_attr.ca_recflags & (kHFSFastDevPinnedMask|kHFSFastDevCandidateMask)) != 0) {
//
// If a file is marked FastDevPinned it is an existing pinned file
// or a new file that should be pinned.
//
// If a file is marked FastDevCandidate it is a new file that is
// being written to for the first time so we don't want to pin it
// just yet as it may not meet the criteria (i.e. too large).
//
if ((fcb->ff_cp->c_attr.ca_recflags & (kHFSFastDevPinnedMask)) != 0) {
pin_blocks = 1;
} else {
pin_blocks = 0;
Expand Down
2 changes: 2 additions & 0 deletions bsd/kern/kern_mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ SYSCTL_PROC(_hw_optional, OID_AUTO, bmi2, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KER
SYSCTL_PROC(_hw_optional, OID_AUTO, rtm, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (void *) kHasRTM, 0, sysctl_cpu_capability, "I", "");
SYSCTL_PROC(_hw_optional, OID_AUTO, hle, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (void *) kHasHLE, 0, sysctl_cpu_capability, "I", "");
SYSCTL_PROC(_hw_optional, OID_AUTO, adx, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (void *) kHasADX, 0, sysctl_cpu_capability, "I", "");
SYSCTL_PROC(_hw_optional, OID_AUTO, mpx, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (void *) kHasMPX, 0, sysctl_cpu_capability, "I", "");
SYSCTL_PROC(_hw_optional, OID_AUTO, sgx, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, (void *) kHasSGX, 0, sysctl_cpu_capability, "I", "");
#else
#error Unsupported arch
#endif /* !__i386__ && !__x86_64 && !__arm__ && ! __arm64__ */
Expand Down
1 change: 1 addition & 0 deletions bsd/kern/kern_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,7 @@ sysctl_procargsx(int *name, u_int namelen, user_addr_t where,
tmp, FALSE) != KERN_SUCCESS) {
kmem_free(kernel_map, copy_start,
round_page(arg_size));
vm_map_copy_discard(tmp);
return (EIO);
}

Expand Down
5 changes: 0 additions & 5 deletions bsd/kern/ubc_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2695,11 +2695,6 @@ static SInt32 cs_blob_size_peak = 0;
static UInt32 cs_blob_size_max = 0;
static SInt32 cs_blob_count_peak = 0;

int cs_validation = 1;

#ifndef SECURE_KERNEL
SYSCTL_INT(_vm, OID_AUTO, cs_validation, CTLFLAG_RW | CTLFLAG_LOCKED, &cs_validation, 0, "Do validate code signatures");
#endif
SYSCTL_INT(_vm, OID_AUTO, cs_blob_count, CTLFLAG_RD | CTLFLAG_LOCKED, (int *)(uintptr_t)&cs_blob_count, 0, "Current number of code signature blobs");
SYSCTL_INT(_vm, OID_AUTO, cs_blob_size, CTLFLAG_RD | CTLFLAG_LOCKED, (int *)(uintptr_t)&cs_blob_size, 0, "Current size of all code signature blobs");
SYSCTL_INT(_vm, OID_AUTO, cs_blob_count_peak, CTLFLAG_RD | CTLFLAG_LOCKED, &cs_blob_count_peak, 0, "Peak number of code signature blobs");
Expand Down
2 changes: 1 addition & 1 deletion bsd/netinet6/ip6_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ ip6_input(struct mbuf *m)
int nxt = 0, ours = 0;
struct ifnet *inifp, *deliverifp = NULL;
ipfilter_t inject_ipfref = NULL;
int seen;
int seen = 1;
struct in6_ifaddr *ia6 = NULL;
struct sockaddr_in6 *dst6;
#if DUMMYNET
Expand Down
1 change: 0 additions & 1 deletion bsd/sys/codesign.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ int cs_allow_invalid(struct proc *);
int cs_invalid_page(addr64_t);
int csproc_get_platform_path(struct proc *);

extern int cs_validation;
#if !SECURE_KERNEL
extern int cs_enforcement_panic;
#endif
Expand Down
30 changes: 0 additions & 30 deletions libkern/.clang-format

This file was deleted.

1 change: 1 addition & 0 deletions libkern/.clang-format
12 changes: 7 additions & 5 deletions libkern/c++/OSKext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2503,14 +2503,16 @@ OSKext::readMkext2Archive(


infoDict = OSDynamicCast(OSDictionary,
mkextInfoDictArray->getObject(i));
mkextInfoDictArray->getObject(i));

/* Create the kext for the entry, then release it, because the
* kext system keeps them around until explicitly removed.
* Any creation/registration failures are already logged for us.
*/
OSKext * newKext = OSKext::withMkext2Info(infoDict, mkextData);
OSSafeRelease(newKext);
if (infoDict) {
OSKext * newKext = OSKext::withMkext2Info(infoDict, mkextData);
OSSafeRelease(newKext);
}
}

/* Even if we didn't keep any kexts from the mkext, we may have a load
Expand Down Expand Up @@ -2558,14 +2560,14 @@ OSKext::initWithMkext2Info(
OSCollectionIterator * iterator = NULL; // must release
OSData * executable = NULL; // must release

if (!super::init()) {
if (anInfoDict == NULL || !super::init()) {
goto finish;
}

/* Get the path. Don't look for an arch-specific path property.
*/
kextPath = OSDynamicCast(OSString,
anInfoDict->getObject(kMKEXTBundlePathKey));
anInfoDict->getObject(kMKEXTBundlePathKey));

if (!setInfoDictionaryAndPath(anInfoDict, kextPath)) {
goto finish;
Expand Down
3 changes: 0 additions & 3 deletions libsyscall/mach/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions osfmk/default_pager/dp_memory_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ default_pager_objects(
FALSE);
assert(KERN_SUCCESS == kr);
kr = vm_map_copyin(ipc_kernel_map, (vm_map_address_t)oaddr,
(vm_map_size_t)osize, TRUE, &pcopy);
(vm_map_size_t)(num_objects * sizeof(*objects)), TRUE, &pcopy);
assert(KERN_SUCCESS == kr);

*objectsp = (default_pager_object_array_t)objects;
Expand Down Expand Up @@ -1183,7 +1183,7 @@ default_pager_object_pages(
FALSE);
assert(KERN_SUCCESS == kr);
kr = vm_map_copyin(ipc_kernel_map, (vm_map_address_t)addr,
(vm_map_size_t)size, TRUE, &copy);
(vm_map_size_t)(actual * sizeof(*pages)), TRUE, &copy);
assert(KERN_SUCCESS == kr);


Expand Down
10 changes: 10 additions & 0 deletions osfmk/i386/Diagnostics.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ diagCall64(x86_saved_state_t * state)
pkes.IA_frequency_clipping_cause = ~0ULL;

uint32_t ia_perf_limits = MSR_IA32_IA_PERF_LIMIT_REASONS;
/* Should perhaps be a generic register map module for these
* registers with identical functionality that were renumbered.
*/
switch (cpuid_cpufamily()) {
case CPUFAMILY_INTEL_SKYLAKE:
ia_perf_limits = MSR_IA32_IA_PERF_LIMIT_REASONS_SKL;
break;
default:
break;
}

rdmsr64_carefully(ia_perf_limits, &pkes.IA_frequency_clipping_cause);

Expand Down
5 changes: 5 additions & 0 deletions osfmk/i386/commpage/commpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ commpage_init_cpu_capabilities( void )
setif(bits, kHasADX, cpuid_features() &
CPUID_LEAF7_FEATURE_ADX);

setif(bits, kHasMPX, cpuid_leaf7_features() &
CPUID_LEAF7_FEATURE_MPX);
setif(bits, kHasSGX, cpuid_leaf7_features() &
CPUID_LEAF7_FEATURE_SGX);

uint64_t misc_enable = rdmsr64(MSR_IA32_MISC_ENABLE);
setif(bits, kHasENFSTRG, (misc_enable & 1ULL) &&
(cpuid_leaf7_features() &
Expand Down
2 changes: 2 additions & 0 deletions osfmk/i386/cpu_capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
#define kHasHLE 0x0000000200000000ULL
#define kHasRDSEED 0x0000000800000000ULL
#define kHasADX 0x0000000400000000ULL
#define kHasMPX 0x0000001000000000ULL
#define kHasSGX 0x0000002000000000ULL


#ifndef __ASSEMBLER__
Expand Down
27 changes: 27 additions & 0 deletions osfmk/i386/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,21 @@ cpuid_set_generic_info(i386_cpu_info_t *info_p)
DBG(" EBX : 0x%x\n", reg[ebx]);
DBG(" ECX : 0x%x\n", reg[ecx]);
}

if (info_p->cpuid_max_basic >= 0x15) {
/*
* TCS/CCC frequency leaf:
*/
cpuid_fn(0x15, reg);
info_p->cpuid_tsc_leaf.denominator = reg[eax];
info_p->cpuid_tsc_leaf.numerator = reg[ebx];

DBG(" TSC/CCC Information Leaf:\n");
DBG(" numerator : 0x%x\n", reg[ebx]);
DBG(" denominator : 0x%x\n", reg[eax]);
}

return;
}

static uint32_t
Expand Down Expand Up @@ -777,6 +792,10 @@ cpuid_set_cpufamily(i386_cpu_info_t *info_p)
case CPUID_MODEL_BRYSTALWELL:
cpufamily = CPUFAMILY_INTEL_BROADWELL;
break;
case CPUID_MODEL_SKYLAKE:
case CPUID_MODEL_SKYLAKE_DT:
cpufamily = CPUFAMILY_INTEL_SKYLAKE;
break;
}
break;
}
Expand Down Expand Up @@ -954,6 +973,14 @@ leaf7_feature_map[] = {
{CPUID_LEAF7_FEATURE_SMAP, "SMAP"},
{CPUID_LEAF7_FEATURE_RDSEED, "RDSEED"},
{CPUID_LEAF7_FEATURE_ADX, "ADX"},
{CPUID_LEAF7_FEATURE_IPT, "IPT"},
{CPUID_LEAF7_FEATURE_SGX, "SGX"},
{CPUID_LEAF7_FEATURE_PQM, "PQM"},
{CPUID_LEAF7_FEATURE_FPU_CSDS, "FPU_CSDS"},
{CPUID_LEAF7_FEATURE_MPX, "MPX"},
{CPUID_LEAF7_FEATURE_PQE, "PQE"},
{CPUID_LEAF7_FEATURE_CLFSOPT, "CLFSOPT"},
{CPUID_LEAF7_FEATURE_SHA, "SHA"},
{0, 0}
};

Expand Down
Loading

0 comments on commit cac3355

Please sign in to comment.