Changeset 79202 in vbox
- Timestamp:
- Jun 18, 2019 9:13:29 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/hm_vmx.h
r79195 r79202 466 466 /** 467 467 * EPT Page Directory Pointer Entry. Bit view. 468 * In accordance with the VT-x spec. 469 * 468 470 * @todo uint64_t isn't safe for bitfields (gcc pedantic warnings, and IIRC, 469 471 * this did cause trouble with one compiler/version). … … 497 499 /** 498 500 * EPT PML4E. 501 * In accordance with the VT-x spec. 499 502 */ 500 503 typedef union EPTPML4E … … 517 520 /** 518 521 * EPT PML4 Table. 522 * In accordance with the VT-x spec. 519 523 */ 520 524 typedef struct EPTPML4 … … 530 534 /** 531 535 * EPT Page Directory Pointer Entry. Bit view. 536 * In accordance with the VT-x spec. 532 537 */ 533 538 typedef struct EPTPDPTEBITS … … 559 564 /** 560 565 * EPT Page Directory Pointer. 566 * In accordance with the VT-x spec. 561 567 */ 562 568 typedef union EPTPDPTE … … 579 585 /** 580 586 * EPT Page Directory Pointer Table. 587 * In accordance with the VT-x spec. 581 588 */ 582 589 typedef struct EPTPDPT … … 592 599 /** 593 600 * EPT Page Directory Table Entry. Bit view. 601 * In accordance with the VT-x spec. 594 602 */ 595 603 typedef struct EPTPDEBITS … … 623 631 /** 624 632 * EPT 2MB Page Directory Table Entry. Bit view. 633 * In accordance with the VT-x spec. 625 634 */ 626 635 typedef struct EPTPDE2MBITS … … 654 663 /** 655 664 * EPT Page Directory Table Entry. 665 * In accordance with the VT-x spec. 656 666 */ 657 667 typedef union EPTPDE … … 676 686 /** 677 687 * EPT Page Directory Table. 688 * In accordance with the VT-x spec. 678 689 */ 679 690 typedef struct EPTPD … … 689 700 /** 690 701 * EPT Page Table Entry. Bit view. 702 * In accordance with the VT-x spec. 691 703 */ 692 704 typedef struct EPTPTEBITS … … 725 737 /** 726 738 * EPT Page Table Entry. 739 * In accordance with the VT-x spec. 727 740 */ 728 741 typedef union EPTPTE … … 745 758 /** 746 759 * EPT Page Table. 760 * In accordance with the VT-x spec. 747 761 */ 748 762 typedef struct EPTPT … … 816 830 /** 817 831 * VMX VMCS revision identifier. 832 * In accordance with the VT-x spec. 818 833 */ 819 834 typedef union … … 837 852 /** 838 853 * VMX VM-exit instruction information. 854 * In accordance with the VT-x spec. 839 855 */ 840 856 typedef union … … 1126 1142 /** 1127 1143 * VMX controls MSR. 1144 * In accordance with the VT-x spec. 1128 1145 */ 1129 1146 typedef union … … 1351 1368 1352 1369 /** @name VM Instruction Errors. 1370 * In accordance with the VT-x spec. 1353 1371 * See Intel spec. "30.4 VM Instruction Error Numbers" 1354 1372 * @{ … … 1413 1431 1414 1432 /** @name VMX abort reasons. 1433 * In accordance with the VT-x spec. 1415 1434 * See Intel spec. "27.7 VMX Aborts". 1416 1435 * Update HMGetVmxAbortDesc() if new reasons are added. @{ … … 1693 1712 1694 1713 1695 /** @name VMCS field encoding: 16-bit control fields. 1696 * @{ 1697 */ 1714 /** @name VMCS fields and encoding. 1715 * 1716 * When adding a new field: 1717 * - Always add it to g_aVmcsFields. 1718 * - Consider if it needs to be added to VMXVVMCS. 1719 * @{ 1720 */ 1721 /** 16-bit control fields. */ 1698 1722 #define VMX_VMCS16_VPID 0x0000 1699 1723 #define VMX_VMCS16_POSTED_INT_NOTIFY_VECTOR 0x0002 1700 1724 #define VMX_VMCS16_EPTP_INDEX 0x0004 1701 /** @} */ 1702 1703 1704 /** @name VMCS field encoding: 16-bit guest-state fields. 1705 * @{ 1706 */ 1725 1726 /** 16-bit guest-state fields. */ 1707 1727 #define VMX_VMCS16_GUEST_ES_SEL 0x0800 1708 1728 #define VMX_VMCS16_GUEST_CS_SEL 0x0802 … … 1715 1735 #define VMX_VMCS16_GUEST_INTR_STATUS 0x0810 1716 1736 #define VMX_VMCS16_GUEST_PML_INDEX 0x0812 1717 /** @} */ 1718 1719 1720 /** @name VMCS field encoding: 16-bits host-state fields. 1721 * @{ 1722 */ 1737 1738 /** 16-bits host-state fields. */ 1723 1739 #define VMX_VMCS16_HOST_ES_SEL 0x0c00 1724 1740 #define VMX_VMCS16_HOST_CS_SEL 0x0c02 … … 1728 1744 #define VMX_VMCS16_HOST_GS_SEL 0x0c0a 1729 1745 #define VMX_VMCS16_HOST_TR_SEL 0x0c0c 1730 /** @} */ 1731 1732 1733 /** @name VMCS field encoding: 64-bit control fields. 1734 * @{ 1735 */ 1746 1747 /** 64-bit control fields. */ 1736 1748 #define VMX_VMCS64_CTRL_IO_BITMAP_A_FULL 0x2000 1737 1749 #define VMX_VMCS64_CTRL_IO_BITMAP_A_HIGH 0x2001 … … 1784 1796 #define VMX_VMCS64_CTRL_TSC_MULTIPLIER_FULL 0x2032 1785 1797 #define VMX_VMCS64_CTRL_TSC_MULTIPLIER_HIGH 0x2033 1786 /** @} */ 1787 1788 1789 /** @name VMCS field encoding: 64-bit read-only data fields. 1790 * @{ 1791 */ 1798 1799 /** 64-bit read-only data fields. */ 1792 1800 #define VMX_VMCS64_RO_GUEST_PHYS_ADDR_FULL 0x2400 1793 1801 #define VMX_VMCS64_RO_GUEST_PHYS_ADDR_HIGH 0x2401 1794 /** @} */ 1795 1796 1797 /** @name VMCS field encoding: 64-bit guest-state fields. 1798 * @{ 1799 */ 1802 1803 /** 64-bit guest-state fields. */ 1800 1804 #define VMX_VMCS64_GUEST_VMCS_LINK_PTR_FULL 0x2800 1801 1805 #define VMX_VMCS64_GUEST_VMCS_LINK_PTR_HIGH 0x2801 … … 1818 1822 #define VMX_VMCS64_GUEST_BNDCFGS_FULL 0x2812 1819 1823 #define VMX_VMCS64_GUEST_BNDCFGS_HIGH 0x2813 1820 /** @} */ 1821 1822 1823 /** @name VMCS field encoding: 64-bit host-state fields. 1824 * @{ 1825 */ 1824 1825 /** 64-bit host-state fields. */ 1826 1826 #define VMX_VMCS64_HOST_PAT_FULL 0x2c00 1827 1827 #define VMX_VMCS64_HOST_PAT_HIGH 0x2c01 … … 1830 1830 #define VMX_VMCS64_HOST_PERF_GLOBAL_CTRL_FULL 0x2c04 1831 1831 #define VMX_VMCS64_HOST_PERF_GLOBAL_CTRL_HIGH 0x2c05 1832 /** @} */ 1833 1834 1835 /** @name VMCS field encoding: 32-bit control fields. 1836 * @{ 1837 */ 1832 1833 /** 32-bit control fields. */ 1838 1834 #define VMX_VMCS32_CTRL_PIN_EXEC 0x4000 1839 1835 #define VMX_VMCS32_CTRL_PROC_EXEC 0x4002 … … 1854 1850 #define VMX_VMCS32_CTRL_PLE_GAP 0x4020 1855 1851 #define VMX_VMCS32_CTRL_PLE_WINDOW 0x4022 1856 /** @} */ 1857 1858 1859 /** @name VMCS field encoding: 32-bits read-only fields. 1860 * @{ 1861 */ 1852 1853 /** 32-bits read-only fields. */ 1862 1854 #define VMX_VMCS32_RO_VM_INSTR_ERROR 0x4400 1863 1855 #define VMX_VMCS32_RO_EXIT_REASON 0x4402 … … 1868 1860 #define VMX_VMCS32_RO_EXIT_INSTR_LENGTH 0x440c 1869 1861 #define VMX_VMCS32_RO_EXIT_INSTR_INFO 0x440e 1870 /** @} */ 1871 1872 1873 /** @name VMCS field encoding: 32-bit guest-state fields. 1874 * @{ 1875 */ 1862 1863 /** 32-bit guest-state fields. */ 1876 1864 #define VMX_VMCS32_GUEST_ES_LIMIT 0x4800 1877 1865 #define VMX_VMCS32_GUEST_CS_LIMIT 0x4802 … … 1897 1885 #define VMX_VMCS32_GUEST_SYSENTER_CS 0x482a 1898 1886 #define VMX_VMCS32_PREEMPT_TIMER_VALUE 0x482e 1899 /** @} */ 1900 1901 1902 /** @name VMCS field encoding: 32-bit host-state fields. 1903 * @{ 1904 */ 1887 1888 /** 32-bit host-state fields. */ 1905 1889 #define VMX_VMCS32_HOST_SYSENTER_CS 0x4C00 1906 /** @} */ 1907 1908 1909 /** @name VMCS field encoding: Natural-width control fields. 1910 * @{ 1911 */ 1890 1891 /** Natural-width control fields. */ 1912 1892 #define VMX_VMCS_CTRL_CR0_MASK 0x6000 1913 1893 #define VMX_VMCS_CTRL_CR4_MASK 0x6002 … … 1918 1898 #define VMX_VMCS_CTRL_CR3_TARGET_VAL2 0x600c 1919 1899 #define VMX_VMCS_CTRL_CR3_TARGET_VAL3 0x600e 1920 /** @} */ 1921 1922 1923 /** @name Natural-width read-only data fields. 1924 * @{ 1925 */ 1900 1901 /** Natural-width read-only data fields. */ 1926 1902 #define VMX_VMCS_RO_EXIT_QUALIFICATION 0x6400 1927 1903 #define VMX_VMCS_RO_IO_RCX 0x6402 … … 1930 1906 #define VMX_VMCS_RO_IO_RIP 0x6408 1931 1907 #define VMX_VMCS_RO_GUEST_LINEAR_ADDR 0x640a 1932 /** @} */ 1933 1934 1935 /** @name VMCS field encoding: Natural-width guest-state fields. 1936 * @{ 1937 */ 1908 1909 /** Natural-width guest-state fields. */ 1938 1910 #define VMX_VMCS_GUEST_CR0 0x6800 1939 1911 #define VMX_VMCS_GUEST_CR3 0x6802 … … 1956 1928 #define VMX_VMCS_GUEST_SYSENTER_ESP 0x6824 1957 1929 #define VMX_VMCS_GUEST_SYSENTER_EIP 0x6826 1958 /** @} */ 1959 1960 1961 /** @name VMCS field encoding: Natural-width host-state fields. 1962 * @{ 1963 */ 1930 1931 /** Natural-width host-state fields. */ 1964 1932 #define VMX_VMCS_HOST_CR0 0x6c00 1965 1933 #define VMX_VMCS_HOST_CR3 0x6c02 … … 1974 1942 #define VMX_VMCS_HOST_RSP 0x6c14 1975 1943 #define VMX_VMCS_HOST_RIP 0x6c16 1976 /** @} */ 1977 1978 1979 /** @name VMCS field encoding: Access. 1980 * @{ */ 1981 typedef enum 1982 { 1983 VMXVMCSFIELDACCESS_FULL = 0, 1984 VMXVMCSFIELDACCESS_HIGH 1985 } VMXVMCSFIELDACCESS; 1986 AssertCompileSize(VMXVMCSFIELDACCESS, 4); 1987 1988 /** VMCS field encoding type: Full. */ 1989 #define VMX_VMCS_ENC_ACCESS_TYPE_FULL 0 1990 /** VMCS field encoding type: High. */ 1991 #define VMX_VMCS_ENC_ACCESS_TYPE_HIGH 1 1992 /** @} */ 1993 1994 1995 /** @name VMCS field encoding: Type. 1996 * @{ */ 1997 typedef enum 1998 { 1999 VMXVMCSFIELDTYPE_CONTROL = 0, 2000 VMXVMCSFIELDTYPE_VMEXIT_INFO, 2001 VMXVMCSFIELDTYPE_GUEST_STATE, 2002 VMXVMCSFIELDTYPE_HOST_STATE 2003 } VMXVMCSFIELDTYPE; 2004 AssertCompileSize(VMXVMCSFIELDTYPE, 4); 2005 2006 /** VMCS field encoding type: Control. */ 2007 #define VMX_VMCS_ENC_TYPE_CONTROL 0 2008 /** VMCS field encoding type: VM-exit information / read-only fields. */ 2009 #define VMX_VMCS_ENC_TYPE_VMEXIT_INFO 1 2010 /** VMCS field encoding type: Guest-state. */ 2011 #define VMX_VMCS_ENC_TYPE_GUEST_STATE 2 2012 /** VMCS field encoding type: Host-state. */ 2013 #define VMX_VMCS_ENC_TYPE_HOST_STATE 3 2014 /** @} */ 2015 2016 2017 /** @name VMCS field encoding: Width. 2018 * @{ */ 2019 typedef enum 2020 { 2021 VMXVMCSFIELDWIDTH_16BIT = 0, 2022 VMXVMCSFIELDWIDTH_64BIT, 2023 VMXVMCSFIELDWIDTH_32BIT, 2024 VMXVMCSFIELDWIDTH_NATURAL 2025 } VMXVMCSFIELDWIDTH; 2026 AssertCompileSize(VMXVMCSFIELDWIDTH, 4); 2027 2028 /** VMCS field encoding width: 16-bit. */ 2029 #define VMX_VMCS_ENC_WIDTH_16BIT 0 2030 /** VMCS field encoding width: 64-bit. */ 2031 #define VMX_VMCS_ENC_WIDTH_64BIT 1 2032 /** VMCS field encoding width: 32-bit. */ 2033 #define VMX_VMCS_ENC_WIDTH_32BIT 2 2034 /** VMCS field encoding width: Natural width. */ 2035 #define VMX_VMCS_ENC_WIDTH_NATURAL 3 2036 /** @} */ 2037 2038 2039 /** @name VMCS field. 2040 * @{ */ 1944 1945 /** 1946 * VMCS field. 1947 * In accordance with the VT-x spec. 1948 */ 2041 1949 typedef union 2042 1950 { … … 2061 1969 } VMXVMCSFIELD; 2062 1970 AssertCompileSize(VMXVMCSFIELD, 4); 2063 /** Pointer to a VMCS field encoding. */1971 /** Pointer to a VMCS field. */ 2064 1972 typedef VMXVMCSFIELD *PVMXVMCSFIELD; 2065 /** Pointer to a const VMCS field encoding. */1973 /** Pointer to a const VMCS field. */ 2066 1974 typedef const VMXVMCSFIELD *PCVMXVMCSFIELD; 2067 1975 2068 /** VMCS field encoding: Mask of reserved bits (bits 63:15 MBZ), bit 12 is 2069 * not included! */ 2070 #define VMX_VMCS_ENC_RSVD_MASK UINT64_C(0xffffffffffff8000) 2071 2072 /** Bits fields for VMCS field encoding. */ 2073 #define VMX_BF_VMCS_ENC_ACCESS_TYPE_SHIFT 0 2074 #define VMX_BF_VMCS_ENC_ACCESS_TYPE_MASK UINT32_C(0x00000001) 2075 #define VMX_BF_VMCS_ENC_INDEX_SHIFT 1 2076 #define VMX_BF_VMCS_ENC_INDEX_MASK UINT32_C(0x000003fe) 2077 #define VMX_BF_VMCS_ENC_TYPE_SHIFT 10 2078 #define VMX_BF_VMCS_ENC_TYPE_MASK UINT32_C(0x00000c00) 2079 #define VMX_BF_VMCS_ENC_RSVD_12_SHIFT 12 2080 #define VMX_BF_VMCS_ENC_RSVD_12_MASK UINT32_C(0x00001000) 2081 #define VMX_BF_VMCS_ENC_WIDTH_SHIFT 13 2082 #define VMX_BF_VMCS_ENC_WIDTH_MASK UINT32_C(0x00006000) 2083 #define VMX_BF_VMCS_ENC_RSVD_15_31_SHIFT 15 2084 #define VMX_BF_VMCS_ENC_RSVD_15_31_MASK UINT32_C(0xffff8000) 2085 RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_VMCS_ENC_, UINT32_C(0), UINT32_MAX, 1976 /** VMCS field: Mask of reserved bits (bits 63:15 MBZ), bit 12 is not included! */ 1977 #define VMX_VMCSFIELD_RSVD_MASK UINT64_C(0xffffffffffff8000) 1978 1979 /** Bits fields for a VMCS field. */ 1980 #define VMX_BF_VMCSFIELD_ACCESS_TYPE_SHIFT 0 1981 #define VMX_BF_VMCSFIELD_ACCESS_TYPE_MASK UINT32_C(0x00000001) 1982 #define VMX_BF_VMCSFIELD_INDEX_SHIFT 1 1983 #define VMX_BF_VMCSFIELD_INDEX_MASK UINT32_C(0x000003fe) 1984 #define VMX_BF_VMCSFIELD_TYPE_SHIFT 10 1985 #define VMX_BF_VMCSFIELD_TYPE_MASK UINT32_C(0x00000c00) 1986 #define VMX_BF_VMCSFIELD_RSVD_12_SHIFT 12 1987 #define VMX_BF_VMCSFIELD_RSVD_12_MASK UINT32_C(0x00001000) 1988 #define VMX_BF_VMCSFIELD_WIDTH_SHIFT 13 1989 #define VMX_BF_VMCSFIELD_WIDTH_MASK UINT32_C(0x00006000) 1990 #define VMX_BF_VMCSFIELD_RSVD_15_31_SHIFT 15 1991 #define VMX_BF_VMCSFIELD_RSVD_15_31_MASK UINT32_C(0xffff8000) 1992 RT_BF_ASSERT_COMPILE_CHECKS(VMX_BF_VMCSFIELD_, UINT32_C(0), UINT32_MAX, 2086 1993 (ACCESS_TYPE, INDEX, TYPE, RSVD_12, WIDTH, RSVD_15_31)); 1994 1995 /** 1996 * VMCS field encoding: Access type. 1997 * In accordance with the VT-x spec. 1998 */ 1999 typedef enum 2000 { 2001 VMXVMCSFIELDACCESS_FULL = 0, 2002 VMXVMCSFIELDACCESS_HIGH 2003 } VMXVMCSFIELDACCESS; 2004 AssertCompileSize(VMXVMCSFIELDACCESS, 4); 2005 /** VMCS field encoding type: Full. */ 2006 #define VMX_VMCSFIELD_ACCESS_FULL 0 2007 /** VMCS field encoding type: High. */ 2008 #define VMX_VMCSFIELD_ACCESS_HIGH 1 2009 2010 /** 2011 * VMCS field encoding: Type. 2012 * In accordance with the VT-x spec. 2013 */ 2014 typedef enum 2015 { 2016 VMXVMCSFIELDTYPE_CONTROL = 0, 2017 VMXVMCSFIELDTYPE_VMEXIT_INFO, 2018 VMXVMCSFIELDTYPE_GUEST_STATE, 2019 VMXVMCSFIELDTYPE_HOST_STATE 2020 } VMXVMCSFIELDTYPE; 2021 AssertCompileSize(VMXVMCSFIELDTYPE, 4); 2022 /** VMCS field encoding type: Control. */ 2023 #define VMX_VMCSFIELD_TYPE_CONTROL 0 2024 /** VMCS field encoding type: VM-exit information / read-only fields. */ 2025 #define VMX_VMCSFIELD_TYPE_VMEXIT_INFO 1 2026 /** VMCS field encoding type: Guest-state. */ 2027 #define VMX_VMCSFIELD_TYPE_GUEST_STATE 2 2028 /** VMCS field encoding type: Host-state. */ 2029 #define VMX_VMCSFIELD_TYPE_HOST_STATE 3 2030 2031 /** 2032 * VMCS field encoding: Width. 2033 * In accordance with the VT-x spec. 2034 */ 2035 typedef enum 2036 { 2037 VMXVMCSFIELDWIDTH_16BIT = 0, 2038 VMXVMCSFIELDWIDTH_64BIT, 2039 VMXVMCSFIELDWIDTH_32BIT, 2040 VMXVMCSFIELDWIDTH_NATURAL 2041 } VMXVMCSFIELDWIDTH; 2042 AssertCompileSize(VMXVMCSFIELDWIDTH, 4); 2043 /** VMCS field encoding width: 16-bit. */ 2044 #define VMX_VMCSFIELD_WIDTH_16BIT 0 2045 /** VMCS field encoding width: 64-bit. */ 2046 #define VMX_VMCSFIELD_WIDTH_64BIT 1 2047 /** VMCS field encoding width: 32-bit. */ 2048 #define VMX_VMCSFIELD_WIDTH_32BIT 2 2049 /** VMCS field encoding width: Natural width. */ 2050 #define VMX_VMCSFIELD_WIDTH_NATURAL 3 2087 2051 /** @} */ 2088 2052 … … 3111 3075 /** 3112 3076 * APIC-access type. 3077 * In accordance with the VT-x spec. 3113 3078 */ 3114 3079 typedef enum … … 3385 3350 3386 3351 /** The highest index value used for supported virtual VMCS field encoding. */ 3387 #define VMX_V_VMCS_MAX_INDEX RT_BF_GET(VMX_VMCS64_CTRL_TSC_MULTIPLIER_HIGH, VMX_BF_VMCS _ENC_INDEX)3352 #define VMX_V_VMCS_MAX_INDEX RT_BF_GET(VMX_VMCS64_CTRL_TSC_MULTIPLIER_HIGH, VMX_BF_VMCSFIELD_INDEX) 3388 3353 3389 3354 /** … … 3472 3437 * 3473 3438 * Note! Any fields that are added or modified here, make sure to update the 3474 * corresponding fields in g_aoffVmcsMap in IEM. 3439 * corresponding fields in IEM (g_aoffVmcsMap), the corresponding saved 3440 * state structure in CPUM (g_aVmxHwvirtVmcs) and bump the SSM version. 3475 3441 */ 3476 3442 #pragma pack(1) -
trunk/include/VBox/vmm/hmvmxinline.h
r78220 r79202 84 84 * @param uFieldEnc The VMCS field encoding. 85 85 * 86 * @remarks Warning! This function does not verify th e encoding is for a valid and87 * supported VMCS field.86 * @remarks Warning! This function does not verify that the encoding is for a valid 87 * and/or supported VMCS field. 88 88 */ 89 89 DECLINLINE(bool) HMVmxIsVmcsFieldReadOnly(uint32_t uFieldEnc) 90 90 { 91 91 /* See Intel spec. B.4.2 "Natural-Width Read-Only Data Fields". */ 92 return (RT_BF_GET(uFieldEnc, VMX_BF_VMCS _ENC_TYPE) == VMXVMCSFIELDTYPE_VMEXIT_INFO);92 return (RT_BF_GET(uFieldEnc, VMX_BF_VMCSFIELD_TYPE) == VMXVMCSFIELDTYPE_VMEXIT_INFO); 93 93 } 94 94 -
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r79194 r79202 3607 3607 * encoding (i.e. bit 12). 3608 3608 */ 3609 if (u64FieldEnc & VMX_VMCS _ENC_RSVD_MASK)3609 if (u64FieldEnc & VMX_VMCSFIELD_RSVD_MASK) 3610 3610 return true; 3611 3611 -
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r79167 r79202 25 25 #include <iprt/asm-amd64-x86.h> 26 26 #include <iprt/thread.h> 27 #include <iprt/mem.h> 27 28 28 29 #include <VBox/vmm/pdmapi.h> … … 489 490 * Global Variables * 490 491 *********************************************************************************************************************************/ 492 #ifdef VBOX_WITH_NESTED_HWVIRT_VMX 493 /** 494 * Array of all VMCS fields. 495 * Any fields added to the VT-x spec. should be added here. 496 * 497 * Currently only used to derive shadow VMCS fields for hardware-assisted execution 498 * of nested-guests. 499 */ 500 static const uint32_t g_aVmcsFields[] = 501 { 502 /* 16-bit control fields. */ 503 VMX_VMCS16_VPID, 504 VMX_VMCS16_POSTED_INT_NOTIFY_VECTOR, 505 VMX_VMCS16_EPTP_INDEX, 506 507 /* 16-bit guest-state fields. */ 508 VMX_VMCS16_GUEST_ES_SEL, 509 VMX_VMCS16_GUEST_CS_SEL, 510 VMX_VMCS16_GUEST_SS_SEL, 511 VMX_VMCS16_GUEST_DS_SEL, 512 VMX_VMCS16_GUEST_FS_SEL, 513 VMX_VMCS16_GUEST_GS_SEL, 514 VMX_VMCS16_GUEST_LDTR_SEL, 515 VMX_VMCS16_GUEST_TR_SEL, 516 VMX_VMCS16_GUEST_INTR_STATUS, 517 VMX_VMCS16_GUEST_PML_INDEX, 518 519 /* 16-bits host-state fields. */ 520 VMX_VMCS16_HOST_ES_SEL, 521 VMX_VMCS16_HOST_CS_SEL, 522 VMX_VMCS16_HOST_SS_SEL, 523 VMX_VMCS16_HOST_DS_SEL, 524 VMX_VMCS16_HOST_FS_SEL, 525 VMX_VMCS16_HOST_GS_SEL, 526 VMX_VMCS16_HOST_TR_SEL, 527 528 /* 64-bit control fields. */ 529 VMX_VMCS64_CTRL_IO_BITMAP_A_FULL, 530 VMX_VMCS64_CTRL_IO_BITMAP_A_HIGH, 531 VMX_VMCS64_CTRL_IO_BITMAP_B_FULL, 532 VMX_VMCS64_CTRL_IO_BITMAP_B_HIGH, 533 VMX_VMCS64_CTRL_MSR_BITMAP_FULL, 534 VMX_VMCS64_CTRL_MSR_BITMAP_HIGH, 535 VMX_VMCS64_CTRL_EXIT_MSR_STORE_FULL, 536 VMX_VMCS64_CTRL_EXIT_MSR_STORE_HIGH, 537 VMX_VMCS64_CTRL_EXIT_MSR_LOAD_FULL, 538 VMX_VMCS64_CTRL_EXIT_MSR_LOAD_HIGH, 539 VMX_VMCS64_CTRL_ENTRY_MSR_LOAD_FULL, 540 VMX_VMCS64_CTRL_ENTRY_MSR_LOAD_HIGH, 541 VMX_VMCS64_CTRL_EXEC_VMCS_PTR_FULL, 542 VMX_VMCS64_CTRL_EXEC_VMCS_PTR_HIGH, 543 VMX_VMCS64_CTRL_EXEC_PML_ADDR_FULL, 544 VMX_VMCS64_CTRL_EXEC_PML_ADDR_HIGH, 545 VMX_VMCS64_CTRL_TSC_OFFSET_FULL, 546 VMX_VMCS64_CTRL_TSC_OFFSET_HIGH, 547 VMX_VMCS64_CTRL_VIRT_APIC_PAGEADDR_FULL, 548 VMX_VMCS64_CTRL_VIRT_APIC_PAGEADDR_HIGH, 549 VMX_VMCS64_CTRL_APIC_ACCESSADDR_FULL, 550 VMX_VMCS64_CTRL_APIC_ACCESSADDR_HIGH, 551 VMX_VMCS64_CTRL_POSTED_INTR_DESC_FULL, 552 VMX_VMCS64_CTRL_POSTED_INTR_DESC_HIGH, 553 VMX_VMCS64_CTRL_VMFUNC_CTRLS_FULL, 554 VMX_VMCS64_CTRL_VMFUNC_CTRLS_HIGH, 555 VMX_VMCS64_CTRL_EPTP_FULL, 556 VMX_VMCS64_CTRL_EPTP_HIGH, 557 VMX_VMCS64_CTRL_EOI_BITMAP_0_FULL, 558 VMX_VMCS64_CTRL_EOI_BITMAP_0_HIGH, 559 VMX_VMCS64_CTRL_EOI_BITMAP_1_FULL, 560 VMX_VMCS64_CTRL_EOI_BITMAP_1_HIGH, 561 VMX_VMCS64_CTRL_EOI_BITMAP_2_FULL, 562 VMX_VMCS64_CTRL_EOI_BITMAP_2_HIGH, 563 VMX_VMCS64_CTRL_EOI_BITMAP_3_FULL, 564 VMX_VMCS64_CTRL_EOI_BITMAP_3_HIGH, 565 VMX_VMCS64_CTRL_EPTP_LIST_FULL, 566 VMX_VMCS64_CTRL_EPTP_LIST_HIGH, 567 VMX_VMCS64_CTRL_VMREAD_BITMAP_FULL, 568 VMX_VMCS64_CTRL_VMREAD_BITMAP_HIGH, 569 VMX_VMCS64_CTRL_VMWRITE_BITMAP_FULL, 570 VMX_VMCS64_CTRL_VMWRITE_BITMAP_HIGH, 571 VMX_VMCS64_CTRL_VIRTXCPT_INFO_ADDR_FULL, 572 VMX_VMCS64_CTRL_VIRTXCPT_INFO_ADDR_HIGH, 573 VMX_VMCS64_CTRL_XSS_EXITING_BITMAP_FULL, 574 VMX_VMCS64_CTRL_XSS_EXITING_BITMAP_HIGH, 575 VMX_VMCS64_CTRL_ENCLS_EXITING_BITMAP_FULL, 576 VMX_VMCS64_CTRL_ENCLS_EXITING_BITMAP_HIGH, 577 VMX_VMCS64_CTRL_TSC_MULTIPLIER_FULL, 578 VMX_VMCS64_CTRL_TSC_MULTIPLIER_HIGH, 579 580 /* 64-bit read-only data fields. */ 581 VMX_VMCS64_RO_GUEST_PHYS_ADDR_FULL, 582 VMX_VMCS64_RO_GUEST_PHYS_ADDR_HIGH, 583 584 /* 64-bit guest-state fields. */ 585 VMX_VMCS64_GUEST_VMCS_LINK_PTR_FULL, 586 VMX_VMCS64_GUEST_VMCS_LINK_PTR_HIGH, 587 VMX_VMCS64_GUEST_DEBUGCTL_FULL, 588 VMX_VMCS64_GUEST_DEBUGCTL_HIGH, 589 VMX_VMCS64_GUEST_PAT_FULL, 590 VMX_VMCS64_GUEST_PAT_HIGH, 591 VMX_VMCS64_GUEST_EFER_FULL, 592 VMX_VMCS64_GUEST_EFER_HIGH, 593 VMX_VMCS64_GUEST_PERF_GLOBAL_CTRL_FULL, 594 VMX_VMCS64_GUEST_PERF_GLOBAL_CTRL_HIGH, 595 VMX_VMCS64_GUEST_PDPTE0_FULL, 596 VMX_VMCS64_GUEST_PDPTE0_HIGH, 597 VMX_VMCS64_GUEST_PDPTE1_FULL, 598 VMX_VMCS64_GUEST_PDPTE1_HIGH, 599 VMX_VMCS64_GUEST_PDPTE2_FULL, 600 VMX_VMCS64_GUEST_PDPTE2_HIGH, 601 VMX_VMCS64_GUEST_PDPTE3_FULL, 602 VMX_VMCS64_GUEST_PDPTE3_HIGH, 603 VMX_VMCS64_GUEST_BNDCFGS_FULL, 604 VMX_VMCS64_GUEST_BNDCFGS_HIGH, 605 606 /* 64-bit host-state fields. */ 607 VMX_VMCS64_HOST_PAT_FULL, 608 VMX_VMCS64_HOST_PAT_HIGH, 609 VMX_VMCS64_HOST_EFER_FULL, 610 VMX_VMCS64_HOST_EFER_HIGH, 611 VMX_VMCS64_HOST_PERF_GLOBAL_CTRL_FULL, 612 VMX_VMCS64_HOST_PERF_GLOBAL_CTRL_HIGH, 613 614 /* 32-bit control fields. */ 615 VMX_VMCS32_CTRL_PIN_EXEC, 616 VMX_VMCS32_CTRL_PROC_EXEC, 617 VMX_VMCS32_CTRL_EXCEPTION_BITMAP, 618 VMX_VMCS32_CTRL_PAGEFAULT_ERROR_MASK, 619 VMX_VMCS32_CTRL_PAGEFAULT_ERROR_MATCH, 620 VMX_VMCS32_CTRL_CR3_TARGET_COUNT, 621 VMX_VMCS32_CTRL_EXIT, 622 VMX_VMCS32_CTRL_EXIT_MSR_STORE_COUNT, 623 VMX_VMCS32_CTRL_EXIT_MSR_LOAD_COUNT, 624 VMX_VMCS32_CTRL_ENTRY, 625 VMX_VMCS32_CTRL_ENTRY_MSR_LOAD_COUNT, 626 VMX_VMCS32_CTRL_ENTRY_INTERRUPTION_INFO, 627 VMX_VMCS32_CTRL_ENTRY_EXCEPTION_ERRCODE, 628 VMX_VMCS32_CTRL_ENTRY_INSTR_LENGTH, 629 VMX_VMCS32_CTRL_TPR_THRESHOLD, 630 VMX_VMCS32_CTRL_PROC_EXEC2, 631 VMX_VMCS32_CTRL_PLE_GAP, 632 VMX_VMCS32_CTRL_PLE_WINDOW, 633 634 /* 32-bits read-only fields. */ 635 VMX_VMCS32_RO_VM_INSTR_ERROR, 636 VMX_VMCS32_RO_EXIT_REASON, 637 VMX_VMCS32_RO_EXIT_INTERRUPTION_INFO, 638 VMX_VMCS32_RO_EXIT_INTERRUPTION_ERROR_CODE, 639 VMX_VMCS32_RO_IDT_VECTORING_INFO, 640 VMX_VMCS32_RO_IDT_VECTORING_ERROR_CODE, 641 VMX_VMCS32_RO_EXIT_INSTR_LENGTH, 642 VMX_VMCS32_RO_EXIT_INSTR_INFO, 643 644 /* 32-bit guest-state fields. */ 645 VMX_VMCS32_GUEST_ES_LIMIT, 646 VMX_VMCS32_GUEST_CS_LIMIT, 647 VMX_VMCS32_GUEST_SS_LIMIT, 648 VMX_VMCS32_GUEST_DS_LIMIT, 649 VMX_VMCS32_GUEST_FS_LIMIT, 650 VMX_VMCS32_GUEST_GS_LIMIT, 651 VMX_VMCS32_GUEST_LDTR_LIMIT, 652 VMX_VMCS32_GUEST_TR_LIMIT, 653 VMX_VMCS32_GUEST_GDTR_LIMIT, 654 VMX_VMCS32_GUEST_IDTR_LIMIT, 655 VMX_VMCS32_GUEST_ES_ACCESS_RIGHTS, 656 VMX_VMCS32_GUEST_CS_ACCESS_RIGHTS, 657 VMX_VMCS32_GUEST_SS_ACCESS_RIGHTS, 658 VMX_VMCS32_GUEST_DS_ACCESS_RIGHTS, 659 VMX_VMCS32_GUEST_FS_ACCESS_RIGHTS, 660 VMX_VMCS32_GUEST_GS_ACCESS_RIGHTS, 661 VMX_VMCS32_GUEST_LDTR_ACCESS_RIGHTS, 662 VMX_VMCS32_GUEST_TR_ACCESS_RIGHTS, 663 VMX_VMCS32_GUEST_INT_STATE, 664 VMX_VMCS32_GUEST_ACTIVITY_STATE, 665 VMX_VMCS32_GUEST_SMBASE, 666 VMX_VMCS32_GUEST_SYSENTER_CS, 667 VMX_VMCS32_PREEMPT_TIMER_VALUE, 668 669 /* 32-bit host-state fields. */ 670 VMX_VMCS32_HOST_SYSENTER_CS, 671 672 /* Natural-width control fields. */ 673 VMX_VMCS_CTRL_CR0_MASK, 674 VMX_VMCS_CTRL_CR4_MASK, 675 VMX_VMCS_CTRL_CR0_READ_SHADOW, 676 VMX_VMCS_CTRL_CR4_READ_SHADOW, 677 VMX_VMCS_CTRL_CR3_TARGET_VAL0, 678 VMX_VMCS_CTRL_CR3_TARGET_VAL1, 679 VMX_VMCS_CTRL_CR3_TARGET_VAL2, 680 VMX_VMCS_CTRL_CR3_TARGET_VAL3, 681 682 /* Natural-width read-only data fields. */ 683 VMX_VMCS_RO_EXIT_QUALIFICATION, 684 VMX_VMCS_RO_IO_RCX, 685 VMX_VMCS_RO_IO_RSI, 686 VMX_VMCS_RO_IO_RDI, 687 VMX_VMCS_RO_IO_RIP, 688 VMX_VMCS_RO_GUEST_LINEAR_ADDR, 689 690 /* Natural-width guest-state field */ 691 VMX_VMCS_GUEST_CR0, 692 VMX_VMCS_GUEST_CR3, 693 VMX_VMCS_GUEST_CR4, 694 VMX_VMCS_GUEST_ES_BASE, 695 VMX_VMCS_GUEST_CS_BASE, 696 VMX_VMCS_GUEST_SS_BASE, 697 VMX_VMCS_GUEST_DS_BASE, 698 VMX_VMCS_GUEST_FS_BASE, 699 VMX_VMCS_GUEST_GS_BASE, 700 VMX_VMCS_GUEST_LDTR_BASE, 701 VMX_VMCS_GUEST_TR_BASE, 702 VMX_VMCS_GUEST_GDTR_BASE, 703 VMX_VMCS_GUEST_IDTR_BASE, 704 VMX_VMCS_GUEST_DR7, 705 VMX_VMCS_GUEST_RSP, 706 VMX_VMCS_GUEST_RIP, 707 VMX_VMCS_GUEST_RFLAGS, 708 VMX_VMCS_GUEST_PENDING_DEBUG_XCPTS, 709 VMX_VMCS_GUEST_SYSENTER_ESP, 710 VMX_VMCS_GUEST_SYSENTER_EIP, 711 712 /* Natural-width host-state fields */ 713 VMX_VMCS_HOST_CR0, 714 VMX_VMCS_HOST_CR3, 715 VMX_VMCS_HOST_CR4, 716 VMX_VMCS_HOST_FS_BASE, 717 VMX_VMCS_HOST_GS_BASE, 718 VMX_VMCS_HOST_TR_BASE, 719 VMX_VMCS_HOST_GDTR_BASE, 720 VMX_VMCS_HOST_IDTR_BASE, 721 VMX_VMCS_HOST_SYSENTER_ESP, 722 VMX_VMCS_HOST_SYSENTER_EIP, 723 VMX_VMCS_HOST_RSP, 724 VMX_VMCS_HOST_RIP 725 }; 726 #endif /* VBOX_WITH_NESTED_HWVIRT_VMX */ 727 491 728 #ifdef VMX_USE_CACHED_VMCS_ACCESSES 492 729 static const uint32_t g_aVmcsCacheSegBase[] = … … 1375 1612 1376 1613 1614 #ifdef VBOX_WITH_NESTED_HWVIRT_VMX 1615 /** 1616 * Initializes the shadow VMCS. 1617 * 1618 * This builds an array (for use later while executing a nested-guest) of VMCS 1619 * fields to copy into the shadow VMCS. 1620 * 1621 * @param pVM The cross context VM structure. 1622 */ 1623 static void hmR0VmxInitShadowVmcsFieldsArray(PVM pVM) 1624 { 1625 uint32_t const cVmcsFields = RT_ELEMENTS(g_aVmcsFields); 1626 for (uint32_t i = 0; i < cVmcsFields; i++) 1627 { 1628 /* 1629 * If the VMCS field depends on a CPU feature that is not exposed to the guest, 1630 * we must not include it in the shadow VMCS fields array. Guests attempting to 1631 * VMREAD/VMWRITE such VMCS fields would cause a VM-exit and we shall emulate 1632 * the required behavior. 1633 */ 1634 uint32_t const uVmcsField = g_aVmcsFields[i]; 1635 bool const fVmcsFieldValid = CPUMIsGuestVmxVmcsFieldValid(pVM, uVmcsField); 1636 if (fVmcsFieldValid) 1637 { 1638 pVM->hm.s.vmx.paShadowVmcsFields[i] = uVmcsField; 1639 ++pVM->hm.s.vmx.cShadowVmcsFields; 1640 } 1641 } 1642 } 1643 1644 1645 /** 1646 * Initializes the VMREAD/VMWRITE bitmaps. 1647 * 1648 * @param pVM The cross context VM structure. 1649 */ 1650 static void hmR0VmxInitVmreadVmwriteBitmaps(PVM pVM) 1651 { 1652 /* 1653 * By default, ensure guest attempts to acceses to any VMCS fields cause VM-exits. 1654 */ 1655 uint32_t const cbBitmap = X86_PAGE_4K_SIZE; 1656 uint8_t *pbVmreadBitmap = (uint8_t *)pVM->hm.s.vmx.pvVmreadBitmap; 1657 uint8_t *pbVmwriteBitmap = (uint8_t *)pVM->hm.s.vmx.pvVmwriteBitmap; 1658 ASMMemFill32(pbVmreadBitmap, cbBitmap, UINT32_C(0xffffffff)); 1659 ASMMemFill32(pbVmwriteBitmap, cbBitmap, UINT32_C(0xffffffff)); 1660 1661 uint32_t const *paShadowVmcsFields = pVM->hm.s.vmx.paShadowVmcsFields; 1662 uint32_t const cShadowVmcsFields = pVM->hm.s.vmx.cShadowVmcsFields; 1663 1664 /* 1665 * Initialize the VMREAD bitmap. 1666 * All valid guest VMCS fields (read-only and read-write) can be accessed 1667 * using VMREAD without causing a VM-exit. 1668 */ 1669 for (uint32_t i = 0; i < cShadowVmcsFields; i++) 1670 { 1671 uint32_t const uVmcsField = paShadowVmcsFields[i]; 1672 Assert(!(uVmcsField & VMX_VMCSFIELD_RSVD_MASK)); 1673 uint8_t *pbField = pbVmreadBitmap + (uVmcsField >> 3); 1674 ASMBitClear(pbField, uVmcsField & 7); 1675 } 1676 1677 /* 1678 * Initialize the VMWRITE bitmap. 1679 * Allow the guest to write to read-only guest VMCS fields only if the 1680 * host CPU supports it, otherwise it would cause a VMWRITE instruction error. 1681 */ 1682 bool const fHasVmwriteAll = RT_BOOL(pVM->hm.s.vmx.Msrs.u64Misc & VMX_MISC_VMWRITE_ALL); 1683 for (uint32_t i = 0; i < cShadowVmcsFields; i++) 1684 { 1685 uint32_t const uVmcsField = paShadowVmcsFields[i]; 1686 if ( fHasVmwriteAll 1687 || !HMVmxIsVmcsFieldReadOnly(uVmcsField)) 1688 { 1689 Assert(!(uVmcsField & VMX_VMCSFIELD_RSVD_MASK)); 1690 uint8_t *pbField = pbVmwriteBitmap + (uVmcsField >> 3); 1691 ASMBitClear(pbField, uVmcsField & 7); 1692 } 1693 } 1694 } 1695 #endif /* VBOX_WITH_NESTED_HWVIRT_VMX */ 1696 1697 1377 1698 /** 1378 1699 * Allocates and maps a physically contiguous page. The allocated page is … … 1433 1754 1434 1755 Assert(pVmcsInfo->hMemObjVmcs == NIL_RTR0MEMOBJ); 1756 Assert(pVmcsInfo->hMemObjShadowVmcs == NIL_RTR0MEMOBJ); 1435 1757 Assert(pVmcsInfo->hMemObjMsrBitmap == NIL_RTR0MEMOBJ); 1436 1758 Assert(pVmcsInfo->hMemObjGuestMsrLoad == NIL_RTR0MEMOBJ); … … 1438 1760 Assert(pVmcsInfo->hMemObjHostMsrLoad == NIL_RTR0MEMOBJ); 1439 1761 pVmcsInfo->HCPhysVmcs = NIL_RTHCPHYS; 1762 pVmcsInfo->HCPhysShadowVmcs = NIL_RTHCPHYS; 1440 1763 pVmcsInfo->HCPhysMsrBitmap = NIL_RTHCPHYS; 1441 1764 pVmcsInfo->HCPhysGuestMsrLoad = NIL_RTHCPHYS; … … 1458 1781 hmR0VmxPageFree(&pVmcsInfo->hMemObjVmcs, &pVmcsInfo->pvVmcs, &pVmcsInfo->HCPhysVmcs); 1459 1782 1783 if ( pVM->cpum.ro.GuestFeatures.fVmx 1784 && (pVM->hm.s.vmx.Msrs.ProcCtls2.n.allowed1 & VMX_PROC_CTLS2_VMCS_SHADOWING)) 1785 hmR0VmxPageFree(&pVmcsInfo->hMemObjShadowVmcs, &pVmcsInfo->pvShadowVmcs, &pVmcsInfo->HCPhysShadowVmcs); 1786 1460 1787 if (pVM->hm.s.vmx.Msrs.ProcCtls.n.allowed1 & VMX_PROC_CTLS_USE_MSR_BITMAPS) 1461 1788 hmR0VmxPageFree(&pVmcsInfo->hMemObjMsrBitmap, &pVmcsInfo->pvMsrBitmap, &pVmcsInfo->HCPhysMsrBitmap); … … 1487 1814 if (!fIsNstGstVmcs) 1488 1815 { 1489 /* Get the allocated virtual-APIC page from the virtual APIC device. */ 1490 if ( PDMHasApic(pVCpu->CTX_SUFF(pVM)) 1491 && (pVM->hm.s.vmx.Msrs.ProcCtls.n.allowed1 & VMX_PROC_CTLS_USE_TPR_SHADOW)) 1816 /* Allocate the shadow VMCS if supported by the CPU. */ 1817 if ( pVM->cpum.ro.GuestFeatures.fVmx 1818 && (pVM->hm.s.vmx.Msrs.ProcCtls2.n.allowed1 & VMX_PROC_CTLS2_VMCS_SHADOWING)) 1819 rc = hmR0VmxPageAllocZ(&pVmcsInfo->hMemObjShadowVmcs, &pVmcsInfo->pvShadowVmcs, &pVmcsInfo->HCPhysShadowVmcs); 1820 1821 if (RT_SUCCESS(rc)) 1492 1822 { 1493 rc = APICGetApicPageForCpu(pVCpu, &pVmcsInfo->HCPhysVirtApic, (PRTR0PTR)&pVmcsInfo->pbVirtApic, 1494 NULL /* pR3Ptr */, NULL /* pRCPtr */); 1823 /* Get the allocated virtual-APIC page from the virtual APIC device. */ 1824 if ( PDMHasApic(pVCpu->CTX_SUFF(pVM)) 1825 && (pVM->hm.s.vmx.Msrs.ProcCtls.n.allowed1 & VMX_PROC_CTLS_USE_TPR_SHADOW)) 1826 { 1827 rc = APICGetApicPageForCpu(pVCpu, &pVmcsInfo->HCPhysVirtApic, (PRTR0PTR)&pVmcsInfo->pbVirtApic, 1828 NULL /* pR3Ptr */, NULL /* pRCPtr */); 1829 } 1495 1830 } 1496 1831 } 1497 1832 else 1498 1833 { 1834 /* We don't yet support exposing VMCS shadowing to the guest. */ 1835 Assert(pVmcsInfo->HCPhysShadowVmcs == NIL_RTHCPHYS); 1836 Assert(!pVmcsInfo->pvShadowVmcs); 1837 1838 /* The host-physical address of the virtual-APIC page in guest memory is taken directly. */ 1499 1839 Assert(pVmcsInfo->HCPhysVirtApic == NIL_RTHCPHYS); 1500 1840 Assert(!pVmcsInfo->pbVirtApic); … … 1570 1910 hmR0VmxPageFree(&pVM->hm.s.vmx.hMemObjApicAccess, (PRTR0PTR)&pVM->hm.s.vmx.pbApicAccess, &pVM->hm.s.vmx.HCPhysApicAccess); 1571 1911 1912 #ifdef VBOX_WITH_NESTED_HWVIRT_VMX 1913 if ( pVM->cpum.ro.GuestFeatures.fVmx 1914 && (pVM->hm.s.vmx.Msrs.ProcCtls2.n.allowed1 & VMX_PROC_CTLS2_VMCS_SHADOWING)) 1915 { 1916 RTMemFree(pVM->hm.s.vmx.paShadowVmcsFields); 1917 hmR0VmxPageFree(&pVM->hm.s.vmx.hMemObjVmreadBitmap, &pVM->hm.s.vmx.pvVmreadBitmap, &pVM->hm.s.vmx.HCPhysVmreadBitmap); 1918 hmR0VmxPageFree(&pVM->hm.s.vmx.hMemObjVmwriteBitmap, &pVM->hm.s.vmx.pvVmwriteBitmap, &pVM->hm.s.vmx.HCPhysVmwriteBitmap); 1919 } 1920 #endif 1921 1572 1922 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++) 1573 1923 { … … 1656 2006 } 1657 2007 } 2008 2009 #ifdef VBOX_WITH_NESTED_HWVIRT_VMX 2010 /* Allocate the shadow VMCS fields array, VMREAD, VMWRITE bitmaps if VMCS shadowing supported by the CPU. */ 2011 if ( pVM->cpum.ro.GuestFeatures.fVmx 2012 && (pVM->hm.s.vmx.Msrs.ProcCtls2.n.allowed1 & VMX_PROC_CTLS2_VMCS_SHADOWING)) 2013 { 2014 pVM->hm.s.vmx.paShadowVmcsFields = (uint32_t *)RTMemAllocZ(sizeof(g_aVmcsFields)); 2015 if (RT_LIKELY(pVM->hm.s.vmx.paShadowVmcsFields)) 2016 { 2017 rc = hmR0VmxPageAllocZ(&pVM->hm.s.vmx.hMemObjVmreadBitmap, &pVM->hm.s.vmx.pvVmreadBitmap, 2018 &pVM->hm.s.vmx.HCPhysVmreadBitmap); 2019 if (RT_SUCCESS(rc)) 2020 { 2021 rc = hmR0VmxPageAllocZ(&pVM->hm.s.vmx.hMemObjVmwriteBitmap, &pVM->hm.s.vmx.pvVmwriteBitmap, 2022 &pVM->hm.s.vmx.HCPhysVmwriteBitmap); 2023 if (RT_SUCCESS(rc)) 2024 { 2025 hmR0VmxInitShadowVmcsFieldsArray(pVM); 2026 hmR0VmxInitVmreadVmwriteBitmaps(pVM); 2027 } 2028 } 2029 } 2030 else 2031 rc = VERR_NO_MEMORY; 2032 2033 if (RT_FAILURE(rc)) 2034 { 2035 hmR0VmxStructsFree(pVM); 2036 return rc; 2037 } 2038 } 2039 #endif 1658 2040 1659 2041 /* … … 1692 2074 } 1693 2075 1694 1695 2076 #ifdef VBOX_WITH_NESTED_HWVIRT_VMX 1696 2077 /** … … 1710 2091 } 1711 2092 #endif 1712 1713 2093 1714 2094 /** … … 3844 4224 3845 4225 # ifdef VBOX_STRICT 3846 static bool hmR0VmxIsValidWriteField (uint32_t idxField)4226 static bool hmR0VmxIsValidWriteFieldInCache(uint32_t idxField) 3847 4227 { 3848 4228 switch (idxField) … … 3868 4248 } 3869 4249 3870 static bool hmR0VmxIsValidReadField (uint32_t idxField)4250 static bool hmR0VmxIsValidReadFieldInCache(uint32_t idxField) 3871 4251 { 3872 4252 switch (idxField) … … 3877 4257 } 3878 4258 /* Remaining readable fields should also be writable. */ 3879 return hmR0VmxIsValidWriteField (idxField);4259 return hmR0VmxIsValidWriteFieldInCache(idxField); 3880 4260 } 3881 4261 # endif /* VBOX_STRICT */ … … 3902 4282 #ifdef VBOX_STRICT 3903 4283 for (uint32_t i = 0; i < pVCpu->hm.s.vmx.VmcsCache.Write.cValidEntries; i++) 3904 Assert(hmR0VmxIsValidWriteField (pVCpu->hm.s.vmx.VmcsCache.Write.aField[i]));4284 Assert(hmR0VmxIsValidWriteFieldInCache(pVCpu->hm.s.vmx.VmcsCache.Write.aField[i])); 3905 4285 3906 4286 for (uint32_t i = 0; i <pVCpu->hm.s.vmx.VmcsCache.Read.cValidEntries; i++) 3907 Assert(hmR0VmxIsValidReadField (pVCpu->hm.s.vmx.VmcsCache.Read.aField[i]));4287 Assert(hmR0VmxIsValidReadFieldInCache(pVCpu->hm.s.vmx.VmcsCache.Read.aField[i])); 3908 4288 #endif 3909 4289 -
trunk/src/VBox/VMM/include/HMInternal.h
r79123 r79202 528 528 /** Set if VT-x VPID is allowed. */ 529 529 bool fAllowVpid; 530 /** Set if unrestricted guest execution is in use (real and protected mode without paging). */ 530 /** Set if unrestricted guest execution is in use (real and protected mode 531 * without paging). */ 531 532 bool fUnrestrictedGuest; 532 533 /** Set if unrestricted guest execution is allowed to be used. */ … … 539 540 /** Virtual address of the TSS page used for real mode emulation. */ 540 541 R3PTRTYPE(PVBOXTSS) pRealModeTSS; 541 /** Virtual address of the identity page table used for real mode and protected mode without paging emulation in EPT mode. */ 542 /** Virtual address of the identity page table used for real mode and protected 543 * mode without paging emulation in EPT mode. */ 542 544 R3PTRTYPE(PX86PD) pNonPagingModeEPTPageTable; 543 545 … … 549 551 R0PTRTYPE(uint8_t *) pbApicAccess; 550 552 553 /** Physical address of the VMREAD bitmap. */ 554 RTHCPHYS HCPhysVmreadBitmap; 555 /** Ring-0 memory object for the VMREAD bitmap. */ 556 RTR0MEMOBJ hMemObjVmreadBitmap; 557 /** Pointer to the VMREAD bitmap. */ 558 R0PTRTYPE(void *) pvVmreadBitmap; 559 560 /** Physical address of the VMWRITE bitmap. */ 561 RTHCPHYS HCPhysVmwriteBitmap; 562 /** Ring-0 memory object for the VMWRITE bitmap. */ 563 RTR0MEMOBJ hMemObjVmwriteBitmap; 564 /** Pointer to the VMWRITE bitmap. */ 565 R0PTRTYPE(void *) pvVmwriteBitmap; 566 551 567 #ifdef VBOX_WITH_CRASHDUMP_MAGIC 568 /** Physical address of the crash-dump scratch area. */ 552 569 RTHCPHYS HCPhysScratch; 570 /** Ring-0 memory object for the crash-dump scratch area. */ 553 571 RTR0MEMOBJ hMemObjScratch; 572 /** Pointer to the crash-dump scratch bitmap. */ 554 573 R0PTRTYPE(uint8_t *) pbScratch; 555 574 #endif … … 583 602 /** Host-physical address for a failing VMXON instruction. */ 584 603 RTHCPHYS HCPhysVmxEnableError; 604 605 /** Pointer to the shadow VMCS fields array. */ 606 R0PTRTYPE(uint32_t *) paShadowVmcsFields; 607 RTR0PTR pvR0Alignment1; 608 /** Number of elements in the shadow VMCS fields array. */ 609 uint32_t cShadowVmcsFields; 610 uint32_t u32Alignemnt0; 585 611 } vmx; 586 612 … … 759 785 /** Host-virtual address of the VMCS. */ 760 786 R0PTRTYPE(void *) pvVmcs; 787 788 /** Host-physical address of the shadow VMCS. */ 789 RTHCPHYS HCPhysShadowVmcs; 790 /** R0 memory object for the shadow VMCS. */ 791 RTR0MEMOBJ hMemObjShadowVmcs; 792 /** Host-virtual address of the shadow VMCS. */ 793 R0PTRTYPE(void *) pvShadowVmcs; 761 794 762 795 /** Host-physical address of the virtual APIC page. */
Note:
See TracChangeset
for help on using the changeset viewer.