VirtualBox

Changeset 72541 in vbox for trunk/src


Ignore:
Timestamp:
Jun 13, 2018 12:14:00 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123031
Message:

NEM/win: Added TSC offset to the complaint list. Some exploration of registers and partition properties. bugref:9044.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp

    r72522 r72541  
    333333                          VERR_NEM_INIT_FAILED);
    334334
    335 
    336335    return rc;
    337336}
     
    22852284}
    22862285
     2286
    22872287VMMR0_INT_DECL(VBOXSTRICTRC) NEMR0RunGuestCode(PGVM pGVM, VMCPUID idCpu)
    22882288{
     
    23692369}
    23702370
     2371
     2372#if 1 && defined(DEBUG_bird)
     2373/**
     2374 * Debug only interface for poking around and exploring Hyper-V stuff.
     2375 *
     2376 * @param   pGVM        The ring-0 VM handle.
     2377 * @param   pVM         The cross context VM handle.
     2378 * @param   idCpu       The calling EMT.
     2379 * @param   u64Arg      What to query.  0 == registers.
     2380 */
     2381VMMR0_INT_DECL(int) NEMR0DoExperiment(PGVM pGVM, PVM pVM, VMCPUID idCpu, uint64_t u64Arg)
     2382{
     2383    /*
     2384     * Resolve CPU structures.
     2385     */
     2386    int rc = GVMMR0ValidateGVMandVMandEMT(pGVM, pVM, idCpu);
     2387    if (RT_SUCCESS(rc))
     2388    {
     2389        PGVMCPU pGVCpu = &pGVM->aCpus[idCpu];
     2390        PVMCPU  pVCpu  = &pVM->aCpus[idCpu];
     2391        if (u64Arg == 0)
     2392        {
     2393            /*
     2394             * Query register.
     2395             */
     2396            HV_INPUT_GET_VP_REGISTERS *pInput = (HV_INPUT_GET_VP_REGISTERS *)pGVCpu->nem.s.HypercallData.pbPage;
     2397            AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
     2398
     2399            size_t const cbInput = RT_ALIGN_Z(RT_OFFSETOF(HV_INPUT_GET_VP_REGISTERS, Names[1]), 32);
     2400            HV_REGISTER_VALUE *paValues = (HV_REGISTER_VALUE *)((uint8_t *)pInput + cbInput);
     2401            RT_BZERO(paValues, sizeof(paValues[0]) * 1);
     2402
     2403            pInput->PartitionId = pGVM->nem.s.idHvPartition;
     2404            pInput->VpIndex     = pGVCpu->idCpu;
     2405            pInput->fFlags      = 0;
     2406            pInput->Names[0]    = (HV_REGISTER_NAME)pVCpu->nem.s.Hypercall.Experiment.uItem;
     2407
     2408            uint64_t uResult = g_pfnHvlInvokeHypercall(HV_MAKE_CALL_INFO(HvCallGetVpRegisters, 1),
     2409                                                       pGVCpu->nem.s.HypercallData.HCPhysPage,
     2410                                                       pGVCpu->nem.s.HypercallData.HCPhysPage + cbInput);
     2411            pVCpu->nem.s.Hypercall.Experiment.fSuccess = uResult == HV_MAKE_CALL_REP_RET(1);
     2412            pVCpu->nem.s.Hypercall.Experiment.uStatus  = uResult;
     2413            pVCpu->nem.s.Hypercall.Experiment.uLoValue = paValues[0].Reg128.Low64;
     2414            pVCpu->nem.s.Hypercall.Experiment.uHiValue = paValues[0].Reg128.High64;
     2415            rc = VINF_SUCCESS;
     2416        }
     2417        else if (u64Arg == 1)
     2418        {
     2419            /*
     2420             * Query partition property.
     2421             */
     2422            HV_INPUT_GET_PARTITION_PROPERTY *pInput = (HV_INPUT_GET_PARTITION_PROPERTY *)pGVCpu->nem.s.HypercallData.pbPage;
     2423            AssertPtrReturn(pInput, VERR_INTERNAL_ERROR_3);
     2424
     2425            size_t const cbInput = RT_ALIGN_Z(sizeof(*pInput), 32);
     2426            HV_OUTPUT_GET_PARTITION_PROPERTY *pOutput = (HV_OUTPUT_GET_PARTITION_PROPERTY *)((uint8_t *)pInput + cbInput);
     2427            pOutput->PropertyValue = 0;
     2428
     2429            pInput->PartitionId  = pGVM->nem.s.idHvPartition;
     2430            pInput->PropertyCode = (HV_PARTITION_PROPERTY_CODE)pVCpu->nem.s.Hypercall.Experiment.uItem;
     2431            pInput->uPadding     = 0;
     2432
     2433            uint64_t uResult = g_pfnHvlInvokeHypercall(HvCallGetPartitionProperty,
     2434                                                       pGVCpu->nem.s.HypercallData.HCPhysPage,
     2435                                                       pGVCpu->nem.s.HypercallData.HCPhysPage + cbInput);
     2436            pVCpu->nem.s.Hypercall.Experiment.fSuccess = uResult == HV_STATUS_SUCCESS;
     2437            pVCpu->nem.s.Hypercall.Experiment.uStatus  = uResult;
     2438            pVCpu->nem.s.Hypercall.Experiment.uLoValue = pOutput->PropertyValue;
     2439            pVCpu->nem.s.Hypercall.Experiment.uHiValue = 0;
     2440            rc = VINF_SUCCESS;
     2441        }
     2442        else
     2443            rc = VERR_INVALID_FUNCTION;
     2444    }
     2445    return rc;
     2446}
     2447#endif /* DEBUG_bird */
     2448
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r72522 r72541  
    20762076            VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    20772077            break;
     2078
     2079#   if 1 && defined(DEBUG_bird)
     2080        case VMMR0_DO_NEM_EXPERIMENT:
     2081            if (pReqHdr)
     2082                return VERR_INVALID_PARAMETER;
     2083            rc = NEMR0DoExperiment(pGVM, pVM, idCpu, u64Arg);
     2084            VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
     2085            break;
     2086#   endif
    20782087# endif
    20792088#endif
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp

    r72526 r72541  
    14441444         * Note! We've already disabled X2APIC via CFGM during the first init call.
    14451445         */
     1446
     1447#if 1 && defined(DEBUG_bird)
     1448        /*
     1449         * Poke and probe a little.
     1450         */
     1451        for (uint32_t iReg = 0; iReg < 0x001101ff; iReg++)
     1452        {
     1453            PVMCPU pVCpu = &pVM->aCpus[0];
     1454            RT_ZERO(pVCpu->nem.s.Hypercall.Experiment);
     1455            pVCpu->nem.s.Hypercall.Experiment.uItem = iReg;
     1456            int rc2 = VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_NEM_EXPERIMENT, 0, NULL);
     1457            AssertLogRelRCBreak(rc2);
     1458            if (pVCpu->nem.s.Hypercall.Experiment.fSuccess)
     1459            {
     1460                LogRel(("Register %#010x = %#18RX64, %#18RX64\n", iReg,
     1461                        pVCpu->nem.s.Hypercall.Experiment.uLoValue, pVCpu->nem.s.Hypercall.Experiment.uHiValue));
     1462                if (iReg == HvX64RegisterTsc)
     1463                {
     1464                    uint64_t uTsc = ASMReadTSC();
     1465                    LogRel(("TSC = %#18RX64; Delta %#18RX64 or %#18RX64\n",
     1466                            uTsc, pVCpu->nem.s.Hypercall.Experiment.uLoValue - uTsc, uTsc - pVCpu->nem.s.Hypercall.Experiment.uLoValue));
     1467                }
     1468            }
     1469        }
     1470        for (uint32_t iProp = 0; iProp < _1M; iProp++)
     1471        {
     1472            if (iProp == HvPartitionPropertyDebugChannelId /* hangs host */)
     1473                continue;
     1474            PVMCPU pVCpu = &pVM->aCpus[0];
     1475            RT_ZERO(pVCpu->nem.s.Hypercall.Experiment);
     1476            pVCpu->nem.s.Hypercall.Experiment.uItem = iProp;
     1477            int rc2 = VMMR3CallR0Emt(pVM, pVCpu, VMMR0_DO_NEM_EXPERIMENT, 1, NULL);
     1478            AssertLogRelRCBreak(rc2);
     1479            if (pVCpu->nem.s.Hypercall.Experiment.fSuccess)
     1480                LogRel(("Property %#010x = %#18RX64\n", iProp, pVCpu->nem.s.Hypercall.Experiment.uLoValue));
     1481        }
     1482#endif
    14461483        return VINF_SUCCESS;
    14471484    }
     
    25072544 *
    25082545 *
    2509  * - Unable to access WHvX64RegisterMsrMtrrCap on AMD Ryzen (build 17134).
     2546 * - How do we modify the TSC offset (or bias if you like).
     2547 *
     2548 *   This is a show stopper as it breaks both pausing the VM and restoring
     2549 *   of saved state.
     2550 *
     2551 *
     2552 * - Unable to access WHvX64RegisterMsrMtrrCap (build 17134).
    25102553 *
    25112554 *
     
    26892732 *
    26902733 *
    2691  * - Query WHvCapabilityCodeExceptionExitBitmap returns zero even when
     2734 * - Querying WHvCapabilityCodeExceptionExitBitmap returns zero even when
    26922735 *   intercepts demonstrably works (17134).
     2736 *
     2737 *
     2738 * - Querying HvPartitionPropertyDebugChannelId via HvCallGetPartitionProperty
     2739 *   (hypercall) hangs the host (17134).
    26932740 *
    26942741 *
  • trunk/src/VBox/VMM/include/NEMInternal.h

    r72526 r72541  
    240240            uint32_t            uAux;
    241241        }                       QueryCpuTick;
     242        /** Input and output for NEMR0DoExperiment. */
     243        struct
     244        {
     245            uint32_t            uItem;
     246            bool                fSuccess;
     247            uint64_t            uStatus;
     248            uint64_t            uLoValue;
     249            uint64_t            uHiValue;
     250        }                       Experiment;
    242251    } Hypercall;
    243252    /** I/O control buffer, we always use this for I/O controls. */
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