Repository navigation
kernel: boot the vmlinux through PVH, randomizing itself (#645) - #682
Merged
Merged
Conversation
Hou Wenlong's RFC (0014-0018, 2026-01-26, unchanged on 7.3.5) lets a vmlinux entered through PVH randomize its own virtual base at startup_64, from a relocation table the relocs tool writes into .data.reloc. 0019 sets KASLR_FLAG when it did, so RANDOMIZE_MEMORY moves the direct map, vmalloc and vmemmap. 0020 reads RDRAND and TSC from the CPUID registers that hold them: the RFC reads them swapped, and drew the virtual base from the i8254 and boot_params alone. The build asserts each patch on the vmlinux, prints how much of the table the kernel uses, and refuses instrumentation or GOT references in the code that runs before the relocation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0008 honours XEN_ELFNOTE_PHYS32_RELOC, which Linux emits under CONFIG_PVH: the physical base a bzImage's decompressor chose before, drawn from qemu_guest_getrandom. pvh.bin ships again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…self (#645) A release whose vmlinux has both Xen notes boots it with pvh.bin; one without (v20261119.02 to v20261123.06) boots its bzImage as before. verify kernel asserts the notes and a filled .data.reloc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run on every change that reaches the machine (compat.yml). The regions are read through real addresses, kptr_restrict at 1: at 0 %pK prints a hash that differs every boot whatever the layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#645) checkpatch's MAINTAINERS question for an added file is left out by name: no patch here goes upstream until it has run in production. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he decompressor (#645) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…empt from mutate (#645) mutate left four edits of internal/elftest's fixture standing (CI run 45228954837): p_align, the sections' alignments and the string table's own name, none of which machine.hasXenNote or build.SelfRandomizing reads. Each line says so. And three of the readers themselves: a note whose descriptor the segment cuts short is now refused by a test (its redundant bound removed), a one-word relocation table is filled, and a 12-byte header alone cannot name "Xen". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#645) grep took the log for binary and printed no line, so the build said it ran no sparse over arch/x86/boot/compressed/misc.c when it had (compat job 137883284845). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… prepared untraced (#645) The RFC is the first series to touch arch/x86/boot/compressed and arch/x86/tools. Made as single objects they took vmlinux's flags: misc.o found no ../voffset.h, which only a linked vmlinux gives, and relocs.o failed vmlinux's -Werror (codeql.yml job 137883774299). `patched prepare` now configures the kernel and, when a touched file is one only the bzImage builds, builds the bzImage, before CodeQL's tracer starts, so the whole kernel is not extracted; `patched compile` touches each file and makes the objects, then the bzImage, in two makes (in one, make built arch/x86/pci/common.o twice at once). Locally: prepare 3m13s, compile 25s, misc.o, kaslr.o and relocs among what it rebuilt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 23, 2026
Closed
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The goal is a cold boot to the first SSH login in under 100 ms (v20261123.06: 370 cold, 72.2 restored). A bzImage's decompressor spent ~21 ms (bench) on a copy, LZ4 and parse_elf before the kernel's clock, and it was the only thing that randomized the kernel. This boots the release's vmlinux through PVH instead, the kernel moving itself to a random base (#645).
What
Kernel 0014-0018: Hou Wenlong's RFC (2026-01-26), made checkpatch --strict clean with each change noted in its header. 0019 sets
KASLR_FLAGonce the kernel moved, soRANDOMIZE_MEMORYruns. 0020 reads RDRAND and TSC from the CPUID registers that hold them: the RFC reads them swapped, so its virtual base was drawn from the i8254 andboot_paramsalone. Config:PVH,RELOCATABLE_UNCOMPRESSED_KERNEL, a 1 MiB table.QEMU 0008: a random physical base from
XEN_ELFNOTE_PHYS32_RELOC.pvh.binships again.machine: a release whose vmlinux carries both Xen notes boots it through PVH; one without (v20261119.02 to v20261123.06) boots its bzImage as before. The bzImage still ships (spin's
hack/machine/place.goasks for it, After #645, the bzImage, KERNEL_LZ4 and QEMU 0007 serve only releases before it #660).Checks:
verify kernelasserts both notes and a filled.data.reloc(fixture:internal/elftest). The kernel build asserts each patch, prints the table's use, and refuses__fentry__, sanitizer, stack-protector or GOT references in the pre-relocation object.boot:kaslr(compat.yml) requires_text, the physical base, the direct map and vmalloc each to move across 10 boots, through real addresses.The kernel build's gates (Carried patches: no static analysis, no fuzzing, and the patched packages' own tests are off #653, kernel: enforce checkpatch --strict and sparse on the patched files (#653) #656), changed for these patches: checkpatch leaves out
FILE_PATH_CHANGES(the MAINTAINERS question for an added file) by name; sparse runs over a file a patch adds with every warning counted new, over the decompressor'smisc.cwith the sparse command the bzImage's build ran for it (a single-object target compiles it with vmlinux's flags and failed, job 137873298240), and not overarch/x86/tools, host programsC=never checks.CodeQL's kernel analysis (codeql: prove the patched files were read, trace the kernel and QEMU, analyse our Go and workflows (#653) #659): the RFC is the first series to touch
arch/x86/boot/compressedandarch/x86/tools, which only the bzImage builds. As single objectsmisc.ofound no../voffset.handrelocs.ofailed vmlinux's-Werror(job 137883774299). A newspin-machine-dev patched prepareconfigures the kernel and builds the bzImage before the tracer starts;patched compilethen touches each patched file and remakes its object and the bzImage, so only those are extracted and the guard that every touched C file is extracted stands.sparse over
misc.c: grep took the bzImage's V=1 log for binary and printed nothing (compat job 137883284845); it reads it with-a.mutate (CI run 45228954837): internal/elftest's
p_align, section alignments and the string table's name are fields neither reader reads, each line exempt saying so; a note truncated by its segment is refused by a new test.Replaces #664, whose branch carried a merge commit from main.
Measured
Bench, spin's shape and login, against v20261123.06, 60 a side, measured on the kernel before 0020. 0020 adds one RDRAND and one RDTSC to the boot and goes in as a security fix, not as a boot change:
State −31.9 MiB, QEMU's RSS −13.8 MiB. The bound (no KASLR) was −18.9 cold, −3.6 restored (labs 45213668842, 45213683698).
The three questions
The machine's record
It does not move (compat run 45232827254). Checkpoints of v20261123.06, .05 and .04 resume on this machine and go on counting; v20261123.03 is refused as before, by
cpu x-legacy-cpuid2-cache(#586).pvh.binreaches the guest through fw_cfg at a boot, as linuxboot_dma.bin did, and is not in the record, and a resumed guest runs the kernel in its saved memory.boot:recordpasses, andboot:kaslrsaw_text, the physical base, vmalloc and the direct map at a different place in each of 10 boots.🤖 Generated with Claude Code