pvmfw: Keep write_sysreg() unsafe
As writing some system registers (such as SCTLR or TTBR) may have
Rust-visible side effects, force the caller to mark the use of the
currently unused macro as unsafe.
Test: -
Change-Id: I24798ca2a295940554d4665dd92ab2855a8c5814
diff --git a/pvmfw/src/helpers.rs b/pvmfw/src/helpers.rs
index 6310826..9c739d1 100644
--- a/pvmfw/src/helpers.rs
+++ b/pvmfw/src/helpers.rs
@@ -40,18 +40,19 @@
}
/// Write a value to a system register.
+///
+/// # Safety
+///
+/// Callers must ensure that side effects of updating the system register are properly handled.
#[macro_export]
macro_rules! write_sysreg {
($sysreg:literal, $val:expr) => {{
let value: usize = $val;
- // Safe because it writes a system register and does not affect Rust.
- unsafe {
- core::arch::asm!(
- concat!("msr ", $sysreg, ", {}"),
- in(reg) value,
- options(nomem, nostack, preserves_flags),
- )
- }
+ core::arch::asm!(
+ concat!("msr ", $sysreg, ", {}"),
+ in(reg) value,
+ options(nomem, nostack, preserves_flags),
+ )
}};
}