File tree 1 file changed +20
-3
lines changed
1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 1
1
//! Provides a type for the task state segment structure.
2
2
3
3
use crate :: VirtAddr ;
4
+ use core:: mem:: size_of;
4
5
5
6
/// In 64-bit mode the TSS holds information that is not
6
7
/// directly related to the task-switch mechanism,
@@ -22,18 +23,34 @@ pub struct TaskStateSegment {
22
23
}
23
24
24
25
impl TaskStateSegment {
25
- /// Creates a new TSS with zeroed privilege and interrupt stack table and a zero
26
- /// `iomap_base`.
26
+ /// Creates a new TSS with zeroed privilege and interrupt stack table and an
27
+ /// empty I/O-Permission Bitmap.
28
+ ///
29
+ /// As we always set the TSS segment limit to
30
+ /// `size_of::<TaskStateSegment>() - 1`, this means that `iomap_base` is
31
+ /// initialized to `size_of::<TaskStateSegment>()`.
27
32
#[ inline]
28
33
pub const fn new ( ) -> TaskStateSegment {
29
34
TaskStateSegment {
30
35
privilege_stack_table : [ VirtAddr :: zero ( ) ; 3 ] ,
31
36
interrupt_stack_table : [ VirtAddr :: zero ( ) ; 7 ] ,
32
- iomap_base : 0 ,
37
+ iomap_base : size_of :: < TaskStateSegment > ( ) as u16 ,
33
38
reserved_1 : 0 ,
34
39
reserved_2 : 0 ,
35
40
reserved_3 : 0 ,
36
41
reserved_4 : 0 ,
37
42
}
38
43
}
39
44
}
45
+
46
+ #[ cfg( test) ]
47
+ mod tests {
48
+ use super :: * ;
49
+
50
+ #[ test]
51
+ pub fn check_tss_size ( ) {
52
+ // Per the SDM, the minimum size of a TSS is 0x68 bytes, giving a
53
+ // minimum limit of 0x67.
54
+ assert_eq ! ( size_of:: <TaskStateSegment >( ) , 0x68 ) ;
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments