Jump to content

AMD Mojave Kernel Development and Testing


Shaneee
 Share

263 posts in this topic

Recommended Posts

17 hours ago, jalavoui said:

 

this can be ported from 10.14.2 (need some fixes to compile)

 

i've just added a cpu errata code to xnu (from freebsd)

attached kernel for testing on 10.14.2

 

will also check https://github.com/torvalds/linux/blob/master/arch/x86/kernel/cpu/amd.c

kernel

 

Can you share the source for that kernel? It performs really well in benchmarks.

 

Screenshot 2019-01-12 17.06.35.png

Link to comment
Share on other sites

18 hours ago, jalavoui said:

 

this can be ported from 10.14.2 (need some fixes to compile)


int __cdecl necp_client_add_flow(necp_fd_data *fd_data, necp_client_action_args *uap, int *retval)
{
  vm_size_t v3; // rdx
  vm_size_t v4; // rsi
  bool v5; // ST2F_1
  bool v6; // ST2D_1
  user_addr_t v7; // rdx
  vm_size_t v8; // rsi
  int result; // eax
  unsigned __int8 *necp_client_uuid; // [rsp+50h] [rbp-230h]
  unsigned int copy_error; // [rsp+7Ch] [rbp-204h]
  necp_stats_bufreq bufreq; // [rsp+80h] [rbp-200h]
  necp_client_flow_stats *stats_request; // [rsp+98h] [rbp-1E8h]
  int request_error; // [rsp+A4h] [rbp-1DCh]
  necp_client_interface_option *option_0; // [rsp+A8h] [rbp-1D8h]
  necp_client_interface_option *option; // [rsp+B0h] [rbp-1D0h]
  u_int32_t option_i; // [rsp+BCh] [rbp-1C4h]
  _Bool found_nexus; // [rsp+C3h] [rbp-1BDh]
  uint32_t_0 interface_index; // [rsp+C4h] [rbp-1BCh]
  size_t_0 assigned_results_length; // [rsp+C8h] [rbp-1B8h]
  void *assigned_results; // [rsp+D0h] [rbp-1B0h]
  necp_client_flow_registration *new_registration; // [rsp+D8h] [rbp-1A8h]
  pid_t pid; // [rsp+E4h] [rbp-19Ch]
  necp_client_add_flow *v24; // [rsp+E8h] [rbp-198h]
  necp_client_add_flow *allocated_add_request; // [rsp+F0h] [rbp-190h]
  necp_client_add_flow *add_request; // [rsp+F8h] [rbp-188h]
  proc *proc; // [rsp+100h] [rbp-180h]
  necp_client *client; // [rsp+108h] [rbp-178h]
  int error; // [rsp+114h] [rbp-16Ch]
  int *retvala; // [rsp+118h] [rbp-168h]
  necp_client_action_args *uapa; // [rsp+120h] [rbp-160h]
  necp_fd_data *fd_dataa; // [rsp+128h] [rbp-158h]
  __int64 v33; // [rsp+130h] [rbp-150h]
  vm_size_t nbytes; // [rsp+138h] [rbp-148h]
  void *kernel_addr; // [rsp+140h] [rbp-140h]
  user_addr_t user_addr; // [rsp+148h] [rbp-138h]
  __int64 v37; // [rsp+150h] [rbp-130h]
  vm_size_t v38; // [rsp+158h] [rbp-128h]
  void *v39; // [rsp+160h] [rbp-120h]
  user_addr_t v40; // [rsp+168h] [rbp-118h]
  __int64 v41; // [rsp+170h] [rbp-110h]
  vm_size_t v42; // [rsp+178h] [rbp-108h]
  void *v43; // [rsp+180h] [rbp-100h]
  user_addr_t v44; // [rsp+188h] [rbp-F8h]
  __int64 v45; // [rsp+190h] [rbp-F0h]
  vm_size_t v46; // [rsp+198h] [rbp-E8h]
  user_addr_t v47; // [rsp+1A0h] [rbp-E0h]
  void *v48; // [rsp+1A8h] [rbp-D8h]
  necp_client_add_flow_default default_add_request; // [rsp+1B0h] [rbp-D0h]
  necp_client_nexus_parameters parameters; // [rsp+1F0h] [rbp-90h]
  uuid_t client_id; // [rsp+250h] [rbp-30h]
  __int64 v52; // [rsp+268h] [rbp-18h]

  fd_dataa = fd_data;
  uapa = uap;
  retvala = retval;
  error = 0;
  client = 0LL;
  secure_memset(&parameters, 0, 0x60uLL);
  proc = 0LL;
  add_request = 0LL;
  allocated_add_request = 0LL;
  secure_memset(&default_add_request, 0, 0x3CuLL);
  if ( !uap->client_id || uapa->client_id_len != 16 )
  {
    error = 22;
    log(3, "%s: necp_client_add_flow invalid client_id (length %zu)\n", "necp_client_add_flow", uapa->client_id_len);
    goto LABEL_64;
  }
  if ( !uapa->buffer || uapa->buffer_size < 0x24 )
  {
    error = 22;
    log(3, "%s: necp_client_add_flow invalid buffer (length %zu)\n", "necp_client_add_flow", uapa->buffer_size);
    goto LABEL_64;
  }
  user_addr = uapa->client_id;
  kernel_addr = client_id;
  nbytes = 16LL;
  v33 = 16LL;
  error = copyin(user_addr, client_id, 0x10uLL);
  if ( error )
  {
    log(3, "%s: necp_client_add_flow copyin client_id error (%d)\n", "necp_client_add_flow", (unsigned int)error);
    goto LABEL_64;
  }
  if ( uapa->buffer_size > 0x3C )
  {
    v24 = (necp_client_add_flow *)_MALLOC(uapa->buffer_size, 118, 4, &necp_client_add_flow_site);
    allocated_add_request = v24;
    if ( !v24 )
    {
      error = 12;
      goto LABEL_64;
    }
    v4 = uapa->buffer_size;
    v44 = uapa->buffer;
    v43 = allocated_add_request;
    v42 = v4;
    v41 = -1LL;
    if ( v4 > 0xFFFFFFFFFFFFFFFFLL )
      panic(
        "\"__copyin_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)\"@/BuildRoot/Library/Caches/com.apple.x"
        "bs/Sources/xnu_debug/xnu-4903.231.4/bsd/libkern/copyio.h:45",
        v44,
        v43,
        v42,
        v41);
    error = copyin(v44, v43, v42);
    if ( error )
    {
      log(
        3,
        "%s: necp_client_add_flow copyin default_add_request error (%d)\n",
        "necp_client_add_flow",
        (unsigned int)error);
      goto LABEL_64;
    }
    add_request = allocated_add_request;
  }
  else
  {
    v3 = uapa->buffer_size;
    v40 = uapa->buffer;
    v39 = &default_add_request;
    v38 = v3;
    v37 = 60LL;
    if ( v3 > 0x3C )
      panic(
        "\"__copyin_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)\"@/BuildRoot/Library/Caches/com.apple.x"
        "bs/Sources/xnu_debug/xnu-4903.231.4/bsd/libkern/copyio.h:45",
        v40,
        v39,
        v38,
        v37);
    error = copyin(v40, v39, v38);
    if ( error )
    {
      log(
        3,
        "%s: necp_client_add_flow copyin default_add_request error (%d)\n",
        "necp_client_add_flow",
        (unsigned int)error);
      goto LABEL_64;
    }
    add_request = (necp_client_add_flow *)&default_add_request;
  }
  lck_mtx_lock((lck_mtx_t *)&fd_dataa->fd_lock);
  pid = fd_dataa->proc_pid;
  proc = proc_find(pid);
  if ( proc )
  {
    client = necp_client_fd_find_client_and_lock(fd_dataa, client_id);
    if ( client )
    {
      *((_BYTE *)client + 100) &= 0xFBu;
      necp_client_retain_locked(client);
      necp_client_copy_parameters_locked(client, &parameters);
      new_registration = necp_client_create_flow_registration(fd_dataa, client);
      if ( new_registration )
      {
        new_registration->flags = add_request->flags;
        uuid_copy(add_request->registration_id, new_registration->registration_id);
        if ( add_request->flags & 1 )
        {
          assigned_results = 0LL;
          assigned_results_length = 0LL;
          interface_index = 0;
          found_nexus = 0;
          for ( option_i = 0; option_i < client->interface_option_count; ++option_i )
          {
            if ( option_i >= 4 )
            {
              option_0 = &client->extra_interface_options[option_i - 4];
              if ( !uuid_compare(option_0->nexus_agent, add_request->agent_uuid) )
              {
                interface_index = option_0->interface_index;
                found_nexus = 1;
                break;
              }
            }
            else
            {
              option = &client->interface_options[option_i];
              if ( !uuid_compare(option->nexus_agent, add_request->agent_uuid) )
              {
                interface_index = option->interface_index;
                found_nexus = 1;
                break;
              }
            }
          }
          if ( found_nexus )
          {
            necp_client_add_nexus_flow_if_needed(new_registration, add_request->agent_uuid, interface_index);
            if ( new_registration->flags & 2 )
              necp_client_uuid = client->client_id;
            else
              necp_client_uuid = new_registration->registration_id;
            request_error = netagent_client_message_with_params(
                              add_request->agent_uuid,
                              necp_client_uuid,
                              pid,
                              client->agent_handle,
                              0xAu,
                              &parameters,
                              &assigned_results,
                              &assigned_results_length);
            if ( request_error )
            {
              if ( assigned_results )
                v5 = assfail(
                       "assigned_results == NULL",
                       "/BuildRoot/Library/Caches/com.apple.xbs/Sources/xnu_debug/xnu-4903.231.4/bsd/net/necp_client.c",
                       6107) != 0;
              if ( assigned_results_length )
                v6 = assfail(
                       "assigned_results_length == 0",
                       "/BuildRoot/Library/Caches/com.apple.xbs/Sources/xnu_debug/xnu-4903.231.4/bsd/net/necp_client.c",
                       6108) != 0;
              log(3, "%s: netagent_client_message error (%d)\n", "necp_client_add_flow", (unsigned int)request_error);
            }
            else if ( assigned_results && assigned_results_length )
            {
              if ( !necp_assign_client_result_locked(
                      proc,
                      fd_dataa,
                      client,
                      new_registration,
                      add_request->agent_uuid,
                      (u_int8_t *)assigned_results,
                      assigned_results_length,
                      0)
                && assigned_results )
              {
                FREE(assigned_results, 124);
              }
            }
            else if ( assigned_results )
            {
              FREE(assigned_results, 124);
            }
          }
          else
          {
            log(3, "%s: %s\n", "necp_client_add_flow", "Requested nexus not found");
          }
        }
        if ( (signed int)add_request->stats_request_count > 0 && !necp_arena_initialize(fd_dataa, 1) )
        {
          stats_request = (necp_client_flow_stats *)&add_request[1];
          secure_memset(&bufreq, 0, 0x18uLL);
          bufreq.necp_stats_bufreq_id = 191;
          *(_QWORD *)&bufreq.necp_stats_bufreq_type = *(_QWORD *)&stats_request->stats_type;
          bufreq.necp_stats_bufreq_size = stats_request->stats_size;
          bufreq._anon_0.necp_stats_bufreq_uaddr = stats_request->stats_addr;
          necp_stats_initialize(fd_dataa, client, new_registration, &bufreq);
          *(_QWORD *)&stats_request->stats_type = *(_QWORD *)&bufreq.necp_stats_bufreq_type;
          stats_request->stats_size = bufreq.necp_stats_bufreq_size;
          stats_request->stats_addr = bufreq._anon_0.necp_stats_bufreq_uaddr;
        }
        lck_mtx_unlock((lck_mtx_t *)&client->lock);
        lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
        necp_client_release(client);
        v7 = uapa->buffer;
        v8 = uapa->buffer_size;
        v48 = add_request;
        v47 = v7;
        v46 = v8;
        v45 = -1LL;
        if ( v8 > 0xFFFFFFFFFFFFFFFFLL )
          panic(
            "\"__copyout_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)\"@/BuildRoot/Library/Caches/com.ap"
            "ple.xbs/Sources/xnu_debug/xnu-4903.231.4/bsd/libkern/copyio.h:54",
            v47,
            v48,
            v46,
            v45);
        copy_error = copyout(v48, v47, v46);
        if ( copy_error )
          log(3, "%s: necp_client_add_flow copyout add_request error (%d)\n", "necp_client_add_flow", copy_error);
      }
      else
      {
        error = 12;
        lck_mtx_unlock((lck_mtx_t *)&client->lock);
        lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
        log(3, "%s: %s\n", "necp_client_add_flow", "Failed to allocate flow registration");
      }
    }
    else
    {
      error = 2;
      lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
    }
  }
  else
  {
    lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
    log(
      3,
      "%s: necp_client_add_flow process not found for pid %d error (%d)\n",
      "necp_client_add_flow",
      (unsigned int)pid,
      (unsigned int)error);
    error = 3;
  }
LABEL_64:
  *retvala = error;
  if ( error )
    log(3, "%s: Add flow error (%d)\n", "necp_client_add_flow", (unsigned int)error);
  if ( allocated_add_request )
    FREE(allocated_add_request, 118);
  if ( proc )
    proc_rele(proc);
  result = error;
  if ( _stack_chk_guard == v52 )
    result = error;
  return result;
}

 

