Changeset 87334 in vbox
- Timestamp:
- Jan 20, 2021 8:58:26 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMR0A.asm
r87330 r87334 76 76 77 77 %ifdef ASM_CALL64_GCC 78 %define CALLEE_PRESERVED_REGISTER_COUNT 5 78 79 %macro PUSH_CALLEE_PRESERVED_REGISTERS 0 79 80 push r15 … … 92 93 93 94 %else ; ASM_CALL64_MSC 95 %define CALLEE_PRESERVED_REGISTER_COUNT 7 94 96 %macro PUSH_CALLEE_PRESERVED_REGISTERS 0 95 97 push r15 … … 1055 1057 mov rbp, rsp 1056 1058 pushf 1059 sub rsp, 30h - 8h ; The frame is 30h bytes, but the rbp-08h entry is the above pushf. 1060 ; And we have CALLEE_PRESERVED_REGISTER_COUNT following it. 1061 %define frm_uHostXcr0 -18h ; 128-bit 1062 %define frm_fNoRestoreXcr0 -20h ; Non-zero if we should skip XCR0 restoring. 1063 %define frm_pVCpu -28h ; Where we stash pVCpu for use after the vmrun. 1064 %define frm_HCPhysVmcbHost -30h ; Where we stash HCPhysVmcbHost for the vmload after vmrun. 1065 %define cbFrame ( 30h + CALLEE_PRESERVED_REGISTER_COUNT*8 ) 1057 1066 1058 1067 ; Manual save and restore: … … 1077 1086 1078 1087 ; Save the host XCR0 and load the guest one if necessary. 1088 mov ecx, 3fh ; indicate that we need not restore XCR0 (in case we jump) 1079 1089 test byte [rsi + VMCPU.hm + HMCPU.fLoadSaveGuestXcr0], 1 1080 1090 jz .xcr0_before_skip … … 1082 1092 xor ecx, ecx 1083 1093 xgetbv ; save the host XCR0 on the stack 1084 pushrdx1085 pushrax1094 mov [rbp + frm_uHostXcr0 + 8], rdx 1095 mov [rbp + frm_uHostXcr0 ], rax 1086 1096 1087 1097 mov eax, [rsi + VMCPU.cpum.GstCtx + CPUMCTX.aXcr] ; load the guest XCR0 1088 1098 mov edx, [rsi + VMCPU.cpum.GstCtx + CPUMCTX.aXcr + 4] 1089 xor ecx, ecx ; paranoia 1099 xor ecx, ecx ; paranoia; Also, indicates that we must restore XCR0 (moved into ecx, thus 0). 1090 1100 xsetbv 1091 1101 1092 push 0 ; indicate that we must restore XCR0 (popped into ecx, thus 0)1093 jmp .xcr0_before_done1094 1095 1102 .xcr0_before_skip: 1096 push 3fh ; indicate that we need not restore XCR0 1097 .xcr0_before_done: 1103 mov [rbp + frm_fNoRestoreXcr0], rcx 1098 1104 1099 1105 ; Save pVCpu pointer for simplifying saving of the GPRs afterwards. 1100 pushrsi1106 mov qword [rbp + frm_pVCpu], rsi 1101 1107 1102 1108 ; Save host fs, gs, sysenter msr etc. 1103 1109 mov rax, [rsi + VMCPU.hm + HMCPU.u + HMCPUSVM.HCPhysVmcbHost] 1104 push rax; save for the vmload after vmrun1110 mov qword [rbp + frm_HCPhysVmcbHost], rax ; save for the vmload after vmrun 1105 1111 vmsave 1106 1112 … … 1141 1147 1142 1148 ; Load host fs, gs, sysenter msr etc. 1143 pop rax ; load HCPhysVmcbHost (pushed above)1149 mov rax, [rsp + cbFrame + frm_HCPhysVmcbHost] ; load HCPhysVmcbHost (rbp is not operational yet, thus rsp) 1144 1150 vmload 1145 1151 … … 1148 1154 stgi 1149 1155 1150 ; Pop pVCpu ( pushed above) and save the guest GPRs (sans RSP and RAX).1151 pop rax1156 ; Pop pVCpu (saved above) and save the guest GPRs (sans RSP and RAX). 1157 mov rax, [rsp + cbFrame + frm_pVCpu] ; (rbp still not operational) 1152 1158 1153 1159 mov qword [rax + VMCPU.cpum.GstCtx + CPUMCTX.ebx], rbx … … 1162 1168 mov rdi, rbx 1163 1169 mov qword [rax + VMCPU.cpum.GstCtx + CPUMCTX.ebp], rbp 1164 mov rbp, rbx1170 lea rbp, [rsp + cbFrame] 1165 1171 mov qword [rax + VMCPU.cpum.GstCtx + CPUMCTX.r8], r8 1166 1172 mov r8, rbx … … 1184 1190 1185 1191 ; Restore the host xcr0 if necessary. 1186 pop rcx1192 mov rcx, [rbp + frm_fNoRestoreXcr0] 1187 1193 test ecx, ecx 1188 1194 jnz .xcr0_after_skip 1189 pop rax1190 pop rdx1195 mov rdx, [rbp + frm_uHostXcr0 + 8] 1196 mov rax, [rbp + frm_uHostXcr0] 1191 1197 xsetbv ; ecx is already zero 1192 1198 .xcr0_after_skip: … … 1197 1203 mov eax, VINF_SUCCESS 1198 1204 1205 add rsp, 30h - 8h 1199 1206 popf 1200 pop rbp ; Do not use leave! rbp is trashed.1207 leave 1201 1208 ret 1209 %undef frm_uHostXcr0 1210 %undef frm_fNoRestoreXcr0 1211 %undef frm_pVCpu 1212 %undef frm_HCPhysVmcbHost 1213 %undef cbFrame 1202 1214 ENDPROC SVMR0VMRun 1203 1215
Note:
See TracChangeset
for help on using the changeset viewer.