RISC-V · Kernel · Livepatch

No Reboot Required: RISC-V Livepatch Is Now One Merge Window Away

📅 2026-11-12 ⏱ 9 min read 🔗 Source: LKML cover letter “[PATCH v7 00/10] riscv: Add reliable stack unwinding for livepatch”, Shuai Xue (Alibaba Cloud), 10 November 2026

Every architecture that runs production server fleets has livepatch: the ability to load a kernel module that redirects a patched function to new code, so a CVE fix ships without the reboot that turns a 30-second patch into a maintenance window. x86 has had it for a decade. Arm64 has had it for years. RISC-V still cannot live-patch at all — not because the consistency model is missing, but because of one prerequisite the architecture never satisfied: a stack unwinder that can say, with certainty, which functions are on a task’s stack.

That prerequisite is what [PATCH v7 00/10] “riscv: Add reliable stack unwinding for livepatch” sets out to deliver. The seventh revision was posted on 10 November 2026 by Shuai Xue (Alibaba Cloud), rebased onto riscv/for-next at 7.4-rc1, with an explicit request that Palmer Dabbelt and Paul Walmsley take it for the 7.4 merge window. Ten patches, nineteen files, +1043/−110. The work started under another author: Wang Han posted v1 on 27 May 2026 and carried it through v5; Shuai Xue took over at v6 after Wang left the team. It has been under public review for nearly six months — and the review has been doing a second job nobody advertised: fixing bugs in the unwinder RISC-V already ships.

The structural story: livepatch’s consistency model requires the unwinder to be reliable in a strict sense — it must never report a wrong stack. It may report failure; it may not report fiction. That is why the series is not “make unwinding better” but “build a walker whose output the rest of the kernel can legally bet kernel memory on”. Frame-pointer unwinding on RISC-V is conservative by design: s0 (x8) is the ABI frame pointer, and if every frame stores and chains it, walking it is a linked-list traversal. The hard part is guaranteeing that every frame does.

Anatomy of the Series

The ten patches are not a monolith. Three are standalone fixes the rest of the kernel can use independently; seven build the unwinder and turn livepatch on.

#PatchAuthorWhat it does
1/10stacktrace: do not report the walker’s own frame from arch_stack_walk() Karl MehltretterFixes the skip-frame accounting of stack_trace_save() users (page_owner, perf) that recorded the wrong caller
2/10Add KUnit test for stack trace start framesMehltretter Five test cases pinning down where a trace must begin
3/10ftrace: use the frame pointer as the function graph return-address cookie Shuai XueMarked Fixes: and Cc: stable — stands on its own without the rest of the series
4/10stacktrace: add frame record metadataWang Han Explicit metadata describing where each frame’s record lives
5/10disable KASAN and KCOV instrumentation for stacktrace.oWang Han The unwinder cannot itself be instrumented by the tools it serves
6/10ftrace: always preserve s0 in dynamic ftrace register frameWang Han The mcount-dyn trampoline must not clobber the frame pointer it will later be walked through
7/10stacktrace: introduce stack-bound tracking helpersWang Han Bounds-checking so the walker stops instead of wandering into unrelated memory
8/10stacktrace: switch to frame-pointer based unwinderWang Han Replaces the open-coded walker; includes a !CONFIG_FRAME_POINTER fallback that reuses patch 1’s extraction helper
9/10Kconfig: enable HAVE_RELIABLE_STACKTRACE and HAVE_LIVEPATCH Wang HanThe switch. Acked by Miroslav Benes (livepatch maintainer)
10/10selftests/livepatch: add RISC-V syscall wrapper prefixWang Han Teaches the livepatch selftests to recognise RISC-V syscall symbol names

Three new files come with the series: asm/stacktrace/common.h, asm/stacktrace/frame.h and kernel/tests/stacktrace_test.c — a 142-line KUnit suite. Notably, the series rejects the shortcut of relying on ORC-style synthetised unwind tables: RISC-V takes the frame-pointer route, the same conservative choice Arm64 made before its own unwinder matured.

The Two Bugs the Review Exposed

The most valuable part of six months of review may be what it found in the existing code. Both bugs are fixed in this series, and both are invisible until you look at a stack trace closely.

BugWhere it showsSince when
arch_stack_walk() reports the walker’s own frame as the first entrystack_trace_save() consumers — page_owner records the wrong caller; the irqsoff tracer’s return_address() level accounting skips a real callerPre-existing; exposed by review of this series
The function-graph tracer’s return-address cookie never matches anything the unwinder can reproduce on the dynamic ftrace path — the path distribution kernels actually useWhile the tracer runs, stack dumps, perf callchains and the scheduler’s wchan show the tracer’s own return handler instead of the real caller Linux 6.8

