@@ -4,116 +4,8 @@ pub mod control;
44pub mod model_specific;
55pub mod rflags;
66
7- /// Gets the current instruction pointer. Note that this is only approximate as it requires a few
8- /// instructions to execute.
9- #[ cfg( feature = "inline_asm" ) ]
10- #[ inline( always) ]
11- pub fn read_rip ( ) -> u64 {
12- let rip: u64 ;
13- unsafe {
14- llvm_asm ! (
15- "lea (%rip), $0"
16- : "=r" ( rip) :: : "volatile"
17- ) ;
18- }
19- rip
20- }
7+ #[ cfg( feature = "instructions" ) ]
8+ pub use crate :: instructions:: { rdfsbase, rdgsbase, wrfsbase, wrgsbase} ;
219
22- /// Writes the FS segment base address
23- ///
24- /// ## Safety
25- ///
26- /// If `CR4.FSGSBASE` is not set, this instruction will throw an `#UD`.
27- ///
28- /// The caller must ensure that this write operation has no unsafe side
29- /// effects, as the FS segment base address is often used for thread
30- /// local storage.
31- #[ inline]
32- pub unsafe fn wrfsbase ( val : u64 ) {
33- #[ cfg( feature = "inline_asm" ) ]
34- #[ inline( always) ]
35- unsafe fn inner ( val : u64 ) {
36- llvm_asm ! ( "wrfsbase $0" :: "r" ( val) :: "volatile" )
37- }
38-
39- #[ cfg( not( feature = "inline_asm" ) ) ]
40- #[ inline( always) ]
41- unsafe fn inner ( val : u64 ) {
42- crate :: asm:: x86_64_asm_wrfsbase ( val)
43- }
44-
45- inner ( val)
46- }
47-
48- /// Reads the FS segment base address
49- ///
50- /// ## Safety
51- ///
52- /// If `CR4.FSGSBASE` is not set, this instruction will throw an `#UD`.
53- #[ inline]
54- pub unsafe fn rdfsbase ( ) -> u64 {
55- #[ cfg( feature = "inline_asm" ) ]
56- #[ inline( always) ]
57- unsafe fn inner ( ) -> u64 {
58- let val: u64 ;
59- llvm_asm ! ( "rdfsbase $0" : "=r" ( val) :: : "volatile" ) ;
60- val
61- }
62-
63- #[ cfg( not( feature = "inline_asm" ) ) ]
64- #[ inline( always) ]
65- unsafe fn inner ( ) -> u64 {
66- crate :: asm:: x86_64_asm_rdfsbase ( )
67- }
68-
69- inner ( )
70- }
71-
72- /// Writes the GS segment base address
73- ///
74- /// ## Safety
75- ///
76- /// If `CR4.FSGSBASE` is not set, this instruction will throw an `#UD`.
77- ///
78- /// The caller must ensure that this write operation has no unsafe side
79- /// effects, as the GS segment base address might be in use.
80- #[ inline]
81- pub unsafe fn wrgsbase ( val : u64 ) {
82- #[ cfg( feature = "inline_asm" ) ]
83- #[ inline( always) ]
84- unsafe fn inner ( val : u64 ) {
85- llvm_asm ! ( "wrgsbase $0" :: "r" ( val) :: "volatile" )
86- }
87-
88- #[ cfg( not( feature = "inline_asm" ) ) ]
89- #[ inline( always) ]
90- unsafe fn inner ( val : u64 ) {
91- crate :: asm:: x86_64_asm_wrgsbase ( val)
92- }
93-
94- inner ( val)
95- }
96-
97- /// Reads the GS segment base address
98- ///
99- /// ## Safety
100- ///
101- /// If `CR4.FSGSBASE` is not set, this instruction will throw an `#UD`.
102- #[ inline]
103- pub unsafe fn rdgsbase ( ) -> u64 {
104- #[ cfg( feature = "inline_asm" ) ]
105- #[ inline( always) ]
106- unsafe fn inner ( ) -> u64 {
107- let val: u64 ;
108- llvm_asm ! ( "rdgsbase $0" : "=r" ( val) :: : "volatile" ) ;
109- val
110- }
111-
112- #[ cfg( not( feature = "inline_asm" ) ) ]
113- #[ inline( always) ]
114- unsafe fn inner ( ) -> u64 {
115- crate :: asm:: x86_64_asm_rdgsbase ( )
116- }
117-
118- inner ( )
119- }
10+ #[ cfg( all( feature = "instructions" , feature = "inline_asm" ) ) ]
11+ pub use crate :: instructions:: read_rip;
0 commit comments