Skip to content

hisilicon: load open_hwrng early in load_hisilicon (entropy)#2058

Merged
widgetii merged 2 commits intomasterfrom
hisi-hwrng-load
May 6, 2026
Merged

hisilicon: load open_hwrng early in load_hisilicon (entropy)#2058
widgetii merged 2 commits intomasterfrom
hisi-hwrng-load

Conversation

@widgetii
Copy link
Copy Markdown
Member

@widgetii widgetii commented May 5, 2026

Summary

  • Loads the redesigned open_hwrng.ko (from hisi-hwrng: hybrid hwrng_register/pump driver, universal V2..V4 openhisilicon#85) before any conditional exit in load_hisilicon. Previously the module wasn't loaded at all; once it lands as part of the openhisilicon PR it would get skipped by every existing os_mem >= total_mem exit and SENSOR=unknown gate. Entropy is platform-essential, not sensor-dependent.
  • Single canonical block placed right after #parse arg end# in all 5 scripts (cv200/cv300/cv500/3519v101/ev200):
    if [ "$b_arg_insmod" = "1" ]; then
        modprobe open_hwrng 2>/dev/null
    fi
  • For cv500/cv300/cv200/3519v101 the post-finalize wipe in hisilicon-opensdk.mk removes lib/modules/*/extra/open_*.ko. Add an explicit verbatim install of open_hwrng.ko into the per-platform hisilicon/ dir so modprobe finds it via modules.dep. ev200/gk7205v200 (V4 fall-through) keep modules in extra/ — no .mk change needed for those.
  • cv100/av100 left out — no documented TRNG block (PR hi3516ev300 mount #54 leaves their hwrng_base = 0).

Test plan

End-to-end QEMU runs under widgetii/qemu-hisilicon (HWRNG block emulation from its PR #54) for every supported platform. Each boots its released firmware tarball, loads open_hwrng automatically via S70vendorload_hisilicon -i, and reaches login with the entropy pool primed:

Platform Family Kernel HW_RANDOM Driver mode TRNG addr entropy_avail /dev/hwrng
hi3516cv200 V2 4.9.37 y hwrng-core 0x20280000+0x4 922→923 yes
hi3516cv300 V3 3.18.20 y hwrng-core + pump 0x120c0000+0x204 1536 yes
hi3519v101 V3A 3.18.20 n pump 0x120c0000+0x204 1536 n/a
hi3516cv500 V3.5 4.9.37 n pump 0x10090000+0x204 0→1280 n/a
hi3516ev200 V4 4.9.37 n pump 0x10080000+0x204 1024 n/a

/dev/random returns immediately on every platform — Majestic / dropbear / openssl no longer block on getrandom().

  • All 5 enabled platforms boot to login under QEMU
  • dmesg shows hisi-hwrng: TRNG at <per-SoC base> registered (<mode>) on each
  • /proc/sys/kernel/random/entropy_avail non-zero immediately
  • dd if=/dev/random bs=32 count=1 returns instantly with random bytes
  • No new rmmod can't unload regressions (existing CI assertion)

Pairs with

🤖 Generated with Claude Code

OpenIPC/openhisilicon#85 redesigns the on-die TRNG driver so it builds
across V2/V3/V3A/V3.5/V4 and lands as open_hwrng.ko. Wire it into the
boot path so the kernel entropy pool is primed before majestic /
dropbear / openssl run getrandom().

For the 4 cv-family / V3A SoCs whose lib/modules/.../extra/open_*.ko
files get wiped at finalize (see opensdk.mk's per-platform rename pass
for hi3516cv500/cv300/cv200/3519v101), copy open_hwrng.ko verbatim into
hisilicon/ so modprobe can find it via modules.dep. V4 (ev200/gk7205v200)
already keeps modules in extra/ — no .mk change needed there.

In each load_hisilicon, drop a single canonical:

  if [ "$b_arg_insmod" = "1" ]; then
      modprobe open_hwrng 2>/dev/null
  fi

right after #parse arg end#. That's BEFORE the os_mem-vs-total_mem check
(which exits when QEMU's mem= disagrees with U-Boot totalmem env) and
BEFORE the SENSOR=unknown gate (which exits when sensor probe fails).
Both paths previously silently skipped vendor module load; HWRNG must
not be coupled to that, since entropy is platform-essential, not
sensor-dependent.

Verified end-to-end in QEMU under widgetii/qemu-hisilicon (HWRNG block
emulation from its PR #54) on all five enabled platforms — every one
boots to /dev/random returning entropy immediately, no getrandom()
stall in userspace.

Pairs with OpenIPC/openhisilicon#85.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Picks up OpenIPC/openhisilicon#85 — hybrid hwrng_register/pump driver
universal across V2..V4 — needed for this PR's modprobe open_hwrng to
have a module to load and for opensdk.mk's verbatim install of
open_hwrng.ko to find the artifact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit baa1366 into master May 6, 2026
93 checks passed
@widgetii widgetii deleted the hisi-hwrng-load branch May 6, 2026 05:11
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.

1 participant