Skip to content

Commit

Permalink
Make ANS2 workaround optional, thx savvas
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Dec 19, 2020
1 parent 026aa5b commit 1e968a4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NVMeFix Changelog
=================
#### v1.0.5
- Fixed quirks enabling per controller
- Fixed initialisation on 10.15+

#### v1.0.4
- Added MacKernelSDK with Xcode 12 compatibility
Expand Down
2 changes: 1 addition & 1 deletion NVMeFix.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
2FF3E70623AE1DA100D8CDEB /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1220;
LastUpgradeCheck = 1230;
ORGANIZATIONNAME = acidanthera;
TargetAttributes = {
2FF3E70E23AE1DA100D8CDEB = {
Expand Down
16 changes: 11 additions & 5 deletions NVMeFix/NVMeFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,18 @@ bool NVMeFixPlugin::solveSymbols(KernelPatcher& kp) {

/* mov eax, [rdi+0xA8] */
res &= kextMembers.AppleNVMeRequest.result.fromFunc(kextFuncs.AppleNVMeRequest.GetStatus.fptr,
0x8b, 0, 7, 4) &
0x8b, 0, 7, 4) &&
/* movzx eax, byte ptr [rdi+0x10A] */
kextMembers.AppleNVMeRequest.command.fromFunc(kextFuncs.AppleNVMeRequest.GetOpcode.fptr,
0xf, 0, 7) &
0xf, 0, 7) &&
/* mov [rbx+0xC0], r12 */
kextMembers.AppleNVMeRequest.prpDescriptor.fromFunc(kextFuncs.IONVMeController.IssueIdentifyCommand.fptr,
0x89, 4, 3) &&
0x89, 4, 3);

/* cmp byte ptr [rdi+269h], 0 */
kextMembers.IONVMeController.ANS2MSIWorkaround.fromFunc(kextFuncs.IONVMeController.FilterInterruptRequest.fptr,
kextMembers.IONVMeController.ANS2MSIWorkaround.fromFunc(kextFuncs.IONVMeController.FilterInterruptRequest.fptr,
0x80, 7, 7, 0, 32);

if (res)
kextMembers.AppleNVMeRequest.controller.offs = kextMembers.AppleNVMeRequest.result.offs - 12;

Expand Down Expand Up @@ -195,7 +197,11 @@ void NVMeFixPlugin::handleController(ControllerEntry& entry) {
* start of FilterIRQ instead so that FilterIRQ does not race with itself. This seems to eliminate
* the timeouts.
**/
kextMembers.IONVMeController.ANS2MSIWorkaround.get(entry.controller) = 1;
if (kextMembers.IONVMeController.ANS2MSIWorkaround.has()) {
kextMembers.IONVMeController.ANS2MSIWorkaround.get(entry.controller) = 1;
} else {
DBGLOG(Log::Plugin, "Ignoring ANS2 workaround patch on newer system");
}

/* First get quirks based on PCI device */
entry.quirks = NVMe::quirksForController(entry.controller);
Expand Down
4 changes: 4 additions & 0 deletions NVMeFix/NVMeFixPlugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ class NVMeFixPlugin {
return getMember<T>(obj, offs);
}

bool has() {
return offs != 0;
}

bool fromFunc(mach_vm_address_t start, uint32_t opcode, uint32_t reg, uint32_t rm,
uint32_t add=0, size_t ninsts_max=128) {
if (offs)
Expand Down

0 comments on commit 1e968a4

Please sign in to comment.