i've just added a cpu errata code to xnu (from freebsd)


static void init_amd_erratas(i386_cpu_info_t *info_p)
{
    uint64_t msr;
    
    /*
     * Work around Erratum 721 for Family 10h and 12h processors.
     * These processors may incorrectly update the stack pointer
     * after a long series of push and/or near-call instructions,
     * or a long series of pop and/or near-return instructions.
     *
     * http://support.amd.com/us/Processor_TechDocs/41322_10h_Rev_Gd.pdf
     * http://support.amd.com/us/Processor_TechDocs/44739_12h_Rev_Gd.pdf
     *
     * Hypervisors do not provide access to the errata MSR,
     * causing #GP exception on attempt to apply the errata.  The
     * MSR write shall be done on host and persist globally
     * anyway, so do not try to do it when under virtualization.
     */
    
    switch (info_p->cpuid_family) {
        case 0x10:
        case 0x12:
            if ((info_p->cpuid_features & 0x80000000) == 0)
                wrmsr64(0xc0011029, rdmsr64(0xc0011029) | 1);
            break;
    }
    
    /*
     * BIOS may fail to set InitApicIdCpuIdLo to 1 as it should per BKDG.
     * So, do it here or otherwise some tools could be confused by
     * Initial Local APIC ID reported with CPUID Function 1 in EBX.
     */
    if (info_p->cpuid_family == 0x10) {
        if ((info_p->cpuid_features & 0x80000000) == 0) {
            msr = rdmsr64(0xc001001f);
            msr |= (uint64_t)1 << 54;
            wrmsr64(0xc001001f, msr);
        }
    }
    
    /*
     * BIOS may configure Family 10h processors to convert WC+ cache type
     * to CD.  That can hurt performance of guest VMs using nested paging.
     * The relevant MSR bit is not documented in the BKDG,
     * the fix is borrowed from Linux.
     */
    if (info_p->cpuid_family == 0x10) {
        if ((info_p->cpuid_features & 0x80000000) == 0) {
            msr = rdmsr64(0xc001102a);
            msr &= ~((uint64_t)1 << 24);
            wrmsr64(0xc001102a, msr);
        }
    }
    
    /*
     * Work around Erratum 793: Specific Combination of Writes to Write
     * Combined Memory Types and Locked Instructions May Cause Core Hang.
     * See Revision Guide for AMD Family 16h Models 00h-0Fh Processors,
     * revision 3.04 or later, publication 51810.
     */
    if (info_p->cpuid_family== 0x16 && info_p->cpuid_model <= 0xf) {
        if ((info_p->cpuid_features & 0x80000000) == 0) {
            msr = rdmsr64(0xc0011020);
            msr |= (uint64_t)1 << 15;
            wrmsr64(0xc0011020, msr);
        }
    }
    
    /* Ryzen erratas. */
    if (info_p->cpuid_family == 0x17 && info_p->cpuid_model == 0x1 &&
        (info_p->cpuid_features & 0x80000000) == 0) {
        /* 1021 */
        msr = rdmsr64(0xc0011029);
        msr |= 0x2000;
        wrmsr64(0xc0011029, msr);
        
        /* 1033 */
        msr = rdmsr64(0xc0011020);
        msr |= 0x10;
        wrmsr64(0xc0011020, msr);
        
        /* 1049 */
        msr = rdmsr64(0xc0011028);
        msr |= 0x10;
        wrmsr64(0xc0011028, msr);
        
        /* 1095 */
        msr = rdmsr64(0xc0011020);
        msr |= 0x200000000000000;
        wrmsr64(0xc0011020, msr);
    }
    
    /*
     * Work around a problem on Ryzen that is triggered by executing
     * code near the top of user memory, in our case the signal
     * trampoline code in the shared page on amd64.
     *
     * This function is executed once for the BSP before tunables take
     * effect so the value determined here can be overridden by the
     * tunable.  This function is then executed again for each AP and
     * also on resume.  Set a flag the first time so that value set by
     * the tunable is not overwritten.
     *
     * The stepping and/or microcode versions should be checked after
     * this issue is fixed by AMD so that we don't use this mode if not
     * needed.
     */
    /*if (lower_sharedpage_init == 0) {
        lower_sharedpage_init = 1;
        if (info_p->cpuid_family == 0x17) {
            hw_lower_amd64_sharedpage = 1;
        }
    }
     amd64_lower_shared_page(struct sysentvec *sv)
    if (hw_lower_amd64_sharedpage != 0) {
                sv->sv_maxuser -= PAGE_SIZE;
                sv->sv_shared_page_base -= PAGE_SIZE;
                sv->sv_usrstack -= PAGE_SIZE;
                sv->sv_psstrings -= PAGE_SIZE;
            }*/
}

attached kernel for testing on 10.14.2

 

will also check https://github.com/torvalds/linux/blob/master/arch/x86/kernel/cpu/amd.c

kernel


nice ! 
kernel booted on 10.14.2 :)
can you also write a patch for the Networking issue (necp client) that will replace the stub function.
thanks !

Link to comment
Share on other sites

On 1/12/2019 at 7:10 AM, jalavoui said:

 

this can be ported from 10.14.2 (need some fixes to compile)


int __cdecl necp_client_add_flow(necp_fd_data *fd_data, necp_client_action_args *uap, int *retval)
{
  vm_size_t v3; // rdx
  vm_size_t v4; // rsi
  bool v5; // ST2F_1
  bool v6; // ST2D_1
  user_addr_t v7; // rdx
  vm_size_t v8; // rsi
  int result; // eax
  unsigned __int8 *necp_client_uuid; // [rsp+50h] [rbp-230h]
  unsigned int copy_error; // [rsp+7Ch] [rbp-204h]
  necp_stats_bufreq bufreq; // [rsp+80h] [rbp-200h]
  necp_client_flow_stats *stats_request; // [rsp+98h] [rbp-1E8h]
  int request_error; // [rsp+A4h] [rbp-1DCh]
  necp_client_interface_option *option_0; // [rsp+A8h] [rbp-1D8h]
  necp_client_interface_option *option; // [rsp+B0h] [rbp-1D0h]
  u_int32_t option_i; // [rsp+BCh] [rbp-1C4h]
  _Bool found_nexus; // [rsp+C3h] [rbp-1BDh]
  uint32_t_0 interface_index; // [rsp+C4h] [rbp-1BCh]
  size_t_0 assigned_results_length; // [rsp+C8h] [rbp-1B8h]
  void *assigned_results; // [rsp+D0h] [rbp-1B0h]
  necp_client_flow_registration *new_registration; // [rsp+D8h] [rbp-1A8h]
  pid_t pid; // [rsp+E4h] [rbp-19Ch]
  necp_client_add_flow *v24; // [rsp+E8h] [rbp-198h]
  necp_client_add_flow *allocated_add_request; // [rsp+F0h] [rbp-190h]
  necp_client_add_flow *add_request; // [rsp+F8h] [rbp-188h]
  proc *proc; // [rsp+100h] [rbp-180h]
  necp_client *client; // [rsp+108h] [rbp-178h]
  int error; // [rsp+114h] [rbp-16Ch]
  int *retvala; // [rsp+118h] [rbp-168h]
  necp_client_action_args *uapa; // [rsp+120h] [rbp-160h]
  necp_fd_data *fd_dataa; // [rsp+128h] [rbp-158h]
  __int64 v33; // [rsp+130h] [rbp-150h]
  vm_size_t nbytes; // [rsp+138h] [rbp-148h]
  void *kernel_addr; // [rsp+140h] [rbp-140h]
  user_addr_t user_addr; // [rsp+148h] [rbp-138h]
  __int64 v37; // [rsp+150h] [rbp-130h]
  vm_size_t v38; // [rsp+158h] [rbp-128h]
  void *v39; // [rsp+160h] [rbp-120h]
  user_addr_t v40; // [rsp+168h] [rbp-118h]
  __int64 v41; // [rsp+170h] [rbp-110h]
  vm_size_t v42; // [rsp+178h] [rbp-108h]
  void *v43; // [rsp+180h] [rbp-100h]
  user_addr_t v44; // [rsp+188h] [rbp-F8h]
  __int64 v45; // [rsp+190h] [rbp-F0h]
  vm_size_t v46; // [rsp+198h] [rbp-E8h]
  user_addr_t v47; // [rsp+1A0h] [rbp-E0h]
  void *v48; // [rsp+1A8h] [rbp-D8h]
  necp_client_add_flow_default default_add_request; // [rsp+1B0h] [rbp-D0h]
  necp_client_nexus_parameters parameters; // [rsp+1F0h] [rbp-90h]
  uuid_t client_id; // [rsp+250h] [rbp-30h]
  __int64 v52; // [rsp+268h] [rbp-18h]

  fd_dataa = fd_data;
  uapa = uap;
  retvala = retval;
  error = 0;
  client = 0LL;
  secure_memset(&parameters, 0, 0x60uLL);
  proc = 0LL;
  add_request = 0LL;
  allocated_add_request = 0LL;
  secure_memset(&default_add_request, 0, 0x3CuLL);
  if ( !uap->client_id || uapa->client_id_len != 16 )
  {
    error = 22;
    log(3, "%s: necp_client_add_flow invalid client_id (length %zu)\n", "necp_client_add_flow", uapa->client_id_len);
    goto LABEL_64;
  }
  if ( !uapa->buffer || uapa->buffer_size < 0x24 )
  {
    error = 22;
    log(3, "%s: necp_client_add_flow invalid buffer (length %zu)\n", "necp_client_add_flow", uapa->buffer_size);
    goto LABEL_64;
  }
  user_addr = uapa->client_id;
  kernel_addr = client_id;
  nbytes = 16LL;
  v33 = 16LL;
  error = copyin(user_addr, client_id, 0x10uLL);
  if ( error )
  {
    log(3, "%s: necp_client_add_flow copyin client_id error (%d)\n", "necp_client_add_flow", (unsigned int)error);
    goto LABEL_64;
  }
  if ( uapa->buffer_size > 0x3C )
  {
    v24 = (necp_client_add_flow *)_MALLOC(uapa->buffer_size, 118, 4, &necp_client_add_flow_site);
    allocated_add_request = v24;
    if ( !v24 )
    {
      error = 12;
      goto LABEL_64;
    }
    v4 = uapa->buffer_size;
    v44 = uapa->buffer;
    v43 = allocated_add_request;
    v42 = v4;
    v41 = -1LL;
    if ( v4 > 0xFFFFFFFFFFFFFFFFLL )
      panic(
        "\"__copyin_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)\"@/BuildRoot/Library/Caches/com.apple.x"
        "bs/Sources/xnu_debug/xnu-4903.231.4/bsd/libkern/copyio.h:45",
        v44,
        v43,
        v42,
        v41);
    error = copyin(v44, v43, v42);
    if ( error )
    {
      log(
        3,
        "%s: necp_client_add_flow copyin default_add_request error (%d)\n",
        "necp_client_add_flow",
        (unsigned int)error);
      goto LABEL_64;
    }
    add_request = allocated_add_request;
  }
  else
  {
    v3 = uapa->buffer_size;
    v40 = uapa->buffer;
    v39 = &default_add_request;
    v38 = v3;
    v37 = 60LL;
    if ( v3 > 0x3C )
      panic(
        "\"__copyin_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)\"@/BuildRoot/Library/Caches/com.apple.x"
        "bs/Sources/xnu_debug/xnu-4903.231.4/bsd/libkern/copyio.h:45",
        v40,
        v39,
        v38,
        v37);
    error = copyin(v40, v39, v38);
    if ( error )
    {
      log(
        3,
        "%s: necp_client_add_flow copyin default_add_request error (%d)\n",
        "necp_client_add_flow",
        (unsigned int)error);
      goto LABEL_64;
    }
    add_request = (necp_client_add_flow *)&default_add_request;
  }
  lck_mtx_lock((lck_mtx_t *)&fd_dataa->fd_lock);
  pid = fd_dataa->proc_pid;
  proc = proc_find(pid);
  if ( proc )
  {
    client = necp_client_fd_find_client_and_lock(fd_dataa, client_id);
    if ( client )
    {
      *((_BYTE *)client + 100) &= 0xFBu;
      necp_client_retain_locked(client);
      necp_client_copy_parameters_locked(client, &parameters);
      new_registration = necp_client_create_flow_registration(fd_dataa, client);
      if ( new_registration )
      {
        new_registration->flags = add_request->flags;
        uuid_copy(add_request->registration_id, new_registration->registration_id);
        if ( add_request->flags & 1 )
        {
          assigned_results = 0LL;
          assigned_results_length = 0LL;
          interface_index = 0;
          found_nexus = 0;
          for ( option_i = 0; option_i < client->interface_option_count; ++option_i )
          {
            if ( option_i >= 4 )
            {
              option_0 = &client->extra_interface_options[option_i - 4];
              if ( !uuid_compare(option_0->nexus_agent, add_request->agent_uuid) )
              {
                interface_index = option_0->interface_index;
                found_nexus = 1;
                break;
              }
            }
            else
            {
              option = &client->interface_options[option_i];
              if ( !uuid_compare(option->nexus_agent, add_request->agent_uuid) )
              {
                interface_index = option->interface_index;
                found_nexus = 1;
                break;
              }
            }
          }
          if ( found_nexus )
          {
            necp_client_add_nexus_flow_if_needed(new_registration, add_request->agent_uuid, interface_index);
            if ( new_registration->flags & 2 )
              necp_client_uuid = client->client_id;
            else
              necp_client_uuid = new_registration->registration_id;
            request_error = netagent_client_message_with_params(
                              add_request->agent_uuid,
                              necp_client_uuid,
                              pid,
                              client->agent_handle,
                              0xAu,
                              &parameters,
                              &assigned_results,
                              &assigned_results_length);
            if ( request_error )
            {
              if ( assigned_results )
                v5 = assfail(
                       "assigned_results == NULL",
                       "/BuildRoot/Library/Caches/com.apple.xbs/Sources/xnu_debug/xnu-4903.231.4/bsd/net/necp_client.c",
                       6107) != 0;
              if ( assigned_results_length )
                v6 = assfail(
                       "assigned_results_length == 0",
                       "/BuildRoot/Library/Caches/com.apple.xbs/Sources/xnu_debug/xnu-4903.231.4/bsd/net/necp_client.c",
                       6108) != 0;
              log(3, "%s: netagent_client_message error (%d)\n", "necp_client_add_flow", (unsigned int)request_error);
            }
            else if ( assigned_results && assigned_results_length )
            {
              if ( !necp_assign_client_result_locked(
                      proc,
                      fd_dataa,
                      client,
                      new_registration,
                      add_request->agent_uuid,
                      (u_int8_t *)assigned_results,
                      assigned_results_length,
                      0)
                && assigned_results )
              {
                FREE(assigned_results, 124);
              }
            }
            else if ( assigned_results )
            {
              FREE(assigned_results, 124);
            }
          }
          else
          {
            log(3, "%s: %s\n", "necp_client_add_flow", "Requested nexus not found");
          }
        }
        if ( (signed int)add_request->stats_request_count > 0 && !necp_arena_initialize(fd_dataa, 1) )
        {
          stats_request = (necp_client_flow_stats *)&add_request[1];
          secure_memset(&bufreq, 0, 0x18uLL);
          bufreq.necp_stats_bufreq_id = 191;
          *(_QWORD *)&bufreq.necp_stats_bufreq_type = *(_QWORD *)&stats_request->stats_type;
          bufreq.necp_stats_bufreq_size = stats_request->stats_size;
          bufreq._anon_0.necp_stats_bufreq_uaddr = stats_request->stats_addr;
          necp_stats_initialize(fd_dataa, client, new_registration, &bufreq);
          *(_QWORD *)&stats_request->stats_type = *(_QWORD *)&bufreq.necp_stats_bufreq_type;
          stats_request->stats_size = bufreq.necp_stats_bufreq_size;
          stats_request->stats_addr = bufreq._anon_0.necp_stats_bufreq_uaddr;
        }
        lck_mtx_unlock((lck_mtx_t *)&client->lock);
        lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
        necp_client_release(client);
        v7 = uapa->buffer;
        v8 = uapa->buffer_size;
        v48 = add_request;
        v47 = v7;
        v46 = v8;
        v45 = -1LL;
        if ( v8 > 0xFFFFFFFFFFFFFFFFLL )
          panic(
            "\"__copyout_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)\"@/BuildRoot/Library/Caches/com.ap"
            "ple.xbs/Sources/xnu_debug/xnu-4903.231.4/bsd/libkern/copyio.h:54",
            v47,
            v48,
            v46,
            v45);
        copy_error = copyout(v48, v47, v46);
        if ( copy_error )
          log(3, "%s: necp_client_add_flow copyout add_request error (%d)\n", "necp_client_add_flow", copy_error);
      }
      else
      {
        error = 12;
        lck_mtx_unlock((lck_mtx_t *)&client->lock);
        lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
        log(3, "%s: %s\n", "necp_client_add_flow", "Failed to allocate flow registration");
      }
    }
    else
    {
      error = 2;
      lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
    }
  }
  else
  {
    lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
    log(
      3,
      "%s: necp_client_add_flow process not found for pid %d error (%d)\n",
      "necp_client_add_flow",
      (unsigned int)pid,
      (unsigned int)error);
    error = 3;
  }
LABEL_64:
  *retvala = error;
  if ( error )
    log(3, "%s: Add flow error (%d)\n", "necp_client_add_flow", (unsigned int)error);
  if ( allocated_add_request )
    FREE(allocated_add_request, 118);
  if ( proc )
    proc_rele(proc);
  result = error;
  if ( _stack_chk_guard == v52 )
    result = error;
  return result;
}

 

i've just added a cpu errata code to xnu (from freebsd)


static void init_amd_erratas(i386_cpu_info_t *info_p)
{
    uint64_t msr;
    
    /*
     * Work around Erratum 721 for Family 10h and 12h processors.
     * These processors may incorrectly update the stack pointer
     * after a long series of push and/or near-call instructions,
     * or a long series of pop and/or near-return instructions.
     *
     * http://support.amd.com/us/Processor_TechDocs/41322_10h_Rev_Gd.pdf
     * http://support.amd.com/us/Processor_TechDocs/44739_12h_Rev_Gd.pdf
     *
     * Hypervisors do not provide access to the errata MSR,
     * causing #GP exception on attempt to apply the errata.  The
     * MSR write shall be done on host and persist globally
     * anyway, so do not try to do it when under virtualization.
     */
    
    switch (info_p->cpuid_family) {
        case 0x10:
        case 0x12:
            if ((info_p->cpuid_features & 0x80000000) == 0)
                wrmsr64(0xc0011029, rdmsr64(0xc0011029) | 1);
            break;
    }
    
    /*
     * BIOS may fail to set InitApicIdCpuIdLo to 1 as it should per BKDG.
     * So, do it here or otherwise some tools could be confused by
     * Initial Local APIC ID reported with CPUID Function 1 in EBX.
     */
    if (info_p->cpuid_family == 0x10) {
        if ((info_p->cpuid_features & 0x80000000) == 0) {
            msr = rdmsr64(0xc001001f);
            msr |= (uint64_t)1 << 54;
            wrmsr64(0xc001001f, msr);
        }
    }
    
    /*
     * BIOS may configure Family 10h processors to convert WC+ cache type
     * to CD.  That can hurt performance of guest VMs using nested paging.
     * The relevant MSR bit is not documented in the BKDG,
     * the fix is borrowed from Linux.
     */
    if (info_p->cpuid_family == 0x10) {
        if ((info_p->cpuid_features & 0x80000000) == 0) {
            msr = rdmsr64(0xc001102a);
            msr &= ~((uint64_t)1 << 24);
            wrmsr64(0xc001102a, msr);
        }
    }
    
    /*
     * Work around Erratum 793: Specific Combination of Writes to Write
     * Combined Memory Types and Locked Instructions May Cause Core Hang.
     * See Revision Guide for AMD Family 16h Models 00h-0Fh Processors,
     * revision 3.04 or later, publication 51810.
     */
    if (info_p->cpuid_family== 0x16 && info_p->cpuid_model <= 0xf) {
        if ((info_p->cpuid_features & 0x80000000) == 0) {
            msr = rdmsr64(0xc0011020);
            msr |= (uint64_t)1 << 15;
            wrmsr64(0xc0011020, msr);
        }
    }
    
    /* Ryzen erratas. */
    if (info_p->cpuid_family == 0x17 && info_p->cpuid_model == 0x1 &&
        (info_p->cpuid_features & 0x80000000) == 0) {
        /* 1021 */
        msr = rdmsr64(0xc0011029);
        msr |= 0x2000;
        wrmsr64(0xc0011029, msr);
        
        /* 1033 */
        msr = rdmsr64(0xc0011020);
        msr |= 0x10;
        wrmsr64(0xc0011020, msr);
        
        /* 1049 */
        msr = rdmsr64(0xc0011028);
        msr |= 0x10;
        wrmsr64(0xc0011028, msr);
        
        /* 1095 */
        msr = rdmsr64(0xc0011020);
        msr |= 0x200000000000000;
        wrmsr64(0xc0011020, msr);
    }
    
    /*
     * Work around a problem on Ryzen that is triggered by executing
     * code near the top of user memory, in our case the signal
     * trampoline code in the shared page on amd64.
     *
     * This function is executed once for the BSP before tunables take
     * effect so the value determined here can be overridden by the
     * tunable.  This function is then executed again for each AP and
     * also on resume.  Set a flag the first time so that value set by
     * the tunable is not overwritten.
     *
     * The stepping and/or microcode versions should be checked after
     * this issue is fixed by AMD so that we don't use this mode if not
     * needed.
     */
    /*if (lower_sharedpage_init == 0) {
        lower_sharedpage_init = 1;
        if (info_p->cpuid_family == 0x17) {
            hw_lower_amd64_sharedpage = 1;
        }
    }
     amd64_lower_shared_page(struct sysentvec *sv)
    if (hw_lower_amd64_sharedpage != 0) {
                sv->sv_maxuser -= PAGE_SIZE;
                sv->sv_shared_page_base -= PAGE_SIZE;
                sv->sv_usrstack -= PAGE_SIZE;
                sv->sv_psstrings -= PAGE_SIZE;
            }*/
}

attached kernel for testing on 10.14.2

source is based on https://github.com/Shaneee92/Mojave_AMD_XNU (with opemu) + 2 functions (check p1.diff)

 

will also check https://github.com/torvalds/linux/blob/master/arch/x86/kernel/cpu/amd.c

 

the mach_msg_destroy_from_kernel_proper() will be available as soon as 10.14.2 sources are out. 

kernel

p1.diff

Thanks for this new kernel which can login desktop & rebuild prelinkedkernel at 10.14.2 & 10.14.3 beta in Ryzen 1700X & FX-6300 hackintoshs.

Firefox, cpu-x & EFI Mount V3, etc. apps worked as usually.

But App Store & Safari crashed on open in FX-6300 & Ryzen 1700X hackintoshs at 10.14.2 only, without this issue at 10.14.1 & 10.14.3.

[Edit]

At 10.14.1/10.14.3 it worked perfectly without any issue in Ryzen 1700X hackintosh.

Also performance of CineBench R15 was the best !

But in FX-6300 hackintosh video play issue in Safari still occured which may be due to RX-560 GPU &/or FX-6300 CPU instead of kernel.

Edited by jsl2000
Link to comment
Share on other sites

On 1/12/2019 at 4:40 AM, jalavoui said:

 

this can be ported from 10.14.2 (need some fixes to compile)


int __cdecl necp_client_add_flow(necp_fd_data *fd_data, necp_client_action_args *uap, int *retval)
{
  vm_size_t v3; // rdx
  vm_size_t v4; // rsi
  bool v5; // ST2F_1
  bool v6; // ST2D_1
  user_addr_t v7; // rdx
  vm_size_t v8; // rsi
  int result; // eax
  unsigned __int8 *necp_client_uuid; // [rsp+50h] [rbp-230h]
  unsigned int copy_error; // [rsp+7Ch] [rbp-204h]
  necp_stats_bufreq bufreq; // [rsp+80h] [rbp-200h]
  necp_client_flow_stats *stats_request; // [rsp+98h] [rbp-1E8h]
  int request_error; // [rsp+A4h] [rbp-1DCh]
  necp_client_interface_option *option_0; // [rsp+A8h] [rbp-1D8h]
  necp_client_interface_option *option; // [rsp+B0h] [rbp-1D0h]
  u_int32_t option_i; // [rsp+BCh] [rbp-1C4h]
  _Bool found_nexus; // [rsp+C3h] [rbp-1BDh]
  uint32_t_0 interface_index; // [rsp+C4h] [rbp-1BCh]
  size_t_0 assigned_results_length; // [rsp+C8h] [rbp-1B8h]
  void *assigned_results; // [rsp+D0h] [rbp-1B0h]
  necp_client_flow_registration *new_registration; // [rsp+D8h] [rbp-1A8h]
  pid_t pid; // [rsp+E4h] [rbp-19Ch]
  necp_client_add_flow *v24; // [rsp+E8h] [rbp-198h]
  necp_client_add_flow *allocated_add_request; // [rsp+F0h] [rbp-190h]
  necp_client_add_flow *add_request; // [rsp+F8h] [rbp-188h]
  proc *proc; // [rsp+100h] [rbp-180h]
  necp_client *client; // [rsp+108h] [rbp-178h]
  int error; // [rsp+114h] [rbp-16Ch]
  int *retvala; // [rsp+118h] [rbp-168h]
  necp_client_action_args *uapa; // [rsp+120h] [rbp-160h]
  necp_fd_data *fd_dataa; // [rsp+128h] [rbp-158h]
  __int64 v33; // [rsp+130h] [rbp-150h]
  vm_size_t nbytes; // [rsp+138h] [rbp-148h]
  void *kernel_addr; // [rsp+140h] [rbp-140h]
  user_addr_t user_addr; // [rsp+148h] [rbp-138h]
  __int64 v37; // [rsp+150h] [rbp-130h]
  vm_size_t v38; // [rsp+158h] [rbp-128h]
  void *v39; // [rsp+160h] [rbp-120h]
  user_addr_t v40; // [rsp+168h] [rbp-118h]
  __int64 v41; // [rsp+170h] [rbp-110h]
  vm_size_t v42; // [rsp+178h] [rbp-108h]
  void *v43; // [rsp+180h] [rbp-100h]
  user_addr_t v44; // [rsp+188h] [rbp-F8h]
  __int64 v45; // [rsp+190h] [rbp-F0h]
  vm_size_t v46; // [rsp+198h] [rbp-E8h]
  user_addr_t v47; // [rsp+1A0h] [rbp-E0h]
  void *v48; // [rsp+1A8h] [rbp-D8h]
  necp_client_add_flow_default default_add_request; // [rsp+1B0h] [rbp-D0h]
  necp_client_nexus_parameters parameters; // [rsp+1F0h] [rbp-90h]
  uuid_t client_id; // [rsp+250h] [rbp-30h]
  __int64 v52; // [rsp+268h] [rbp-18h]

  fd_dataa = fd_data;
  uapa = uap;
  retvala = retval;
  error = 0;
  client = 0LL;
  secure_memset(&parameters, 0, 0x60uLL);
  proc = 0LL;
  add_request = 0LL;
  allocated_add_request = 0LL;
  secure_memset(&default_add_request, 0, 0x3CuLL);
  if ( !uap->client_id || uapa->client_id_len != 16 )
  {
    error = 22;
    log(3, "%s: necp_client_add_flow invalid client_id (length %zu)\n", "necp_client_add_flow", uapa->client_id_len);
    goto LABEL_64;
  }
  if ( !uapa->buffer || uapa->buffer_size < 0x24 )
  {
    error = 22;
    log(3, "%s: necp_client_add_flow invalid buffer (length %zu)\n", "necp_client_add_flow", uapa->buffer_size);
    goto LABEL_64;
  }
  user_addr = uapa->client_id;
  kernel_addr = client_id;
  nbytes = 16LL;
  v33 = 16LL;
  error = copyin(user_addr, client_id, 0x10uLL);
  if ( error )
  {
    log(3, "%s: necp_client_add_flow copyin client_id error (%d)\n", "necp_client_add_flow", (unsigned int)error);
    goto LABEL_64;
  }
  if ( uapa->buffer_size > 0x3C )
  {
    v24 = (necp_client_add_flow *)_MALLOC(uapa->buffer_size, 118, 4, &necp_client_add_flow_site);
    allocated_add_request = v24;
    if ( !v24 )
    {
      error = 12;
      goto LABEL_64;
    }
    v4 = uapa->buffer_size;
    v44 = uapa->buffer;
    v43 = allocated_add_request;
    v42 = v4;
    v41 = -1LL;
    if ( v4 > 0xFFFFFFFFFFFFFFFFLL )
      panic(
        "\"__copyin_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)\"@/BuildRoot/Library/Caches/com.apple.x"
        "bs/Sources/xnu_debug/xnu-4903.231.4/bsd/libkern/copyio.h:45",
        v44,
        v43,
        v42,
        v41);
    error = copyin(v44, v43, v42);
    if ( error )
    {
      log(
        3,
        "%s: necp_client_add_flow copyin default_add_request error (%d)\n",
        "necp_client_add_flow",
        (unsigned int)error);
      goto LABEL_64;
    }
    add_request = allocated_add_request;
  }
  else
  {
    v3 = uapa->buffer_size;
    v40 = uapa->buffer;
    v39 = &default_add_request;
    v38 = v3;
    v37 = 60LL;
    if ( v3 > 0x3C )
      panic(
        "\"__copyin_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)\"@/BuildRoot/Library/Caches/com.apple.x"
        "bs/Sources/xnu_debug/xnu-4903.231.4/bsd/libkern/copyio.h:45",
        v40,
        v39,
        v38,
        v37);
    error = copyin(v40, v39, v38);
    if ( error )
    {
      log(
        3,
        "%s: necp_client_add_flow copyin default_add_request error (%d)\n",
        "necp_client_add_flow",
        (unsigned int)error);
      goto LABEL_64;
    }
    add_request = (necp_client_add_flow *)&default_add_request;
  }
  lck_mtx_lock((lck_mtx_t *)&fd_dataa->fd_lock);
  pid = fd_dataa->proc_pid;
  proc = proc_find(pid);
  if ( proc )
  {
    client = necp_client_fd_find_client_and_lock(fd_dataa, client_id);
    if ( client )
    {
      *((_BYTE *)client + 100) &= 0xFBu;
      necp_client_retain_locked(client);
      necp_client_copy_parameters_locked(client, &parameters);
      new_registration = necp_client_create_flow_registration(fd_dataa, client);
      if ( new_registration )
      {
        new_registration->flags = add_request->flags;
        uuid_copy(add_request->registration_id, new_registration->registration_id);
        if ( add_request->flags & 1 )
        {
          assigned_results = 0LL;
          assigned_results_length = 0LL;
          interface_index = 0;
          found_nexus = 0;
          for ( option_i = 0; option_i < client->interface_option_count; ++option_i )
          {
            if ( option_i >= 4 )
            {
              option_0 = &client->extra_interface_options[option_i - 4];
              if ( !uuid_compare(option_0->nexus_agent, add_request->agent_uuid) )
              {
                interface_index = option_0->interface_index;
                found_nexus = 1;
                break;
              }
            }
            else
            {
              option = &client->interface_options[option_i];
              if ( !uuid_compare(option->nexus_agent, add_request->agent_uuid) )
              {
                interface_index = option->interface_index;
                found_nexus = 1;
                break;
              }
            }
          }
          if ( found_nexus )
          {
            necp_client_add_nexus_flow_if_needed(new_registration, add_request->agent_uuid, interface_index);
            if ( new_registration->flags & 2 )
              necp_client_uuid = client->client_id;
            else
              necp_client_uuid = new_registration->registration_id;
            request_error = netagent_client_message_with_params(
                              add_request->agent_uuid,
                              necp_client_uuid,
                              pid,
                              client->agent_handle,
                              0xAu,
                              &parameters,
                              &assigned_results,
                              &assigned_results_length);
            if ( request_error )
            {
              if ( assigned_results )
                v5 = assfail(
                       "assigned_results == NULL",
                       "/BuildRoot/Library/Caches/com.apple.xbs/Sources/xnu_debug/xnu-4903.231.4/bsd/net/necp_client.c",
                       6107) != 0;
              if ( assigned_results_length )
                v6 = assfail(
                       "assigned_results_length == 0",
                       "/BuildRoot/Library/Caches/com.apple.xbs/Sources/xnu_debug/xnu-4903.231.4/bsd/net/necp_client.c",
                       6108) != 0;
              log(3, "%s: netagent_client_message error (%d)\n", "necp_client_add_flow", (unsigned int)request_error);
            }
            else if ( assigned_results && assigned_results_length )
            {
              if ( !necp_assign_client_result_locked(
                      proc,
                      fd_dataa,
                      client,
                      new_registration,
                      add_request->agent_uuid,
                      (u_int8_t *)assigned_results,
                      assigned_results_length,
                      0)
                && assigned_results )
              {
                FREE(assigned_results, 124);
              }
            }
            else if ( assigned_results )
            {
              FREE(assigned_results, 124);
            }
          }
          else
          {
            log(3, "%s: %s\n", "necp_client_add_flow", "Requested nexus not found");
          }
        }
        if ( (signed int)add_request->stats_request_count > 0 && !necp_arena_initialize(fd_dataa, 1) )
        {
          stats_request = (necp_client_flow_stats *)&add_request[1];
          secure_memset(&bufreq, 0, 0x18uLL);
          bufreq.necp_stats_bufreq_id = 191;
          *(_QWORD *)&bufreq.necp_stats_bufreq_type = *(_QWORD *)&stats_request->stats_type;
          bufreq.necp_stats_bufreq_size = stats_request->stats_size;
          bufreq._anon_0.necp_stats_bufreq_uaddr = stats_request->stats_addr;
          necp_stats_initialize(fd_dataa, client, new_registration, &bufreq);
          *(_QWORD *)&stats_request->stats_type = *(_QWORD *)&bufreq.necp_stats_bufreq_type;
          stats_request->stats_size = bufreq.necp_stats_bufreq_size;
          stats_request->stats_addr = bufreq._anon_0.necp_stats_bufreq_uaddr;
        }
        lck_mtx_unlock((lck_mtx_t *)&client->lock);
        lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
        necp_client_release(client);
        v7 = uapa->buffer;
        v8 = uapa->buffer_size;
        v48 = add_request;
        v47 = v7;
        v46 = v8;
        v45 = -1LL;
        if ( v8 > 0xFFFFFFFFFFFFFFFFLL )
          panic(
            "\"__copyout_chk object size check failed: uaddr %p, kaddr %p, (%zu < %zu)\"@/BuildRoot/Library/Caches/com.ap"
            "ple.xbs/Sources/xnu_debug/xnu-4903.231.4/bsd/libkern/copyio.h:54",
            v47,
            v48,
            v46,
            v45);
        copy_error = copyout(v48, v47, v46);
        if ( copy_error )
          log(3, "%s: necp_client_add_flow copyout add_request error (%d)\n", "necp_client_add_flow", copy_error);
      }
      else
      {
        error = 12;
        lck_mtx_unlock((lck_mtx_t *)&client->lock);
        lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
        log(3, "%s: %s\n", "necp_client_add_flow", "Failed to allocate flow registration");
      }
    }
    else
    {
      error = 2;
      lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
    }
  }
  else
  {
    lck_mtx_unlock((lck_mtx_t *)&fd_dataa->fd_lock);
    log(
      3,
      "%s: necp_client_add_flow process not found for pid %d error (%d)\n",
      "necp_client_add_flow",
      (unsigned int)pid,
      (unsigned int)error);
    error = 3;
  }
LABEL_64:
  *retvala = error;
  if ( error )
    log(3, "%s: Add flow error (%d)\n", "necp_client_add_flow", (unsigned int)error);
  if ( allocated_add_request )
    FREE(allocated_add_request, 118);
  if ( proc )
    proc_rele(proc);
  result = error;
  if ( _stack_chk_guard == v52 )
    result = error;
  return result;
}

 

i've just added a cpu errata code to xnu (from freebsd)


