8080#endif
8181
8282#define _GNU_SOURCE
83- #include "include/kasld/api.h"
84- #include "include/kasld/cli.h"
8583#include "include/cmdline.h"
8684#include "include/dmesg.h"
85+ #include "include/kasld/api.h"
86+ #include "include/kasld/cli.h"
8787#include "include/kasld/kaslr_default.h"
8888#include <sched.h>
8989#include <setjmp.h>
@@ -146,8 +146,8 @@ KASLD_META("method:timing\n"
146146
147147/* Reached only where the oracle has already proved itself, so the budget bounds
148148 * a scan expected to succeed rather than a speculative one. A VA_BITS=39 window
149- * is ~97k slots and finishes in seconds; wider paging modes exhaust this and say
150- * so, and -t raises it. */
149+ * is ~97k slots and finishes in seconds; wider paging modes exhaust this and
150+ * say so, and -t raises it. */
151151#define DEFAULT_BUDGET_S 30
152152
153153/* Per-slot firehose. -v carries the calibration table and the edge walk, which
@@ -285,8 +285,8 @@ static double median_of(const double *v, size_t n) {
285285 * calibration misclassifies everything once the governor changes its mind
286286 * mid-sweep. The gap between mapped and unmapped is a stable FRACTION of the
287287 * floor -- 18-24% on the A72 and 10-13% on the A53, each steady while its own
288- * absolute times triple -- so the comparison is made against a running median of
289- * recent unmapped slots and scaled to it. */
288+ * absolute times triple -- so the comparison is made against a running median
289+ * of recent unmapped slots and scaled to it. */
290290static double g_gap_ratio ;
291291static int g_mapped_is_slower ;
292292
@@ -309,7 +309,8 @@ static void ring_push(double v) {
309309 * were feeding the floor, every subsequent slot then read "mapped" too. The
310310 * floor could never catch up, and the run grew to 74 MiB before the size test
311311 * rejected it. Bounding the band above breaks that feedback: an excursion
312- * beyond it is treated as a floor shift and folded into the baseline instead. */
312+ * beyond it is treated as a floor shift and folded into the baseline instead.
313+ */
313314#define BAND_LO 0.5
314315#define BAND_HI 3.0
315316
@@ -378,9 +379,8 @@ static int give_up(const char *msg) {
378379
379380static unsigned long detect_va_bits (double * mapped_ref , double * unmapped_ref ) {
380381 static const unsigned long cand [] = VA_BITS_CANDIDATES ;
381- static const unsigned long off [VA_ROUNDS ] = {64ul << 20 , 128ul << 20 ,
382- 192ul << 20 , 96ul << 20 ,
383- 160ul << 20 };
382+ static const unsigned long off [VA_ROUNDS ] = {
383+ 64ul << 20 , 128ul << 20 , 192ul << 20 , 96ul << 20 , 160ul << 20 };
384384 size_t n = sizeof (cand ) / sizeof (cand [0 ]), i , r , best_i = 0 ;
385385 double per [16 ][VA_ROUNDS ], ratio [16 ][VA_ROUNDS ], row_med [VA_ROUNDS ];
386386 double med [16 ], dev [16 ];
@@ -497,10 +497,10 @@ int main(int argc, char **argv) {
497497
498498 /* Nothing to search for when the base is not randomized -- checked FIRST.
499499 *
500- * arch/arm64/kernel/pi/kaslr_early.c leaves the image at KIMAGE_VADDR on three
501- * paths: a nokaslr command line, CONFIG_RANDOMIZE_BASE=n, or no seed from
502- * either the FDT or RNDR. Two are cheap to observe and are checked here; the
503- * third would need the kernel config and does not need to be.
500+ * arch/arm64/kernel/pi/kaslr_early.c leaves the image at KIMAGE_VADDR on
501+ * three paths: a nokaslr command line, CONFIG_RANDOMIZE_BASE=n, or no seed
502+ * from either the FDT or RNDR. Two are cheap to observe and are checked here;
503+ * the third would need the kernel config and does not need to be.
504504 *
505505 * Ordered ahead of calibration deliberately. These are deterministic fact
506506 * reads costing microseconds, where calibration is a timing measurement that
@@ -515,8 +515,9 @@ int main(int argc, char **argv) {
515515 * second source.
516516 *
517517 * This is a fast path, not a correctness gate. Missing a way for KASLR to be
518- * off costs a scan that finds nothing and declines -- wasteful, never wrong --
519- * so a future kernel growing a fourth path degrades runtime, not the answer.
518+ * off costs a scan that finds nothing and declines -- wasteful, never wrong
519+ * -- so a future kernel growing a fourth path degrades runtime, not the
520+ * answer.
520521 *
521522 * The seed test is kasld_kaslr_disabled_text_default() rather than an
522523 * open-coded one, so the arch's notion of "no seed" lives in one place: it
@@ -659,8 +660,9 @@ int main(int argc, char **argv) {
659660
660661 if (debug_mode )
661662 kasld_info ("slot 0x%016lx %8.1f ns (floor %8.1f) %s" , addr , t , baseline ,
662- cls == SLOT_MAPPED ? "mapped"
663- : cls == SLOT_OUTLIER ? "outlier" : "-" );
663+ cls == SLOT_MAPPED ? "mapped"
664+ : cls == SLOT_OUTLIER ? "outlier"
665+ : "-" );
664666
665667 if (!mapped ) {
666668 ring_push (t ); /* unmapped samples and clock excursions both define it */
@@ -695,8 +697,7 @@ int main(int argc, char **argv) {
695697 /* Walk to the far side of the run to size it, but no further than a
696698 * plausible image: unbounded, this walks a large mapped region for
697699 * minutes with no budget check, which is what hung a field run. */
698- for (a = edge ;
699- a < top && a < edge + ((EXTENT_MAX_MB + 8 ) << 20 );
700+ for (a = edge ; a < top && a < edge + ((EXTENT_MAX_MB + 8 ) << 20 );
700701 a += SCAN_STEP ) {
701702 if (is_mapped_at (a , ITERS_SCAN , ring_baseline (unmapped_ref ), NULL )) {
702703 end = a ;
@@ -718,7 +719,8 @@ int main(int argc, char **argv) {
718719 * measured from `edge`, which sits at or below the slot the loop has
719720 * reached, so assigning it unconditionally can move the cursor
720721 * BACKWARDS; the run is then re-detected, re-confirmed and re-rejected
721- * at the same address forever. That is the loop that hung both boards. */
722+ * at the same address forever. That is the loop that hung both boards.
723+ */
722724 if (end > addr )
723725 addr = end ;
724726 } else {
@@ -798,8 +800,8 @@ int main(int argc, char **argv) {
798800 }
799801
800802 if (!is_mapped_at (base , ITERS_CONFIRM , ring_baseline (unmapped_ref ), NULL ) ||
801- is_mapped_at (base - FINE_STEP , ITERS_CONFIRM ,
802- ring_baseline ( unmapped_ref ), NULL )) {
803+ is_mapped_at (base - FINE_STEP , ITERS_CONFIRM , ring_baseline ( unmapped_ref ),
804+ NULL )) {
803805 kasld_err ("edge at 0x%016lx did not confirm on re-measurement" , base );
804806 return give_up ("edge unstable on confirmation; a quieter run may resolve "
805807 "it" );
0 commit comments