The second one deserves emphasis. It is not part of the livepatch feature — patch 3/10 is marked Fixes: and Cc: stable so it can be picked independently by any stable tree. Every RISC-V distribution kernel running the function-graph tracer since 6.8 has had its tracing output corrupted in exactly this way, and apparently nobody noticed until an unwinder series needed a consistent cookie to be reliable.

Five Months, Seven Revisions

RevDateWhat changed
v12026-05-27Initial series (Wang Han)
v22026-05-28Fast follow-up (Wang Han)
v3–v4 RESEND2026-06Review iteration; v4 resent 29 June (Wang Han)
v52026-08-04Last Wang Han revision
v62026-09-14Shuai Xue takes over after Wang left the team; carries the series forward
v72026-11-10Rebase to 7.4-rc1; fold in Mehltretter’s two patches (1/10, 2/10) to keep the series self-contained; split the cookie fix out as 3/10 at Martin Kaiser’s suggestion; rework the !CONFIG_FRAME_POINTER fallback so both walkers report the same start frame
The subtle bit is patch 6/10. s0 is not a dedicated frame-pointer register in RISC-V — it is an ordinary callee-saved general register that any function may reuse once it has spilled the old value. Dynamic ftrace patches call sites with a generated trampoline (mcount-dyn); if that trampoline clobbers s0, every stack walked through a traced function is garbage — and on livepatch, garbage means patching the wrong function. “Always preserve s0” is one line of intent and several dozen lines of assembly, and it is exactly the kind of detail that makes “reliable” an engineering property rather than a Kconfig symbol.

What Has Actually Been Tested

EnvironmentResult
rv64 QEMU + rv64 CHERI builds (v6 validation, Martin Kaiser, Tested-by)Livepatch working on both. The CHERI adjustments are “simple fixups of data types and assembly instructions” — and explicitly not upstreamable at this point
GCC 15.2.0 + binutils 2.46, including a CONFIG_IRQ_STACKS=n variant; QEMU 8.2.2, 1 and 4 CPUslivepatch selftests 7 pass / 1 skip / 0 fail; ftrace function graph 3 passed, 0 failed, 3 unsupported
Fresh build with GCC 16.2.0 on 7.4-rc1: full livepatch config (CONFIG_LIVEPATCH=y with dynamic ftrace + function graph) and a !CONFIG_FRAME_POINTER variant Both link successfully; the fallback build boots and its panic backtrace unwinds cleanly
QEMU 11.1.1, rv64 virt, 4 CPUsKUnit suite 5/5 on the frame-pointer build
BeagleV Ahead (TH1520) real hardware, KUnit suite from 2/10, clang 22 (LLVM=1) and GCC 15.2All five test cases pass
Validation log scansNo BUG, WARNING, Oops, panic, unreliable stack or Call Trace found
Honesty check: the series is not merged; the 7.4 merge window request is exactly that — a request. Apart from the TH1520 KUnit run, all validation is QEMU; no full livepatch load/unload cycle has been demonstrated on RISC-V silicon in the cover letter. No performance or code-size numbers are given for what enabling frame pointers everywhere costs — a real trade-off that Arm64 users know well. CHERI support stays a local patch set. And the review history is a warning and a comfort at once: six months is what “reliable” costs, and the bar is correctness, not benchmarks.

Why It Matters

For a distribution, this closes the last architectural gap between RISC-V and the architectures users expect to run fleets on. RISC-V server silicon is no longer hypothetical — SpacemiT’s V100 is in RHEL 10.2 developer preview, and our 9 November analysis of the per-CPU fast path covered the same pattern from another angle: the kernel-infrastructure work that x86 and Arm64 accumulated over a decade is arriving on RISC-V in a compressed burst. Zalrsc atomics in early November, per-CPU fast paths, and now livepatch.

For an operator, the practical test after merge will be concrete: CONFIG_LIVEPATCH=y plus a distribution’s kpatch-style stream means RISC-V machines stop rebooting for kernel CVEs. Until a merge lands, treat every RISC-V “server-ready” claim as missing this row of the checklist — and treat patch 3/10 as worth backporting to stable trees on its own, merged or not, because the 6.8 function-graph bug it fixes is already in every distribution kernel built with dynamic ftrace.

For the ecosystem, this is the third kernel-infrastructure series we have deep-dived in as many weeks, and the pattern is consistent: RISC-V’s silicon is arriving faster than its kernel-fundamentals, and the people closing the gap are increasingly production users — Alibaba Cloud here, ByteDance on per-CPU — for whom a reboot is a cost centre. When the motivation is an SLA rather than a showcase, the patches tend to finally merge.

