@@ -20,16 +20,24 @@ impl Vmx {
2020
2121 unsafe {
2222 // Enable NE in CR0, This is fixed bit in VMX CR0
23- llvm_asm ! ( "movq %cr0, %rax; orq %rdx, %rax; movq %rax, %cr0;"
24- :
25- : "{rdx}" ( 0x20 )
26- : "rax" ) ;
23+ asm ! (
24+ "mov rax, cr0" ,
25+ "or rax, rdx" ,
26+ "mov cr0, rax" ,
27+ in( "rdx" ) 0x20 ,
28+ lateout( "rax" ) _,
29+ options( nomem, nostack)
30+ ) ;
2731
2832 // Enable vmx in CR4
29- llvm_asm ! ( "movq %cr4, %rax; orq %rdx, %rax; movq %rax, %cr4;"
30- :
31- : "{rdx}" ( VMX_ENABLE_FLAG )
32- : "rax" ) ;
33+ asm ! (
34+ "mov rax, cr4" ,
35+ "or rax, rdx" ,
36+ "mov cr4, rax" ,
37+ in( "rdx" ) VMX_ENABLE_FLAG ,
38+ lateout( "rax" ) _,
39+ options( nomem, nostack)
40+ ) ;
3341 }
3442
3543 let revision_id = Self :: revision ( ) ;
@@ -45,10 +53,13 @@ impl Vmx {
4553
4654 let rflags = unsafe {
4755 let rflags: u64 ;
48- llvm_asm ! ( "vmxon $1; pushfq; popq $0"
49- : "=r" ( rflags)
50- : "m" ( vmxon_region_addr)
51- : "rflags" ) ;
56+ asm ! (
57+ "vmxon [{}]" ,
58+ "pushf" ,
59+ "pop {}" ,
60+ in( reg) & vmxon_region_addr,
61+ lateout( reg) rflags,
62+ ) ;
5263 rflags
5364 } ;
5465
@@ -63,10 +74,12 @@ impl Vmx {
6374 // was originally activated from
6475 let rflags = unsafe {
6576 let rflags: u64 ;
66- llvm_asm ! ( "vmxoff; pushfq; popq $0"
67- : "=r" ( rflags)
68- :
69- : "rflags" ) ;
77+ asm ! (
78+ "vmxoff" ,
79+ "pushf" ,
80+ "pop {}" ,
81+ lateout( reg) rflags,
82+ ) ;
7083 rflags
7184 } ;
7285
@@ -85,9 +98,14 @@ impl Vmx {
8598
8699 let rflags = unsafe {
87100 let rflags: u64 ;
88- llvm_asm ! ( "invept $1, $2; pushfq; popq $0"
89- : "=r" ( rflags)
90- : "m" ( val) , "r" ( t) ) ;
101+ asm ! (
102+ "invept {}, [{}]" ,
103+ "pushfq" ,
104+ "pop {}" ,
105+ in( reg) t,
106+ in( reg) & val,
107+ lateout( reg) rflags
108+ ) ;
91109 rflags
92110 } ;
93111 error:: check_vm_insruction ( rflags, "Failed to execute invept" . into ( ) )
@@ -107,9 +125,14 @@ impl Vmx {
107125
108126 let rflags = unsafe {
109127 let rflags: u64 ;
110- llvm_asm ! ( "invvpid $1, $2; pushfq; popq $0"
111- : "=r" ( rflags)
112- : "m" ( val) , "r" ( t) ) ;
128+ asm ! (
129+ "invvpid {}, [{}]" ,
130+ "pushfq" ,
131+ "pop {}" ,
132+ in( reg) t,
133+ in( reg) & val,
134+ lateout( reg) rflags
135+ ) ;
113136 rflags
114137 } ;
115138 error:: check_vm_insruction ( rflags, "Failed to execute invvpid" . into ( ) )
0 commit comments