Skip to content

Commit 9a6dfd3

Browse files
committed
check-results: validate the resolved image-base windows against truth
The resolved-window check greped for "Inferred text range:", a line the renderer stopped printing when the readout became the labelled "Virtual/ Physical Image Base" table, so validate_inferred always got an empty line and skipped -- the engine's resolved window was never checked against ground truth. This is the only check that exercises the resolution over the live-only leaks (perf, prefetch, side channels) that an offline replay cannot run, so its silence mattered. Grep the guaranteed rows the renderer prints now, and compare _text to _text on both sides: virt _text from /proc/kallsyms (not _stext, which differs by the head gap on arm64/arm32/mips/loongarch and would false-fail a pinned window), phys _text from /proc/iomem "Kernel code" (the kernel sets its start to __pa_symbol(_text), so truth_ptext_lo already is phys _text). Where kallsyms is masked or the iomem line is absent, the truth is empty and the check skips.
1 parent a9dc616 commit 9a6dfd3

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

extra/check-results

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ numeric() {
138138
return 0 # never fail the substitution (a rejected value is just empty output)
139139
}
140140

141-
# Validate a rendered "Inferred ... text range" window against ground truth: the
142-
# real kernel base must fall inside the inferred candidate window. Catches
143-
# resolved-inference errors that no single leaked result reveals.
141+
# Validate a resolved image-base window (the rendered "guaranteed" row) against
142+
# ground truth: the real _text base must fall inside it. Catches over-narrowing
143+
# in the engine's resolution that no single leaked result reveals -- including
144+
# resolution over the live-only leaks (perf, prefetch, side channels) that an
145+
# offline replay cannot exercise.
144146
# Usage: validate_inferred LABEL TRUTH16 RENDERED_LINE
145147
validate_inferred() {
146148
_label="$1"; _truth="$2"; _line="$3"
@@ -222,6 +224,7 @@ echo
222224
# -------------------------------------------------------------------------
223225
# Extract ground truth from /proc/kallsyms
224226
# -------------------------------------------------------------------------
227+
truth_text=$(awk '$3 == "_text" { print $1 }' /proc/kallsyms 2>/dev/null)
225228
truth_stext=$(awk '$3 == "_stext" { print $1 }' /proc/kallsyms 2>/dev/null)
226229
truth_etext=$(awk '$3 == "_etext" { print $1 }' /proc/kallsyms 2>/dev/null)
227230
truth_sdata=$(awk '$3 == "_sdata" { print $1 }' /proc/kallsyms 2>/dev/null)
@@ -230,10 +233,11 @@ truth_sdata=$(awk '$3 == "_sdata" { print $1 }' /proc/kallsyms 2>/dev/null)
230233
case "$truth_stext" in
231234
0000000000000000|00000000)
232235
echo "warning: /proc/kallsyms symbols are zeroed (kptr_restrict?)" >&2
233-
truth_stext="" ;;
236+
truth_text="" truth_stext="" ;;
234237
esac
235238

236239
# Normalize to 16-char hex
240+
if [ -n "$truth_text" ]; then truth_text=$(hex16 "$truth_text"); fi
237241
if [ -n "$truth_stext" ]; then truth_stext=$(hex16 "$truth_stext"); fi
238242
if [ -n "$truth_etext" ]; then truth_etext=$(hex16 "$truth_etext"); fi
239243
if [ -n "$truth_sdata" ]; then truth_sdata=$(hex16 "$truth_sdata"); fi
@@ -835,15 +839,19 @@ printf '%s\n' "$tagged_lines" | while IFS= read -r line; do
835839
done
836840

837841
# -------------------------------------------------------------------------
838-
# Validate the engine's RESOLVED text windows (rendered summary), not just the
839-
# per-component leaks: the real kernel base must fall inside the inferred
840-
# candidate window. Present in --verbose output when the base is inferred
841-
# rather than leaked/pinned; absent otherwise (the call no-ops).
842+
# Validate the engine's RESOLVED image-base windows (rendered summary), not just
843+
# the per-component leaks: the real _text base must fall inside the guaranteed
844+
# window. The window is the image base (_text), so both sides compare _text to
845+
# _text -- virt _text from /proc/kallsyms, phys _text from /proc/iomem "Kernel
846+
# code" (whose start the kernel sets to __pa_symbol(_text)). Comparing _stext
847+
# here would false-fail on arches whose _text->_stext head gap is non-zero.
848+
# The guaranteed row is always rendered by `kasld -v`; piping a single
849+
# component's output has no window, and validate_inferred skips it.
842850
# -------------------------------------------------------------------------
843-
virt_win=$(printf '%s\n' "$raw_input" | grep 'Inferred text range:' | head -1)
844-
phys_win=$(printf '%s\n' "$raw_input" | grep 'Inferred phys text range:' | head -1)
845-
validate_inferred "Inferred virt text window" "$truth_stext" "$virt_win"
846-
validate_inferred "Inferred phys text window" "$truth_ptext_lo" "$phys_win"
851+
virt_win=$(printf '%s\n' "$raw_input" | grep 'Virtual Image Base' | grep 'guaranteed' | head -1)
852+
phys_win=$(printf '%s\n' "$raw_input" | grep 'Physical Image Base' | grep 'guaranteed' | head -1)
853+
validate_inferred "Resolved virt image-base window" "$truth_text" "$virt_win"
854+
validate_inferred "Resolved phys image-base window" "$truth_ptext_lo" "$phys_win"
847855

848856
# -------------------------------------------------------------------------
849857
# RAM-map coverage. A `pos=extent` line is one member of a COMPLETE single-source

0 commit comments

Comments
 (0)