摘要(中文)——Linux 至今无法对运行中的 RISC-V 内核做热补丁(livepatch),根因是本架构没有 一个「可靠栈展开器」。2026 年 11 月 10 日,阿里云的 Shuai Xue 在 LKML 发布该系列的第七版 [PATCH v7 00/10] riscv: Add reliable stack unwinding for livepatch:基于 riscv/for-next (7.4-rc1),10 个补丁、19 个文件、+1043/−110,并明确请求 Palmer/Paul 在 7.4 合并窗口收下。系列由王晗于 2026 年 5 月 27 日发起(v1–v5),其离开团队后 v6 起由 Shuai Xue 接手,已公开评审近六个月。

系列结构:前三个是可独立使用的既有修复——Mehltretter 的 arch_stack_walk() 首帧误报修复 (page_owner/perf 记错调用者)+ KUnit 测试,以及 Shuai Xue 的 function-graph 返回地址 cookie 修复 (Fixes: + Cc: stable,该 bug 自 Linux 6.8 起存在于发行版内核实际使用的 dynamic ftrace 路径)。后七个是主体:显式 frame record 元数据、stacktrace.o 关 KASAN/KCOV、dynamic ftrace 始终保存 s0(RISC-V 的帧指针寄存器)、栈边界跟踪、切换为保守的帧指针展开器,最后打开 HAVE_RELIABLE_STACKTRACE 与 HAVE_LIVEPATCH(livepatch 维护者 Miroslav Benes 已 ack)。

验证:rv64 QEMU 与 rv64 CHERI 双环境 livepatch 均已跑通(Martin Kaiser Tested-by);KUnit 5/5;TH1520 实机(BeagleV Ahead)全部通过;无 CONFIG_FRAME_POINTER 回退分支也能链接并干净展开 panic 回溯。

诚实点:系列尚未合并;除 TH1520 的 KUnit 外全部验证都在 QEMU,封面信 没有给出实机完整 livepatch 加载/卸载循环,也没有给出全内核开帧指针的性能/体积代价;CHERI 适配明确暂不可上游。 但 3/10(6.8 以来的 function-graph cookie bug)建议独立回移 stable——无论整系列是否合并。

Кратко (RU). Linux до сих пор не может накладывать live-патчи на работающее ядро RISC-V — в архитектуре нет надёжного развёртывателя стека. 10 ноября 2026 года Shuai Xue (Alibaba Cloud) опубликовал седьмую версию серии [PATCH v7 00/10] riscv: Add reliable stack unwinding for livepatch: база riscv/for-next (7.4-rc1), 10 патчей, 19 файлов, +1043/−110, с просьбой взять работу в merge-окно 7.4. Серия начата Ван Ханом 27 мая 2026 (v1–v5); после его ухода с v6 её ведёт Shuai Xue — почти шесть месяцев публичного ревью.

Структура: первые три патча — самостоятельные исправления (ошибка первого кадра в arch_stack_walk() от Mehltretter + KUnit-тест; исправление return-address cookie function-graph от Shuai Xue, Fixes: + Cc: stable, баг существует с Linux 6.8 на пути dynamic ftrace). Основная часть: явные метаданные frame record, отключение KASAN/KCOV для stacktrace.o, гарантированное сохранение s0 в dynamic ftrace, отслеживание границ стека, переключение на консервативный развёртыватель по frame pointer и включение HAVE_RELIABLE_STACKTRACE + HAVE_LIVEPATCH (ack от Miroslav Benes).

Проверено: livepatch работает на rv64 QEMU и rv64 CHERI (Tested-by Martin Kaiser); KUnit 5/5; на реальной плате TH1520 (BeagleV Ahead) все пять тестов проходят; вариант без CONFIG_FRAME_POINTER собирается и корректно разворачивает panic-трейс.

Честная оговорка: серия ещё не слита; кроме KUnit на TH1520 вся валидация — QEMU; полного цикла загрузки/выгрузки livepatch на реальном кремнии в письме нет; цена включения frame pointer по производительности и размеру не публикуется; поддержка CHERI не подлежит апстриму. Патч 3/10 стоит бэкпортировать в stable независимо от судьбы серии.

