Skip to content

Commit a61df2d

Browse files
committed
components: emit the RAM hull as a single bounded range
sysfs_devicetree_memory and sysfs_firmware_memmap emitted the hull's low edge as a base record and its high edge as a separate top record, so one bounded measurement reached the engine as two independent records of the same (phys, ram) region. Emit a single kasld_result_range when both edges are known; the low-edge-only case still emits a bare base.
1 parent 6710684 commit a61df2d

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

src/components/sysfs_devicetree_memory.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,13 @@ int main(void) {
230230
kasld_info("device tree: %d memory region(s)", count);
231231

232232
kasld_info("lowest DRAM start: 0x%016lx", lo);
233-
kasld_result_base(KASLD_TYPE_PHYS, REGION_RAM, lo, NULL, CONF_PARSED);
234-
235233
if (hi && hi != lo) {
236234
kasld_info("highest DRAM end: 0x%016lx", hi);
237-
kasld_result_top(KASLD_TYPE_PHYS, REGION_RAM, hi, NULL, CONF_PARSED);
235+
/* Both edges known: one bounded range (validated lo <= hi at the source).
236+
*/
237+
kasld_result_range(KASLD_TYPE_PHYS, REGION_RAM, lo, hi, NULL, CONF_PARSED);
238+
} else {
239+
kasld_result_base(KASLD_TYPE_PHYS, REGION_RAM, lo, NULL, CONF_PARSED);
238240
}
239241

240242
#ifdef phys_to_directmap_virt

src/components/sysfs_firmware_memmap.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,13 @@ int main(void) {
130130
kasld_info("firmware memmap: %d System RAM entries", count);
131131

132132
kasld_info("lowest System RAM start: 0x%016lx", lo);
133-
kasld_result_base(KASLD_TYPE_PHYS, REGION_RAM, lo, NULL, CONF_PARSED);
134-
135133
if (hi && hi != lo) {
136134
kasld_info("highest System RAM end: 0x%016lx", hi);
137-
kasld_result_top(KASLD_TYPE_PHYS, REGION_RAM, hi, NULL, CONF_PARSED);
135+
/* Both edges known: one bounded range (validated lo <= hi at the source).
136+
*/
137+
kasld_result_range(KASLD_TYPE_PHYS, REGION_RAM, lo, hi, NULL, CONF_PARSED);
138+
} else {
139+
kasld_result_base(KASLD_TYPE_PHYS, REGION_RAM, lo, NULL, CONF_PARSED);
138140
}
139141

140142
#ifdef phys_to_directmap_virt

tests/test_sysfs_devicetree_memory.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ static void test_complete_map_emits_hull_and_extents(void) {
138138
rm_memory_node("memory@0");
139139
rm_memory_node("memory@1");
140140

141-
assert(strstr(cap, "ram pos=base conf=parsed lo=0x40000000") != NULL);
142-
assert(strstr(cap, "ram pos=top conf=parsed hi=0xa0000000") != NULL);
141+
/* Both edges known → a single bounded range (pos=base carrying lo and hi). */
142+
assert(strstr(cap, "ram pos=base conf=parsed lo=0x40000000 hi=0xa0000000") !=
143+
NULL);
143144
assert(strstr(cap, "ram pos=extent") != NULL);
144145
}
145146

@@ -166,8 +167,8 @@ static void test_overflow_emits_hull_only(void) {
166167
rm_memory_node("memory@0");
167168
rm_memory_node("memory@1");
168169

169-
assert(strstr(cap, "ram pos=base") != NULL);
170-
assert(strstr(cap, "ram pos=top") != NULL);
170+
/* Hull only, as a bounded range (pos=base with both edges); no covering. */
171+
assert(strstr(cap, "ram pos=base conf=parsed lo=0x40000000 hi=") != NULL);
171172
assert(strstr(cap, "ram pos=extent") == NULL);
172173
}
173174

0 commit comments

Comments
 (0)