Changeset 87431 in vbox for trunk/src/VBox/VMM/VMMR0
- Timestamp:
- Jan 26, 2021 12:17:26 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142438
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/HMR0A.asm
r87429 r87431 824 824 %endif 825 825 826 ; Load CR2 if necessary ( may be expensive as writing CR2 is a synchronizing instruction).826 ; Load CR2 if necessary (expensive as writing CR2 is a synchronizing instruction - (bird: still expensive on 10980xe)). 827 827 mov rcx, qword [rdi + CPUMCTX.cr2] 828 828 mov rdx, cr2 … … 830 830 je .skip_cr2_write 831 831 mov cr2, rcx 832 833 832 .skip_cr2_write: 834 ; Set the vmlaunch/vmresume "return" host RIP and RSP values. 835 lea rcx, [NAME(hmR0VMXStartVMHostRIP) wrt rip] ;; @todo It is only strictly necessary to write VMX_VMCS_HOST_RIP when 836 mov eax, VMX_VMCS_HOST_RIP ;; the VMXVMCSINFO::pfnStartVM function changes (eventually 837 vmwrite rax, rcx ;; take the Windows/SSE stuff into account then)... 838 %ifdef VBOX_STRICT 839 jna NAME(hmR0VMXStartVMHostRIP.vmwrite_failed) 840 %endif 841 mov edx, VMX_VMCS_HOST_RSP ;; @todo The HOST_RSP value is unlikely to change much, so if vmwrite 842 vmwrite rdx, rsp ;; can be noticably more expensive than a memory read, we could 843 %ifdef VBOX_STRICT ;; easily optimize this one away almost completely by comparing 844 jna NAME(hmR0VMXStartVMHostRIP.vmwrite_failed) ;; rsp with a shadow copy of VMX_VMCS_HOST_RSP. 845 %endif 833 834 ; Set the vmlaunch/vmresume "return" host RIP and RSP values if they've changed (unlikly). 835 ; The vmwrite isn't quite for free (on an 10980xe at least), thus we check if anything changed 836 ; before writing here. 837 lea rcx, [NAME(hmR0VMXStartVMHostRIP) wrt rip] 838 cmp rcx, [rsi + VMCPU.hm + HMCPU.u + HMCPUVMX.uHostRIP] 839 jne .write_host_rip 840 .wrote_host_rip: 841 cmp rsp, [rsi + VMCPU.hm + HMCPU.u + HMCPUVMX.uHostRSP] 842 jne .write_host_rsp 843 .wrote_host_rsp: 846 844 847 845 ; Fight spectre and similar. Trashes rax, rcx, and rdx. … … 880 878 jz NAME(hmR0VMXStartVMHostRIP.vmxstart64_start_failed) 881 879 jmp NAME(hmR0VMXStartVMHostRIP) ; here if vmlaunch detected a failure 880 881 882 ; Put these two outside the normal code path as they should rarely change. 883 ALIGNCODE(8) 884 .write_host_rip: 885 mov [rsi + VMCPU.hm + HMCPU.u + HMCPUVMX.uHostRIP], rcx 886 mov eax, VMX_VMCS_HOST_RIP ;; @todo It is only strictly necessary to write VMX_VMCS_HOST_RIP when 887 vmwrite rax, rcx ;; the VMXVMCSINFO::pfnStartVM function changes (eventually 888 %ifdef VBOX_STRICT ;; take the Windows/SSE stuff into account then)... 889 jna NAME(hmR0VMXStartVMHostRIP.vmwrite_failed) 890 %endif 891 jmp .wrote_host_rip 892 893 ALIGNCODE(8) 894 .write_host_rsp: 895 mov [rsi + VMCPU.hm + HMCPU.u + HMCPUVMX.uHostRSP], rsp 896 mov eax, VMX_VMCS_HOST_RSP 897 vmwrite rax, rsp 898 %ifdef VBOX_STRICT 899 jna NAME(hmR0VMXStartVMHostRIP.vmwrite_failed) 900 %endif 901 jmp .wrote_host_rsp 882 902 883 903 ALIGNCODE(64)
Note:
See TracChangeset
for help on using the changeset viewer.