Skip to content

Commit cbc4c9d

Browse files
tool: simplify pv_offset use
inittask_p_v_offset doesn't actually need to be calculated. For ui_p_reg_end we know the size of the init task so can just use that instead. This change was motivated by inittask_p_v_offset causing exceptions in debug builds of the tool (which are not released in the SDK) since it is unsigned overflow and Rust does not panic for integer overflow in release mode by default. Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
1 parent 2130325 commit cbc4c9d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tool/microkit/src/loader.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ impl<'a> Loader<'a> {
200200

201201
// Compute an available physical memory segment large enough to house the initial task (CapDL initialiser with spec)
202202
// that is after the kernel window.
203-
let inittask_p_v_offset = initial_task_vaddr_range.start - initial_task_phy_base;
204203
let inittask_v_entry = initial_task_elf.entry;
205204

206205
for segment in initial_task_segments.iter() {
@@ -259,10 +258,13 @@ impl<'a> Loader<'a> {
259258

260259
let kernel_entry = kernel_elf.entry;
261260

261+
// initial task virt + pv_offset == initial task physical, so
262+
// pv_offset == initial task physical - initial task virt
262263
let pv_offset = initial_task_phy_base.wrapping_sub(initial_task_vaddr_range.start);
263264

264265
let ui_p_reg_start = initial_task_phy_base;
265-
let ui_p_reg_end = initial_task_vaddr_range.end - inittask_p_v_offset;
266+
let ui_p_reg_end =
267+
ui_p_reg_start + (initial_task_vaddr_range.end - initial_task_vaddr_range.start);
266268
assert!(ui_p_reg_end > ui_p_reg_start);
267269

268270
// This clone isn't too bad as it is just a Vec<(u64, &[u8])>

0 commit comments

Comments
 (0)