File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ edition = "2018"
28
28
[dependencies ]
29
29
bit_field = " 0.9.0"
30
30
bitflags = " 1.0.4"
31
+ volatile = " 0.4.4"
31
32
32
33
[build-dependencies ]
33
34
cc = { version = " 1.0.37" , optional = true }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ use core::fmt;
16
16
use core:: marker:: PhantomData ;
17
17
use core:: ops:: Bound :: { Excluded , Included , Unbounded } ;
18
18
use core:: ops:: { Deref , Index , IndexMut , RangeBounds } ;
19
+ use volatile:: Volatile ;
19
20
20
21
/// An Interrupt Descriptor Table with 256 entries.
21
22
///
@@ -720,16 +721,22 @@ pub struct InterruptStackFrame {
720
721
impl InterruptStackFrame {
721
722
/// Gives mutable access to the contents of the interrupt stack frame.
722
723
///
724
+ /// The `Volatile` wrapper is used because LLVM optimizations remove non-volatile
725
+ /// modifications of the interrupt stack frame.
726
+ ///
723
727
/// ## Safety
724
728
///
725
729
/// This function is unsafe since modifying the content of the interrupt stack frame
726
730
/// can easily lead to undefined behavior. For example, by writing an invalid value to
727
731
/// the instruction pointer field, the CPU can jump to arbitrary code at the end of the
728
732
/// interrupt.
733
+ ///
734
+ /// Also, it is not fully clear yet whether modifications of the interrupt stack frame are
735
+ /// officially supported by LLVM's x86 interrupt calling convention.
729
736
#[ allow( clippy:: should_implement_trait) ]
730
737
#[ inline]
731
- pub unsafe fn as_mut ( & mut self ) -> & mut InterruptStackFrameValue {
732
- & mut self . value
738
+ pub unsafe fn as_mut ( & mut self ) -> Volatile < & mut InterruptStackFrameValue > {
739
+ Volatile :: new ( & mut self . value )
733
740
}
734
741
}
735
742
You can’t perform that action at this time.
0 commit comments