File tree 3 files changed +18
-21
lines changed
3 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -224,21 +224,19 @@ _x86_64_asm_write_cr4:
224
224
.global _x86_64_asm_rdmsr
225
225
.p2align 4
226
226
_x86_64_asm_rdmsr:
227
- mov %edi ,%ecx
227
+ mov %edi , %ecx # First param is the MSR number
228
228
rdmsr
229
- shl $0x20 , %rdx # shift edx to upper 32bit
230
- mov %eax ,%eax # clear upper 32bit of rax
231
- or %rdx ,%rax # or with rdx
229
+ shl $32 , %rdx # shift edx to upper 32bit
230
+ mov %eax , %eax # clear upper 32bit of rax
231
+ or %rdx , %rax # or with rdx
232
232
retq
233
233
234
234
.global _x86_64_asm_wrmsr
235
235
.p2align 4
236
236
_x86_64_asm_wrmsr:
237
- mov %edi ,%ecx
238
- movq %rsi ,%rax
239
- movq %rsi ,%rdx
240
- shr $0x20 ,%rdx
241
- wrmsr
237
+ movl %edi , %ecx # First param is the MSR number
238
+ movl %esi , %eax # Second param is the low 32-bits
239
+ wrmsr # Third param (high 32-bits) is already in %edx
242
240
retq
243
241
244
242
.global _x86_64_asm_hlt
Original file line number Diff line number Diff line change @@ -214,7 +214,7 @@ extern "C" {
214
214
any( target_env = "gnu" , target_env = "musl" ) ,
215
215
link_name = "_x86_64_asm_wrmsr"
216
216
) ]
217
- pub ( crate ) fn x86_64_asm_wrmsr ( msr : u32 , value : u64 ) ;
217
+ pub ( crate ) fn x86_64_asm_wrmsr ( msr : u32 , low : u32 , high : u32 ) ;
218
218
219
219
#[ cfg_attr(
220
220
any( target_env = "gnu" , target_env = "musl" ) ,
Original file line number Diff line number Diff line change @@ -142,20 +142,19 @@ mod x86_64 {
142
142
/// effects.
143
143
#[ inline]
144
144
pub unsafe fn write ( & mut self , value : u64 ) {
145
+ let low = value as u32 ;
146
+ let high = ( value >> 32 ) as u32 ;
147
+
145
148
#[ cfg( feature = "inline_asm" ) ]
146
- {
147
- let low = value as u32 ;
148
- let high = ( value >> 32 ) as u32 ;
149
- asm ! (
150
- "wrmsr" ,
151
- in( "ecx" ) self . 0 ,
152
- in( "eax" ) low, in( "edx" ) high,
153
- options( nostack, preserves_flags) ,
154
- ) ;
155
- }
149
+ asm ! (
150
+ "wrmsr" ,
151
+ in( "ecx" ) self . 0 ,
152
+ in( "eax" ) low, in( "edx" ) high,
153
+ options( nostack, preserves_flags) ,
154
+ ) ;
156
155
157
156
#[ cfg( not( feature = "inline_asm" ) ) ]
158
- crate :: asm:: x86_64_asm_wrmsr ( self . 0 , value ) ;
157
+ crate :: asm:: x86_64_asm_wrmsr ( self . 0 , low , high ) ;
159
158
}
160
159
}
161
160
You can’t perform that action at this time.
0 commit comments