VirtualBox

Changeset 52672 in vbox


Ignore:
Timestamp:
Sep 10, 2014 11:27:22 AM (10 years ago)
Author:
vboxsync
Message:

VMM/GIM/Minimal: Expose hypervisor timing information leaves.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/GIMMinimal.cpp

    r52247 r52672  
    2525#include <iprt/err.h>
    2626#include <iprt/asm-amd64-x86.h>
     27#include <iprt/string.h>
    2728
    2829#include <VBox/vmm/cpum.h>
    2930#include <VBox/vmm/vm.h>
     31#include <VBox/vmm/tm.h>
     32#include <VBox/vmm/pdmapi.h>
    3033
    3134/*******************************************************************************
     
    4346    CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
    4447
     48    /*
     49     * Expose a generic hypervisor-agnostic leaf (originally defined VMware).
     50     * The leaves range from  0x40000010 to 0x400000FF.
     51     */
     52    CPUMCPUIDLEAF HyperLeaf;
     53    int rc = CPUMR3CpuIdGetLeaf(pVM, &HyperLeaf, 0x40000000, 0 /* uSubLeaf */);
     54    if (RT_SUCCESS(rc))
     55    {
     56        HyperLeaf.uEax         = UINT32_C(0x40000010);  /* Maximum leaf we implement. */
     57        rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
     58        AssertLogRelRCReturn(rc, rc);
     59
     60        /*
     61         * Add the timing information hypervisor leaf.
     62         * MacOS X uses this to determine the TSC, bus frequency. See @bugref{7270}.
     63         *
     64         * EAX - TSC frequency in KHz.
     65         * EBX - APIC frequency in KHz.
     66         * ECX, EDX - Reserved.
     67         */
     68        uint64_t uApicFreq;
     69        rc = PDMApicGetTimerFreq(pVM, &uApicFreq);
     70        AssertLogRelRCReturn(rc, rc);
     71
     72        RT_ZERO(HyperLeaf);
     73        HyperLeaf.uLeaf        = UINT32_C(0x40000010);
     74        HyperLeaf.uEax         = TMCpuTicksPerSecond(pVM) / UINT64_C(1000);
     75        HyperLeaf.uEbx         = uApicFreq / UINT64_C(1000);
     76        rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
     77        AssertLogRelRCReturn(rc, rc);
     78    }
     79
    4580    return VINF_SUCCESS;
    4681}
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