From ea61b79012ef2798fcc596d1041353ef781af374 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Thu, 21 Dec 2023 13:25:25 +0000 Subject: [PATCH] bolts/minibsod add openbsd arm64 support (#1724) * bolts/minibsod adding openbsd arm64 part. * disable core ids test on freebsd --- libafl_bolts/src/core_affinity.rs | 2 +- libafl_bolts/src/minibsod.rs | 38 ++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/libafl_bolts/src/core_affinity.rs b/libafl_bolts/src/core_affinity.rs index dc50853f40..76ecf17f22 100644 --- a/libafl_bolts/src/core_affinity.rs +++ b/libafl_bolts/src/core_affinity.rs @@ -936,7 +936,7 @@ mod tests { use super::*; #[test] - #[cfg_attr(miri, ignore)] + #[cfg_attr(any(miri, target_os = "freebsd"), ignore)] fn test_get_core_ids() { let set = get_core_ids().unwrap(); assert_eq!(set.len(), usize::from(available_parallelism().unwrap())); diff --git a/libafl_bolts/src/minibsod.rs b/libafl_bolts/src/minibsod.rs index 491c31080a..4dc98f8745 100644 --- a/libafl_bolts/src/minibsod.rs +++ b/libafl_bolts/src/minibsod.rs @@ -380,6 +380,26 @@ pub fn dump_registers( write!(writer, "cs : {:#016x}, ", ucontext.sc_cs)?; Ok(()) } +/// +/// Write the content of all important registers +#[cfg(all(target_os = "openbsd", target_arch = "aarch64"))] +#[allow(clippy::similar_names)] +pub fn dump_registers( + writer: &mut BufWriter, + ucontext: &ucontext_t, +) -> Result<(), std::io::Error> { + for reg in 0..29_usize { + write!(writer, "x{:02}: 0x{:016x} ", reg, ucontext.sc_x[reg])?; + if reg % 4 == 3 { + writeln!(writer)?; + } + } + write!(writer, "lr : {:#016x}, ", ucontext.sc_lr)?; + write!(writer, "elr : {:#016x}, ", ucontext.sc_elr)?; + write!(writer, "sp : {:#016x}, ", ucontext.sc_sp)?; + write!(writer, "spsr : {:#016x}, ", ucontext.sc_spsr)?; +} + /// /// Write the content of all important registers #[cfg(all( @@ -630,7 +650,7 @@ fn write_crash( Ok(()) } -#[cfg(target_os = "openbsd")] +#[cfg(all(target_os = "openbsd", target_arch = "x86_64"))] #[allow(clippy::similar_names)] fn write_crash( writer: &mut BufWriter, @@ -646,6 +666,22 @@ fn write_crash( Ok(()) } +#[cfg(all(target_os = "openbsd", target_arch = "aarch64"))] +#[allow(clippy::similar_names)] +fn write_crash( + writer: &mut BufWriter, + signal: Signal, + ucontext: &ucontext_t, +) -> Result<(), std::io::Error> { + writeln!( + writer, + "Received signal {} at{:016x}", + signal, ucontext.sc_elr + )?; + + Ok(()) +} + #[cfg(all(target_os = "netbsd", target_arch = "x86_64"))] fn write_crash( writer: &mut BufWriter,