VirtualBox

Changeset 46724 in vbox for trunk/src


Ignore:
Timestamp:
Jun 21, 2013 12:48:38 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86647
Message:

VMM/HM: Refactor the state-flags for proper sharing between old, new VT-x and AMD-V code combinations.

Location:
trunk/src/VBox/VMM
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMR0.cpp

    r46420 r46724  
    13781378    /* On first entry we'll sync everything. */
    13791379    for (VMCPUID i = 0; i < pVM->cCpus; i++)
    1380         pVM->aCpus[i].hm.s.fContextUseFlags = HM_CHANGED_ALL;
     1380        pVM->aCpus[i].hm.s.fContextUseFlags = (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST);
    13811381
    13821382    /* Enable VT-x or AMD-V if local init is required. */
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r46719 r46724  
    67106710
    67116711    /* Clear any unused and reserved bits. */
    6712     pVCpu->hm.s.fContextUseFlags &= ~HM_CHANGED_GUEST_CR2;
     6712    pVCpu->hm.s.fContextUseFlags &= ~(  HM_CHANGED_GUEST_CR2
     6713                                      | HM_CHANGED_GUEST_MSR  /* legacy */);
    67136714
    67146715    AssertMsg(!pVCpu->hm.s.fContextUseFlags,
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r46659 r46724  
    28112811        /** @todo we can do better than this */
    28122812        /* Not in the VINF_PGM_CHANGE_MODE though! */
    2813         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_ALL;
     2813        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST;
    28142814    }
    28152815
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r46420 r46724  
    40504050                         * whole context to be done with it.
    40514051                         */
    4052                         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_ALL;
     4052                        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST;
    40534053
    40544054                        /* Only resume if successful. */
     
    50245024        /** @todo we can do better than this */
    50255025        /* Not in the VINF_PGM_CHANGE_MODE though! */
    5026         pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_ALL;
     5026        pVCpu->hm.s.fContextUseFlags |= HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST;
    50275027    }
    50285028
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r46718 r46724  
    16671667{
    16681668    /* On first entry we'll sync everything. */
    1669     pVCpu->hm.s.fContextUseFlags = HM_CHANGED_ALL;
     1669    pVCpu->hm.s.fContextUseFlags = (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_ALL_GUEST);
    16701670
    16711671    pVCpu->hm.s.vmx.u32CR0Mask = 0;
  • trunk/src/VBox/VMM/include/HMInternal.h

    r46711 r46724  
    8181 * @{
    8282 */
    83 #ifdef VBOX_WITH_OLD_VTX_CODE
    84 # define HM_CHANGED_GUEST_FPU                RT_BIT(0)
    85 # define HM_CHANGED_GUEST_CR0                RT_BIT(1)
    86 # define HM_CHANGED_GUEST_CR3                RT_BIT(2)
    87 # define HM_CHANGED_GUEST_CR4                RT_BIT(3)
    88 # define HM_CHANGED_GUEST_GDTR               RT_BIT(4)
    89 # define HM_CHANGED_GUEST_IDTR               RT_BIT(5)
    90 # define HM_CHANGED_GUEST_LDTR               RT_BIT(6)
    91 # define HM_CHANGED_GUEST_TR                 RT_BIT(7)
    92 # define HM_CHANGED_GUEST_MSR                RT_BIT(8)
    93 # define HM_CHANGED_GUEST_SEGMENT_REGS       RT_BIT(9)
    94 # define HM_CHANGED_GUEST_DEBUG              RT_BIT(10)
    95 # define HM_CHANGED_HOST_CONTEXT             RT_BIT(11)
    96 # define HM_CHANGED_ALL_GUEST               (  HM_CHANGED_GUEST_SEGMENT_REGS \
    97                                             | HM_CHANGED_GUEST_CR0          \
    98                                             | HM_CHANGED_GUEST_CR3          \
    99                                             | HM_CHANGED_GUEST_CR4          \
    100                                             | HM_CHANGED_GUEST_GDTR         \
    101                                             | HM_CHANGED_GUEST_IDTR         \
    102                                             | HM_CHANGED_GUEST_LDTR         \
    103                                             | HM_CHANGED_GUEST_TR           \
    104                                             | HM_CHANGED_GUEST_MSR          \
    105                                             | HM_CHANGED_GUEST_DEBUG        \
    106                                             | HM_CHANGED_GUEST_FPU)
    107 #else
    108 # define HM_CHANGED_GUEST_RIP                    RT_BIT(0)
    109 # define HM_CHANGED_GUEST_RSP                    RT_BIT(1)
    110 # define HM_CHANGED_GUEST_RFLAGS                 RT_BIT(2)
    111 # define HM_CHANGED_GUEST_CR0                    RT_BIT(3)
    112 # define HM_CHANGED_GUEST_CR2                    RT_BIT(4)
    113 # define HM_CHANGED_GUEST_CR3                    RT_BIT(5)
    114 # define HM_CHANGED_GUEST_CR4                    RT_BIT(6)
    115 # define HM_CHANGED_GUEST_GDTR                   RT_BIT(7)
    116 # define HM_CHANGED_GUEST_IDTR                   RT_BIT(8)
    117 # define HM_CHANGED_GUEST_LDTR                   RT_BIT(9)
    118 # define HM_CHANGED_GUEST_TR                     RT_BIT(10)
    119 # define HM_CHANGED_GUEST_SEGMENT_REGS           RT_BIT(11)
    120 # define HM_CHANGED_GUEST_DEBUG                  RT_BIT(12)
    121 # define HM_CHANGED_GUEST_SYSENTER_CS_MSR        RT_BIT(13)
    122 # define HM_CHANGED_GUEST_SYSENTER_EIP_MSR       RT_BIT(14)
    123 # define HM_CHANGED_GUEST_SYSENTER_ESP_MSR       RT_BIT(15)
     83#define HM_CHANGED_GUEST_CR0                     RT_BIT(0)
     84#define HM_CHANGED_GUEST_CR3                     RT_BIT(1)
     85#define HM_CHANGED_GUEST_CR4                     RT_BIT(2)
     86#define HM_CHANGED_GUEST_GDTR                    RT_BIT(3)
     87#define HM_CHANGED_GUEST_IDTR                    RT_BIT(4)
     88#define HM_CHANGED_GUEST_LDTR                    RT_BIT(5)
     89#define HM_CHANGED_GUEST_TR                      RT_BIT(6)
     90#define HM_CHANGED_GUEST_MSR                     RT_BIT(7)  /* Unused in new VT-x, AMD-V code. */
     91#define HM_CHANGED_GUEST_SEGMENT_REGS            RT_BIT(8)
     92#define HM_CHANGED_GUEST_DEBUG                   RT_BIT(9)
     93#define HM_CHANGED_ALL_GUEST_BASE                (  HM_CHANGED_GUEST_CR0          \
     94                                                  | HM_CHANGED_GUEST_CR3          \
     95                                                  | HM_CHANGED_GUEST_CR4          \
     96                                                  | HM_CHANGED_GUEST_GDTR         \
     97                                                  | HM_CHANGED_GUEST_IDTR         \
     98                                                  | HM_CHANGED_GUEST_LDTR         \
     99                                                  | HM_CHANGED_GUEST_TR           \
     100                                                  | HM_CHANGED_GUEST_MSR          \
     101                                                  | HM_CHANGED_GUEST_SEGMENT_REGS \
     102                                                  | HM_CHANGED_GUEST_DEBUG)
     103#define HM_CHANGED_ALL_GUEST                     HM_CHANGED_ALL_GUEST_BASE
     104
     105/** New VT-x, AMD-V code uses extra flags for more fine-grained state
     106 *  tracking. */
     107#if !defined(VBOX_WITH_OLD_VTX_CODE) || !defined(VBOX_WITH_OLD_AMDV_CODE)
     108# define HM_CHANGED_GUEST_RIP                    RT_BIT(10)
     109# define HM_CHANGED_GUEST_RSP                    RT_BIT(11)
     110# define HM_CHANGED_GUEST_RFLAGS                 RT_BIT(12)
     111# define HM_CHANGED_GUEST_CR2                    RT_BIT(13)
     112# define HM_CHANGED_GUEST_SYSENTER_CS_MSR        RT_BIT(14)
     113# define HM_CHANGED_GUEST_SYSENTER_EIP_MSR       RT_BIT(15)
     114# define HM_CHANGED_GUEST_SYSENTER_ESP_MSR       RT_BIT(16)
    124115/* VT-x specific state. */
    125 # define HM_CHANGED_VMX_GUEST_AUTO_MSRS          RT_BIT(16)
    126 # define HM_CHANGED_VMX_GUEST_ACTIVITY_STATE     RT_BIT(17)
    127 # define HM_CHANGED_VMX_GUEST_APIC_STATE         RT_BIT(18)
    128 # define HM_CHANGED_VMX_ENTRY_CTLS               RT_BIT(19)
    129 # define HM_CHANGED_VMX_EXIT_CTLS                RT_BIT(20)
     116# define HM_CHANGED_VMX_GUEST_AUTO_MSRS          RT_BIT(17)
     117# define HM_CHANGED_VMX_GUEST_ACTIVITY_STATE     RT_BIT(18)
     118# define HM_CHANGED_VMX_GUEST_APIC_STATE         RT_BIT(19)
     119# define HM_CHANGED_VMX_ENTRY_CTLS               RT_BIT(20)
     120# define HM_CHANGED_VMX_EXIT_CTLS                RT_BIT(21)
    130121/* AMD-V specific state. */
    131 # define HM_CHANGED_SVM_GUEST_APIC_STATE         RT_BIT(16)
    132122# define HM_CHANGED_SVM_GUEST_EFER_MSR           RT_BIT(17)
    133 # define HM_CHANGED_SVM_RESERVED2                RT_BIT(18)
    134 # define HM_CHANGED_SVM_RESERVED3                RT_BIT(19)
    135 # define HM_CHANGED_SVM_RESERVED4                RT_BIT(20)
    136 
    137 # define HM_CHANGED_HOST_CONTEXT                 RT_BIT(21)
    138 # define HM_CHANGED_ALL_GUEST                   (  HM_CHANGED_GUEST_RIP                \
     123# define HM_CHANGED_SVM_GUEST_APIC_STATE         RT_BIT(18)
     124# define HM_CHANGED_SVM_RESERVED1                RT_BIT(19)
     125# define HM_CHANGED_SVM_RESERVED2                RT_BIT(20)
     126# define HM_CHANGED_SVM_RESERVED3                RT_BIT(21)
     127
     128# undef  HM_CHANGED_ALL_GUEST
     129# define HM_CHANGED_ALL_GUEST                   (  HM_CHANGED_ALL_GUEST_BASE           \
     130                                                 | HM_CHANGED_GUEST_RIP                \
    139131                                                 | HM_CHANGED_GUEST_RSP                \
    140132                                                 | HM_CHANGED_GUEST_RFLAGS             \
    141                                                  | HM_CHANGED_GUEST_CR0                \
    142133                                                 | HM_CHANGED_GUEST_CR2                \
    143                                                  | HM_CHANGED_GUEST_CR3                \
    144                                                  | HM_CHANGED_GUEST_CR4                \
    145                                                  | HM_CHANGED_GUEST_GDTR               \
    146                                                  | HM_CHANGED_GUEST_IDTR               \
    147                                                  | HM_CHANGED_GUEST_LDTR               \
    148                                                  | HM_CHANGED_GUEST_TR                 \
    149                                                  | HM_CHANGED_GUEST_SEGMENT_REGS       \
    150                                                  | HM_CHANGED_GUEST_DEBUG              \
    151134                                                 | HM_CHANGED_GUEST_SYSENTER_CS_MSR    \
    152135                                                 | HM_CHANGED_GUEST_SYSENTER_EIP_MSR   \
     
    159142#endif
    160143
    161 #define HM_CHANGED_ALL                          (HM_CHANGED_ALL_GUEST | HM_CHANGED_HOST_CONTEXT)
     144#define HM_CHANGED_HOST_CONTEXT                 RT_BIT(22)
    162145/** @} */
    163146
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette