Jump to content

Clover Bug/Issue Report and Patch

Clover Issue Bug Report Patch

  • Please log in to reply
2533 replies to this topic

#2521
Download-Fritz

Download-Fritz

    ygolohcysp desreveR

  • Developers
  • 758 posts
  • Gender:Not Telling

That's restoring from SMRAM but I was just showing you that it can only be written in PEI. S3 SMM driver runs in PEI, and DXE must dispatch SMM call to save it. You can see that from the code you just linked, it uses SMM lock box. Look at the code for SMM lock box, the service instance runs in PEI (and obviously SMM).

 

Well, of course it uses the LockBox...

DXE driver writes a Boot Script -> BootScriptLib saves the data to LockBox -> reset -> PEIM retrieves lock box -> DXE executes Boot Scripts and resumes.



#2522
apianti

apianti

    I have dementia!

  • Developers
  • 470 posts
  • Gender:Not Telling

Well, of course it uses the LockBox...

DXE driver writes a Boot Script -> BootScriptLib saves the data to LockBox -> reset -> PEIM retrieves lock box -> DXE executes Boot Scripts and resumes.

 

I guess I am not being clear enough or something. That's only valid for EDK2 based firmware. You don't know how the firmware actually performs this, maybe it doesn't use SMM and instead uses some internal stuff in NVRAM/ROM. Since you don't know how the firmware actually stores the boot script table, you using that code means you have to change the DXE driver for S3 so that you do know how it's stored - in an SMM lock box. You changing that S3 DXE driver means you also have to change the S3 PEI driver because you can't be sure the method that is being used store/retrieve the boot script table otherwise. If you store in an SMM lock box and the PEI driver doesn't read from there to restore then it's useless. Is that clearer for what I'm trying to say?



#2523
Zenith432

Zenith432

    InsanelyMac Legend

  • Developers
  • 733 posts
  • Gender:Male
In Clover's Kext Patcher, there is an option to patch a kext's Info.plist with
<key>InfoPlistPatch</key>
<true/>
 
Unfortunately, for kexts packed in prelinkedkernel this feature is nearly useless.  Because the Info.Plist used is the one placed inside __PRELINK_INFO segment of the prelinked kernel.
For example, here's the full Info.plist for AppleHDAController
Spoiler


and here's what's found inside __PRELINK_INFO
Spoiler


The section IOKitPersonalities is missing, which is the most useful part to patch.
The personalities for kexts are cached in
/System/Library/Caches/com.apple.kext.caches/Startup/IOKitPersonalities_x86_64.ioplist.gz
which is only loaded by the kernel after starting.

#2524
Slice

Slice

    InsanelyMac V.I.P.

  • Local Moderators
  • 6,341 posts
  • Gender:Male
  • Location:Moscow

@fabiosun

Your posts moved to General Discussion. This topic is for developers.



#2525
PMheart

PMheart

    InsanelyMac Legend

  • Coders
  • 838 posts
  • Gender:Female
  • Location:Singapore

Hi, a bit off-topic:

In this line: https://sourceforge....patcher.c#l1879

Better to use DBG_RT() for consistency...

 

And also. The code somehow doesn't look healthy to me. Under "switch (gCPUStructure.Model)" branch, if a "stupid" (no offense) user enable "KernelXCPM" by accident and his/her CPU is supported natively (e.g. Haswell/Broadwell, etc), then HaswellLowEndXCPM patch will get applied...



#2526
Slice

Slice

    InsanelyMac V.I.P.

  • Local Moderators
  • 6,341 posts
  • Gender:Male
  • Location:Moscow

Hi, a bit off-topic:

In this line: https://sourceforge....patcher.c#l1879

Better to use DBG_RT() for consistency...

 

And also. The code somehow doesn't look healthy to me. Under "switch (gCPUStructure.Model)" branch, if a "stupid" (no offense) user enable "KernelXCPM" by accident and his/her CPU is supported natively (e.g. Haswell/Broadwell, etc), then HaswellLowEndXCPM patch will get applied...

Agree about DBG_RT, fixed.

      switch (gCPUStructure.Model) {
...
          default:
            if (gCPUStructure.Model >= CPU_MODEL_HASWELL &&
               (AsciiStrStr(gCPUStructure.BrandString, "Celeron") || AsciiStrStr(gCPUStructure.BrandString, "Pentium"))) {
              // Haswell+ low-end CPU
              EnableExtCpuXCPM = HaswellLowEndXCPM;
            }
            break;

It will be for Haswell Celeron of higher Celeron.

Else EnableExtCpuXCPM == NULL (? - I wish duplicate it)



#2527
RehabMan

RehabMan

    InsanelyMacaholic

  • Developers
  • 3,138 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars
The commit for r4242 breaks InjectKexts=Detect.

When InjectKexts=Detect and FakeSMC.kext is in the kernel cache, no kexts from EFI/Clover/kexts should be injected.

And there's more.
Even with that fixed (reverted), still kexts are being injected with Detect and FakeSMC.kext installed.
I'll try to figure out why (probably this new "kext management" stuff is the problem).

But yeah, InjectKexts=Detect is broken.

#2528
cecekpawon

cecekpawon

    InsanelyMac Legend

  • Developers
  • 856 posts
  • Gender:Male

Check here.



#2529
apianti

apianti

    I have dementia!

  • Developers
  • 470 posts
  • Gender:Not Telling

Slice, unsure why you removed that search for FakeSMC. There was always ability to disable kext injection, now each kext can be disabled individually. The behavior by the Detect value was that kexts are injected if there is no FakeSMC in the cache. This is to provide different behavior for installers and system volumes with no kexts installed, and system volumes with kexts installed. This is to prevent having to use multiple instances of clover, one that has injection and one that doesn't, say if you have an install already but want to create another.

 

EDIT: I guess what you're saying is go through, disable all of them and it's the same behavior? That seems like a lot more work though...
EDIT2: Also that code is atrocious... -1 and -2 offsets? Why wouldn't it just find every "<" and then check if it ended with "dict>" or "/dict>"... lol

EDIT3: @RehabMan, You need to revert multiple sources to fix it: https://sourceforge....boot/code/4242/



#2530
RehabMan

RehabMan

    InsanelyMacaholic

  • Developers
  • 3,138 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars

EDIT3: @RehabMan, You need to revert multiple sources to fix it: https://sourceforge....boot/code/4242/


I know. But even with both changes, not enough. New code for "kext management" stuff is interfering I think.
I was going to work on it, but then I got caught in a quagmire of trying to make the Esc key do the right thing (that one has bugged me for a long time).

Are we having fun yet?

#2531
apianti

apianti

    I have dementia!

  • Developers
  • 470 posts
  • Gender:Not Telling

Entirely possible that it's broken because of that, I'm not exactly sure why it was even necessary to provide such detailed kext injection disabling... Who's injecting that many kexts? I have FakeSMC and that's it... I install the rest I want after the OS. I think they don't understand that the injection is meant to be used in situations where you can't install kexts... But eh. As for trying to figure out anything with the GUI, good luck with that. There's so many random loops inside of each other because the GUI (rEFIt) was badly designed from the start (sorry Christoph!)... Granted, I think Clover has pushed it beyond the breaking point. But GUIs should have only one loop that draws, handles input and dispatches it accordingly.. A single task GUI can be easily implemented with a stack of "screens" that are drawn so the loop just walks down the stack until it reaches a fullscreen "screen" then walks back up the stack drawing each "screen". Entering a menu just pushes that menu onto the top of the stack and exiting means popping from the stack. Multitasking is a little harder but really only involves using a list of "windows" instead of a stack, only updating the screen when you know something changes (invalidation), and directing input towards the active "window" (or sometimes switching the active "window" or directing the input to a inactive window, like scroll wheel). Though I digress, lol.



#2532
RehabMan

RehabMan

    InsanelyMacaholic

  • Developers
  • 3,138 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars

Entirely possible that it's broken because of that, I'm not exactly sure why it was even necessary to provide such detailed kext injection disabling... Who's injecting that many kexts? I have FakeSMC and that's it... I install the rest I want after the OS. I think they don't understand that the injection is meant to be used in situations where you can't install kexts... But eh. As for trying to figure out anything with the GUI, good luck with that. There's so many random loops inside of each other because the GUI (rEFIt) was badly designed from the start (sorry Christoph!)... Granted I think Clover has pushed it beyond the breaking point. But GUIs should have only one loop that draws, handles input and dispatches it accordingly.. A single task GUI can be easily implemented with a stack of "screens" that are drawn so the loop just walks down the stack until it reaches a fullscreen "screen" then walks back up the stack drawing each "screen". Entering a menu just pushes that menu onto the top of the stack and exiting means popping from the stack. Multitasking is a little harder but really only involves using a list of "windows" instead of a stack, only updating the screen when you know something changes (invalidation), and directing input towards the active "window" (or sometimes switching the active "window" or directing the input to a inactive window, like scroll wheel). Though I digress, lol.


Agree 100% on the questionable need for this kext management feature.
And also 100% on injection vs. installing... I usually explain to people several times per day that they should be installing kexts, not injecting and that injection is only for essential kexts needed by the installer or recovery.
But I'll work out the issue of InjectKexts=Detect, it is just a matter of time.

And now I have the Esc key and space key working correctly.

And yes, the menu handling code in there could use a redesign (like you mention), but it is workable if you're careful. As always, rushed code is buggy code.

#2533
RehabMan

RehabMan

    InsanelyMacaholic

  • Developers
  • 3,138 posts
  • Gender:Male
  • Location:Bellingham, WA
  • Interests:skiing, software, classic cars

But I'll work out the issue of InjectKexts=Detect, it is just a matter of time.


Got it.
I think I was running the wrong build when initially testing (then got sidetracked on the other things I mentioned).

That said, now that InjectKexts=Detect is working again, things are little strange with that kext management menu.
For example, with Detect and FakeSMC.kext installed, you would expect that all the kexts would be marked for exclusion when you enter that menu, but that is not the case... they are unchecked in that scenario which might lead one to believe they'll be injected, which is not going to happen. This is probably what prompted the other changes that broke InjectKexts. But we can't break InjectKexts=Detect for this GUI feature.

So, two things need to happen:
- the initial checkmarks should represent the current state of whether the system will inject or not (depending on InjectKexts setting and FakeSMC status)
- once changes are made to the status of those checkmarks, it should be honored regardless of InjectKexts setting

I'll see if I can work that out (probably won't be today, and all this is happening in my github fork anyway).

Edit: The trick will be how to determine the status of FakeSMC relative to the prelinked kernel when the prelinked kernel hasn't been loaded yet!

#2534
Slice

Slice

    InsanelyMac V.I.P.

  • Local Moderators
  • 6,341 posts
  • Gender:Male
  • Location:Moscow

I need kexts injection from EFI for a testing purpose. If the testing kexts leads to panic then I can disable it through GUI.

Moreover I can remove it by Shell or place good one instead of it. For example PS2Keyboard. I need the working kext and can't boot with bad one.

 

About "Detect". What if FakeSMC presents in both places, in SLE and in Other/ ? I think it will work.







Also tagged with one or more of these keywords: Clover, Issue, Bug, Report, Patch


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2017 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy