Skip to content
This repository has been archived by the owner on Aug 3, 2018. It is now read-only.

Commit

Permalink
Add igfxsnb=1 to ensure proper IntelAccelerator name for Sandy Bridge…
Browse files Browse the repository at this point in the history
… CPUs for GVA support
  • Loading branch information
vit9696 committed Apr 8, 2018
1 parent 16ab53c commit 13c64b0
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 7 deletions.
9 changes: 4 additions & 5 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,13 @@ IntelGraphicsFixup Changelog
- Ensure standard connector-less framebuffers are used

#### v1.2.7
- Added `igfxgl=1` boot argument (and `disable-metal` property) to disable Metal support
- Add `igfxgl=1` boot argument (and `disable-metal` property) to disable Metal support
- Add `igfxsnb=1` boot argument (and `modern-sandy` property) to rename Gen6Accelerator with IntelAccelerator to fix GVA warnings
- Harden solved symbol verification to avoid panics with broken kext cache
- Replace connector-less Sandy Bridge framebuffer for unsupported macmodels from 0x30030 to 0x50000

In order to boot with `igfxgl=1` on 10.13.x you may need to set the defaults:
```
sudo defaults write /Library/Preferences/com.apple.CoreDisplay useMetal -boolean no
sudo defaults write /Library/Preferences/com.apple.CoreDisplay useIOP -boolean no
```

### v1.2.8
- Harden solved symbol verification to avoid panics with broken kext cache
- Replace connector-less Sandy Bridge framebuffer for unsupported macmodels from 0x30030 to 0x50000
4 changes: 2 additions & 2 deletions IntelGraphicsFixup.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
MODULE_NAME = as.lvs1974.IntelGraphicsFixup;
MODULE_START = "$(PRODUCT_NAME)_kern_start";
MODULE_STOP = "$(PRODUCT_NAME)_kern_stop";
MODULE_VERSION = 1.2.8;
MODULE_VERSION = 1.2.7;
OTHER_CFLAGS = (
"-mmmx",
"-msse",
Expand Down Expand Up @@ -448,7 +448,7 @@
MODULE_NAME = as.lvs1974.IntelGraphicsFixup;
MODULE_START = "$(PRODUCT_NAME)_kern_start";
MODULE_STOP = "$(PRODUCT_NAME)_kern_stop";
MODULE_VERSION = 1.2.8;
MODULE_VERSION = 1.2.7;
OTHER_CFLAGS = (
"-mmmx",
"-msse",
Expand Down
43 changes: 43 additions & 0 deletions IntelGraphicsFixup/kern_igfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ bool IGFX::intelGraphicsStart(IOService *that, IOService *provider) {
that->removeProperty("MetalStatisticsName");
}

if (CPUInfo::getGeneration() == CPUInfo::CpuGeneration::SandyBridge) {
callbackIgfx->moderniseAccelerator = provider->getProperty("modern-sandy") != nullptr;
PE_parse_boot_argn("igfxsnb", &callbackIgfx->moderniseAccelerator, sizeof(callbackIgfx->moderniseAccelerator));
if (callbackIgfx->moderniseAccelerator)
that->setName("IntelAccelerator");
}

return callbackIgfx->orgGraphicsStart(that, provider);
}

Expand Down Expand Up @@ -964,6 +971,25 @@ bool IGFX::loadCustomBinary(void *that, bool restore) {
return false;
}

OSObject *IGFX::copyExistingServices(OSDictionary *matching, IOOptionBits inState, IOOptionBits options) {
if (callbackIgfx && callbackIgfx->orgCopyExistingServices) {
if (callbackIgfx->moderniseAccelerator && matching && inState == kIOServiceMatchedState && options == 0) {
auto name = OSDynamicCast(OSString, matching->getObject(gIONameMatchKey));
if (name) {
DBGLOG("igfx", "found matching request by name %s", name->getCStringNoCopy());
if (name->isEqualTo("Gen6Accelerator")) {
DBGLOG("igfx", "found and fixed Gen6Accelerator request");
matching->setObject(gIONameMatchKey, OSString::withCString("IntelAccelerator"));
}
}
}

return callbackIgfx->orgCopyExistingServices(matching, inState, options);
}

return nullptr;
}

void IGFX::processKernel(KernelPatcher &patcher) {
// We need to load vinfo in all cases but reset
if (resetFramebuffer != FBRESET) {
Expand All @@ -983,6 +1009,23 @@ void IGFX::processKernel(KernelPatcher &patcher) {
patcher.clearError();
}

// This is necessary, because Sandy VAD bundle refers to Gen6Accelerator (unlike AppleGVA, which forces IntelAccelerator).
if (CPUInfo::getGeneration() == CPUInfo::CpuGeneration::SandyBridge) {
auto copyServices = patcher.solveSymbol(KernelPatcher::KernelID, "__ZN9IOService20copyExistingServicesEP12OSDictionaryjj");
if (copyServices) {
orgCopyExistingServices = reinterpret_cast<t_copy_existing_services>(patcher.routeFunction(copyServices, reinterpret_cast<mach_vm_address_t>(copyExistingServices), true));
if (patcher.getError() == KernelPatcher::Error::NoError)
DBGLOG("igfx", "routed __ZN9IOService20copyExistingServicesEP12OSDictionaryjj");
else
SYSLOG("igfx", "failed to route __ZN9IOService20copyExistingServicesEP12OSDictionaryjj");

} else {
SYSLOG("igfx", "failed to obtain __ZN9IOService20copyExistingServicesEP12OSDictionaryjj");
}

patcher.clearError();
}

lockDeviceAccess();
correctDeviceProperties();
unlockDeviceAccess();
Expand Down
9 changes: 9 additions & 0 deletions IntelGraphicsFixup/kern_igfx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class IGFX {

using t_safe_force_wake = void (*)(void *that, bool a, uint32_t b);

using t_copy_existing_services = OSObject *(*)(OSDictionary *matching, IOOptionBits inState, IOOptionBits options);

/**
* Hooked methods / callbacks
*/
Expand All @@ -193,6 +195,7 @@ class IGFX {
static uint64_t igBufferGetGpuVirtualAddress(void *that);
static bool dmaHostToGuC(void *that, uint64_t gpuAddr, uint32_t gpuReg, uint32_t dataLen, uint32_t dmaType, bool unk);
static void initInterruptServices(void *that);
static OSObject *copyExistingServices(OSDictionary *matching, IOOptionBits inState, IOOptionBits options);

/**
* IGPU PCI Config device-id faking wrappers
Expand Down Expand Up @@ -221,6 +224,7 @@ class IGFX {
t_dma_host_to_guc orgDmaHostToGuC {nullptr};
t_init_intr_services orgInitInterruptServices {nullptr};
t_safe_force_wake orgSafeForceWake {nullptr};
t_copy_existing_services orgCopyExistingServices {nullptr};

/**
* Original IGPU PCI Config readers
Expand Down Expand Up @@ -317,6 +321,11 @@ class IGFX {
*/
bool hasExternalAMD {false};

/**
* Set modern name to Sandy Accelerator
*/
int moderniseAccelerator {0};

/**
* Loaded vinfo
*/
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ An open source kernel extension providing patches to select Intel GPUs.
- Allows booting in VESA mode with Intel HD graphics (via `-igfxvesa` boot argument)
- Performs basic framebuffer id injection when none is specified (connector-less frames will be used with discrete GPUs)
- Allows GuC microcode loading with Intel Skylake/Kaby Lake Graphics in 10.13 (via `igfxfw=1` boot argument)
- Renames Gen6Accelerator with IntelAccelerator for Sandy Bridge CPUs for GVA support (via `igfxsnb=1` boot argument or `modern-sandy` property)
- Allows booting with OpenGL-only acceleration (via `ngfxgl=0` boot argument or `disable-metal` property)

#### Configuration
Add `-igfxdbg` to enable debug printing (available in DEBUG binaries).
Expand All @@ -23,6 +25,8 @@ Add `-igfxvesa` to boot Intel graphics without hardware acceleration (VESA mode)
Add `igfxfw=1` to enable GuC microcode loading in 10.13 or newer.
Add `igfxrst=1` to prefer drawing Apple logo at 2nd boot stage instead of framebuffer copying.
Add `igfxframe=frame` to inject a dedicated framebuffer identifier into IGPU (only for TESTING purposes).
Add `igfxsnb=1` to ensure proper IntelAccelerator name for Sandy Bridge CPUs for GVA support
Add `ngfxgl=0` to disable Metal support

#### Credits
- [Apple](https://www.apple.com) for macOS
Expand Down

0 comments on commit 13c64b0

Please sign in to comment.