static void init_amd_erratas(i386_cpu_info_t *info_p)
{
    uint64_t msr;
    
    /*
     * Work around Erratum 721 for Family 10h and 12h processors.
     * These processors may incorrectly update the stack pointer
     * after a long series of push and/or near-call instructions,
     * or a long series of pop and/or near-return instructions.
     *
     * http://support.amd.com/us/Processor_TechDocs/41322_10h_Rev_Gd.pdf
     * http://support.amd.com/us/Processor_TechDocs/44739_12h_Rev_Gd.pdf
     *
     * Hypervisors do not provide access to the errata MSR,
     * causing #GP exception on attempt to apply the errata.  The
     * MSR write shall be done on host and persist globally
     * anyway, so do not try to do it when under virtualization.
     */
    
    switch (info_p->cpuid_family) {
        case 0x10:
        case 0x12:
            if ((info_p->cpuid_features & 0x80000000) == 0)
                wrmsr64(0xc0011029, rdmsr64(0xc0011029) | 1);
            break;
    }
    
    /*
     * BIOS may fail to set InitApicIdCpuIdLo to 1 as it should per BKDG.
     * So, do it here or otherwise some tools could be confused by
     * Initial Local APIC ID reported with CPUID Function 1 in EBX.
     */
    if (info_p->cpuid_family == 0x10) {
        if ((info_p->cpuid_features & 0x80000000) == 0) {
            msr = rdmsr64(0xc001001f);
            msr |= (uint64_t)1 << 54;
            wrmsr64(0xc001001f, msr);
        }
    }
    
    /*
     * BIOS may configure Family 10h processors to convert WC+ cache type
     * to CD.  That can hurt performance of guest VMs using nested paging.
     * The relevant MSR bit is not documented in the BKDG,
     * the fix is borrowed from Linux.
     */
    if (info_p->cpuid_family == 0x10) {
        if ((info_p->cpuid_features & 0x80000000) == 0) {
            msr = rdmsr64(0xc001102a);
            msr &= ~((uint64_t)1 << 24);
            wrmsr64(0xc001102a, msr);
        }
    }
    
    /*
     * Work around Erratum 793: Specific Combination of Writes to Write
     * Combined Memory Types and Locked Instructions May Cause Core Hang.
     * See Revision Guide for AMD Family 16h Models 00h-0Fh Processors,
     * revision 3.04 or later, publication 51810.
     */
    if (info_p->cpuid_family== 0x16 && info_p->cpuid_model <= 0xf) {
        if ((info_p->cpuid_features & 0x80000000) == 0) {
            msr = rdmsr64(0xc0011020);
            msr |= (uint64_t)1 << 15;
            wrmsr64(0xc0011020, msr);
        }
    }
    
    /* Ryzen erratas. */
    if (info_p->cpuid_family == 0x17 && info_p->cpuid_model == 0x1 &&
        (info_p->cpuid_features & 0x80000000) == 0) {
        /* 1021 */
        msr = rdmsr64(0xc0011029);
        msr |= 0x2000;
        wrmsr64(0xc0011029, msr);
        
        /* 1033 */
        msr = rdmsr64(0xc0011020);
        msr |= 0x10;
        wrmsr64(0xc0011020, msr);
        
        /* 1049 */
        msr = rdmsr64(0xc0011028);
        msr |= 0x10;
        wrmsr64(0xc0011028, msr);
        
        /* 1095 */
        msr = rdmsr64(0xc0011020);
        msr |= 0x200000000000000;
        wrmsr64(0xc0011020, msr);
    }
    
    /*
     * Work around a problem on Ryzen that is triggered by executing
     * code near the top of user memory, in our case the signal
     * trampoline code in the shared page on amd64.
     *
     * This function is executed once for the BSP before tunables take
     * effect so the value determined here can be overridden by the
     * tunable.  This function is then executed again for each AP and
     * also on resume.  Set a flag the first time so that value set by
     * the tunable is not overwritten.
     *
     * The stepping and/or microcode versions should be checked after
     * this issue is fixed by AMD so that we don't use this mode if not
     * needed.
     */
    /*if (lower_sharedpage_init == 0) {
        lower_sharedpage_init = 1;
        if (info_p->cpuid_family == 0x17) {
            hw_lower_amd64_sharedpage = 1;
        }
    }
     amd64_lower_shared_page(struct sysentvec *sv)
    if (hw_lower_amd64_sharedpage != 0) {
                sv->sv_maxuser -= PAGE_SIZE;
                sv->sv_shared_page_base -= PAGE_SIZE;
                sv->sv_usrstack -= PAGE_SIZE;
                sv->sv_psstrings -= PAGE_SIZE;
            }*/
}

attached kernel for testing on 10.14.2

source is based on https://github.com/Shaneee92/Mojave_AMD_XNU (with opemu) + 2 functions (check p1.diff)

 

will also check https://github.com/torvalds/linux/blob/master/arch/x86/kernel/cpu/amd.c

 

the mach_msg_destroy_from_kernel_proper() will be available as soon as 10.14.2 sources are out. 

the necp_client_add_flow() doesnt exist in 10.14.1 sources - maybe remove it and test ?

 

update:

- fixed cpu errata call spot

 

 

 

 

kernel

p2.diff

any changes between p1 and p2 diff ?
coz they both look the same .

Link to comment
Share on other sites

i've changed the pat patch in mtrr.c (check .diff)

need re-check amd errata flags - linux as many more.

 

please test it on 10.14.1/2

 

safari issues might be fixed when we get 10.14.2 sources (this is 10.14.1 hacked version)

 

updated with bsd code (for errata) - this rises others questions (check amd features code)

 

shanee u need to revert previous github pach to apply this one.

 

bsd sources can be found here http://fxr.watson.org/fxr/source/amd64/amd64/initcpu.c#L135

 

xlnc this is from 10.14.2

int __cdecl necp_client_action(proc *p, necp_client_action_args *uap, int *retval)
{
  u_int32_t action; // [rsp+1Ch] [rbp-34h]
  necp_fd_data *fd_data; // [rsp+20h] [rbp-30h]
  int return_value; // [rsp+28h] [rbp-28h]
  int error; // [rsp+2Ch] [rbp-24h]
  int *retvala; // [rsp+30h] [rbp-20h]
  necp_client_action_args *uapa; // [rsp+38h] [rbp-18h]
  proc *pa; // [rsp+40h] [rbp-10h]
  int v11; // [rsp+4Ch] [rbp-4h]

  pa = p;
  uapa = uap;
  retvala = retval;
  error = 0;
  return_value = 0;
  fd_data = 0LL;
  error = necp_find_fd_data(uap->necp_fd, &fd_data);
  if ( error )
  {
    log(3, "%s: necp_client_action find fd error (%d)\n", "necp_client_action", (unsigned int)error);
    v11 = error;
  }
  else
  {
    action = uapa->action;
    switch ( action )
    {
      case 1u:
        return_value = necp_client_add(pa, fd_data, uapa, retvala);
        break;
      case 2u:
        return_value = necp_client_remove(fd_data, uapa, retvala);
        break;
      case 3u:
      case 4u:
      case 16u:
        return_value = necp_client_copy(fd_data, uapa, retvala);
        break;
      case 5u:
        return_value = necp_client_list(fd_data, uapa, retvala);
        break;
      case 6u:
        return_value = necp_client_request_nexus(fd_data, uapa, retvala);
        break;
      case 7u:
        return_value = necp_client_agent_action(fd_data, uapa, retvala);
        break;
      case 8u:
        return_value = necp_client_copy_agent(fd_data, uapa, retvala);
        break;
      case 9u:
        return_value = necp_client_copy_interface(fd_data, uapa, retvala);
        break;
      case 10u:
        return_value = 45;
        break;
      case 11u:
        return_value = necp_client_copy_route_statistics(fd_data, uapa, retvala);
        break;
      case 12u:
        return_value = necp_client_agent_use(fd_data, uapa, retvala);
        break;
      case 13u:
        return_value = necp_client_map_sysctls(fd_data, uapa, retvala);
        break;
      case 14u:
        return_value = necp_client_update_cache(fd_data, uapa, retvala);
        break;
      case 15u:
        return_value = necp_client_copy_client_update(fd_data, uapa, retvala);
        break;
      case 17u:
        return_value = necp_client_add_flow(fd_data, uapa, retvala);
        break;
      case 18u:
        return_value = necp_client_remove_flow(fd_data, uapa, retvala);
        break;
      default:
        log(3, "%s: necp_client_action unknown action (%u)\n", "necp_client_action", action);
        return_value = 22;
        break;
    }
    file_drop(uapa->necp_fd);
    v11 = return_value;
  }
  return v11;
}

we will get this code with new sources, i tried to start porting some code but it as so many calls - i'll wait for apple to release it.

 

i'll keep this code here for further checking

