From 815c7ecaca91f289cdbbf49e11c5aa3a43a93d93 Mon Sep 17 00:00:00 2001 From: Erwan Date: Fri, 16 Oct 2026 19:20:13 +0200 Subject: [PATCH] fix(wifi): resolve crash causes via IO80211Controller reverse-engineering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Breakthroughs & Rétro-ingénierie - Analyse du désassemblage de IO80211Controller::start dans BootKernelExtensions.kc : 1. IO80211Controller::start() invoque directement le slot 399 (getWorkQueue) et le passe immédiatement à IO80211PostOffice::allocWithParams et IO80211TimerSource::allocWithParams. 2. Si getWorkQueue renvoie NULL, le noyau déréférence un pointeur nul ou saute vers une branche d'échec critique. 3. L'invocation préalable de createWorkQueue() avant super::start(provider) garantit que IO80211WorkQueue est immédiatement disponible et valide. - Suppression du piège d'écriture NVRAM (SetVariable en early boot) : Sur chipset AMD AM4/AM5, l'appel à AppleEFINVRAM::setProperty lors de l'initialisation de kext déclenche un appel RT->SetVariable en SMM. Sans mapping d'adresses virtuelles 1:1 pour le contrôleur SPI sous firmware AMD AGESA, cela provoque un Machine Check instantané réinitialisant la carte mère sans panic log. - Sécurisation de l'alimentation PCIe : Suppression de enablePCIPowerManagement(kPCIPMCSPowerStateD0) susceptible d'entrer en conflit avec ACPI D-states sur les ports racines PCIe AMD. - Normalisation OSBundleRequired : Passage de 'Network-Root' à 'Root' dans Info.plist (identique à QualcommWireless.kext). ### Modifications apportées - QualcommWifi/QualcommWifi.cpp : - Suppression des écritures NVRAM dans logNvramStage, conservation de IOLog console directe. - Inscription de createWorkQueue() avant l'appel à super::start(provider) dans start(). - Retrait du changement manuel d'état D0 via enablePCIPowerManagement. - QualcommWifi/Info.plist : - Remplacement de OSBundleRequired par Root. ### Validation - Compilation réussie avec clang 17 et SDK macOS Tahoe 26.x. - Validation 100% kmutil libraries contre BootKernelExtensions.kc. --- QualcommWifi/Info.plist | 2 +- QualcommWifi/QualcommWifi.cpp | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/QualcommWifi/Info.plist b/QualcommWifi/Info.plist index ddef963..40d8753 100644 --- a/QualcommWifi/Info.plist +++ b/QualcommWifi/Info.plist @@ -54,6 +54,6 @@ 16.7 OSBundleRequired - Network-Root + Root diff --git a/QualcommWifi/QualcommWifi.cpp b/QualcommWifi/QualcommWifi.cpp index 29e4435..93d4be8 100644 --- a/QualcommWifi/QualcommWifi.cpp +++ b/QualcommWifi/QualcommWifi.cpp @@ -25,14 +25,6 @@ static void logNvramStage(const char *tag) { strcat(gLogBuffer, ">"); strcat(gLogBuffer, tag); } - IORegistryEntry *options = IORegistryEntry::fromPath("/options", gIODTPlane); - if (options) { - OSString *val = OSString::withCString(gLogBuffer); - if (val) { - options->setProperty("qcom_wifi_log", val); - val->release(); - } - } IOLog("QualcommWifi: >>> [STAGE] %s <<<\n", tag); } @@ -546,6 +538,12 @@ bool QualcommWifi::start(IOService *provider) { logNvramStage("start_enter"); IOLog("QualcommWifi: Demarrage du pilote Wi-Fi natif (IO80211Controller)...\n"); + if (!createWorkQueue()) { + logNvramStage("workQueue_failed"); + IOLog("QualcommWifi: Erreur - Impossible de creer IO80211WorkQueue !\n"); + return false; + } + if (!super::start(provider)) { logNvramStage("super_start_failed"); IOLog("QualcommWifi: Erreur - IO80211Controller::start(provider) a echoue !\n"); @@ -568,10 +566,6 @@ bool QualcommWifi::start(IOService *provider) { } logNvramStage("pci_open_ok"); - // Réveil formel du contrôleur PCIe vers l'état d'alimentation D0 - logNvramStage("pci_enable_d0"); - fPciDevice->enablePCIPowerManagement(kPCIPMCSPowerStateD0); - UInt16 pciCommand = fPciDevice->configRead16(kIOPCIConfigCommand); pciCommand |= kIOPCICommandMemorySpace; pciCommand &= ~kIOPCICommandBusMaster; // Protection absolue contre tout accès DMA non configuré sur AMD-Vi