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"
2828[dependencies ]
2929bit_field = " 0.9.0"
3030bitflags = " 1.0.4"
31+ volatile = " 0.4.4"
3132
3233[build-dependencies ]
3334cc = { version = " 1.0.37" , optional = true }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ use core::fmt;
1616use core:: marker:: PhantomData ;
1717use core:: ops:: Bound :: { Excluded , Included , Unbounded } ;
1818use core:: ops:: { Deref , Index , IndexMut , RangeBounds } ;
19+ use volatile:: Volatile ;
1920
2021/// An Interrupt Descriptor Table with 256 entries.
2122///
@@ -720,16 +721,22 @@ pub struct InterruptStackFrame {
720721impl InterruptStackFrame {
721722 /// Gives mutable access to the contents of the interrupt stack frame.
722723 ///
724+ /// The `Volatile` wrapper is used because LLVM optimizations remove non-volatile
725+ /// modifications of the interrupt stack frame.
726+ ///
723727 /// ## Safety
724728 ///
725729 /// This function is unsafe since modifying the content of the interrupt stack frame
726730 /// can easily lead to undefined behavior. For example, by writing an invalid value to
727731 /// the instruction pointer field, the CPU can jump to arbitrary code at the end of the
728732 /// 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.
729736 #[ allow( clippy:: should_implement_trait) ]
730737 #[ 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 )
733740 }
734741}
735742
You can’t perform that action at this time.
0 commit comments