VirtualBox

Changeset 55316 in vbox


Ignore:
Timestamp:
Apr 16, 2015 5:34:30 PM (10 years ago)
Author:
vboxsync
Message:

CPUM,IEM,HM: Enabled XSAVE and AVX for AMD-V too.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAll.cpp

    r55292 r55316  
    92229222    do \
    92239223    { \
    9224         if (RT_LIKELY((pIemCpu->fPrefixes & (IEM_OP_PRF_LOCK | IEM_OP_PRF_REPNZ | IEM_OP_PRF_REPZ)))) \
     9224        if (RT_LIKELY(!(pIemCpu->fPrefixes & (IEM_OP_PRF_LOCK | IEM_OP_PRF_REPNZ | IEM_OP_PRF_REPZ)))) \
    92259225        { /* likely */ } \
    92269226        else \
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r55306 r55316  
    2323#include <iprt/thread.h>
    2424
     25#include <VBox/vmm/pdmapi.h>
     26#include <VBox/vmm/dbgf.h>
     27#include <VBox/vmm/iem.h>
     28#include <VBox/vmm/iom.h>
     29#include <VBox/vmm/tm.h>
     30#include <VBox/vmm/gim.h>
    2531#include "HMInternal.h"
    2632#include <VBox/vmm/vm.h>
    2733#include "HMSVMR0.h"
    28 #include <VBox/vmm/pdmapi.h>
    29 #include <VBox/vmm/dbgf.h>
    30 #include <VBox/vmm/iom.h>
    31 #include <VBox/vmm/tm.h>
    32 #include <VBox/vmm/gim.h>
    3334#include "dtrace/VBoxVMM.h"
    3435
     
    288289static FNSVMEXITHANDLER hmR0SvmExitReadDRx;
    289290static FNSVMEXITHANDLER hmR0SvmExitWriteDRx;
     291static FNSVMEXITHANDLER hmR0SvmExitXsetbv;
    290292static FNSVMEXITHANDLER hmR0SvmExitIOInstr;
    291293static FNSVMEXITHANDLER hmR0SvmExitNestedPF;
     
    724726                                        | SVM_CTRL2_INTERCEPT_WBINVD        /* WBINVD causes a #VMEXIT. */
    725727                                        | SVM_CTRL2_INTERCEPT_MONITOR       /* MONITOR causes a #VMEXIT. */
    726                                         | SVM_CTRL2_INTERCEPT_MWAIT;        /* MWAIT causes a #VMEXIT. */
     728                                        | SVM_CTRL2_INTERCEPT_MWAIT         /* MWAIT causes a #VMEXIT. */
     729                                        | SVM_CTRL2_INTERCEPT_XSETBV;       /* XSETBV causes a #VMEXIT. */
    727730
    728731        /* CR0, CR4 reads must be intercepted, our shadow values are not necessarily the same as the guest's. */
     
    12491252    /*
    12501253     * Guest CR4.
     1254     * ASSUMES this is done everytime we get in from ring-3! (XCR0)
    12511255     */
    12521256    if (HMCPU_CF_IS_PENDING(pVCpu, HM_CHANGED_GUEST_CR4))
     
    12891293        pVmcb->guest.u64CR4 = u64GuestCR4;
    12901294        pVmcb->ctrl.u64VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_CRX_EFER;
     1295
     1296        /* Whether to save/load/restore XCR0 during world switch depends on CR4.OSXSAVE and host+guest XCR0. */
     1297        pVCpu->hm.s.fLoadSaveGuestXcr0 = (u64GuestCR4 & X86_CR4_OSXSAVE) && pCtx->aXcr[0] != ASMGetXcr0();
     1298
    12911299        HMCPU_CF_CLEAR(pVCpu, HM_CHANGED_GUEST_CR4);
    12921300    }
     
    35823590                case SVM_EXIT_WRITE_DR14:   case SVM_EXIT_WRITE_DR15:
    35833591                    return hmR0SvmExitWriteDRx(pVCpu, pCtx, pSvmTransient);
     3592
     3593                case SVM_EXIT_XSETBV:
     3594                    return hmR0SvmExitXsetbv(pVCpu, pCtx, pSvmTransient);
    35843595
    35853596                case SVM_EXIT_TASK_SWITCH:
     
    47114722
    47124723/**
     4724 * #VMEXIT handler for XCRx write (SVM_EXIT_XSETBV). Conditional #VMEXIT.
     4725 */
     4726HMSVM_EXIT_DECL hmR0SvmExitXsetbv(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMTRANSIENT pSvmTransient)
     4727{
     4728    HMSVM_VALIDATE_EXIT_HANDLER_PARAMS();
     4729
     4730    /** @todo decode assists... */
     4731    VBOXSTRICTRC rcStrict = IEMExecOne(pVCpu);
     4732    if (rcStrict == VINF_IEM_RAISED_XCPT)
     4733        HMCPU_CF_SET(pVCpu, HM_CHANGED_ALL_GUEST);
     4734
     4735    pVCpu->hm.s.fLoadSaveGuestXcr0 = (pCtx->cr4 & X86_CR4_OSXSAVE) && pCtx->aXcr[0] != ASMGetXcr0();
     4736
     4737    HMSVM_CHECK_SINGLE_STEP(pVCpu, rcStrict);
     4738    return VBOXSTRICTRC_TODO(rcStrict);
     4739}
     4740
     4741
     4742/**
    47134743 * #VMEXIT handler for I/O instructions (SVM_EXIT_IOIO). Conditional #VMEXIT.
    47144744 */
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r55307 r55316  
    2424#include <iprt/thread.h>
    2525
    26 #include "HMInternal.h"
    27 #include <VBox/vmm/vm.h>
    28 #include "HMVMXR0.h"
    2926#include <VBox/vmm/pdmapi.h>
    3027#include <VBox/vmm/dbgf.h>
     
    3734# include <VBox/vmm/rem.h>
    3835#endif
    39 # include "dtrace/VBoxVMM.h"
     36#include "HMInternal.h"
     37#include <VBox/vmm/vm.h>
     38#include "HMVMXR0.h"
     39#include "dtrace/VBoxVMM.h"
    4040
    4141#ifdef DEBUG_ramshankar
     
    40184018    /*
    40194019     * Guest CR4.
     4020     * ASSUMES this is done everytime we get in from ring-3! (XCR0)
    40204021     */
    40214022    if (HMCPU_CF_IS_PENDING(pVCpu, HM_CHANGED_GUEST_CR4))
     
    41004101
    41014102        /* Setup CR4 mask. CR4 flags owned by the host, if the guest attempts to change them, that would cause a VM-exit. */
    4102         uint32_t u32CR4Mask = 0;
    4103         u32CR4Mask =  X86_CR4_VME
    4104                     | X86_CR4_PAE
    4105                     | X86_CR4_PGE
    4106                     | X86_CR4_PSE
    4107                     | X86_CR4_VMXE;
     4103        uint32_t u32CR4Mask = X86_CR4_VME
     4104                            | X86_CR4_PAE
     4105                            | X86_CR4_PGE
     4106                            | X86_CR4_PSE
     4107                            | X86_CR4_VMXE;
     4108        if (pVM->cpum.ro.HostFeatures.fXSaveRstor)
     4109            u32CR4Mask |= X86_CR4_OSXSAVE;
    41084110        pVCpu->hm.s.vmx.u32CR4Mask = u32CR4Mask;
    41094111        rc = VMXWriteVmcs32(VMX_VMCS_CTRL_CR4_MASK, u32CR4Mask);
    41104112        AssertRCReturn(rc, rc);
     4113
     4114        /* Whether to save/load/restore XCR0 during world switch depends on CR4.OSXSAVE and host+guest XCR0. */
     4115        pVCpu->hm.s.fLoadSaveGuestXcr0 = (pMixedCtx->cr4 & X86_CR4_OSXSAVE) && pMixedCtx->aXcr[0] != ASMGetXcr0();
    41114116
    41124117        HMCPU_CF_CLEAR(pVCpu, HM_CHANGED_GUEST_CR4);
     
    1064910654    pVCpu->hm.s.fLoadSaveGuestXcr0 = (pMixedCtx->cr4 & X86_CR4_OSXSAVE) && pMixedCtx->aXcr[0] != ASMGetXcr0();
    1065010655
    10651     return VBOXSTRICTRC_VAL(rcStrict);
     10656    return VBOXSTRICTRC_TODO(rcStrict);
    1065210657}
    1065310658
     
    1104911054                    break;
    1105011055                case 4: /* CR4 */
    11051                     pVCpu->hm.s.fLoadSaveGuestXcr0 = (pMixedCtx->cr4 & X86_CR4_OSXSAVE) && pMixedCtx->aXcr[0] != ASMGetXcr0();
    1105211056                    HMCPU_CF_SET(pVCpu, HM_CHANGED_GUEST_CR4);
    1105311057                    Log4(("CRX CR4 write rc=%Rrc CR4=%#RX64 fLoadSaveGuestXcr0=%u\n",
  • trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp

    r55293 r55316  
    36433643    AssertLogRelRCReturn(rc, rc);
    36443644
    3645 #if 1 /* Incomplete, so not yet enabled.  */
    36463645    bool const fMayHaveXSave = fNestedPagingAndFullGuestExec
    36473646                            && pVM->cpum.s.HostFeatures.fXSaveRstor
    3648                             && pVM->cpum.s.HostFeatures.fOpSysXSaveRstor
    3649                             && pVM->cpum.s.HostFeatures.enmCpuVendor == CPUMCPUVENDOR_INTEL /** @todo test and enable on AMD! */;
    3650 #else
    3651     bool const fMayHaveXSave = false;
    3652 #endif
     3647                            && pVM->cpum.s.HostFeatures.fOpSysXSaveRstor;
    36533648    /** @cfgm{/CPUM/IsaExts/XSAVE, boolean, depends}
    36543649     * Expose XSAVE/XRSTOR to the guest if available.  For the time being the
Note: See TracChangeset for help on using the changeset viewer.

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