Resumen (ES). Linux todavía no puede aplicar livepatch a un kernel RISC-V en ejecución: la arquitectura carece de un desenrollador de pila fiable. El 10 de noviembre de 2026, Shuai Xue (Alibaba Cloud) publicó la séptima revisión de la serie [PATCH v7 00/10] riscv: Add reliable stack unwinding for livepatch: base riscv/for-next (7.4-rc1), 10 parches, 19 archivos, +1043/−110, con petición explícita de entrar en la ventana de fusión de 7.4. La serie la inició Wang Han el 27 de mayo de 2026 (v1–v5); tras su salida, Shuai Xue la recoge desde v6 — casi seis meses de revisión pública.

Estructura: los tres primeros parches son correcciones independientes (el primer fotograma erróneo de arch_stack_walk() según Mehltretter + test KUnit; el return-address cookie de function-graph según Shuai Xue, Fixes: + Cc: stable, un bug presente desde Linux 6.8 en la ruta dynamic ftrace que usan los kernels de distribución). El cuerpo: metadatos de frame record, KASAN/KCOV desactivado para stacktrace.o, preservación garantizada de s0 en dynamic ftrace, seguimiento de límites de pila, conmutación a un desenrollador conservador por frame pointer y activación de HAVE_RELIABLE_STACKTRACE + HAVE_LIVEPATCH (ack de Miroslav Benes).

Validado: livepatch funciona en rv64 QEMU y rv64 CHERI (Tested-by Martin Kaiser); KUnit 5/5; en hardware real TH1520 (BeagleV Ahead) pasan los cinco tests; la variante sin CONFIG_FRAME_POINTER enlaza y desenrolla limpiamente un panic backtrace.

Nota de honestidad: la serie no está fusionada; salvo el KUnit en TH1520 toda la validación es QEMU; no hay ciclo completo de carga/descarga de livepatch en silicio real en la carta, ni cifras de coste de rendimiento o tamaño por activar frame pointers; el soporte CHERI no es upstreamable. El parche 3/10 merece backport a stable con independencia de la serie.

Résumé (FR). Linux ne peut toujours pas appliquer de livepatch à un noyau RISC-V en cours d’exécution : l’architecture n’a pas de dérouleur de pile fiable. Le 10 novembre 2026, Shuai Xue (Alibaba Cloud) a publié la septième révision de la série [PATCH v7 00/10] riscv: Add reliable stack unwinding for livepatch : base riscv/for-next (7.4-rc1), 10 correctifs, 19 fichiers, +1043/−110, avec une demande explicite de l’intégrer à la fenêtre de fusion 7.4. La série a été initiée par Wang Han le 27 mai 2026 (v1–v5) ; après son départ, Shuai Xue la reprend depuis v6 — près de six mois de revue publique.

Structure : les trois premiers correctifs sont autonomes (première trame erronée de arch_stack_walk() selon Mehltretter + test KUnit ; return-address cookie de function-graph selon Shuai Xue, Fixes: + Cc: stable, bug présent depuis Linux 6.8 sur le chemin dynamic ftrace utilisé par les noyaux de distribution). Le corps : métadonnées de frame record, désactivation de KASAN/KCOV pour stacktrace.o, préservation garantie de s0 dans dynamic ftrace, suivi des bornes de pile, bascule vers un dérouleur conservateur par frame pointer, puis activation de HAVE_RELIABLE_STACKTRACE + HAVE_LIVEPATCH (ack de Miroslav Benes).

Validé : livepatch fonctionne sur rv64 QEMU et rv64 CHERI (Tested-by Martin Kaiser) ; KUnit 5/5 ; sur le matériel réel TH1520 (BeagleV Ahead), les cinq tests passent ; la variante sans CONFIG_FRAME_POINTER se lie et déroule proprement un panic backtrace.

Honnêteté : la série n’est pas fusionnée ; hormis le KUnit sur TH1520, toute la validation est en QEMU ; aucun cycle complet de chargement/déchargement livepatch sur silicium réel dans la lettre, ni de chiffrage du coût performance/taille de l’activation des frame pointers ; le support CHERI n’est pas upstreamable. Le correctif 3/10 mérite un backport vers stable indépendamment du sort de la série.

Zusammenfassung (DE). Linux kann einen laufenden RISC-V-Kernel bislang nicht livepatchen: der Architektur fehlt ein zuverlässiger Stack-Unwinder. Am 10. November 2026 veröffentlichte Shuai Xue (Alibaba Cloud) die siebte Revision der Serie [PATCH v7 00/10] riscv: Add reliable stack unwinding for livepatch: Basis riscv/for-next (7.4-rc1), 10 Patches, 19 Dateien, +1043/−110, mit ausdrücklicher Bitte, die Arbeit ins 7.4-Merge-Fenster zu nehmen. Begonnen hatte Wang Han die Serie am 27. Mai 2026 (v1–v5); nach seinem Weggang führt Shuai Xue sie seit v6 weiter — knapp sechs Monate öffentlicher Review.

Aufbau: Die ersten drei Patches sind eigenständige Fixes (Mehltretters Korrektur des falschen ersten Frames in arch_stack_walk() + KUnit-Test; Shuai Xues Fix des Return-Address-Cookie im Function-Graph-Tracer, Fixes: + Cc: stable — der Bug existiert seit Linux 6.8 auf dem Dynamic-ftrace-Pfad der Distributionskernel). Der Hauptteil: explizite Frame-Record-Metadaten, KASAN/KCOV-Deaktivierung für stacktrace.o, garantierte Erhaltung von s0 im Dynamic ftrace, Stack-Bound-Tracking, Umschaltung auf einen konservativen Frame-Pointer-Unwinder und schließlich die Aktivierung von HAVE_RELIABLE_STACKTRACE + HAVE_LIVEPATCH (Ack von Miroslav Benes).

Validiert: Livepatch läuft auf rv64 QEMU und rv64 CHERI (Tested-by Martin Kaiser); KUnit 5/5; auf echter TH1520-Hardware (BeagleV Ahead) bestehen alle fünf Tests; die Variante ohne CONFIG_FRAME_POINTER linkt und wickelt einen Panic-Backtrace sauber ab.

Ehrlichkeitsprüfung: die Serie ist noch nicht gemerged; abgesehen vom KUnit-Run auf dem TH1520 ist alles QEMU; ein vollständiger Livepatch-Lade-/Entladezyklus auf echter Silizium-Hardware fehlt im Cover Letter ebenso wie Zahlen zu Performance-/Größenkosten des flächendeckenden Frame Pointers; CHERI-Support ist nicht upstreamfähig. Patch 3/10 verdient ein unabhängiges Stable-Backport — egal wie die Serie ausgeht.

خلاصه (FA). لینوکس هنوز نمی‌تواند روی هستهٔ در حال اجرای RISC-V لایوپچ اعمال کند: معماری فاقد یک بازکنندهٔ پشتهٔ قابل‌اتکاست. در ۱۰ نوامبر ۲۰۲۶، شواای شویو (Shuai Xue، Alibaba Cloud) نسخهٔ هفتم سری [PATCH v7 00/10] riscv: Add reliable stack unwinding for livepatch را منتشر کرد: پایه riscv/for-next (7.4-rc1)، ۱۰ پچ، ۱۹ فایل، +1043/−110، با درخواست صریح برای ورود به پنجرهٔ ادغام 7.4. سری را وانگ هان در ۲۷ مهٔ ۲۰۲۶ آغاز کرد (v1 تا v5)؛ پس از ترک تیم، از v6 شواای شویو ادامه داده است — نزدیک به شش ماه بازبینی عمومی.

ساختار: سه پچ نخست اصلاحات مستقل‌اند (فریم اول اشتباه arch_stack_walk() از Mehltretter + تست KUnit؛ اصلاح return-address cookie تابع گراف از Shuai Xue، Fixes: + Cc: stable — باگی از لینوکس 6.8 در مسیر dynamic ftrace). بدنهٔ اصلی: متادیتای frame record، غیرفعال‌سازی KASAN/KCOV برای stacktrace.o، تضمین حفظ s0 در dynamic ftrace، ردیابی مرز پشته، سوییچ به بازکنندهٔ محافظه‌کار frame-pointer و در نهایت فعال‌سازی HAVE_RELIABLE_STACKTRACE + HAVE_LIVEPATCH (ack از Miroslav Benes).

اعتبارسنجی: livepatch روی rv64 QEMU و rv64 CHERI کار می‌کند (Tested-by Martin Kaiser)؛ KUnit 5/5؛ روی سخت‌افزار واقعی TH1520 (BeagleV Ahead) هر پنج تست پاس می‌شود؛ نسخهٔ بدون CONFIG_FRAME_POINTER لینک می‌شود و panic backtrace را تمیز باز می‌کند.

هشدار صادقانه: سری هنوز merge نشده؛ جز KUnit روی TH1520 همهٔ اعتبارسنجی در QEMU است؛ چرخهٔ کامل بارگذاری/تخلیهٔ livepatch روی سیلیکون واقعی در نامه نیامده و هزینهٔ کارایی/حجم فعال‌سازی frame pointer در کل هسته منتشر نشده؛ پشتیبانی CHERI فعلاً بالادست‌شدنی نیست. پچ 3/10 مستقل از سرنوشت سری شایستهٔ backport به stable است.

Sources

← All articles