Skip to content

Commit

Permalink
Fix the increment_counter logic
Browse files Browse the repository at this point in the history
Currently, a world-switch round trip is being counted twice, and a jump to the payload is mistakenly being counted as a firmware trap.
  • Loading branch information
francois141 authored and CharlyCst committed Jan 28, 2025
1 parent 95cbbe0 commit d2ca431
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ fn handle_trap(
ExecutionMode::Payload => ctx.handle_payload_trap(mctx, policy),
};

if exec_mode == ExecutionMode::Firmware {
Benchmark::increment_counter(Counter::FirmwareExits);
}

if exec_mode != ctx.mode.to_exec_mode() {
if exec_mode == ExecutionMode::Firmware && ctx.mode.to_exec_mode() == ExecutionMode::Firmware {
Benchmark::increment_counter(Counter::WorldSwitches);
} else if exec_mode == ExecutionMode::Firmware
&& ctx.mode.to_exec_mode() == ExecutionMode::Firmware
{
Benchmark::increment_counter(Counter::FirmwareExits);
}

// Inject interrupts if required
Expand Down

0 comments on commit d2ca431

Please sign in to comment.