KernelPatch 0.13.8 fundamental incompatibility with MTK 4.14 (begonia/Redmi Note 8 Pro)
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- c, linux
- Área
- operating-systems, security
Línea de trabajo
Empieza leyendo el código de mapeo inicial en start.c y map.c, especialmente map_phys_alloc() y mem_proc(), e inspecciona cómo se resuelven los símbolos de memblock en MTK 4.14. Reproduce el fallo de begonia usando las imágenes de arranque indicadas y el canal de crash de expdb. Se considera terminado cuando el fallback de 5 argumentos se gestione de forma segura y se valide una ruta de mapeo compatible con 4.x sin hooks.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Upstream Report: KernelPatch Incompatibility with MTK 4.14 (begonia/Redmi Note 8 Pro)
Device Information
- Codename: begonia
- Device: Redmi Note 8 Pro (Xiaomi)
- Platform: MT6785 (MTK)
- Kernel: 4.14.356-openela-rc1-Suzakukernel-V2
- Compiler: Clang version 11.0.1 (Android build)
- KP version: 0.13.8 (d08)
Executive Summary
KernelPatch's early-boot virtual-memory rework (_paging_init + memblock reserve/alloc/image relocation) is fundamentally incompatible with this MTK 4.14 kernel across ALL KP versions (0.13.0 through 0.13.8), even with zero hooks installed. The fault is in KP's core boot-time mapping machinery, not the hook subsystem or feature toggles.
Cross-Version Behavioral Matrix (all fresh-repatched from boot_work.img)
| kpimg | map/start path | failure mode | time->recovery | boots? |
|---|---|---|---|---|
| stock (no KP) | n/a | none | n/a | YES |
| 0.13.8 d08 | new _paging_init | quick crash → recovery | ~1 min | NO |
0.13.8 no-hooks (patch()=0) |
none | quick crash → recovery | ~1 min | NO |
| 0.13.0 d00 | old/simple paging | LONG hang → recovery | ~7 min | NO |
| 0.13.7 d07 | intermediate | LONG hang → recovery | ~7 min | NO |
Key observation: 0.13.0/0.13.7 with the old simpler paging path ALSO fail. This is NOT a 0.13.8 regression — the entire KP early mapping path is incompatible with this device.
Root-Cause Localization
1. Memblock 5-arg argument fragility (CONFIRMED)
On begonia, memblock_phys_alloc_try_nid (3-arg) is absent from the kernel. The patcher falls back to the 5-arg memblock_alloc_try_nid(size, align, min_addr, max_addr, nid).
The bug: KP's map_phys_alloc() calls through a 3-arg typedef memblock_phys_alloc_try_nid_f(size, align, int nid) even when the resolved function is the 5-arg memblock_alloc_try_nid. Only x0=size, x1=align, x2=third_arg(=0) are set; x3 (max_addr) and x4 (nid) hold garbage from registers at the call site.
Consequence: In memblock_alloc_try_nid, if the garbage max_addr lands below min_addr=0, the range is empty, allocation fails, start_pa returns 0, and the paging hook relocates the kernel into physical address 0 → init SIGSEGV at ~2.4s.
Evidence:
- Patch log line 53-56:
[?] no symbol: memblock_phys_alloc_try_nid/[+] use memblock_alloc_try_nid as map phys alloc - Upstream 0.13.8 map.c lines 54-64 already has the
third_argdistiction but it's insufficient when the 5-arg path is taken with garbage max_addr
Fix: When memblock_phys_alloc_type == MAP_SYM_MEMBLOCK_ALLOC_TRY_NID, call the 5-arg function with all 5 arguments properly: (size, align, 0, ~0ULL, 0) — i.e., min_addr=0, max_addr=anywhere, nid=0.
2. mem_proc linear_voffset probe (same class of bug)
The linear map offset detection at map.c lines 140-149 calls memblock_phys_alloc_try_nid(0, 0x10, NUMA_NO_NODE) through the 3-arg typedef against the 5-arg function, producing garbage detect_phys → linear_voffset is wrong → kernel image relocation is wrong → later crash.
Fix: Same pattern — detect the memblock_phys_alloc_type and call the 5-arg memblock_alloc_try_nid with all 5 args when needed.
3. Fundamental KP/core incompatibility (CONFIRMED by cross-version)
- 0.13.8 (new
_paging_initscratch path, gated to 6.x vianew_era = kmajor > 5) → crashes on 4.14 taking legacy path - 0.13.0 (old simple paging, no scratch) → crashes with long hang
- 0.13.7 (intermediate) → crashes
- Zero-hooks build (patch() returns 0 immediately, no panic/rest_init/kernel_init hooks installed) → still crashes
- Conclusion: The bug is in KP's early
start.c/map.cmapping code, not the hook subsystem or feature toggles. The entire_paging_init/_paging_initrework approach is incompatible with this MTK 4.14 kernel.
Diagnostic Channels
/sys/fs/pstore/console-ramoops — USELESS
- Returns the same 27711-byte dump (md5
912f79c4358489313533346be5c068d8) every crash - Even after
rm -fand a fresh crash - MTK crashes go through
mrdump/aeepath which does NOT refresh console-ramoops
/dev/block/by-name/expdb — RELIABLE CRASH CHANNEL
- Captures fresh mrdump crash logs via MTK's
mrdump/aeemechanism - Contains full backtrace:
dump_backtrace → mrdump_common_die → make_task_dead → panic → ipanic - KP bootlog lines NOT observed in the kernel log immediately before panic — meaning KP's
printkeither doesn't reach the log buffer before crash, or the mrdump RAM console capture starts after KP's phase - 20MB partition, always openable without a mounted filesystem
File-dump to /cache/``/data//sdcard` — FAILS
- Partitions are not mounted at 2.4s crash time during normal boot
filp_open/kernel_writesilently fail (orbefore_panicnever runs)
Evidence Summary
| Evidence Type | Result |
|---|---|
| Cross-version matrix (0.13.0/0.13.7/0.13.8) | ALL crash → fundamental incompatibility |
| Zero-hooks build | Still crashes → fault in core mapping, not hooks |
| Memblock 5-arg fragility | Confirmed bug; fixable but not sole root cause |
| pstore console-ramoops | STALE — unusable |
| File-dump to /cache /data /sdcard | Fails (partitions not mounted at crash) |
| Expdb mrdump channel | Fresh crash logs captureable; KP lines not visible |
| Custom tail-return in start.c | Present in upstream 0.13.8; may contribute but not sole cause |
Requested Actions for Upstream
-
Add a 4.x-safe mapping path or config option in KP to bypass the
_paging_initrework on kernels where it's known incompatible (similar to thenew_era = kmajor > 5gate, but for specific known-incompatible devices/SoCs). -
Fix the memblock 5-arg calling convention in
map_phys_alloc()andmem_proc()to pass all 5 arguments when the resolved function is the 5-argmemblock_alloc_try_nid(rather than the 3-arg typedef call that leaves max_addr/nid as garbage). -
Consider a device-specific quirk for MTK 4.14 kernels (begonia, sagit, etc.) that notes the absent
memblock_phys_alloc_try_nidsymbol and the fallback path fragility. -
Enable the expdb diagnostic channel in future KP releases so developers can capture fresh crash logs via
mrdump→ expdb for post-crash analysis.
Maintainer Notes
- This is NOT a 0.13.8 regression — the issue exists in 0.13.0 and 0.13.7 as well, confirming it's a fundamental KP/core incompatibility with this device's MTK 4.14 kernel.
- The
new_era = kmajor > 5gate in map.c correctly routes 4.14 to the legacy path, but the legacy path itself has device-specific breakage (the 5-arg memblock calling convention). - The two anonymous panic frames (offset 0x17f8ff3d8 / 0x17f901204) are KP core code in the vmalloc region it allocates during early mapping — not user-space or init code.
- pstore console-ramoops is NOT usable for observing fresh crashes on MTK devices; use the expdb mrdump channel instead.
Report generated from extensive behavioral bisection on real device (begonia, adb serial 8t9dl7ukaulvh6h6). All test images flashed via TWRP dd if=/sdcard/*.img of=/dev/block/by-name/boot bs=4k. Device restored to working stock V2 after testing.
- Lenguaje dominante
- C
- Estrellas
- 1.6k
- Forks
- 393
- Merge medio
- 3 d 23 h
- PR fusionados (30 d)
- 7
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bmax121/KernelPatch
-
official LineageOS on nicepool: APpatch patching fails but only if done via recovery sideloadPosiblemente ocupada @bmax121 la tomó hace 9 días. Abierto
bmax121/KernelPatch#332 · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
bmax121/KernelPatch#329 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
kernel stack overflow: handle_supercmd 与 supercmd_echo 各持 4KB 栈缓冲区嵌套,event 上报改写 argv 时栈耗尽 panicAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
bmax121/KernelPatch#323 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
bmax121/KernelPatch#319 · 9 comentarios ·
Los mantenedores suelen responder en 3 días
-
SUPERCALL_KSTORAGE_LIST_IDS writes to an unvalidated userspace pointer with a raw memcpy → kernel KEAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
bmax121/KernelPatch#308 ·
Los mantenedores suelen responder en 3 días
Todos los issues de bmax121/KernelPatch
Issues similares
-
dspromote: /etc/exports uses -alldirs on non-mount-point directories, so mountd exports nothingAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
nextbsd/nextbsd-userland#434 ·
Los mantenedores suelen responder en 1 día
-
[YSQL] Local-node initdb reads postgres.bki, but YB clusters bootstrap only from yb_postgres.bkiAbiertoarea/ysql kind/enhancement priority/low status/awaiting-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
yugabyte/yugabyte-db#35763 ·
Los mantenedores suelen responder en 1 día
-
[mimalloc] update to 3.6.0Abiertocategory:port-update
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 2 días
-
emerge failure MARK mark-unstable media-kit
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
macaroni-os/mark-issues#834 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
NVIDIA/open-gpu-kernel-modules#1479 · 2 comentarios ·
Los mantenedores suelen responder en 1 día