Commit 1557129
committed
components: recover the arm64 image base from fault-path timing
A store to a kernel address from EL0 always faults, but the fault costs
measurably more when the address is mapped: the translation walk
completes and raises a permission fault, where an unmapped address
terminates early with a translation fault at a higher level. Timing the
faulting store distinguishes mapped from unmapped kernel pages without a
cycle counter, which matters because PMCCNTR_EL0 is normally
inaccessible from EL0; clock_gettime over a short run of faults
suffices. Measured separation is 21% of the unmapped floor on a
Cortex-A72 and 11% on a Cortex-A53, both timing a mapped address slower.
The direction is taken from a reference probe of the linear map rather
than assumed, since the published account reports it the other way.
That reference probe doubles as the paging-mode detector: whichever
VA_BITS candidate has a backed linear map identifies the mode, published
as SF_VIRT_ADDR_BITS. Candidates are probed round-robin and normalised
against each round's median, because cpufreq moves the floor by a factor
of three and a per-candidate sweep attributes that drift to the
candidate. The scan applies the same frequency-invariance, classifying
against a rolling median of recent slots with the margin as a fraction
of the local floor.
The image is the left edge of an image-sized mapped run within the
middle half of the vmalloc area, which is where kaslr_early_init places
it. Confining the scan there is what separates the image from its
neighbours: VMALLOC_START equals KIMAGE_VADDR, so the region opens with
early vmalloc allocations that are themselves image-sized, and the two
gigabytes below it are the module region.
KPTI removes kernel tables from the EL0 page tables and the technique
goes inert; arm64 forces KPTI on whenever KASLR is enabled unless the
CPU implements E0PD, which serves the same purpose, so the live vantage
is an explicit kpti=off or a build without CONFIG_UNMAP_KERNEL_AT_EL0.
Detected KPTI is reported as a confirmed active mitigation. A kernel
whose base is not randomized is declined before calibration from the
command line and the FDT seed, rather than scanned for an image that is
not in the window.1 parent 3fa3fdf commit 1557129
4 files changed
Lines changed: 839 additions & 3 deletions
File tree
- docs
- src/components
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
0 commit comments