VirtualBox

Changeset 61073 in vbox


Ignore:
Timestamp:
May 20, 2016 3:01:00 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
107340
Message:

VMMPatchHypercall: Use CPUMGetHostCpuVendor() instead of three ASMIsXxxCpu() calls to figure out the host CPU.

File:
1 edited

Legend:

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

    r58965 r61073  
    414414    AssertReturn(pcbWritten, VERR_INVALID_POINTER);
    415415
    416     NOREF(pVM);
    417 
    418     if (ASMIsAmdCpu())
    419     {
    420         uint8_t abHypercall[] = { 0x0F, 0x01, 0xD9 };   /* VMMCALL */
    421         if (RT_LIKELY(cbBuf >= sizeof(abHypercall)))
    422         {
    423             memcpy(pvBuf, abHypercall, sizeof(abHypercall));
    424             *pcbWritten = sizeof(abHypercall);
    425             return VINF_SUCCESS;
    426         }
    427         return VERR_BUFFER_OVERFLOW;
    428     }
    429     else
    430     {
    431         AssertReturn(ASMIsIntelCpu() || ASMIsViaCentaurCpu(), VERR_UNSUPPORTED_CPU);
    432         uint8_t abHypercall[] = { 0x0F, 0x01, 0xC1 };   /* VMCALL */
    433         if (RT_LIKELY(cbBuf >= sizeof(abHypercall)))
    434         {
    435             memcpy(pvBuf, abHypercall, sizeof(abHypercall));
    436             *pcbWritten = sizeof(abHypercall);
    437             return VINF_SUCCESS;
    438         }
    439         return VERR_BUFFER_OVERFLOW;
     416    CPUMCPUVENDOR enmHostCpu = CPUMGetHostCpuVendor(pVM);
     417    switch (enmHostCpu)
     418    {
     419        case CPUMCPUVENDOR_AMD:
     420        {
     421            uint8_t abHypercall[] = { 0x0F, 0x01, 0xD9 };   /* VMMCALL */
     422            if (RT_LIKELY(cbBuf >= sizeof(abHypercall)))
     423            {
     424                memcpy(pvBuf, abHypercall, sizeof(abHypercall));
     425                *pcbWritten = sizeof(abHypercall);
     426                return VINF_SUCCESS;
     427            }
     428            return VERR_BUFFER_OVERFLOW;
     429        }
     430
     431        case CPUMCPUVENDOR_INTEL:
     432        case CPUMCPUVENDOR_VIA:
     433        {
     434            uint8_t abHypercall[] = { 0x0F, 0x01, 0xC1 };   /* VMCALL */
     435            if (RT_LIKELY(cbBuf >= sizeof(abHypercall)))
     436            {
     437                memcpy(pvBuf, abHypercall, sizeof(abHypercall));
     438                *pcbWritten = sizeof(abHypercall);
     439                return VINF_SUCCESS;
     440            }
     441            return VERR_BUFFER_OVERFLOW;
     442        }
     443
     444        default:
     445            AssertFailed();
     446            return VERR_UNSUPPORTED_CPU;
    440447    }
    441448}
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