Jump to content

AMD Mojave Kernel Development and Testing


Shaneee
 Share

263 posts in this topic

Recommended Posts

1 hour ago, XLNC said:


@jsl2000 can you change your accent color ( System Preferences -> General ) on your FX system .
because on my FX system selecting a different accent color doesnt change the window color .
same as this user :
 

  Reveal hidden contents

 

 

I think it's the bug of Mojave O.S. or memory.

I have tested with two different kernels/prelinkedkernels got the same result:

1. Basically it can correctly change the colors if selected from the left blue to the right grey by order.

2. But repeated or randomly changes it may resume previous color instead of current selection.

Link to comment
Share on other sites

9 minutes ago, jsl2000 said:

I think it's the bug of Mojave O.S. or memory.

I have tested with two different kernels/prelinkedkernels got the same result:

1. Basically it can correctly change the colors if selected from the left blue to the right grey by order.

2. But repeated or randomly changes it may resume previous color instead of current selection.

Yes but the window color should change like this

 

47D0B066-AB0D-473B-B5E5-438C839B9F06.jpeg

 

But it doesnt . 

Only the highlight color gets changed but not the background window color on FX.

Edited by XLNC
Link to comment
Share on other sites

49 minutes ago, XLNC said:

Yes but the window color should change like this

 

47D0B066-AB0D-473B-B5E5-438C839B9F06.jpeg

 

But it doesnt . 

Only the highlight color gets changed but not the background window color on FX.

What I got when it's wrong was attached here:

Screen Shot 2019-01-10 at 6.47.12 AM.png

Screen Shot 2019-01-10 at 6.47.37 AM.png

Link to comment
Share on other sites

8 hours ago, XLNC said:


try this one .
https://www.dropbox.com/s/usrhnr4apbagxpj/XLNC_prelinkedkernel.fx4.zip?dl=0

and as shaneee mentioned . also do share the pk screenshot when occured .
also add your complete system specs in your signature.

Thanks for this fx4 can login to desktop at 10.14.1 in FX-6300 hackintosh smoothly, but it did not work at 10.14.2 yet !

Video play in Safari still not compatible, but other apps working fine.

fx4.txt

Edited by jsl2000
Link to comment
Share on other sites

I just have a few questions since I've wiped my drive and prepped it for installation.

 

  1. After the reboot from pre-installing Mojave, besides replacing the PK and editing the plist, what other steps are needed to be done before rebooting to finish the installation?
  2. The step(s) that specifies to rebuild PK, kexts, etc. via installer doesn't work for me, as I am not sure when that step should be done (whether before attempting to boot to the desktop or after)?
  3. I've downloaded XLNC_v3, used the prelinkedkernel from that folder the replace the exisiting PK in the macOS Install Data folder of the drive. Should I do anything with the kernel and System.kext files BEFORE rebooting to complete the installation?

I've attached my CLOVER folder to display the drivers/kext I currently have. Now, whether I'm missing anything or something is in the wrong place, I'm not 100% sure. My USB uses the same CLOVER files (kexts,drivers) as High Sierra, which installed successfully.

 

Here's my specs:

 

MSI B350M GAMING PRO

Ryzen 5-1600 @ 3.7GHz

16GB DDR4 2666MHz

GIGABYTE Radeon RX 560 4GB

CLOVER.zip

Link to comment
Share on other sites

6 hours ago, vintr said:

Nothing but KP :( 
Right before the KP it always drops something I believe to be related with the USB host controller. Tried to google it, but no luck. Dunno how to overcome this.

IMG_20190110_020030.jpg

Whats your system specs ?

and the pk has usb kexts in so you should not get usb error spam.

did you boot with kcsuffix=fx4 ?

4 hours ago, Datdude717 said:

I just have a few questions since I've wiped my drive and prepped it for installation.

 

  1. After the reboot from pre-installing Mojave, besides replacing the PK and editing the plist, what other steps are needed to be done before rebooting to finish the installation?
  2. The step(s) that specifies to rebuild PK, kexts, etc. via installer doesn't work for me, as I am not sure when that step should be done (whether before attempting to boot to the desktop or after)?
  3. I've downloaded XLNC_v3, used the prelinkedkernel from that folder the replace the exisiting PK in the macOS Install Data folder of the drive. Should I do anything with the kernel and System.kext files BEFORE rebooting to complete the installation?

I've attached my CLOVER folder to display the drivers/kext I currently have. Now, whether I'm missing anything or something is in the wrong place, I'm not 100% sure. My USB uses the same CLOVER files (kexts,drivers) as High Sierra, which installed successfully.

 

Here's my specs:

 

MSI B350M GAMING PRO

Ryzen 5-1600 @ 3.7GHz

16GB DDR4 2666MHz

GIGABYTE Radeon RX 560 4GB

CLOVER.zip

 

After initial install replace pk and edit the plist 

then proceed for second stage installation from clover menu and when its done

reboot to usb again open terminal 

copy the kernel and kext to installed mojave then fix permissions and rebuild caches 

finally boot to that macos volume from clover menu of your usb .

Link to comment
Share on other sites

14 minutes ago, XLNC said:

Whats your system specs ?

and the pk has usb kexts in so you should not get usb error spam.

did you boot with kcsuffix=fx4 ?

My system specs are in my signature, should I add more info about RAM, HDDs, etc?

Actually, I did boot with -v npci=0x3000 debug=0x100 keepsyms=1 kcsuffix=fx4. For some reason even with this kernel I still get USB error.

 

UPD: apparently, my signature doesn't show up, I'll deal with that a little later.

My specs are:

ASUS M5A78L-M LX3
FX 4300, 8 GB DDR3
GTX 760 2 GB
macOS High Sierra 10.13.1 // Windows 10

Edited by vintr
Link to comment
Share on other sites

On 1/10/2019 at 2:36 PM, vintr said:

My system specs are in my signature, should I add more info about RAM, HDDs, etc?

Actually, I did boot with -v npci=0x3000 debug=0x100 keepsyms=1 kcsuffix=fx4. For some reason even with this kernel I still get USB error.

 

UPD: apparently, my signature doesn't show up, I'll deal with that a little later.

My specs are:

ASUS M5A78L-M LX3
FX 4300, 8 GB DDR3
GTX 760 2 GB
macOS High Sierra 10.13.1 // Windows 10

According to my experience up to now  Shaneee's prelinkedkernel.test & XLNC's prelinkedkernel.v3, prelinkedkernel.xlnc, prelinkedkernel.fx4 can login desktop at 10.14.1  in my FX-6300 hackintosh. You may try other kernels/prelinkedkernels, but I guess all will get KP before login to desktop.

[Edit]

1. Install LZVN decompressor tool at /usr/local/bin/lzvn I can extract kernel and kexts from different prelinkedkernels.

2. Repeated testing again found that after rebuild prelinkedkernel with kernel.v3 or kernel.xlnc will work in FX-6300 hackintosh too !

Edited by jsl2000
Link to comment
Share on other sites

16 minutes ago, jsl2000 said:

You may try other kernels/prelinkedkernels, but I guess all will get KP before login to desktop.

You're right, I've tried all PKs, but no matter which one of them I'm using, I always get KP.

Edited by vintr
Link to comment
Share on other sites

45 minutes ago, vintr said:

You're right, I've tried all PKs, but no matter which one of them I'm using, I always get KP.

If you can get a cloned Intel partition of 10.14.1, just replaced kernel/prelinkedkernel/System.kext, etc. in respective location you can login desktop without KP immediately !

Link to comment
Share on other sites

UPDATE 4 :-
These are the bugs currently i am experiencing on FX system. 

 

- Launching few websites like "brew.sh" or "facebook.com" in safari will keep on reloading the webpage in a loop.
- Fast forwarding any video on youtube in safari will reload the webpage .
- brew.sh opens fine on chrome but upon opening facebook.com website on chrome crashes the webpage with "aw snap message"

so the only issues i have are related to networking or caused due to networking 
may be caused due to this stub function 
https://github.com/Shaneee92/Mojave_AMD_XNU/commit/4e0ec7372aaa6f457baad7027c48f91f110b08fc

i have recorded the console log upon launching those websites
look at the below videos :
https://www.dropbox.com/s/m9k4kw8lmxcxjuf/Screen Recording 2019-01-10 at 10.03.02 AM.mov?dl=0
https://www.dropbox.com/s/rbfwgstytts0y8z/Screen Recording 2019-01-10 at 10.15.16 AM.mov?dl=0


other than these issues everything else is working fine .

Edited by XLNC
  • Like 1
Link to comment
Share on other sites

3 hours ago, XLNC said:

UPDATE 4 :-
These are the bugs currently i am experiencing on FX system. 

 

- Launching few websites like "brew.sh" or "facebook.com" in safari will keep on reloading the webpage in a loop.
- Fast forwarding any video on youtube in safari will reload the webpage .
- brew.sh opens fine on chrome but upon opening facebook.com website on chrome crashes the webpage with "aw snap message"

so the only issues i have are related to networking or caused due to networking 
may be caused due to this stub function 
https://github.com/Shaneee92/Mojave_AMD_XNU/commit/4e0ec7372aaa6f457baad7027c48f91f110b08fc

i have recorded the console log upon launching those websites
look at the below videos :
https://www.dropbox.com/s/m9k4kw8lmxcxjuf/Screen Recording 2019-01-10 at 10.03.02 AM.mov?dl=0
https://www.dropbox.com/s/rbfwgstytts0y8z/Screen Recording 2019-01-10 at 10.15.16 AM.mov?dl=0


other than these issues everything else is working fine .

even I have problems with facebook, with youtube I have no problems
Link to comment
Share on other sites

6 hours ago, XLNC said:

UPDATE 4 :-
These are the bugs currently i am experiencing on FX system. 

 

- Launching few websites like "brew.sh" or "facebook.com" in safari will keep on reloading the webpage in a loop.
- Fast forwarding any video on youtube in safari will reload the webpage .
- brew.sh opens fine on chrome but upon opening facebook.com website on chrome crashes the webpage with "aw snap message"

so the only issues i have are related to networking or caused due to networking 
may be caused due to this stub function 
https://github.com/Shaneee92/Mojave_AMD_XNU/commit/4e0ec7372aaa6f457baad7027c48f91f110b08fc

i have recorded the console log upon launching those websites
look at the below videos :
https://www.dropbox.com/s/m9k4kw8lmxcxjuf/Screen Recording 2019-01-10 at 10.03.02 AM.mov?dl=0
https://www.dropbox.com/s/rbfwgstytts0y8z/Screen Recording 2019-01-10 at 10.15.16 AM.mov?dl=0


other than these issues everything else is working fine .

I have successfully installed mojave thanks to your tip related to data/privacy screen.

With both your files and Shanee's ı can boot to desktop now but as you said some websites are the only seen problem as for now.

ı am using fx 8370 and amd r9 280x gpu by the way.

Thanks to both of you.

Link to comment
Share on other sites

On 1/3/2019 at 1:12 AM, jalavoui said:

testing both kernels, all good so far.

Is there a way to ignore kext errors and generate a valid prelinkedkernel ?

 

got missing symbols in AppleMobileFileIntegrity.kext

so i hacked 10.14.1 shanee source and rebuild for 10.14.2

this version rebuilds the prelinked kernel without errors

 

i've made a prelinkedkernel using the basesystem kexts (from the installer media)

might help if u cant use the os x installer (just replace the prelinkedkernel in your usb install media) 

 

System.zip

prelinkedkernel.zip

Thanks for this testing kernel/prelinkedkernel/System.kext which worked at 10.14.2 in my Ryzen 1700X hackintosh.

But cpu-x, EFI Mount V3, App Store, & Safari crashed on open.

Need change Audio ID (1 --> 0) to enable HDMI audio from AMD 7950 GPU.

[Edit]

It got KP during booting in FX-6300 hackintosh.

Edited by jsl2000
Link to comment
Share on other sites

On 1/10/2019 at 6:26 PM, XLNC said:

so the only issues i have are related to networking or caused due to networking 
may be caused due to this stub function 
https://github.com/Shaneee92/Mojave_AMD_XNU/commit/4e0ec7372aaa6f457baad7027c48f91f110b08fc
 

 

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

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

 Share

×
×
  • Create New...