File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,28 @@ pub mod tss;
13
13
/// A struct describing a pointer to a descriptor table (GDT / IDT).
14
14
/// This is in a format suitable for giving to 'lgdt' or 'lidt'.
15
15
#[ derive( Debug , Clone , Copy ) ]
16
- #[ repr( C , packed) ]
16
+ #[ repr( C , packed( 2 ) ) ]
17
17
pub struct DescriptorTablePointer {
18
18
/// Size of the DT.
19
19
pub limit : u16 ,
20
20
/// Pointer to the memory region containing the DT.
21
21
pub base : VirtAddr ,
22
22
}
23
+
24
+ #[ cfg( test) ]
25
+ mod tests {
26
+ use super :: * ;
27
+ use std:: mem:: size_of;
28
+
29
+ #[ test]
30
+ pub fn check_descriptor_pointer_size ( ) {
31
+ // Per the SDM, a descriptor pointer has to be 2+8=10 bytes
32
+ assert_eq ! ( size_of:: <DescriptorTablePointer >( ) , 10 ) ;
33
+ // Make sure that we can reference a pointer's limit
34
+ let p = DescriptorTablePointer {
35
+ limit : 5 ,
36
+ base : VirtAddr :: zero ( ) ,
37
+ } ;
38
+ let _: & u16 = & p. limit ;
39
+ }
40
+ }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use core::mem::size_of;
8
8
/// but is used for finding kernel level stack
9
9
/// if interrupts arrive while in kernel mode.
10
10
#[ derive( Debug , Clone , Copy ) ]
11
- #[ repr( C , packed) ]
11
+ #[ repr( C , packed( 4 ) ) ]
12
12
pub struct TaskStateSegment {
13
13
reserved_1 : u32 ,
14
14
/// The full 64-bit canonical forms of the stack pointers (RSP) for privilege levels 0-2.
You can’t perform that action at this time.
0 commit comments