File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -330,10 +330,22 @@ impl Descriptor {
330330 /// either be global or per-CPU).
331331 #[ inline]
332332 pub fn tss_segment ( tss : & ' static TaskStateSegment ) -> Descriptor {
333+ // SAFETY: The pointer is derived from a &'static reference, which ensures its validity.
334+ unsafe { Self :: tss_segment_unchecked ( tss) }
335+ }
336+
337+ /// Similar to [`Descriptor::tss_segment`], but unsafe since it does not enforce a lifetime
338+ /// constraint on the provided TSS.
339+ ///
340+ /// # Safety
341+ /// The caller must ensure that the passed pointer is valid for as long as the descriptor is
342+ /// being used.
343+ #[ inline]
344+ pub unsafe fn tss_segment_unchecked ( tss : * const TaskStateSegment ) -> Descriptor {
333345 use self :: DescriptorFlags as Flags ;
334346 use core:: mem:: size_of;
335347
336- let ptr = tss as * const _ as u64 ;
348+ let ptr = tss as u64 ;
337349
338350 let mut low = Flags :: PRESENT . bits ( ) ;
339351 // base
You can’t perform that action at this time.
0 commit comments