VirtualBox

Changeset 54819 in vbox


Ignore:
Timestamp:
Mar 17, 2015 5:58:30 PM (10 years ago)
Author:
vboxsync
Message:

VMM/GIM: Implemented KVM paravirt. provider.

Location:
trunk/src/VBox/VMM
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/Makefile.kmk

    r54799 r54819  
    151151        VMMR3/GIM.cpp \
    152152        VMMR3/GIMHv.cpp \
     153        VMMR3/GIMKvm.cpp \
    153154        VMMR3/GIMMinimal.cpp \
    154155        VMMR3/IEMR3.cpp \
     
    230231        VMMAll/GIMAll.cpp \
    231232        VMMAll/GIMAllHv.cpp \
     233        VMMAll/GIMAllKvm.cpp \
    232234        VMMAll/TMAll.cpp \
    233235        VMMAll/TMAllCpu.cpp \
     
    456458        VMMRC/VMMRCA.asm \
    457459        $(if-expr defined(VBOX_WITH_RAW_MODE), \
    458         VMMRC/CSAMRC.cpp \
     460        VMMRC/CSAMRC.cpp \
    459461        VMMRC/PATMRC.cpp \
    460         ,) \
     462        ,) \
    461463        VMMRZ/DBGFRZ.cpp \
    462464        VMMRZ/PGMRZDynMap.cpp \
    463465        VMMRZ/VMMRZ.cpp \
    464466        VMMAll/CPUMAllRegs.cpp \
    465         VMMAll/CPUMAllMsrs.cpp \
     467        VMMAll/CPUMAllMsrs.cpp \
    466468        VMMAll/DBGFAll.cpp \
    467         VMMAll/IEMAll.cpp \
    468         VMMAll/IEMAllAImpl.asm \
    469         VMMAll/IEMAllAImplC.cpp \
    470         VMMAll/IOMAll.cpp \
     469        VMMAll/IEMAll.cpp \
     470        VMMAll/IEMAllAImpl.asm \
     471        VMMAll/IEMAllAImplC.cpp \
     472        VMMAll/IOMAll.cpp \
    471473        VMMAll/IOMAllMMIO.cpp \
    472474        VMMAll/EMAll.cpp \
    473475        VMMAll/EMAllA.asm \
    474         VMMAll/FTMAll.cpp \
    475         VMMAll/GIMAll.cpp \
    476         VMMAll/GIMAllHv.cpp \
     476        VMMAll/FTMAll.cpp \
     477        VMMAll/GIMAll.cpp \
     478        VMMAll/GIMAllHv.cpp \
     479        VMMAll/GIMAllKvm.cpp \
    477480        VMMAll/MMAll.cpp \
    478481        VMMAll/MMAllHyper.cpp \
     
    498501        VMMAll/VMMAllA.asm \
    499502        $(if-expr defined(VBOX_WITH_RAW_MODE), \
    500         VMMAll/CSAMAll.cpp \
     503        VMMAll/CSAMAll.cpp \
    501504        VMMAll/PATMAll.cpp \
    502505       ,)
     
    552555        VMMR0/CPUMR0.cpp \
    553556        VMMR0/CPUMR0A.asm \
    554         VMMR0/GIMR0.cpp \
    555         VMMR0/GIMR0Hv.cpp \
     557        VMMR0/GIMR0.cpp \
     558        VMMR0/GIMR0Hv.cpp \
    556559        VMMR0/GMMR0.cpp \
    557560        VMMR0/GVMMR0.cpp \
    558561        VMMR0/HMR0.cpp \
    559562        VMMR0/HMR0A.asm \
    560         VMMR0/HMVMXR0.cpp \
    561         VMMR0/HMSVMR0.cpp \
     563        VMMR0/HMVMXR0.cpp \
     564        VMMR0/HMSVMR0.cpp \
    562565        VMMR0/PDMR0Device.cpp \
    563566        VMMR0/PDMR0Driver.cpp \
     
    570573        VMMRZ/VMMRZ.cpp \
    571574        VMMAll/CPUMAllRegs.cpp \
    572         VMMAll/CPUMAllMsrs.cpp \
     575        VMMAll/CPUMAllMsrs.cpp \
    573576        VMMAll/CPUMStack.cpp \
    574577        VMMAll/DBGFAll.cpp \
     
    576579        VMMAll/EMAllA.asm \
    577580        VMMAll/FTMAll.cpp \
    578         VMMAll/GIMAll.cpp \
    579         VMMAll/GIMAllHv.cpp \
     581        VMMAll/GIMAll.cpp \
     582        VMMAll/GIMAllHv.cpp \
     583        VMMAll/GIMAllKvm.cpp \
    580584        VMMAll/HMAll.cpp \
    581         VMMAll/IEMAll.cpp \
    582         VMMAll/IEMAllAImpl.asm \
    583         VMMAll/IEMAllAImplC.cpp \
     585        VMMAll/IEMAll.cpp \
     586        VMMAll/IEMAllAImpl.asm \
     587        VMMAll/IEMAllAImplC.cpp \
    584588        VMMAll/IOMAll.cpp \
    585589        VMMAll/IOMAllMMIO.cpp \
     
    613617  VMMR0_SOURCES += \
    614618        VMMR0/VMMR0TripleFaultHack.cpp \
    615         VMMR0/VMMR0TripleFaultHackA.asm
     619        VMMR0/VMMR0TripleFaultHackA.asm
    616620 endif
    617621 ifdef VBOX_WITH_NETSHAPER
     
    661665 VMMLibDTrace_INST    = $(VBOX_INST_DTRACE_LIB)$(KBUILD_TARGET_ARCH)/
    662666 VMMLibDTrace_SOURCES = \
    663         dtrace/lib/vbox-types.d \
    664         dtrace/lib/$(KBUILD_TARGET_ARCH)/vbox-arch-types.d \
    665         $(VMMLibDTrace_0_OUTDIR)/vm.d \
    666         $(VMMLibDTrace_0_OUTDIR)/cpumctx.d \
    667         $(VMMLibDTrace_0_OUTDIR)/CPUMInternal.d \
    668         $(VMMLibDTrace_0_OUTDIR)/x86.d \
     667        dtrace/lib/vbox-types.d \
     668        dtrace/lib/$(KBUILD_TARGET_ARCH)/vbox-arch-types.d \
     669        $(VMMLibDTrace_0_OUTDIR)/vm.d \
     670        $(VMMLibDTrace_0_OUTDIR)/cpumctx.d \
     671        $(VMMLibDTrace_0_OUTDIR)/CPUMInternal.d \
     672        $(VMMLibDTrace_0_OUTDIR)/x86.d \
    669673
    670674
  • trunk/src/VBox/VMM/VMMAll/GIMAll.cpp

    r54654 r54819  
    154154            return gimHvReadMsr(pVCpu, idMsr, pRange, puValue);
    155155
     156        case GIMPROVIDERID_KVM:
     157            return gimKvmReadMsr(pVCpu, idMsr, pRange, puValue);
     158
    156159        default:
    157160            AssertMsgFailed(("GIMReadMsr: for unknown provider %u idMsr=%#RX32 -> #GP(0)", pVM->gim.s.enmProviderId, idMsr));
     
    188191            return gimHvWriteMsr(pVCpu, idMsr, pRange, uRawValue);
    189192
     193        case GIMPROVIDERID_KVM:
     194            return gimKvmWriteMsr(pVCpu, idMsr, pRange, uRawValue);
     195
    190196        default:
    191197            AssertMsgFailed(("GIMWriteMsr: for unknown provider %u idMsr=%#RX32 -> #GP(0)", pVM->gim.s.enmProviderId, idMsr));
  • trunk/src/VBox/VMM/VMMAll/GIMAllHv.cpp

    r54701 r54819  
    154154
    155155        default:
     156        {
    156157#ifdef IN_RING3
    157158            static uint32_t s_cTimes = 0;
     
    161162            LogFunc(("Unknown/invalid RdMsr (%#RX32) -> #GP(0)\n", idMsr));
    162163            break;
     164        }
    163165    }
    164166
     
    314316
    315317        default:
     318        {
    316319#ifdef IN_RING3
    317320            static uint32_t s_cTimes = 0;
    318321            if (s_cTimes++ < 20)
    319                 LogRel(("GIM: HyperV: Unknown/invalid WrMsr (%#x,%#x`%08x) -> #GP(0)\n", idMsr, uRawValue & UINT64_C(0xffffffff00000000),
    320                         uRawValue & UINT64_C(0xffffffff)));
     322                LogRel(("GIM: HyperV: Unknown/invalid WrMsr (%#x,%#x`%08x) -> #GP(0)\n", idMsr,
     323                        uRawValue & UINT64_C(0xffffffff00000000), uRawValue & UINT64_C(0xffffffff)));
    321324#endif
    322325            LogFunc(("Unknown/invalid WrMsr (%#RX32,%#RX64) -> #GP(0)\n", idMsr, uRawValue));
    323326            break;
     327        }
    324328    }
    325329
  • trunk/src/VBox/VMM/VMMR0/GIMR0.cpp

    r54655 r54819  
    9696            return gimR0HvUpdateParavirtTsc(pVM, u64Offset);
    9797
     98        case GIMPROVIDERID_KVM:
     99            return VINF_SUCCESS;
     100
    98101        case GIMPROVIDERID_NONE:
    99102            return VERR_GIM_NOT_ENABLED;
  • trunk/src/VBox/VMM/VMMR3/GIM.cpp

    r54654 r54819  
    3030 * ease the guest in running under a recognized, virtualized environment.
    3131 *
    32  * If the GIM provider configured for the VM needs to be recognized by the guest
    33  * OS inorder to make use of features supported by the interface. Since it
    34  * requires co-operation from the guest OS, a GIM provider is also referred to
     32 * The GIM provider configured for the VM needs to be recognized by the guest OS
     33 * in order to make use of features supported by the interface. Since it
     34 * requires co-operation from the guest OS, a GIM provider may also referred to
    3535 * as a paravirtualization interface.
    3636 *
    37  * One of the ideas behind this, is primarily for making guests more accurate
    38  * and efficient when operating in a virtualized environment. For instance, a
    39  * guest OS which interfaces to VirtualBox through a GIM provider may rely on
    40  * the provider (and VirtualBox ultimately) for providing the correct TSC
    41  * frequency of the host processor and may therefore not have to caliberate the
    42  * TSC itself, resulting in higher accuracy and saving several CPU cycles.
     37 * One of the goals of having a paravirtualized interface is for enabling guests
     38 * to be more accurate and efficient when operating in a virtualized
     39 * environment. For instance, a guest OS which interfaces to VirtualBox through
     40 * a GIM provider may rely on the provider for supplying the correct TSC
     41 * frequency of the host processor. The guest can then avoid caliberating the
     42 * TSC itself, resulting in higher accuracy and better performance.
    4343 *
    4444 * At most, only one GIM provider can be active for a running VM and cannot be
     
    6363#include "GIMMinimalInternal.h"
    6464#include "GIMHvInternal.h"
     65#include "GIMKvmInternal.h"
    6566
    6667/*******************************************************************************
     
    6869*******************************************************************************/
    6970static DECLCALLBACK(int) gimR3Save(PVM pVM, PSSMHANDLE pSSM);
    70 static DECLCALLBACK(int) gimR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
     71static DECLCALLBACK(int) gimR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uSSMVersion, uint32_t uPass);
    7172
    7273
     
    136137            rc = gimR3HvInit(pVM);
    137138        }
     139        else if (!RTStrCmp(szProvider, "KVM"))
     140        {
     141            pVM->gim.s.enmProviderId = GIMPROVIDERID_KVM;
     142            rc = gimR3KvmInit(pVM);
     143        }
    138144        /** @todo KVM and others. */
    139145        else
     
    164170            return gimR3HvInitCompleted(pVM);
    165171
     172        case GIMPROVIDERID_KVM:
     173            return gimR3KvmInitCompleted(pVM);
     174
    166175        default:
    167176            break;
    168177    }
     178
     179    if (!TMR3CpuTickIsFixedRateMonotonic(pVM, true /* fWithParavirtEnabled */))
     180        LogRel(("GIM: Warning!!! Host TSC is unstable. The guest may behave unpredictably with a paravirtualized clock.\n"));
     181
    169182    return VINF_SUCCESS;
    170183}
     
    186199    if (   pVM->gim.s.enmProviderId == GIMPROVIDERID_NONE
    187200        || HMIsEnabled(pVM))
    188     {
    189201        return;
    190     }
    191202
    192203    switch (pVM->gim.s.enmProviderId)
     
    204215        }
    205216
    206         case GIMPROVIDERID_KVM:            /** @todo KVM. */
     217        case GIMPROVIDERID_KVM:
     218        {
     219            gimR3KvmRelocate(pVM, offDelta);
     220            break;
     221        }
     222
    207223        default:
    208224        {
     
    252268            break;
    253269
     270        case GIMPROVIDERID_KVM:
     271            rc = gimR3KvmSave(pVM, pSSM);
     272            AssertRCReturn(rc, rc);
     273            break;
     274
    254275        default:
    255276            break;
     
    269290 * @param   uPass           The data pass.
    270291 */
    271 DECLCALLBACK(int) gimR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
     292DECLCALLBACK(int) gimR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t uSSMVersion, uint32_t uPass)
    272293{
    273294    if (uPass != SSM_PASS_FINAL)
    274295        return VINF_SUCCESS;
    275     if (uVersion != GIM_SAVED_STATE_VERSION)
     296    if (uSSMVersion != GIM_SAVED_STATE_VERSION)
    276297        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    277298
     
    311332    {
    312333        case GIMPROVIDERID_HYPERV:
    313             rc = gimR3HvLoad(pVM, pSSM, uVersion);
     334            rc = gimR3HvLoad(pVM, pSSM, uSSMVersion);
     335            AssertRCReturn(rc, rc);
     336            break;
     337
     338        case GIMPROVIDERID_KVM:
     339            rc = gimR3KvmLoad(pVM, pSSM, uSSMVersion);
    314340            AssertRCReturn(rc, rc);
    315341            break;
     
    339365            return gimR3HvTerm(pVM);
    340366
     367        case GIMPROVIDERID_KVM:
     368            return gimR3KvmTerm(pVM);
     369
    341370        default:
    342371            break;
     
    361390        case GIMPROVIDERID_HYPERV:
    362391            return gimR3HvReset(pVM);
     392
     393        case GIMPROVIDERID_KVM:
     394            return gimR3KvmReset(pVM);
    363395
    364396        default:
     
    403435            return gimR3HvGetMmio2Regions(pVM, pcRegions);
    404436
    405         case GIMPROVIDERID_KVM:            /** @todo KVM. */
    406437        default:
    407438            break;
  • trunk/src/VBox/VMM/VMMR3/GIMHv.cpp

    r54701 r54819  
    380380    SSMR3PutU32(pSSM, GIM_HV_SAVED_STATE_VERSION);
    381381
    382     /** @todo Save per-VCPU data. */
    383 
    384382    /*
    385383     * Save per-VM MSRs.
     
    451449    if (uHvSavedStatVersion != GIM_HV_SAVED_STATE_VERSION)
    452450        return SSMR3SetLoadError(pSSM, VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION, RT_SRC_POS,
    453                                  N_("Unsupported Hyper-V saved state version %u (expected %u)."),
    454                                  uHvSavedStatVersion, GIM_HV_SAVED_STATE_VERSION);
    455 
    456     /** @todo Load per-VCPU data. */
     451                                 N_("Unsupported Hyper-V saved-state version %u (expected %u)."), uHvSavedStatVersion,
     452                                 GIM_HV_SAVED_STATE_VERSION);
    457453
    458454    /*
  • trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp

    r54793 r54819  
    45744574
    45754575    /** @todo What about ballooning of large pages??! */
     4576#if 0
    45764577    Assert(   PGM_PAGE_GET_PDE_TYPE(pPage) != PGM_PAGE_PDE_TYPE_PDE
    45774578           && PGM_PAGE_GET_PDE_TYPE(pPage) != PGM_PAGE_PDE_TYPE_PDE_DISABLED);
     4579#endif
    45784580
    45794581    if (    PGM_PAGE_IS_ZERO(pPage)
  • trunk/src/VBox/VMM/include/GIMInternal.h

    r52772 r54819  
    2121#include <VBox/vmm/gim.h>
    2222#include "GIMHvInternal.h"
     23#include "GIMKvmInternal.h"
    2324#include "GIMMinimalInternal.h"
    2425
     
    7374    {
    7475        GIMHV Hv;
    75 
    76         /** @todo KVM and others. */
     76        GIMKVM Kvm;
    7777    } u;
    7878} GIM;
     
    8686typedef struct GIMCPU
    8787{
     88    union
     89    {
     90        GIMKVMCPU KvmCpu;
     91    } u;
    8892} GIMCPU;
    8993/** Pointer to GIM VMCPU instance data. */
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