VirtualBox

Ignore:
Timestamp:
Jul 3, 2015 4:19:59 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101441
Message:

VMM/GIM: Try passing identical TSC and NanoTS pairs to all VCPUs for KVM guests.

File:
1 edited

Legend:

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

    r56693 r56791  
    358358        SSMR3GetGCPhys(pSSM, &pKvmCpu->GCPhysSystemTime);
    359359        SSMR3GetU32(pSSM, &pKvmCpu->u32SystemTimeVersion);
    360         rc = SSMR3GetU8(pSSM, &fSystemTimeFlags);
     360        rc = SSMR3GetU8(pSSM, &pKvmCpu->fSystemTimeFlags);
    361361        AssertRCReturn(rc, rc);
    362362
    363363        /* Enable the system-time struct. if necessary. */
     364        /** @todo update guest struct only if cTscTicksPerSecond doesn't match host
     365         *        anymore. */
    364366        if (MSR_GIM_KVM_SYSTEM_TIME_IS_ENABLED(pKvmCpu->u64SystemTimeMsr))
    365367        {
    366368            Assert(!TMVirtualIsTicking(pVM));       /* paranoia. */
    367369            Assert(!TMCpuTickIsTicking(pVCpu));
    368             rc = gimR3KvmEnableSystemTime(pVM, pVCpu, pKvmCpu, fSystemTimeFlags);
     370            rc = gimR3KvmEnableSystemTime(pVM, pVCpu);
    369371            AssertRCReturn(rc, rc);
    370372        }
     
    388390 * @param   pVM                Pointer to the VM.
    389391 * @param   pVCpu              Pointer to the VMCPU.
    390  * @param   pKvmCpu            Pointer to the GIMKVMCPU with all fields
    391  *                             populated by the caller.
    392  * @param   fFlags             The system-time struct. flags.
    393392 *
    394393 * @remarks Don't do any release assertions here, these can be triggered by
    395394 *          guest R0 code.
    396395 */
    397 VMMR3_INT_DECL(int) gimR3KvmEnableSystemTime(PVM pVM, PVMCPU pVCpu, PGIMKVMCPU pKvmCpu, uint8_t fFlags)
    398 {
     396VMMR3_INT_DECL(int) gimR3KvmEnableSystemTime(PVM pVM, PVMCPU pVCpu)
     397{
     398    PGIMKVM    pKvm    = &pVM->gim.s.u.Kvm;
     399    PGIMKVMCPU pKvmCpu = &pVCpu->gim.s.u.KvmCpu;
     400
    399401    /*
    400402     * Validate the mapping address first.
     
    407409    }
    408410
     411    /*
     412     * Construct the system-time struct.
     413     */
    409414    GIMKVMSYSTEMTIME SystemTime;
    410415    RT_ZERO(SystemTime);
     
    412417    SystemTime.u64NanoTS   = pKvmCpu->uVirtNanoTS;
    413418    SystemTime.u64Tsc      = pKvmCpu->uTsc;
    414     SystemTime.fFlags      = fFlags | GIM_KVM_SYSTEM_TIME_FLAGS_TSC_STABLE;
     419    SystemTime.fFlags      = pKvmCpu->fSystemTimeFlags | GIM_KVM_SYSTEM_TIME_FLAGS_TSC_STABLE;
    415420
    416421    /*
     
    424429     * time = ((tsc * SysTime.u32TscScale) >> 32) + SysTime.u64NanoTS
    425430     */
    426     PGIMKVM pKvm = &pVM->gim.s.u.Kvm;
    427431    uint64_t u64TscFreq   = pKvm->cTscTicksPerSecond;
    428432    SystemTime.i8TscShift = 0;
     
    440444    SystemTime.u32TscScale = ASMDivU64ByU32RetU32(RT_NS_1SEC_64 << 32, uTscFreqLo);
    441445
     446    /*
     447     * Update guest memory with the system-time struct.
     448     */
    442449    Assert(!(SystemTime.u32Version & UINT32_C(1)));
    443450    int rc = PGMPhysSimpleWriteGCPhys(pVM, pKvmCpu->GCPhysSystemTime, &SystemTime, sizeof(GIMKVMSYSTEMTIME));
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