/*
  753                  * AMD CPUID Specification
  754                  * http://support.amd.com/us/Embedded_TechDocs/25481.pdf
  755                  *
  756                  * Intel Processor Identification and CPUID Instruction
  757                  * http://www.intel.com/assets/pdf/appnote/241618.pdf
  758                  */
  759                 if (cpu_high > 0) {
  760 
  761                         /*
  762                          * Here we should probably set up flags indicating
  763                          * whether or not various features are available.
  764                          * The interesting ones are probably VME, PSE, PAE,
  765                          * and PGE.  The code already assumes without bothering
  766                          * to check that all CPUs >= Pentium have a TSC and
  767                          * MSRs.
  768                          */
  769                         printf("\n  Features=0x%b", cpu_feature,
  770                         "\020"
  771                         "\001FPU"       /* Integral FPU */
  772                         "\002VME"       /* Extended VM86 mode support */
  773                         "\003DE"        /* Debugging Extensions (CR4.DE) */
  774                         "\004PSE"       /* 4MByte page tables */
  775                         "\005TSC"       /* Timestamp counter */
  776                         "\006MSR"       /* Machine specific registers */
  777                         "\007PAE"       /* Physical address extension */
  778                         "\010MCE"       /* Machine Check support */
  779                         "\011CX8"       /* CMPEXCH8 instruction */
  780                         "\012APIC"      /* SMP local APIC */
  781                         "\013oldMTRR"   /* Previous implementation of MTRR */
  782                         "\014SEP"       /* Fast System Call */
  783                         "\015MTRR"      /* Memory Type Range Registers */
  784                         "\016PGE"       /* PG_G (global bit) support */
  785                         "\017MCA"       /* Machine Check Architecture */
  786                         "\020CMOV"      /* CMOV instruction */
  787                         "\021PAT"       /* Page attributes table */
  788                         "\022PSE36"     /* 36 bit address space support */
  789                         "\023PN"        /* Processor Serial number */
  790                         "\024CLFLUSH"   /* Has the CLFLUSH instruction */
  791                         "\025<b20>"
  792                         "\026DTS"       /* Debug Trace Store */
  793                         "\027ACPI"      /* ACPI support */
  794                         "\030MMX"       /* MMX instructions */
  795                         "\031FXSR"      /* FXSAVE/FXRSTOR */
  796                         "\032SSE"       /* Streaming SIMD Extensions */
  797                         "\033SSE2"      /* Streaming SIMD Extensions #2 */
  798                         "\034SS"        /* Self snoop */
  799                         "\035HTT"       /* Hyperthreading (see EBX bit 16-23) */
  800                         "\036TM"        /* Thermal Monitor clock slowdown */
  801                         "\037IA64"      /* CPU can execute IA64 instructions */
  802                         "\040PBE"       /* Pending Break Enable */
  803                         );
  804 
  805                         if (cpu_feature2 != 0) {
  806                                 printf("\n  Features2=0x%b", cpu_feature2,
  807                                 "\020"
  808                                 "\001SSE3"      /* SSE3 */
  809                                 "\002PCLMULQDQ" /* Carry-Less Mul Quadword */
  810                                 "\003DTES64"    /* 64-bit Debug Trace */
  811                                 "\004MON"       /* MONITOR/MWAIT Instructions */
  812                                 "\005DS_CPL"    /* CPL Qualified Debug Store */
  813                                 "\006VMX"       /* Virtual Machine Extensions */
  814                                 "\007SMX"       /* Safer Mode Extensions */
  815                                 "\010EST"       /* Enhanced SpeedStep */
  816                                 "\011TM2"       /* Thermal Monitor 2 */
  817                                 "\012SSSE3"     /* SSSE3 */
  818                                 "\013CNXT-ID"   /* L1 context ID available */
  819                                 "\014SDBG"      /* IA32 silicon debug */
  820                                 "\015FMA"       /* Fused Multiply Add */
  821                                 "\016CX16"      /* CMPXCHG16B Instruction */
  822                                 "\017xTPR"      /* Send Task Priority Messages*/
  823                                 "\020PDCM"      /* Perf/Debug Capability MSR */
  824                                 "\021<b16>"
  825                                 "\022PCID"      /* Process-context Identifiers*/
  826                                 "\023DCA"       /* Direct Cache Access */
  827                                 "\024SSE4.1"    /* SSE 4.1 */
  828                                 "\025SSE4.2"    /* SSE 4.2 */
  829                                 "\026x2APIC"    /* xAPIC Extensions */
  830                                 "\027MOVBE"     /* MOVBE Instruction */
  831                                 "\030POPCNT"    /* POPCNT Instruction */
  832                                 "\031TSCDLT"    /* TSC-Deadline Timer */
  833                                 "\032AESNI"     /* AES Crypto */
  834                                 "\033XSAVE"     /* XSAVE/XRSTOR States */
  835                                 "\034OSXSAVE"   /* OS-Enabled State Management*/
  836                                 "\035AVX"       /* Advanced Vector Extensions */
  837                                 "\036F16C"      /* Half-precision conversions */
  838                                 "\037RDRAND"    /* RDRAND Instruction */
  839                                 "\040HV"        /* Hypervisor */
  840                                 );
  841                         }
  842 
  843                         if (amd_feature != 0) {
  844                                 printf("\n  AMD Features=0x%b", amd_feature,
  845                                 "\020"          /* in hex */
  846                                 "\001<s0>"      /* Same */
  847                                 "\002<s1>"      /* Same */
  848                                 "\003<s2>"      /* Same */
  849                                 "\004<s3>"      /* Same */
  850                                 "\005<s4>"      /* Same */
  851                                 "\006<s5>"      /* Same */
  852                                 "\007<s6>"      /* Same */
  853                                 "\010<s7>"      /* Same */
  854                                 "\011<s8>"      /* Same */
  855                                 "\012<s9>"      /* Same */
  856                                 "\013<b10>"     /* Undefined */
  857                                 "\014SYSCALL"   /* Have SYSCALL/SYSRET */
  858                                 "\015<s12>"     /* Same */
  859                                 "\016<s13>"     /* Same */
  860                                 "\017<s14>"     /* Same */
  861                                 "\020<s15>"     /* Same */
  862                                 "\021<s16>"     /* Same */
  863                                 "\022<s17>"     /* Same */
  864                                 "\023<b18>"     /* Reserved, unknown */
  865                                 "\024MP"        /* Multiprocessor Capable */
  866                                 "\025NX"        /* Has EFER.NXE, NX */
  867                                 "\026<b21>"     /* Undefined */
  868                                 "\027MMX+"      /* AMD MMX Extensions */
  869                                 "\030<s23>"     /* Same */
  870                                 "\031<s24>"     /* Same */
  871                                 "\032FFXSR"     /* Fast FXSAVE/FXRSTOR */
  872                                 "\033Page1GB"   /* 1-GB large page support */
  873                                 "\034RDTSCP"    /* RDTSCP */
  874                                 "\035<b28>"     /* Undefined */
  875                                 "\036LM"        /* 64 bit long mode */
  876                                 "\0373DNow!+"   /* AMD 3DNow! Extensions */
  877                                 "\0403DNow!"    /* AMD 3DNow! */
  878                                 );
  879                         }
  880 
  881                         if (amd_feature2 != 0) {
  882                                 printf("\n  AMD Features2=0x%b", amd_feature2,
  883                                 "\020"
  884                                 "\001LAHF"      /* LAHF/SAHF in long mode */
  885                                 "\002CMP"       /* CMP legacy */
  886                                 "\003SVM"       /* Secure Virtual Mode */
  887                                 "\004ExtAPIC"   /* Extended APIC register */
  888                                 "\005CR8"       /* CR8 in legacy mode */
  889                                 "\006ABM"       /* LZCNT instruction */
  890                                 "\007SSE4A"     /* SSE4A */
  891                                 "\010MAS"       /* Misaligned SSE mode */
  892                                 "\011Prefetch"  /* 3DNow! Prefetch/PrefetchW */
  893                                 "\012OSVW"      /* OS visible workaround */
  894                                 "\013IBS"       /* Instruction based sampling */
  895                                 "\014XOP"       /* XOP extended instructions */
  896                                 "\015SKINIT"    /* SKINIT/STGI */
  897                                 "\016WDT"       /* Watchdog timer */
  898                                 "\017<b14>"
  899                                 "\020LWP"       /* Lightweight Profiling */
  900                                 "\021FMA4"      /* 4-operand FMA instructions */
  901                                 "\022TCE"       /* Translation Cache Extension */
  902                                 "\023<b18>"
  903                                 "\024NodeId"    /* NodeId MSR support */
  904                                 "\025<b20>"
  905                                 "\026TBM"       /* Trailing Bit Manipulation */
  906                                 "\027Topology"  /* Topology Extensions */
  907                                 "\030PCXC"      /* Core perf count */
  908                                 "\031PNXC"      /* NB perf count */
  909                                 "\032<b25>"
  910                                 "\033DBE"       /* Data Breakpoint extension */
  911                                 "\034PTSC"      /* Performance TSC */
  912                                 "\035PL2I"      /* L2I perf count */
  913                                 "\036MWAITX"    /* MONITORX/MWAITX instructions */
  914                                 "\037<b30>"
  915                                 "\040<b31>"
  916                                 );
  917                         }
  918 
  919                         if (cpu_stdext_feature != 0) {
  920                                 printf("\n  Structured Extended Features=0x%b",
  921                                     cpu_stdext_feature,
  922                                        "\020"
  923                                        /* RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */
  924                                        "\001FSGSBASE"
  925                                        "\002TSCADJ"
  926                                        "\003SGX"
  927                                        /* Bit Manipulation Instructions */
  928                                        "\004BMI1"
  929                                        /* Hardware Lock Elision */
  930                                        "\005HLE"
  931                                        /* Advanced Vector Instructions 2 */
  932                                        "\006AVX2"
  933                                        /* FDP_EXCPTN_ONLY */
  934                                        "\007FDPEXC"
  935                                        /* Supervisor Mode Execution Prot. */
  936                                        "\010SMEP"
  937                                        /* Bit Manipulation Instructions */
  938                                        "\011BMI2"
  939                                        "\012ERMS"
  940                                        /* Invalidate Processor Context ID */
  941                                        "\013INVPCID"
  942                                        /* Restricted Transactional Memory */
  943                                        "\014RTM"
  944                                        "\015PQM"
  945                                        "\016NFPUSG"
  946                                        /* Intel Memory Protection Extensions */
  947                                        "\017MPX"
  948                                        "\020PQE"
  949                                        /* AVX512 Foundation */
  950                                        "\021AVX512F"
  951                                        "\022AVX512DQ"
  952                                        /* Enhanced NRBG */
  953                                        "\023RDSEED"
  954                                        /* ADCX + ADOX */
  955                                        "\024ADX"
  956                                        /* Supervisor Mode Access Prevention */
  957                                        "\025SMAP"
  958                                        "\026AVX512IFMA"
  959                                        "\027PCOMMIT"
  960                                        "\030CLFLUSHOPT"
  961                                        "\031CLWB"
  962                                        "\032PROCTRACE"
  963                                        "\033AVX512PF"
  964                                        "\034AVX512ER"
  965                                        "\035AVX512CD"
  966                                        "\036SHA"
  967                                        "\037AVX512BW"
  968                                        "\040AVX512VL"
  969                                        );
  970                         }
  971 
  972                         if (cpu_stdext_feature2 != 0) {
  973                                 printf("\n  Structured Extended Features2=0x%b",
  974                                     cpu_stdext_feature2,
  975                                        "\020"
  976                                        "\001PREFETCHWT1"
  977                                        "\002AVX512VBMI"
  978                                        "\003UMIP"
  979                                        "\004PKU"
  980                                        "\005OSPKE"
  981                                        "\027RDPID"
  982                                        "\037SGXLC"
  983                                        );
  984                         }
  985 
  986                         if (cpu_stdext_feature3 != 0) {
  987                                 printf("\n  Structured Extended Features3=0x%b",
  988                                     cpu_stdext_feature3,
  989                                        "\020"
  990                                        "\033IBPB"
  991                                        "\034STIBP"
  992                                        "\035L1DFL"
  993                                        "\036ARCH_CAP"
  994                                        "\040SSBD"
  995                                        );
  996                         }
  997 
  998                         if ((cpu_feature2 & CPUID2_XSAVE) != 0) {
  999                                 cpuid_count(0xd, 0x1, regs);
 1000                                 if (regs[0] != 0) {
 1001                                         printf("\n  XSAVE Features=0x%b",
 1002                                             regs[0],
 1003                                             "\020"
 1004                                             "\001XSAVEOPT"
 1005                                             "\002XSAVEC"
 1006                                             "\003XINUSE"
 1007                                             "\004XSAVES");
 1008                                 }
 1009                         }
 1010 
 1011                         if (cpu_ia32_arch_caps != 0) {
 1012                                 printf("\n  IA32_ARCH_CAPS=0x%b",
 1013                                     (u_int)cpu_ia32_arch_caps,
 1014                                        "\020"
 1015                                        "\001RDCL_NO"
 1016                                        "\002IBRS_ALL"
 1017                                        "\003RSBA"
 1018                                        "\004SKIP_L1DFL_VME"
 1019                                        "\005SSB_NO"
 1020                                        );
 1021                         }
 1022 
 1023                         if (amd_extended_feature_extensions != 0) {
 1024                                 printf("\n  "
 1025                                     "AMD Extended Feature Extensions ID EBX="
 1026                                     "0x%b", amd_extended_feature_extensions,
 1027                                     "\020"
 1028                                     "\001CLZERO"
 1029                                     "\002IRPerf"
 1030                                     "\003XSaveErPtr");
 1031                         }

btw the attached kernel is from 10.14.1 sources so it should work better on same os x version. 

 

found pci/quircks fixs from linux we might need todo on xnu

https://elixir.bootlin.com/linux/v5.0-rc3/source/arch/x86/pci/fixup.c

https://elixir.bootlin.com/linux/v5.0-rc3/source/arch/x86/kernel/quirks.c#L50

the usb fix is just great.

 

kernel

 

p3rupN.diff

Edited by jalavoui
  • Like 2
Link to comment
Share on other sites

1 hour ago, jalavoui said:

i've changed the pat patch in mtrr.c (check .diff)

need re-check amd errata flags - linux as many more.

 

please test it on 10.14.1/2

 

safari issues might be fixed when we get 10.14.2 sources (this is 10.14.1 hacked version)

 

 

 

 

p4.diff

kernel

 

Can you make the diff like so please,

 

diff -rupN "original xnu folder" "patched xnu folder" > "output.name" 

Having issues applying it to my source.

 

Edit: Runs well. Not noticing any improvements from previous source though.

Link to comment
Share on other sites

1 hour ago, jalavoui said:

i've changed the pat patch in mtrr.c (check .diff)

need re-check amd errata flags - linux as many more.

 

please test it on 10.14.1/2

 

safari issues might be fixed when we get 10.14.2 sources (this is 10.14.1 hacked version)

 

 

 

 

p4.diff

kernel

Please post the unified diff using -u flag

thanks

Link to comment
Share on other sites

2 hours ago, jalavoui said:

i've changed the pat patch in mtrr.c (check .diff)

need re-check amd errata flags - linux as many more.

 

please test it on 10.14.1/2

 

safari issues might be fixed when we get 10.14.2 sources (this is 10.14.1 hacked version)

 

updated with bsd code (for errata)

shanee u need to revert previous github pach to apply this one.

 

 

 

 

 

p5.diff

Thanks for this p4 version which worked perfectly at 10.14.1 & 10.14.3 beta, but App Store & Safari still crashed on open at 10.14.2 in Ryzen 1700X hackintosh.

Link to comment
Share on other sites

Hi guys, tried to update to 10.14.3 but I'm having problem to rebuild the prelinkedkernel

Link failed (error code 5).
Prelink failed for com.apple.driver.AppleMobileFileIntegrity; omitting from prelinked kernel.
Can't use AppleMobileFileIntegrity.kext - not linked.
Prelink failed for com.apple.security.sandbox; omitting from prelinked kernel.
Can't use Sandbox.kext - not linked.
Prelink failed for com.apple.security.quarantine; omitting from prelinked kernel.
Can't use AppleMobileFileIntegrity.kext - not linked.
Prelink failed for com.apple.AppleSystemPolicy; aborting prelink.
Failed to generate prelinked kernel.
Child process /usr/sbin/kextcache[856] exited with status 71.
Error 107 rebuilding /System/Library/PrelinkedKernels/prelinkedkernel

 

Link to comment
Share on other sites

5 minutes ago, innerd said:

Hi guys, tried to update to 10.14.3 but I'm having problem to rebuild the prelinkedkernel


Link failed (error code 5).
Prelink failed for com.apple.driver.AppleMobileFileIntegrity; omitting from prelinked kernel.
Can't use AppleMobileFileIntegrity.kext - not linked.
Prelink failed for com.apple.security.sandbox; omitting from prelinked kernel.
Can't use Sandbox.kext - not linked.
Prelink failed for com.apple.security.quarantine; omitting from prelinked kernel.
Can't use AppleMobileFileIntegrity.kext - not linked.
Prelink failed for com.apple.AppleSystemPolicy; aborting prelink.
Failed to generate prelinked kernel.
Child process /usr/sbin/kextcache[856] exited with status 71.
Error 107 rebuilding /System/Library/PrelinkedKernels/prelinkedkernel

 

 

Use the kernel attached to this post, 

Don't use a custom System kext and it'll work.

 

 

  • Like 1
Link to comment
Share on other sites

 

Thanks for this p3rupN kernel which can login to desktop and rebuild prelinkedkernel at 10.14.1, 10.14.2, & 10.14.3 beta.

Video play issue in Safari still occured at 10.14.1 & 10.14.3 beta in FX-6300 hackintosh.

App Store & Safari crashed on open at 10.14.2.

[Edit]

Darwin JSs-iMac-2.local 18.2.0 Darwin Kernel Version 18.2.0: Mon Jan 21 23:01:11 WET 2019; root:xnu-4903.221.2/BUILD/obj/RELEASE_X86_64 x86_64

This kernel can login to desktop and rebuild prelinkedkernel at 10.14.4 beta1 in Ryzen 1700X hackintosh, but not working in FX-6300 hackintosh.

[Edit 2]

App Store & Safari crashed on open at 10.14.2 can be fixed by

Replace this framework in /System/Library/PrivateFrameworks

After open Safari and other Apple app.

AppleMediaServices.framework.zip provided by gengik84

Screen Shot 2019-01-26 at 12.02.17 PM.png

 

Edited by jsl2000
Link to comment
Share on other sites

UPDATE 5 :- 

The reloading bug seems to be only on FX 8xxx/9xxx model cpu's and some apu's . Ryzen cpu's/apu's are unaffected ofc.
To fix the reloading issue's i mentioned on "UPDATE-4" post
Go to System Preferences -> General 

And set the Accent Color to the last one color i.e ( Grey ) .
NOTE
You can keep the Appereance settings to Light or Dark , its your choice.

but this workaround still doesnt fix this one issue " Fast forwarding any video on youtube in safari will reload the webpage ." 
but fixes the rest of the issues .

XLNC_10.14.1.zip

sysctl.txt

Screenshot_2019-01-08_at_2.55.49_PM.png

Screenshot 2019-01-09 at 6.43.38 AM.png

Link to comment
Share on other sites

55 minutes ago, XLNC said:

UPDATE 5 :- 

The reloading bug seems to be only on FX 8xxx/9xxx model cpu's and some apu's . Ryzen cpu's/apu's are unaffected ofc.
To fix the reloading issue's i mentioned on "UPDATE-4" post
Go to System Preferences -> General 

And set the Accent Color to the last one color i.e ( Grey ) .
NOTE
You can keep the Appereance settings to Light or Dark , its your choice.

but this workaround still doesnt fix this one issue " Fast forwarding any video on youtube in safari will reload the webpage ." 
but fixes the rest of the issues .

XLNC_10.14.1.zip

sysctl.txt

Screenshot_2019-01-08_at_2.55.49_PM.png

Screenshot 2019-01-09 at 6.43.38 AM.png

Thanks, but it did not fix video play issue of Safari at 10.14.1 in my FX-6300 hackintosh.

FX-6300.txt.zip

Edited by jsl2000
Link to comment
Share on other sites

1 hour ago, jsl2000 said:

Thanks, but it did not fix video play issue of Safari at 10.14.1 in my FX-6300 hackintosh.

FX-6300.txt.zip

yes i know .
thats why i mentioned    " but this workaround still doesnt fix this one issue " Fast forwarding any video on youtube in safari will reload the webpage ." "
in my above post .
but it fixes rest of the issues like while opening facebook.com reloads the webpage issue etc .

Link to comment
Share on other sites

8 hours ago, XLNC said:

yes i know .
thats why i mentioned    " but this workaround still doesnt fix this one issue " Fast forwarding any video on youtube in safari will reload the webpage ." "
in my above post .
but it fixes rest of the issues like while opening facebook.com reloads the webpage issue etc .

Yes, but I mean that it's worse in FX-6300 hackintosh.

Every movement in Safari for video will induce webpage reload issue.

Link to comment
Share on other sites

05.02.2019 в 04:59 justinjohn0306 сказал:

AMD FX-4100  // Gigabyte  -970A-DS3P  // Сапфир AMD / ATI Radeon HD 6670

 

Я получаю панику ядра после раскладки экрана клавиатуры ... после экрана данных и конфиденциальности

 


 

Read the post carefully

Edited by myrsikus
Link to comment
Share on other sites

 Share

×
×
  • Create New...