Skip to content

Commit

Permalink
boot/paging: assert that long mode active is set after enable_paging
Browse files Browse the repository at this point in the history
  • Loading branch information
mewmew committed May 25, 2022
1 parent 5b2cf08 commit c0a85cb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/boot/paging_32.zig
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,7 @@ export fn enable_paging() void {
var cr0_value = zasm.Cr0.read();
cr0_value.paging = true; // 1 << 31
cr0_value.write();

// Assert that long mode is active.
std.debug.assert(zasm.Efer.read().long_mode_active);

This comment has been minimized.

Copy link
@karlek

karlek May 26, 2022

Owner

Will std.debug exist in non-debug release modes?

This comment has been minimized.

Copy link
@mewmew

mewmew May 26, 2022

Author Collaborator

Assert checks are only present in debug releases (same as in C). So in release builds this effectively turns into a NOP.

Edit: if we prefer to have the check present also in release builds, we can use std.testing.expect(zasm.Efer.read().long_mode_active) instead.

}

0 comments on commit c0a85cb

Please sign in to comment.