VirtualBox

Changeset 25825 in vbox


Ignore:
Timestamp:
Jan 14, 2010 10:39:12 AM (15 years ago)
Author:
vboxsync
Message:

r=bird: hot-plug review and code style cleanup. check out the @todos

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/hwaccm.h

    r25816 r25825  
    129129VMMR3DECL(int)          HWACCMR3TermCPU(PVM pVM);
    130130VMMR3DECL(void)         HWACCMR3Reset(PVM pVM);
     131VMMR3DECL(void)         HWACCMR3ResetCpu(PVMCPU pVCpu);
    131132VMMR3DECL(void)         HWACCMR3CheckError(PVM pVM, int iStatusCode);
    132133VMMR3DECL(bool)         HWACCMR3CanExecuteGuest(PVM pVM, PCPUMCTX pCtx);
     
    144145VMMR3DECL(int)          HWACMMR3DisablePatching(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
    145146VMMR3DECL(int)          HWACCMR3PatchTprInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
    146 VMMR3DECL(void)         HWACCMR3ResetCPU(PVMCPU pVCpu);
    147147
    148148/** @} */
  • trunk/include/VBox/pgm.h

    r25816 r25825  
    444444VMMR3DECL(int)      PGMR3InitFinalize(PVM pVM);
    445445VMMR3DECL(void)     PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
    446 VMMR3DECL(void)     PGMR3ResetCpu(PVM pVM, PVMCPU pVCpu);
     446VMMR3DECL(void)     PGMR3ResetUnpluggedCpu(PVM pVM, PVMCPU pVCpu);
    447447VMMR3DECL(void)     PGMR3Reset(PVM pVM);
    448448VMMR3DECL(int)      PGMR3Term(PVM pVM);
  • trunk/include/VBox/vmapi.h

    r25816 r25825  
    407407VMMR3DECL(RTNATIVETHREAD)   VMR3GetVMCPUNativeThread(PVM pVM);
    408408VMMR3DECL(RTNATIVETHREAD)   VMR3GetVMCPUNativeThreadU(PUVM pUVM);
    409 
    410409VMMR3DECL(int)              VMR3GetCPUCoreAndPackageIdFromCPUId(PVM pVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);
    411410VMMR3DECL(int)              VMR3HotunplugCPU(PVM pVM, VMCPUID idCpu);
  • trunk/src/VBox/Devices/Makefile.kmk

    r25819 r25825  
    471471 vboxaml.hex:: $$(PATH_DevicesR3)/vboxaml.hex
    472472
    473  # CPU hotplug version
     473 # CPU hot-plug version
    474474 DevicesR3_CLEAN        += $(PATH_DevicesR3)/vboxaml-cpuhotplug.hex $(PATH_DevicesR3)/vboxaml-cpuhotplug.hex.tmp $(PATH_DevicesR3)/vboxaml-cpuhotplug.aml
    475475 PC/ACPI/VBoxAcpi.cpp_DEPS += $(PATH_DevicesR3)/vboxaml-cpuhotplug.hex
     
    477477 $$(PATH_DevicesR3)/vboxaml-cpuhotplug.hex: $(PATH_SUB_CURRENT)/PC/vbox-cpuhotplug.dsl | $$(dir $$@)
    478478        $(call MSG_TOOL,iasl,DevicesR3,$<,$@)
     479        $(QUIET)$(RM) -f $@ [email protected]
    479480        $(QUIET)$(VBOX_IASLCMD) -tc -vs -p $@ $<
    480         $(QUIET)$(MV) $@ [email protected]
     481        $(QUIET)$(MV) -f $@ [email protected]
    481482        $(QUIET)$(SED) -e 's/AmlCode/AmlCodeCpuHotplug/' \
    482483                --output $@ [email protected]
     484        $(QUIET)$(RM) -f [email protected]
     485
    483486
    484487 vboxaml-cpuhotplug.hex:: $$(PATH_DevicesR3)/vboxaml-cpuhotplug.hex
  • trunk/src/VBox/Devices/PC/ACPI/VBoxAcpi.cpp

    r25817 r25825  
    144144    unsigned char *pbAmlCode = NULL;
    145145    size_t cbAmlCode = 0;
    146     bool fCpuHotplug = false;
    147     int rc = CFGMR3QueryBoolDef(pDevIns->pCfgHandle, "CpuHotplug", &fCpuHotplug, false);
     146    bool fCpuHotPlug = false;
     147    int rc = CFGMR3QueryBoolDef(pDevIns->pCfgHandle, "CpuHotplug", &fCpuHotPlug, false); /** @todo r=bird: Rename to CpuHotPlug. */
    148148    if (RT_FAILURE(rc))
    149149        return PDMDEV_SET_ERROR(pDevIns, rc,
    150150                                N_("Configuration error: Failed to read \"CpuHotplug\""));
    151151
    152     if (fCpuHotplug)
     152    if (fCpuHotPlug)
    153153    {
    154154        pbAmlCode = AmlCodeCpuHotplug;
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r25820 r25825  
    238238    uint32_t            cbMADT;
    239239    /** Array of flags of attached CPUs */
    240     bool                afCpuAttached[32]; /* Maximum we support atm */
     240    bool                afCpuAttached[VMM_MAX_CPU_COUNT]; /**< @todo use VMCPUSET. */
    241241    /** Mask of locked CPUs (used by the guest) */
    242     uint32_t            uCpusLocked;
    243     /** Flag whether CPU hotplugging is enabled */
    244     bool                fCpuHotplug;
     242    uint32_t            uCpusLocked;                      /**< @todo use VMCPUSET. */
     243    /** Flag whether CPU hot plugging is enabled */
     244    bool                fCpuHotPlug;
    245245    /** Aligning IBase. */
    246246    bool                afAlignment[4];
     
    731731
    732732    /* We have to force physical APIC mode or Linux can't use more than 8 CPUs */
    733     if (s->fCpuHotplug)
     733    if (s->fCpuHotPlug)
    734734        fadt.u32Flags |= RT_H2LE_U32(FADT_FL_FORCE_APIC_PHYS_DEST_MODE);
    735735
     
    20952095        /*
    20962096         * Lock the CPU because we don't know if the guest will use it or not.
    2097          * Prevents ejection while the CPU is still used 
     2097         * Prevents ejection while the CPU is still used
    20982098         */
    20992099        s->uCpusLocked |= RT_BIT(iLUN);
     
    21952195                              "ShowRtc\0"
    21962196                              "ShowCpu\0"
    2197                               "CpuHotplug\0"
     2197                              "CpuHotplug\0" /** @todo r=bird: Rename to CpuHotPlug. */
    21982198                              ))
    21992199        return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
     
    22422242                                N_("Configuration error: Failed to read \"ShowCpu\""));
    22432243
    2244     /* query whether we are allow CPU hotplugging */
    2245     rc = CFGMR3QueryBoolDef(pCfgHandle, "CpuHotplug", &s->fCpuHotplug, false);
     2244    /* query whether we are allow CPU hot plugging */
     2245    rc = CFGMR3QueryBoolDef(pCfgHandle, "CpuHotplug", &s->fCpuHotPlug, false); /** @todo r=bird: Rename to CpuHotPlug. */
    22462246    if (RT_FAILURE(rc))
    22472247        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    22812281    for (unsigned i = 1; i < s->cCpus; i++)
    22822282    {
    2283         if (s->fCpuHotplug)
     2283        if (s->fCpuHotPlug)
    22842284        {
    22852285            PPDMIBASE IBaseTmp;
     
    23022302        else
    23032303        {
    2304             /* CPU is always attached if hotplug is not enabled. */
     2304            /* CPU is always attached if hot-plug is not enabled. */
    23052305            s->afCpuAttached[i] = true;
    23062306            s->uCpusLocked |= RT_BIT(i);
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp

    r25817 r25825  
    468468    GEN_CHECK_OFF(ACPIState, afCpuAttached);
    469469    GEN_CHECK_OFF(ACPIState, uCpusLocked);
    470     GEN_CHECK_OFF(ACPIState, fCpuHotplug);
     470    GEN_CHECK_OFF(ACPIState, fCpuHotPlug);
    471471    GEN_CHECK_OFF(ACPIState, IBase);
    472472    GEN_CHECK_OFF(ACPIState, IACPIPort);
  • trunk/src/VBox/VMM/CPUM.cpp

    r25814 r25825  
    870870}
    871871
     872
     873/**
     874 * Resets a virtual CPU.
     875 *
     876 * Used by CPUMR3Reset and CPU hot plugging.
     877 *
     878 * @param   pVCpu               The virtual CPU handle.
     879 */
    872880VMMR3DECL(void) CPUMR3ResetCpu(PVMCPU pVCpu)
    873881{
    874     /* @todo anything different for VCPU > 0? */
     882    /** @todo anything different for VCPU > 0? */
    875883    PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu);
    876884
     
    947955    pCtx->msrEFER                   = 0;
    948956}
     957
    949958
    950959/**
  • trunk/src/VBox/VMM/EM.cpp

    r25816 r25825  
    437437}
    438438
     439
     440/**
     441 * Reset the EM state for a CPU.
     442 *
     443 * Called by EMR3Reset and hot plugging.
     444 *
     445 * @param   pVCpu               The virtual CPU.
     446 */
    439447VMMR3DECL(void) EMR3ResetCpu(PVMCPU pVCpu)
    440448{
     
    442450
    443451    /* VMR3Reset may return VINF_EM_RESET or VINF_EM_SUSPEND, so transition
    444         out of the HALTED state here so that enmPrevState doesn't end up as
    445         HALTED when EMR3Execute returns. */
     452       out of the HALTED state here so that enmPrevState doesn't end up as
     453       HALTED when EMR3Execute returns. */
    446454    if (pVCpu->em.s.enmState == EMSTATE_HALTED)
    447455    {
     
    451459}
    452460
     461
    453462/**
    454463 * Reset notification.
    455464 *
    456  * @param   pVM
     465 * @param   pVM                 The VM handle.
    457466 */
    458467VMMR3DECL(void) EMR3Reset(PVM pVM)
     
    460469    Log(("EMR3Reset: \n"));
    461470    for (VMCPUID i = 0; i < pVM->cCpus; i++)
    462     {
    463         PVMCPU pVCpu = &pVM->aCpus[i];
    464         EMR3ResetCpu(pVCpu);
    465     }
     471        EMR3ResetCpu(&pVM->aCpus[i]);
    466472}
    467473
  • trunk/src/VBox/VMM/HWACCM.cpp

    r25816 r25825  
    14601460 * Resets a virtual CPU.
    14611461 *
    1462  * @param pVCpu    The CPu to reset.
    1463  */
    1464 VMMR3DECL(void) HWACCMR3ResetCPU(PVMCPU pVCpu)
     1462 * Used by HWACCMR3Reset and CPU hot plugging.
     1463 *
     1464 * @param   pVCpu   The CPU to reset.
     1465 */
     1466VMMR3DECL(void) HWACCMR3ResetCpu(PVMCPU pVCpu)
    14651467{
    14661468    /* On first entry we'll sync everything. */
     
    15091511        PVMCPU pVCpu = &pVM->aCpus[i];
    15101512
    1511         HWACCMR3ResetCPU(pVCpu);
     1513        HWACCMR3ResetCpu(pVCpu);
    15121514    }
    15131515
  • trunk/src/VBox/VMM/PDM.cpp

    r25816 r25825  
    155155 * table) which is used to construct, destruct, attach, detach,( ++,) and query
    156156 * other interfaces. A device will query the interfaces required for it's
    157  * operation during init and hotplug.  PDM may query some interfaces during
     157 * operation during init and hot-plug.  PDM may query some interfaces during
    158158 * runtime mounting too.
    159159 *
     
    11531153}
    11541154
     1155
     1156/**
     1157 * Resets a virtual CPU.
     1158 *
     1159 * Used by PDMR3Reset and CPU hot plugging.
     1160 *
     1161 * @param   pVCpu               The virtual CPU handle.
     1162 */
    11551163VMMR3DECL(void) PDMR3ResetCpu(PVMCPU pVCpu)
    11561164{
     
    11601168    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_INTERRUPT_SMI);
    11611169}
     1170
    11621171
    11631172/**
     
    12501259     */
    12511260    for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
    1252     {
    1253         PVMCPU pVCpu = &pVM->aCpus[idCpu];
    1254         PDMR3ResetCpu(pVCpu);
    1255     }
     1261        PDMR3ResetCpu(&pVM->aCpus[idCpu]);
    12561262    VM_FF_CLEAR(pVM, VM_FF_PDM_DMA);
    12571263
  • trunk/src/VBox/VMM/PGM.cpp

    r25816 r25825  
    21722172}
    21732173
    2174 VMMR3DECL(void) PGMR3ResetCpu(PVM pVM, PVMCPU pVCpu)
     2174
     2175/**
     2176 * Resets a virtual CPU when unplugged.
     2177 *
     2178 * @param   pVM                 The VM handle.
     2179 * @param   pVCpu               The virtual CPU handle.
     2180 */
     2181VMMR3DECL(void) PGMR3ResetUnpluggedCpu(PVM pVM, PVMCPU pVCpu)
    21752182{
    21762183    int rc = PGM_GST_PFN(Exit, pVCpu)(pVCpu);
     
    21822189    STAM_REL_COUNTER_RESET(&pVCpu->pgm.s.cGuestModeChanges);
    21832190
    2184     pgmR3PoolResetCpu(pVM, pVCpu);
     2191    pgmR3PoolResetUnpluggedCpu(pVM, pVCpu);
    21852192
    21862193    /*
     
    21952202    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL);
    21962203}
     2204
    21972205
    21982206/**
  • trunk/src/VBox/VMM/PGMInternal.h

    r25816 r25825  
    32843284int             pgmR3PoolInit(PVM pVM);
    32853285void            pgmR3PoolRelocate(PVM pVM);
     3286void            pgmR3PoolResetUnpluggedCpu(PVM pVM, PVMCPU pVCpu);
    32863287void            pgmR3PoolReset(PVM pVM);
    3287 void            pgmR3PoolResetCpu(PVM pVM, PVMCPU pVCpu);
    32883288void            pgmR3PoolClearAll(PVM pVM);
    32893289
  • trunk/src/VBox/VMM/TRPM.cpp

    r25816 r25825  
    713713}
    714714
     715
     716/**
     717 * Resets a virtual CPU.
     718 *
     719 * Used by TRPMR3Reset and CPU hot plugging.
     720 *
     721 * @param   pVCpu               The virtual CPU handle.
     722 */
    715723VMMR3DECL(void) TRPMR3ResetCpu(PVMCPU pVCpu)
    716724{
     
    718726}
    719727
     728
    720729/**
    721730 * The VM is being reset.
     
    748757     */
    749758    for (VMCPUID i = 0; i < pVM->cCpus; i++)
    750     {
    751         PVMCPU pVCpu = &pVM->aCpus[i];
    752         TRPMR3ResetCpu(pVCpu);
    753     }
     759        TRPMR3ResetCpu(&pVM->aCpus[i]);
    754760    memcpy(&pVM->trpm.s.aIdt[0], &g_aIdt[0], sizeof(pVM->trpm.s.aIdt));
    755761    memset(pVM->trpm.s.aGuestTrapHandler, 0, sizeof(pVM->trpm.s.aGuestTrapHandler));
  • trunk/src/VBox/VMM/VM.cpp

    r25816 r25825  
    40424042}
    40434043
    4044 DECLCALLBACK(int) vmR3HotunplugCPU(PVM pVM, VMCPUID idCpu)
    4045 {
    4046     PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
    4047     VMCPU_ASSERT_EMT(pVCpu);
    4048 
    4049     /*
    4050      * Reset per CPU resources.
    4051      * Actually only needed for VT-x because the CPU
    4052      * seems to be still in some paged mode and startup
    4053      * fails after a new hotplug event.
    4054      * SVM works fine even without this.
    4055      */
    4056     Log(("vmR3HotunplugCPU for VCPU %d\n", idCpu));
    4057     PGMR3ResetCpu(pVM, pVCpu);
    4058     PDMR3ResetCpu(pVCpu);
    4059     TRPMR3ResetCpu(pVCpu);
    4060     CPUMR3ResetCpu(pVCpu);
    4061     EMR3ResetCpu(pVCpu);
    4062     HWACCMR3ResetCPU(pVCpu);
    4063     return VINF_EM_WAIT_SIPI;
    4064 }
    40654044
    40664045/**
     
    40724051 * @param   pidCpuCore       Where to store the core ID of the virtual CPU.
    40734052 * @param   pidCpuPackage    Where to store the package ID of the virtual CPU.
     4053 *
     4054 * @todo    r=bird: Rename to VMR3GetCpuCoreAndPackageIdFromCpuId. We currently
     4055 *          try avoid holding down the shift key, so 'Cpu' is favored over 'CPU'
     4056 *          now.
    40744057 */
    40754058VMMR3DECL(int) VMR3GetCPUCoreAndPackageIdFromCPUId(PVM pVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage)
     
    40894072}
    40904073
    4091 /**
    4092  * Unplugs a CPU from the guest.
     4074
     4075/**
     4076 * Worker for VMR3HotUnplugCpu.
     4077 *
     4078 * @returns VINF_EM_WAIT_SPIP (strict status code).
     4079 * @param   pVM                 The VM handle.
     4080 * @param   idCpu               The current CPU.
     4081 */
     4082static DECLCALLBACK(int) vmR3HotUnplugCpu(PVM pVM, VMCPUID idCpu)
     4083{
     4084    PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
     4085    VMCPU_ASSERT_EMT(pVCpu);
     4086
     4087    /*
     4088     * Reset per CPU resources.
     4089     *
     4090     * Actually only needed for VT-x because the CPU seems to be still in some
     4091     * paged mode and startup fails after a new hot plug event. SVM works fine
     4092     * even without this.
     4093     */
     4094    Log(("vmR3HotUnplugCpu for VCPU %u\n", idCpu));
     4095    PGMR3ResetUnpluggedCpu(pVM, pVCpu);
     4096    PDMR3ResetCpu(pVCpu);
     4097    TRPMR3ResetCpu(pVCpu);
     4098    CPUMR3ResetCpu(pVCpu);
     4099    EMR3ResetCpu(pVCpu);
     4100    HWACCMR3ResetCpu(pVCpu);
     4101    return VINF_EM_WAIT_SIPI;
     4102}
     4103
     4104
     4105/**
     4106 * Hot-unplugs a CPU from the guest.
    40934107 *
    40944108 * @returns VBox status code.
    40954109 * @param   pVM     The VM to operate on.
    4096  * @param   idCpu   Virtual CPU to perform the unplug operation on.
     4110 * @param   idCpu   Virtual CPU to perform the hot unplugging operation on.
     4111 * @todo r=bird:  Rename to VMR3HotUnplugCpu.
    40974112 */
    40984113VMMR3DECL(int) VMR3HotunplugCPU(PVM pVM, VMCPUID idCpu)
     
    41014116
    41024117    /** @todo Destroy EMT and not needed resources. */
    4103     return VMR3ReqCallNoWaitU(pVM->pUVM, idCpu, (PFNRT)vmR3HotunplugCPU, 2, pVM, idCpu);
    4104 }
    4105 
    4106 /**
    4107  * Hotplugs a CPU on the guest.
     4118    /** @todo r=bird: Don't destroy the EMT, it'll break VMMR3EmtRendezvous and
     4119     *        broadcast requests.  Just note down somewhere that the CPU is
     4120     *        offline and send it to SPIP wait.  Maybe modify VMCPUSTATE and push
     4121     *        it out of the EM loops when offline. */
     4122    return VMR3ReqCallNoWaitU(pVM->pUVM, idCpu, (PFNRT)vmR3HotUnplugCpu, 2, pVM, idCpu);
     4123}
     4124
     4125
     4126/**
     4127 * Hot-plugs a CPU on the guest.
    41084128 *
    41094129 * @returns VBox status code.
    41104130 * @param   pVM     The VM to operate on.
    4111  * @param   idCpu   Virtual CPU to perform the hotplug operation on.
     4131 * @param   idCpu   Virtual CPU to perform the hot plugging operation on.
     4132 * @todo r=bird: Rename to VMR3HotPlugCpu.
    41124133 */
    41134134VMMR3DECL(int) VMR3HotplugCPU(PVM pVM, VMCPUID idCpu)
     
    41164137
    41174138    /** @todo start EMT and allocate needed resources. */
     4139    /** @todo r-bird: Just mark it online and make sure it waits on SPIP. */
    41184140    return VINF_SUCCESS;
    41194141}
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r25816 r25825  
    18811881    /*
    18821882     * Found a usable page, flush it and return.
    1883      */   
    1884     int rc = pgmPoolFlushPage(pPool, pPage); 
    1885     /* This flush was initiated by us and not the guest, so explicitly flush the TLB. */ 
     1883     */
     1884    int rc = pgmPoolFlushPage(pPool, pPage);
     1885    /* This flush was initiated by us and not the guest, so explicitly flush the TLB. */
    18861886    /* todo: find out why this is necessary; pgmPoolFlushPage should trigger a flush if one is really needed. */
    18871887    if (rc == VINF_SUCCESS)
    1888         PGM_INVL_ALL_VCPU_TLBS(pVM); 
     1888        PGM_INVL_ALL_VCPU_TLBS(pVM);
    18891889    return rc;
    18901890}
     
    47684768#ifdef IN_RING3
    47694769
    4770 void pgmR3PoolResetCpu(PVM pVM, PVMCPU pVCpu)
     4770
     4771/**
     4772 * Reset CPU on hot plugging.
     4773 *
     4774 * @param   pVM                 The VM handle.
     4775 * @param   pVCpu               The virtual CPU.
     4776 */
     4777void pgmR3PoolResetUnpluggedCpu(PVM pVM, PVMCPU pVCpu)
    47714778{
    47724779    pgmR3ExitShadowModeBeforePoolFlush(pVM, pVCpu);
     
    47764783    VMCPU_FF_SET(pVCpu, VMCPU_FF_TLB_FLUSH);
    47774784}
     4785
    47784786
    47794787/**
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