Skip to content

Fix aarch64 read_time_counter()#849

Merged
tokatoka merged 3 commits intomainfrom
revert_aarch64
Oct 21, 2022
Merged

Fix aarch64 read_time_counter()#849
tokatoka merged 3 commits intomainfrom
revert_aarch64

Conversation

@tokatoka
Copy link
Copy Markdown
Member

introspection does not work on aarch64

@tokatoka
Copy link
Copy Markdown
Member Author

Hi @devnexen
We've noticed that your change on #790 does not work well.
You can reproduce this issue by adding "introspection" feature to libfuzzer_libpng and run the fuzzer on a m1mac computer (or any aarch64)
like:

[dependencies]
libafl = { path = "../../libafl/", features = ["default", "introspection"] }

The introspection output does not give meaningful results after #790

[Testcase    #1]  (GLOBAL) run time: 0h-0m-15s, clients: 2, corpus: 299, objectives: 0, executions: 1540160, exec/sec: 97484
                  (CLIENT) corpus: 299, objectives: 0, executions: 1540160, exec/sec: 97484, edges: 802/11460 (6%)
Client 001:
     NaN: Scheduler
     NaN: Manager
  Stage 0:
       NaN: GetInputFromCorpus
       NaN: Mutate
       NaN: MutatePostExec
       NaN: TargetExecution
       NaN: PreExec
       NaN: PostExec
       NaN: PreExecObservers
       NaN: PostExecObservers
       NaN: GetFeedbackInterestingAll
       NaN: GetObjectivesInterestingAll
  Feedbacks:
       NaN: TimeoutFeedback
       NaN: CrashFeedback
       NaN: time
       NaN: mapfeedback_metadata_edges
     NaN: Not Measured

Do you have any suggestion on how to fix this? (We could just fall back to current_nanos() but we want to use your code bc it should be faster)

@tokatoka
Copy link
Copy Markdown
Member Author

tokatoka commented Oct 21, 2022

FYI: this value is print-ed here is always 0

#[cfg(target_arch = "aarch64")]
#[must_use]
pub fn read_time_counter() -> u64 {
    let v: u64 = 0;
    unsafe {
        // TODO pushing a change in core::arch::aarch64 ?
        asm!("mrs {v}, cntvct_el0", v = out(reg) _);
    }
    println!("{}", v);
    v
}

@tokatoka
Copy link
Copy Markdown
Member Author

5c6aa2c should be the fix

@tokatoka tokatoka changed the title Revert #790 Changes Fix aarch64 read_time_counter() Oct 21, 2022
@tokatoka tokatoka merged commit 64ec5c3 into main Oct 21, 2022
@tokatoka tokatoka deleted the revert_aarch64 branch October 21, 2022 07:23
@devnexen
Copy link
Copy Markdown
Contributor

sorry for late reply, pretty busy at the moment, thx for the change ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants