Changeset 67916 in vbox
- Timestamp:
- Jul 12, 2017 5:02:12 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
include/VBox/vmm/hm_svm.h (modified) (7 diffs)
-
src/VBox/VMM/VMMR0/HMR0A.asm (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/hm_svm.h
r67660 r67916 467 467 */ 468 468 /** External or virtual interrupt. */ 469 #define SVM_EVENT_EXTERNAL_IRQ 0469 #define SVM_EVENT_EXTERNAL_IRQ 0 470 470 /** Non-maskable interrupt. */ 471 #define SVM_EVENT_NMI 2471 #define SVM_EVENT_NMI 2 472 472 /** Exception; fault or trap. */ 473 #define SVM_EVENT_EXCEPTION 3473 #define SVM_EVENT_EXCEPTION 3 474 474 /** Software interrupt. */ 475 #define SVM_EVENT_SOFTWARE_INT 4475 #define SVM_EVENT_SOFTWARE_INT 4 476 476 /** @} */ 477 477 … … 728 728 SVMAVIC AvicBar; 729 729 /** Offset 0xa0-0xa7 - Reserved. */ 730 uint8_t u8Reserved2[0xA8 -0xA0];730 uint8_t u8Reserved2[0xA8 - 0xA0]; 731 731 /** Offset 0xa8 - Event injection. */ 732 732 SVMEVENT EventInject; … … 819 819 SVMSEL TR; 820 820 /** Offset 0x4A0-0x4CA - Reserved. */ 821 uint8_t u8Reserved4[0x4CB -0x4A0];821 uint8_t u8Reserved4[0x4CB - 0x4A0]; 822 822 /** Offset 0x4CB - CPL. */ 823 823 uint8_t u8CPL; 824 824 /** Offset 0x4CC-0x4CF - Reserved. */ 825 uint8_t u8Reserved5[0x4D0 -0x4CC];825 uint8_t u8Reserved5[0x4D0 - 0x4CC]; 826 826 /** Offset 0x4D0 - EFER. */ 827 827 uint64_t u64EFER; 828 828 /** Offset 0x4D8-0x547 - Reserved. */ 829 uint8_t u8Reserved6[0x548 -0x4D8];829 uint8_t u8Reserved6[0x548 - 0x4D8]; 830 830 /** Offset 0x548 - CR4. */ 831 831 uint64_t u64CR4; … … 843 843 uint64_t u64RIP; 844 844 /** Offset 0x580-0x5D7 - Reserved. */ 845 uint8_t u8Reserved7[0x5D8 -0x580];845 uint8_t u8Reserved7[0x5D8 - 0x580]; 846 846 /** Offset 0x5D8 - RSP. */ 847 847 uint64_t u64RSP; 848 848 /** Offset 0x5E0-0x5F7 - Reserved. */ 849 uint8_t u8Reserved8[0x5F8 -0x5E0];849 uint8_t u8Reserved8[0x5F8 - 0x5E0]; 850 850 /** Offset 0x5F8 - RAX. */ 851 851 uint64_t u64RAX; … … 869 869 uint64_t u64CR2; 870 870 /** Offset 0x648-0x667 - Reserved. */ 871 uint8_t u8Reserved9[0x668 -0x648];871 uint8_t u8Reserved9[0x668 - 0x648]; 872 872 /** Offset 0x668 - G_PAT. */ 873 873 uint64_t u64GPAT; … … 941 941 SVMVMCBCTRL ctrl; 942 942 /** Offset 0x100-0x3FF - Reserved. */ 943 uint8_t u8Reserved3[0x400 -0x100];943 uint8_t u8Reserved3[0x400 - 0x100]; 944 944 /** Offset 0x400 - State save area. */ 945 945 SVMVMCBSTATESAVE guest; 946 946 /** Offset 0x698-0xFFF- Reserved. */ 947 uint8_t u8Reserved10[0x1000 -0x698];947 uint8_t u8Reserved10[0x1000 - 0x698]; 948 948 } SVMVMCB; 949 949 #pragma pack() … … 952 952 /** Pointer to a const SVMVMCB structure. */ 953 953 typedef const SVMVMCB *PCSVMVMCB; 954 AssertCompileMemberOffset(SVMVMCB, ctrl, 0x00);955 AssertCompileMemberOffset(SVMVMCB, u8Reserved3, 0x100);956 AssertCompileMemberOffset(SVMVMCB, guest, 0x400);954 AssertCompileMemberOffset(SVMVMCB, ctrl, 0x00); 955 AssertCompileMemberOffset(SVMVMCB, u8Reserved3, 0x100); 956 AssertCompileMemberOffset(SVMVMCB, guest, 0x400); 957 957 AssertCompileMemberOffset(SVMVMCB, u8Reserved10, 0x698); 958 958 AssertCompileSize(SVMVMCB, 0x1000); -
trunk/src/VBox/VMM/VMMR0/HMR0A.asm
r67136 r67916 805 805 ; load the guest ones when necessary. 806 806 ; 807 ; @cproto DECLASM(int) HMR0VMXStartVMhmR0DumpDescriptorM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu, PFNHMVMXSTARTVM pfnStartVM); 807 ; @cproto DECLASM(int) HMR0VMXStartVMhmR0DumpDescriptorM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, 808 ; PVMCPU pVCpu, PFNHMVMXSTARTVM pfnStartVM); 808 809 ; 809 810 ; @returns eax … … 984 985 ; load the guest ones when necessary. 985 986 ; 986 ; @cproto DECLASM(int) hmR0SVMRunWrapXMM(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu, PFNHMSVMVMRUN pfnVMRun); 987 ; @cproto DECLASM(int) hmR0SVMRunWrapXMM(RTHCPHYS HCPhysVmcbHost, RTHCPHYS HCPhysVmcb, PCPUMCTX pCtx, PVM pVM, PVMCPU pVCpu, 988 ; PFNHMSVMVMRUN pfnVMRun); 987 989 ; 988 990 ; @returns eax 989 991 ; 990 ; @param pVMCBHostPhysmsc:rcx991 ; @param pVMCBPhysmsc:rdx992 ; @param HCPhysVmcbHost msc:rcx 993 ; @param HCPhysVmcb msc:rdx 992 994 ; @param pCtx msc:r8 993 995 ; @param pVM msc:r9 … … 1011 1013 1012 1014 ; spill input parameters. 1013 mov [xBP + 010h], rcx ; pVMCBHostPhys1014 mov [xBP + 018h], rdx ; pVMCBPhys1015 mov [xBP + 010h], rcx ; HCPhysVmcbHost 1016 mov [xBP + 018h], rdx ; HCPhysVmcb 1015 1017 mov [xBP + 020h], r8 ; pCtx 1016 1018 mov [xBP + 028h], r9 ; pVM … … 1026 1028 mov r10, [xBP + 30h] ; pVCpu 1027 1029 mov [xSP + 020h], r10 1028 mov rcx, [xBP + 010h] ; pVMCBHostPhys1029 mov rdx, [xBP + 018h] ; pVMCBPhys1030 mov rcx, [xBP + 010h] ; HCPhysVmcbHost 1031 mov rdx, [xBP + 018h] ; HCPhysVmcb 1030 1032 mov r8, [xBP + 020h] ; pCtx 1031 1033 mov r9, [xBP + 028h] ; pVM … … 1067 1069 mov r10, [xBP + 30h] ; pVCpu 1068 1070 mov [xSP + 020h], r10 1069 mov rcx, [xBP + 010h] ; pVMCBHostPhys1070 mov rdx, [xBP + 018h] ; pVMCBPhys1071 mov rcx, [xBP + 010h] ; HCPhysVmcbHost 1072 mov rdx, [xBP + 018h] ; HCPhysVmcb 1071 1073 mov r8, [xBP + 020h] ; pCtx 1072 1074 mov r9, [xBP + 028h] ; pVM … … 1129 1131 mov r10, [xBP + 30h] ; pVCpu 1130 1132 mov [xSP + 020h], r10 1131 mov rcx, [xBP + 010h] ; pVMCBHostPhys1132 mov rdx, [xBP + 018h] ; pVMCBPhys1133 mov rcx, [xBP + 010h] ; HCPhysVmcbHost 1134 mov rdx, [xBP + 018h] ; HCPhysVmcb 1133 1135 mov r8, [xBP + 020h] ; pCtx 1134 1136 mov r9, [xBP + 028h] ; pVM … … 1765 1767 ; 1766 1768 ; @returns VBox status code 1767 ; @param HCPhysV MCBPhysical address of host VMCB.1768 ; @param HCPhysV MCBPhysical address of guest VMCB.1769 ; @param pCtx Pointer to the guest CPU-context.1770 ; @param pVM msc:r9, gcc:rcxThe cross context VM structure.1769 ; @param HCPhysVmcbHost msc:rcx,gcc:rdi Physical address of host VMCB. 1770 ; @param HCPhysVmcb msc:rdx,gcc:rsi Physical address of guest VMCB. 1771 ; @param pCtx msc:r8,gcc:rdx Pointer to the guest CPU-context. 1772 ; @param pVM msc:r9,gcc:rcx The cross context VM structure. 1771 1773 ; @param pVCpu msc:[rsp+28],gcc:r8 The cross context virtual CPU structure of the calling EMT. 1772 1774 ; … … 1775 1777 %ifdef RT_ARCH_AMD64 ; fake a cdecl stack frame 1776 1778 %ifdef ASM_CALL64_GCC 1777 push r8 1778 push rcx 1779 push rdx 1780 push rsi 1781 push rdi 1779 push r8 ; pVCpu 1780 push rcx ; pVM 1781 push rdx ; pCtx 1782 push rsi ; HCPhysVmcb 1783 push rdi ; HCPhysVmcbHost 1782 1784 %else 1783 1785 mov rax, [rsp + 28h] 1784 push rax ; pVCpu1785 push r9 ; pVM1786 push r8 ; pCtx1787 push rdx ; HCPHYSGuestVMCB1788 push rcx ; HCPhysHostVMCB1786 push rax ; pVCpu 1787 push r9 ; pVM 1788 push r8 ; pCtx 1789 push rdx ; HCPhysVmcb 1790 push rcx ; HCPhysVmcbHost 1789 1791 %endif 1790 1792 push 0 … … 1794 1796 pushf 1795 1797 1796 ;1797 1798 ; Save all general purpose host registers. 1798 ;1799 1799 MYPUSHAD 1800 1800 1801 ;1802 1801 ; Load pCtx into xSI. 1803 ;1804 1802 mov xSI, [xBP + xCB * 2 + RTHCPHYS_CB * 2] ; pCtx 1805 1803 1806 ;1807 1804 ; Save the host XCR0 and load the guest one if necessary. 1808 ;1809 1805 mov xAX, [xBP + xCB * 2 + RTHCPHYS_CB * 2 + xCB * 2] ; pVCpu 1810 1806 test byte [xAX + VMCPU.hm + HMCPU.fLoadSaveGuestXcr0], 1 … … 1812 1808 1813 1809 xor ecx, ecx 1814 xgetbv ; Save the host one on the stack.1810 xgetbv ; Save the host XCR0 on the stack 1815 1811 push xDX 1816 1812 push xAX 1817 1813 1818 1814 mov xSI, [xBP + xCB * 2 + RTHCPHYS_CB * 2] ; pCtx 1819 mov eax, [xSI + CPUMCTX.aXcr] ; Load the guest one.1815 mov eax, [xSI + CPUMCTX.aXcr] ; load the guest XCR0 1820 1816 mov edx, [xSI + CPUMCTX.aXcr + 4] 1821 xor ecx, ecx ; paranoia1817 xor ecx, ecx ; paranoia 1822 1818 xsetbv 1823 1819 1824 push 0 ; Indicate that we must restore XCR0 (popped into ecx, thus 0).1820 push 0 ; indicate that we must restore XCR0 (popped into ecx, thus 0) 1825 1821 jmp .xcr0_before_done 1826 1822 1827 1823 .xcr0_before_skip: 1828 push 3fh ; indicate that we need not.1824 push 3fh ; indicate that we need not restore XCR0 1829 1825 .xcr0_before_done: 1830 1826 1831 ;1832 1827 ; Save guest CPU-context pointer for simplifying saving of the GPRs afterwards. 1833 ;1834 1828 push xSI 1835 1829 1836 1830 ; Save host fs, gs, sysenter msr etc. 1837 mov xAX, [xBP + xCB * 2] ; pVMCBHostPhys(64 bits physical address; x86: take low dword only)1831 mov xAX, [xBP + xCB * 2] ; HCPhysVmcbHost (64 bits physical address; x86: take low dword only) 1838 1832 push xAX ; save for the vmload after vmrun 1839 1833 vmsave 1840 1834 1841 1835 ; Setup xAX for VMLOAD. 1842 mov xAX, [xBP + xCB * 2 + RTHCPHYS_CB] ; pVMCBPhys (64 bits physical address;take low dword only)1836 mov xAX, [xBP + xCB * 2 + RTHCPHYS_CB] ; HCPhysVmcb (64 bits physical address; x86: take low dword only) 1843 1837 1844 1838 ; Load guest general purpose registers. … … 1857 1851 ; Load guest fs, gs, sysenter msr etc. 1858 1852 vmload 1853 1859 1854 ; Run the VM. 1860 1855 vmrun 1861 1856 1862 ; eax is in the VMCB already; we can use it here.1863 1864 1857 ; Save guest fs, gs, sysenter msr etc. 1865 1858 vmsave 1866 1859 1867 1860 ; Load host fs, gs, sysenter msr etc. 1868 pop xAX ; Pushed above1861 pop rax ; load HCPhysVmcbHost (pushed above) 1869 1862 vmload 1870 1863 … … 1873 1866 stgi 1874 1867 1875 ;1876 1868 ; Pop the context pointer (pushed above) and save the guest GPRs (sans RSP and RAX). 1877 ;1878 1869 pop xAX 1879 1870 … … 1885 1876 mov [ss:xAX + CPUMCTX.ebp], ebp 1886 1877 1887 ;1888 1878 ; Restore the host xcr0 if necessary. 1889 ;1890 1879 pop xCX 1891 1880 test ecx, ecx … … 1893 1882 pop xAX 1894 1883 pop xDX 1895 xsetbv ; ecx is already zero .1884 xsetbv ; ecx is already zero 1896 1885 .xcr0_after_skip: 1897 1886 1898 ;1899 1887 ; Restore host general purpose registers. 1900 ;1901 1888 MYPOPAD 1902 1889 … … 1917 1904 ; 1918 1905 ; @returns VBox status code 1919 ; @param HCPhysV MCBPhysical address of host VMCB.1920 ; @param HCPhysV MCBPhysical address of guest VMCB.1921 ; @param pCtx Pointer to the guest-CPU context.1922 ; @param pVM msc:r9, gcc:rcxThe cross context VM structure.1906 ; @param HCPhysVmcbHost msc:rcx,gcc:rdi Physical address of host VMCB. 1907 ; @param HCPhysVmcb msc:rdx,gcc:rsi Physical address of guest VMCB. 1908 ; @param pCtx msc:r8,gcc:rdx Pointer to the guest-CPU context. 1909 ; @param pVM msc:r9,gcc:rcx The cross context VM structure. 1923 1910 ; @param pVCpu msc:[rsp+28],gcc:r8 The cross context virtual CPU structure of the calling EMT. 1924 1911 ; … … 1927 1914 ; Fake a cdecl stack frame 1928 1915 %ifdef ASM_CALL64_GCC 1929 push r8 1930 push rcx 1931 push rdx 1932 push rsi 1933 push rdi 1916 push r8 ;pVCpu 1917 push rcx ;pVM 1918 push rdx ;pCtx 1919 push rsi ;HCPhysVmcb 1920 push rdi ;HCPhysVmcbHost 1934 1921 %else 1935 1922 mov rax, [rsp + 28h] 1936 push rax ; rbp + 30h pVCpu1937 push r9 ; rbp + 28h pVM1938 push r8 ; rbp + 20h pCtx1939 push rdx ; rbp + 18h HCPHYSGuestVMCB1940 push rcx ; rbp + 10h HCPhysHostVMCB1941 %endif 1942 push 0 ; rbp + 08h "fake ret addr"1943 push rbp ; rbp + 00h1923 push rax ; rbp + 30h pVCpu 1924 push r9 ; rbp + 28h pVM 1925 push r8 ; rbp + 20h pCtx 1926 push rdx ; rbp + 18h HCPhysVmcb 1927 push rcx ; rbp + 10h HCPhysVmcbHost 1928 %endif 1929 push 0 ; rbp + 08h "fake ret addr" 1930 push rbp ; rbp + 00h 1944 1931 mov rbp, rsp 1945 1932 pushf … … 1953 1940 ; - DRx (presumably not changed at all) 1954 1941 ; - DR7 (reset to 0x400) 1955 ; 1956 1957 ; 1942 1958 1943 ; Save all general purpose host registers. 1959 ;1960 1944 MYPUSHAD 1961 1945 1962 ;1963 1946 ; Load pCtx into xSI. 1964 ;1965 1947 mov xSI, [rbp + xCB * 2 + RTHCPHYS_CB * 2] 1966 1948 1967 ;1968 1949 ; Save the host XCR0 and load the guest one if necessary. 1969 ; 1970 mov rax, [xBP + 30h] ; pVCpu 1950 mov rax, [xBP + 30h] ; pVCpu 1971 1951 test byte [xAX + VMCPU.hm + HMCPU.fLoadSaveGuestXcr0], 1 1972 1952 jz .xcr0_before_skip 1973 1953 1974 1954 xor ecx, ecx 1975 xgetbv ; Save the host oneon the stack.1955 xgetbv ; save the host XCR0 on the stack. 1976 1956 push xDX 1977 1957 push xAX 1978 1958 1979 1959 mov xSI, [xBP + xCB * 2 + RTHCPHYS_CB * 2] ; pCtx 1980 mov eax, [xSI + CPUMCTX.aXcr] ; Load the guest one.1960 mov eax, [xSI + CPUMCTX.aXcr] ; load the guest XCR0 1981 1961 mov edx, [xSI + CPUMCTX.aXcr + 4] 1982 xor ecx, ecx ; paranoia1962 xor ecx, ecx ; paranoia 1983 1963 xsetbv 1984 1964 1985 push 0 ; Indicate that we must restore XCR0 (popped into ecx, thus 0).1965 push 0 ; indicate that we must restore XCR0 (popped into ecx, thus 0) 1986 1966 jmp .xcr0_before_done 1987 1967 1988 1968 .xcr0_before_skip: 1989 push 3fh ; indicate that we need not.1969 push 3fh ; indicate that we need not restore XCR0 1990 1970 .xcr0_before_done: 1991 1971 1992 ;1993 1972 ; Save guest CPU-context pointer for simplifying saving of the GPRs afterwards. 1994 ;1995 1973 push rsi 1996 1974 1997 ;1998 1975 ; Save host fs, gs, sysenter msr etc. 1999 ; 2000 mov rax, [rbp + xCB * 2] ; pVMCBHostPhys (64 bits physical address; x86: take low dword only) 2001 push rax ; Save for the vmload after vmrun 1976 mov rax, [rbp + xCB * 2] ; HCPhysVmcbHost (64 bits physical address; x86: take low dword only) 1977 push rax ; save for the vmload after vmrun 2002 1978 vmsave 2003 1979 2004 1980 ; Setup rax for VMLOAD. 2005 mov rax, [rbp + xCB * 2 + RTHCPHYS_CB] ; pVMCBPhys (64 bits physical address; take low dword only) 2006 2007 ; Load guest general purpose registers. 2008 ; rax is loaded from the VMCB by VMRUN. 1981 mov rax, [rbp + xCB * 2 + RTHCPHYS_CB] ; HCPhysVmcb (64 bits physical address; take low dword only) 1982 1983 ; Load guest general purpose registers (rax is loaded from the VMCB by VMRUN). 2009 1984 mov rbx, qword [xSI + CPUMCTX.ebx] 2010 1985 mov rcx, qword [xSI + CPUMCTX.ecx] … … 2026 2001 sti 2027 2002 2028 ; Load guest fs, gs, sysenter msretc.2003 ; Load guest FS, GS, Sysenter MSRs etc. 2029 2004 vmload 2005 2030 2006 ; Run the VM. 2031 2007 vmrun 2032 2008 2033 ; rax is in the VMCB already; we can use it here.2034 2035 2009 ; Save guest fs, gs, sysenter msr etc. 2036 2010 vmsave 2037 2011 2038 ;2039 2012 ; Load host fs, gs, sysenter msr etc. 2040 ; 2041 pop rax ; pushed above 2013 pop rax ; load HCPhysVmcbHost (pushed above) 2042 2014 vmload 2043 2015 2044 ;2045 2016 ; Set the global interrupt flag again, but execute cli to make sure IF=0. 2046 ;2047 2017 cli 2048 2018 stgi 2049 2019 2050 ;2051 2020 ; Pop the context pointer (pushed above) and save the guest GPRs (sans RSP and RAX). 2052 ;2053 2021 pop rax 2054 2022 … … 2068 2036 mov qword [rax + CPUMCTX.r15], r15 2069 2037 2070 ;2071 2038 ; Restore the host xcr0 if necessary. 2072 ;2073 2039 pop xCX 2074 2040 test ecx, ecx … … 2076 2042 pop xAX 2077 2043 pop xDX 2078 xsetbv ; ecx is already zero .2044 xsetbv ; ecx is already zero 2079 2045 .xcr0_after_skip: 2080 2046 2081 ;2082 2047 ; Restore host general purpose registers. 2083 ;2084 2048 MYPOPAD 2085 2049
Note:
See TracChangeset
for help on using the changeset viewer.

