Skip to content

kernel/osal_v2_shim,osal_v2a_shim: cover the full V2/V2A blob-symbol set#170

Merged
widgetii merged 1 commit into
mainfrom
feat/v2-shim-expand-modpost-syms
May 22, 2026
Merged

kernel/osal_v2_shim,osal_v2a_shim: cover the full V2/V2A blob-symbol set#170
widgetii merged 1 commit into
mainfrom
feat/v2-shim-expand-modpost-syms

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

Extends the V2 (cv200, #162) and V2A (av100, #165) blob-symbol shims to cover the full undefined-symbol set revealed by exercising the real firmware build for the first time. The original PRs based the shim contents on the issue #50 audit (4 symbols for cv200, 3 for av100), which only counted explicit blob source-imports. Modpost on the actual hi3516cv200_neo firmware build surfaced 8 more undefined symbols pulled in via inline-expansion at blob-build time against 4.9 headers (e.g. memset → __memzero, kmalloc → __kmalloc).

Plus one source-side compat shim for pte_offset_map (its inline now calls the unexported __pte_offset_map on 6.5+).

Verification

Built end-to-end against the merged opensdk-bumped firmware tree:

Target Kernel Result
hi3516cv200_neo 7.0 (openipc/linux upstream-patches) Builds clean; boots in QEMU; meets DoD
hi3516cv200_lite 4.9 (production) 331/331 rootfs files, 68/68 .ko set — byte-equivalent to nightly
hi3516av100_lite 4.9 (production) 290/290 rootfs files, 61/61 .ko set — byte-equivalent to nightly

cv200_neo QEMU DoD report:

[PASS] login prompt
[PASS] DoD probe fired
[PASS] eth0 has IP (10.0.2.15, SLIRP DHCP)
[PASS] ping reply (10.0.2.2, 4.218 ms, 0% loss)
--- errors ---
(none)

Symbols added to both shims (gated >= 5.0)

Legacy symbol Modern target
_cond_resched __cond_resched
__kmalloc __kmalloc_noprof (6.5+)
kmem_cache_alloc kmem_cache_alloc_noprof (7.0 macro)
__memzero memset(ptr, 0, n)
PDE_DATA pde_data (5.17 rename)
printk vprintk via _printk (6.0 rename)
register_sysctl_paths register_sysctl_sz / register_sysctl
jiffies_to_msecs inline (MSEC_PER_SEC / HZ) * j
del_timer timer_delete (7.0 rename)
vmalloc vmalloc_noprof (7.0 macro)
dev_err dev_vprintk_emit at KERN_ERR
sched_setscheduler sched_set_fifo / sched_set_normal — best-effort, drops caller priority

Source-side compat

kernel/compat/kernel_compat.h adds pte_offset_map(pmd, addr) → pte_offset_kernel(...) on >= 6.5. Modern pte_offset_map() inlines to the unexported __pte_offset_map() so modules can't link it; pte_offset_kernel is a static inline over pmd_page_vaddr() + pte_index() — same lookup, no exported-symbol dep, matches the (unlocked) semantics of the legacy code.

Header collisions

_cond_resched and jiffies_to_msecs are static inline in modern kernel headers — function definitions under the same name collide. Both Kbuilds (hi3516cv200.kbuild, hi3516av100.kbuild) pass a per-shim -D<sym>=... rename in CFLAGS_<obj> so the static-inline definition is suppressed during header processing; the shim source then #undefs the rename and provides the legacy export.

Macro-style conflicts (kmem_cache_alloc, vmalloc, PDE_DATA, printk, dev_err, del_timer — last one collides with our own kernel_compat.h source-side rename) handled with #undef in the shim source.

Out of scope (still tracked in #51)

  • struct timer_list.data ABI drift (chnl/viu/vpss blobs) — the shim resolves init_timer_key but timers don't fire with the correct argument until the blob is recompiled. Documented in both shim sources. Surfaces as broken video pipeline on cv200_neo / av100_neo; not a load-time error.
  • hi3516av100 mainline DT / CRG — av100_neo firmware target is blocked on a separate openipc/linux PR (av100 has no mainline Kconfig / DT / clock-driver support yet, unlike cv200 which landed in arm: hisilicon: add hi3516cv200 / hi3518ev20x SoC support (CRG + DT + Kconfig) linux#43). cv200_neo unblocked by this PR.

Test plan

  • Linux 7.0 compile clean (no modpost errors)
  • hi3516cv200_neo QEMU smoke meeting DoD (login + ping)
  • hi3516cv200_lite (4.9) byte-equivalence vs nightly
  • hi3516av100_lite (4.9) byte-equivalence vs nightly
  • Real-hardware test cv200_neo — deferred to firmware-side PR landing
  • av100_neo — blocked on openipc/linux av100 mainline support

🤖 Generated with Claude Code

PRs #162 and #165 landed the initial V2/V2A bring-up shims based on the
issue #50 audit (4 symbols for cv200, 3 for av100). Exercising the
real firmware build for the first time (hi3516cv200_neo via the
upstream-patches 7.0 base) surfaced 8 more undefined symbols that
issue #50 missed — the audit only covered blob source-imports, not
the compiler-generated calls (memset → __memzero, kmalloc → __kmalloc
internal slowpath, etc.) and not the symbols pulled in via inline-
function expansion at blob-build time against the 4.9 kernel headers.

This commit extends both shims (V2 cv200 + V2A av100) to cover every
symbol modpost reports as undefined for the V2/V2A blob set on Linux
7.0. Verified empirically: hi3516cv200_neo now builds, boots in QEMU
to a login prompt, and meets the openipc/firmware QEMU DoD
(eth0 link, DHCP via SLIRP, ping 10.0.2.2). hi3516cv200_lite and
hi3516av100_lite (kernel 4.9 production targets) rebuilt against this
tree are byte-equivalent to nightly:

  - cv200_lite: 331/331 rootfs files, 68/68 hisilicon .ko, sets
    identical
  - av100_lite: 290/290 rootfs files, 61/61 hisilicon .ko, sets
    identical

kernel/compat/kernel_compat.h adds:

  - pte_offset_map(pmd, addr) -> pte_offset_kernel(...) on >= 6.5.
    Modern pte_offset_map() inlines to __pte_offset_map() which is
    NOT EXPORT_SYMBOL'd, so modules can't link it. pte_offset_kernel
    is a static inline over pmd_page_vaddr() + pte_index() — same
    user-page-table lookup the legacy code already did without
    locking. Source-side fix because the call is in our own
    cv200/av100 mmz-userdev usr_virt_to_phys, not the blob.

Both shim modules add the following exports (gated >= 5.0 so 4.9
lite stays a no-op shell):

   Symbol               Modern equivalent we forward to
   ──────────────────   ───────────────────────────────────────
   _cond_resched        __cond_resched
   __kmalloc            __kmalloc_noprof          (6.5+)
   kmem_cache_alloc     kmem_cache_alloc_noprof   (7.0 macro)
   __memzero            memset(ptr, 0, n)
   PDE_DATA             pde_data                  (5.17 rename)
   printk               vprintk via _printk       (6.0 rename)
   register_sysctl_paths register_sysctl_sz / register_sysctl
   jiffies_to_msecs     (MSEC_PER_SEC / HZ) * j   — header inline
   del_timer            timer_delete              (7.0 rename)
   vmalloc              vmalloc_noprof            (7.0 macro)
   dev_err              dev_vprintk_emit at KERN_ERR
   sched_setscheduler   sched_set_fifo / sched_set_normal — caller
                        priority is dropped (sched_set_fifo doesn't
                        accept one); SCHED_RR mapped to FIFO. Best-
                        effort for legacy blobs that just want
                        "raise above SCHED_NORMAL".

Two header-collision cases needed a Kbuild-level macro rename
(passed as -D... in CFLAGS_) so the static-inline definition in
<linux/sched.h> / <linux/jiffies.h> doesn't conflict with our
EXPORT_SYMBOL'd function under the same name:

  - _cond_resched         (static inline since 5.10 preempt-dynamic
                           rework; commit fe32d3cd5e8e)
  - jiffies_to_msecs      (static inline when HZ | MSEC_PER_SEC —
                           HZ=100 production config)

For the macro-style conflicts (kmem_cache_alloc, vmalloc, PDE_DATA,
printk, dev_err, del_timer) #undef in the shim source is sufficient.

Out of scope for this commit (still tracked in issue #51):

  - struct timer_list .data ABI drift (chnl/viu/vpss blobs) — the
    shim resolves init_timer_key but timers don't fire with the
    correct argument until the blob is recompiled. Documented in
    both shim sources. Surfaces as broken video pipeline on
    cv200_neo / av100_neo; not a load-time error.

  - hi3516av100 mainline DT / CRG — av100_neo firmware target is
    blocked on a separate openipc/linux PR (av100 has no mainline
    Kconfig / DT / clock-driver support yet, unlike cv200 which
    landed in OpenIPC/linux#43). cv200_neo unblocked.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit b7daf6f into main May 22, 2026
28 checks passed
widgetii pushed a commit that referenced this pull request May 22, 2026
Two follow-ups discovered while exercising the hi3516av100_neo
firmware build for the first time (cv200 was unblocked by #170; av100
hit two further issues this commit closes):

  - kernel/hi3516av100.kbuild: gate open_pm.ko build behind
    DISABLE_PM (opensdk already passes DISABLE_PM=1 by default;
    matching the gate makes the directive effective). The vendor blob
    hi3516a_pm.o references dev_pm_opp_init_cpufreq_table,
    cpufreq_table_validate_and_show, cpufreq_generic_attr — all
    removed in mainline. Even with CONFIG_CPU_FREQ + REGULATOR
    enabled, modpost still fails. open_pm.ko is the AVS / CPU-DVFS
    blob; not needed for boot. Lite (4.9) is unaffected — the
    DISABLE_PM=1 default already applied there and the previous
    unconditional obj-m made it a no-op anyway.

  - osal_v2_shim/cv200_shim.c, osal_v2a_shim/av100_shim.c: add
    dev_warn export. Same shape as the dev_err shim landed in #170 —
    macro in <linux/dev_printk.h> that funnels through _dev_err;
    variadic wrapper via dev_vprintk_emit at KERN_WARNING (loglevel
    digit 4). av100 blobs reference dev_warn from open_pm (gated out
    above) and from other vendor sources; safer to ship the shim
    for symmetry.

Verified end-to-end: hi3516av100_neo now builds and boots to
login prompt with eth0 up via the new mainline higmac driver
(openipc/linux feat/av100-mainline), DHCP from SLIRP, ping 10.0.2.2
succeeds. cv200_neo continues to meet the same DoD. cv200_lite and
av100_lite (4.9 kernel) remain byte-equivalent to nightly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
widgetii pushed a commit that referenced this pull request May 22, 2026
Two follow-ups discovered while exercising the hi3516av100_neo
firmware build for the first time (cv200 was unblocked by #170; av100
hit two further issues this commit closes):

  - kernel/hi3516av100.kbuild: gate open_pm.ko build behind
    DISABLE_PM (opensdk already passes DISABLE_PM=1 by default;
    matching the gate makes the directive effective). The vendor blob
    hi3516a_pm.o references dev_pm_opp_init_cpufreq_table,
    cpufreq_table_validate_and_show, cpufreq_generic_attr — all
    removed in mainline. Even with CONFIG_CPU_FREQ + REGULATOR
    enabled, modpost still fails. open_pm.ko is the AVS / CPU-DVFS
    blob; not needed for boot. Lite (4.9) is unaffected — the
    DISABLE_PM=1 default already applied there and the previous
    unconditional obj-m made it a no-op anyway.

  - osal_v2_shim/cv200_shim.c, osal_v2a_shim/av100_shim.c: add
    dev_warn export. Same shape as the dev_err shim landed in #170 —
    macro in <linux/dev_printk.h> that funnels through _dev_err;
    variadic wrapper via dev_vprintk_emit at KERN_WARNING (loglevel
    digit 4). av100 blobs reference dev_warn from open_pm (gated out
    above) and from other vendor sources; safer to ship the shim
    for symmetry.

Verified end-to-end: hi3516av100_neo now builds and boots to
login prompt with eth0 up via the new mainline higmac driver
(openipc/linux feat/av100-mainline), DHCP from SLIRP, ping 10.0.2.2
succeeds. cv200_neo continues to meet the same DoD. cv200_lite and
av100_lite (4.9 kernel) remain byte-equivalent to nightly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
widgetii added a commit that referenced this pull request May 22, 2026
…0/av100 neo unblock) (#171)

* kernel/obj/hi3516cv200,hi3516av100: ship stub .o.cmd files for modpost

Linux 7.0 modpost (scripts/mod/modpost.c) calls read_text_file() on the
.<basename>.o.cmd sibling of every .o referenced from a module's .mod
list, and exits non-zero if the file is missing. For prebuilt blob .o
files (cv200's hi3518e_*.o, av100's hi3516a_*.o) there's no kbuild rule
that generates the .cmd — they're committed binaries with no build
metadata.

cv500 already has these .cmd files committed (31 of them, dating back
to the cv500 mainline-kernel bring-up). cv200 and av100 didn't — which
worked fine on 4.9 lite (modpost was lax) and on standalone CI builds
(actions/checkout fetches dotfiles), but breaks on firmware-tarball
neo builds where the github-archive tarball strips them.

Each .cmd is a one-line stub:
    savedcmd_kernel/obj/<chiparch>/<obj>.o := :
satisfying modpost's read_text_file() without claiming any CRC info
(no #SYMVER lines). Linker symbol resolution is unaffected.

47 files total (21 cv200 + 26 av100). Unblocks cv200_neo and
av100_neo firmware builds end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* kernel/hi3516av100,osal_v2[a]_shim: gate open_pm + add dev_warn shim

Two follow-ups discovered while exercising the hi3516av100_neo
firmware build for the first time (cv200 was unblocked by #170; av100
hit two further issues this commit closes):

  - kernel/hi3516av100.kbuild: gate open_pm.ko build behind
    DISABLE_PM (opensdk already passes DISABLE_PM=1 by default;
    matching the gate makes the directive effective). The vendor blob
    hi3516a_pm.o references dev_pm_opp_init_cpufreq_table,
    cpufreq_table_validate_and_show, cpufreq_generic_attr — all
    removed in mainline. Even with CONFIG_CPU_FREQ + REGULATOR
    enabled, modpost still fails. open_pm.ko is the AVS / CPU-DVFS
    blob; not needed for boot. Lite (4.9) is unaffected — the
    DISABLE_PM=1 default already applied there and the previous
    unconditional obj-m made it a no-op anyway.

  - osal_v2_shim/cv200_shim.c, osal_v2a_shim/av100_shim.c: add
    dev_warn export. Same shape as the dev_err shim landed in #170 —
    macro in <linux/dev_printk.h> that funnels through _dev_err;
    variadic wrapper via dev_vprintk_emit at KERN_WARNING (loglevel
    digit 4). av100 blobs reference dev_warn from open_pm (gated out
    above) and from other vendor sources; safer to ship the shim
    for symmetry.

Verified end-to-end: hi3516av100_neo now builds and boots to
login prompt with eth0 up via the new mainline higmac driver
(openipc/linux feat/av100-mainline), DHCP from SLIRP, ping 10.0.2.2
succeeds. cv200_neo continues to meet the same DoD. cv200_lite and
av100_lite (4.9 kernel) remain byte-equivalent to nightly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Vasiliy Yakovlev <vixand@openipc.org>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants