Skip to content

Commit 93a68e4

Browse files
committed
inference: gate [layout] diagnostic output on --verbose
Four plugins (dram_bound, kaslr_ceiling, phys_virt_synth, riscv64_non_efi_phys_base) were printing unconditionally. Wrap their fprintf calls in if (verbose && !quiet) to match the convention used by all other inference plugins.
1 parent 1b9c05d commit 93a68e4

4 files changed

Lines changed: 37 additions & 30 deletions

File tree

src/inference/dram_bound.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ static void dram_bound_run(struct kasld_analysis_ctx *ctx) {
7070

7171
if (pdram_lo > phys_arch_min && pdram_lo > ctx->phys_base_min &&
7272
pdram_lo < ctx->phys_base_max) {
73-
fprintf(stderr,
74-
"[layout] phys_base_min tightened by dram_bound:"
75-
" %#lx -> %#lx (min PHYS/DRAM=%#lx)\n",
76-
ctx->phys_base_min, pdram_lo, pdram_lo);
73+
if (verbose && !quiet)
74+
fprintf(stderr,
75+
"[layout] phys_base_min tightened by dram_bound:"
76+
" %#lx -> %#lx (min PHYS/DRAM=%#lx)\n",
77+
ctx->phys_base_min, pdram_lo, pdram_lo);
7778
ctx->phys_base_min = pdram_lo;
7879
}
7980
} else {
@@ -95,10 +96,11 @@ static void dram_bound_run(struct kasld_analysis_ctx *ctx) {
9596

9697
if (virt_lo > kaslr_min && virt_lo > ctx->text_base_min &&
9798
virt_lo < ctx->text_base_max) {
98-
fprintf(stderr,
99-
"[layout] text_base_min tightened by dram_bound:"
100-
" %#lx -> %#lx (min PHYS/DRAM=%#lx)\n",
101-
ctx->text_base_min, virt_lo, pdram_lo);
99+
if (verbose && !quiet)
100+
fprintf(stderr,
101+
"[layout] text_base_min tightened by dram_bound:"
102+
" %#lx -> %#lx (min PHYS/DRAM=%#lx)\n",
103+
ctx->text_base_min, virt_lo, pdram_lo);
102104
ctx->text_base_min = virt_lo;
103105
}
104106
}

src/inference/kaslr_ceiling.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ static void kaslr_ceiling_run(struct kasld_analysis_ctx *ctx) {
108108
* Align down to the nearest slot boundary. */
109109
unsigned long new_max = (kaslr_max - kernel_size) & ~(kaslr_align - 1);
110110
if (new_max > kaslr_min && new_max < ctx->text_base_max) {
111-
fprintf(stderr,
112-
"[layout] text_base_max tightened by kaslr_ceiling:"
113-
" %#lx -> %#lx (kernel_size=%#lx)\n",
114-
ctx->text_base_max, new_max, kernel_size);
111+
if (verbose && !quiet)
112+
fprintf(stderr,
113+
"[layout] text_base_max tightened by kaslr_ceiling:"
114+
" %#lx -> %#lx (kernel_size=%#lx)\n",
115+
ctx->text_base_max, new_max, kernel_size);
115116
ctx->text_base_max = new_max;
116117
}
117118
}
@@ -124,10 +125,11 @@ static void kaslr_ceiling_run(struct kasld_analysis_ctx *ctx) {
124125
if (phys_max > phys_min && kernel_size < phys_max - phys_min) {
125126
unsigned long new_phys_max = (phys_max - kernel_size) & ~(phys_align - 1);
126127
if (new_phys_max > phys_min && new_phys_max < ctx->phys_base_max) {
127-
fprintf(stderr,
128-
"[layout] phys_base_max tightened by kaslr_ceiling:"
129-
" %#lx -> %#lx (kernel_size=%#lx)\n",
130-
ctx->phys_base_max, new_phys_max, kernel_size);
128+
if (verbose && !quiet)
129+
fprintf(stderr,
130+
"[layout] phys_base_max tightened by kaslr_ceiling:"
131+
" %#lx -> %#lx (kernel_size=%#lx)\n",
132+
ctx->phys_base_max, new_phys_max, kernel_size);
131133
ctx->phys_base_max = new_phys_max;
132134
}
133135
}

src/inference/phys_virt_synth.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,19 @@ static void phys_virt_synth_run(struct kasld_analysis_ctx *ctx) {
126126
return;
127127

128128
if (cand_lo > ctx->page_offset_min) {
129-
fprintf(stderr,
130-
"[layout] page_offset_min tightened by phys_virt_synth:"
131-
" %#lx -> %#lx\n",
132-
ctx->page_offset_min, cand_lo);
129+
if (verbose && !quiet)
130+
fprintf(stderr,
131+
"[layout] page_offset_min tightened by phys_virt_synth:"
132+
" %#lx -> %#lx\n",
133+
ctx->page_offset_min, cand_lo);
133134
ctx->page_offset_min = cand_lo;
134135
}
135136
if (cand_hi < ctx->page_offset_max) {
136-
fprintf(stderr,
137-
"[layout] page_offset_max tightened by phys_virt_synth:"
138-
" %#lx -> %#lx\n",
139-
ctx->page_offset_max, cand_hi);
137+
if (verbose && !quiet)
138+
fprintf(stderr,
139+
"[layout] page_offset_max tightened by phys_virt_synth:"
140+
" %#lx -> %#lx\n",
141+
ctx->page_offset_max, cand_hi);
140142
ctx->page_offset_max = cand_hi;
141143
}
142144
}

src/inference/riscv64_non_efi_phys_base.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ static void riscv64_nonEFI_phys_base_run(struct kasld_analysis_ctx *ctx) {
8282
if (phys_exact < ctx->phys_base_min || phys_exact > ctx->phys_base_max)
8383
return;
8484

85-
fprintf(
86-
stderr,
87-
"[layout] phys_base pinned by riscv64_nonEFI_phys_base:"
88-
" [%#lx, %#lx] -> %#lx (non-EFI, DRAM_BASE=%#lx + TEXT_OFFSET=%#lx)\n",
89-
ctx->phys_base_min, ctx->phys_base_max, phys_exact, pdram_lo,
90-
(unsigned long)TEXT_OFFSET);
85+
if (verbose && !quiet)
86+
fprintf(
87+
stderr,
88+
"[layout] phys_base pinned by riscv64_nonEFI_phys_base:"
89+
" [%#lx, %#lx] -> %#lx (non-EFI, DRAM_BASE=%#lx + TEXT_OFFSET=%#lx)\n",
90+
ctx->phys_base_min, ctx->phys_base_max, phys_exact, pdram_lo,
91+
(unsigned long)TEXT_OFFSET);
9192
ctx->phys_base_min = phys_exact;
9293
ctx->phys_base_max = phys_exact;
9394
#else

0 commit comments

Comments
 (0)