From 50a4d9e0a49beaeac04fb13fcf3dc2a2d4c5d863 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Thu, 5 Sep 2024 20:46:00 -0600 Subject: [PATCH] Add options to asm blocks --- aarch64-dit/src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/aarch64-dit/src/lib.rs b/aarch64-dit/src/lib.rs index 01f68e17..2239537e 100644 --- a/aarch64-dit/src/lib.rs +++ b/aarch64-dit/src/lib.rs @@ -15,14 +15,18 @@ use core::arch::asm; #[target_feature(enable = "dit")] pub unsafe fn get_dit_enabled() -> bool { let mut dit: u64; - asm!("mrs {dit}, DIT", dit = out(reg) dit); + asm!( + "mrs {dit}, DIT", + dit = out(reg) dit, + options(nomem, nostack, preserves_flags) + ); (dit >> 24) & 1 != 0 } /// Enable DIT for the current thread. #[target_feature(enable = "dit")] pub unsafe fn set_dit_enabled() { - asm!("msr DIT, #1"); + asm!("msr DIT, #1", options(nomem, nostack, preserves_flags)); } /// Restore DIT state depending on the enabled bit. @@ -30,7 +34,7 @@ pub unsafe fn set_dit_enabled() { pub unsafe fn restore_dit(enabled: bool) { if !enabled { // Disable DIT - asm!("msr DIT, #0"); + asm!("msr DIT, #0", options(nomem, nostack, preserves_flags)); } }