VirtualBox

Changeset 19468 in vbox for trunk


Ignore:
Timestamp:
May 7, 2009 9:03:15 AM (16 years ago)
Author:
vboxsync
Message:

VMM: better SIPI sending, reschedule to R3 as needed

Location:
trunk
Files:
7 edited

Legend:

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

    r19437 r19468  
    11591159    DECLRCCALLBACKMEMBER(VMCPUID, pfnGetCpuId,(PPDMDEVINS pDevIns));
    11601160
    1161     /**
    1162      * Sends SIPI to given virtual CPU.
    1163      *
    1164      * @param   pDevIns         The APIC device instance.
    1165      * @param   idCpu           Virtual CPU to perform SIPI on
    1166      * @param   iVector         SIPI vector
    1167      */
    1168     DECLRCCALLBACKMEMBER(void,  pfnSendSipi,(PPDMDEVINS pDevIns, VMCPUID idCpu, int iVector));
    1169 
    11701161    /** Just a safety precaution. */
    11711162    uint32_t                u32TheEnd;
     
    12361227    DECLR0CALLBACKMEMBER(VMCPUID, pfnGetCpuId,(PPDMDEVINS pDevIns));
    12371228
    1238     /**
    1239      * Sends SIPI to given virtual CPU.
    1240      *
    1241      * @param   pDevIns         The APIC device instance.
    1242      * @param   idCpu           Virtual CPU to perform SIPI on
    1243      * @param   iVector         SIPI vector
    1244      */
    1245     DECLR0CALLBACKMEMBER(void,    pfnSendSipi,(PPDMDEVINS pDevIns, VMCPUID idCpu, int iVector));
    1246 
    12471229    /** Just a safety precaution. */
    12481230    uint32_t                u32TheEnd;
     
    13191301     * @param   iVector         SIPI vector
    13201302     */
    1321     DECLR3CALLBACKMEMBER(void,    pfnSendSipi,(PPDMDEVINS pDevIns, VMCPUID idCpu, int iVector));
     1303    DECLR3CALLBACKMEMBER(void,    pfnSendSipi,(PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t uVector));
    13221304
    13231305    /**
  • trunk/include/VBox/vmm.h

    r19454 r19468  
    117117VMMDECL(uint32_t)    VMMGetSvnRev(void);
    118118VMMDECL(VMMSWITCHER) VMMGetSwitcher(PVM pVM);
    119 VMMDECL(void)        VMMSendSipi(PVM pVM, VMCPUID idCpu, int iVector);
    120119
    121120/** @def VMMIsHwVirtExtForced
     
    160159VMMR3DECL(void)     VMMR3YieldStop(PVM pVM);
    161160VMMR3DECL(void)     VMMR3YieldResume(PVM pVM);
     161VMMR3DECL(void)     VMMR3SendSipi(PVM pVM, VMCPUID idCpu, uint32_t uVector);
    162162/** @} */
    163163#endif /* IN_RING3 */
  • trunk/src/VBox/Devices/PC/DevAPIC.cpp

    r19443 r19468  
    320320
    321321static void apic_eoi(APICDeviceInfo *dev, APICState* s);
    322 static void apic_deliver(APICDeviceInfo* dev, APICState *s,
    323                          uint8_t dest, uint8_t dest_mode,
    324                          uint8_t delivery_mode, uint8_t vector_num,
    325                          uint8_t polarity, uint8_t trigger_mode);
     322static int apic_deliver(APICDeviceInfo* dev, APICState *s,
     323                        uint8_t dest, uint8_t dest_mode,
     324                        uint8_t delivery_mode, uint8_t vector_num,
     325                        uint8_t polarity, uint8_t trigger_mode);
    326326static void apic_timer_update(APICDeviceInfo* dev, APICState *s,
    327327                              int64_t current_time);
     
    363363                                                 getCpuFromLapic(dev, s));
    364364}
    365 
     365#ifdef IN_RING3
    366366DECLINLINE(void) cpuSendSipi(APICDeviceInfo* dev, APICState *s, int vector)
    367367{
    368368    Log2(("apic: send SIPI vector=%d\n", vector));
    369     dev->CTX_SUFF(pApicHlp)->pfnSendSipi(dev->CTX_SUFF(pDevIns),
    370                                          getCpuFromLapic(dev, s),
    371                                          vector);
    372 }
    373 
    374 
     369
     370    dev->pApicHlpR3->pfnSendSipi(dev->pDevInsR3,
     371                                 getCpuFromLapic(dev, s),
     372                                 vector);
     373}
     374#endif
    375375
    376376DECLINLINE(uint32_t) getApicEnableBits(APICDeviceInfo* dev)
     
    672672{
    673673    APICDeviceInfo *dev = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
     674    int rv = VINF_SUCCESS;
    674675
    675676    if (dev->enmVersion < PDMAPICVERSION_X2APIC)
     
    677678
    678679    uint32_t index = (u32Reg - MSR_IA32_APIC_START) & 0xff;
    679     //LogRel(("nike: WRMSR on %d: to %x written %llx\n", idCpu, index, u64Value));
    680680
    681681    APICState* apic = getLapicById(dev, idCpu);
     
    718718            apic->icr[0] = (uint32_t)u64Value;
    719719            apic->icr[1] = (uint32_t)(u64Value >> 32);
    720             apic_deliver(dev, apic, (apic->icr[1] >> 24) & 0xff, (apic->icr[0] >> 11) & 1,
    721                          (apic->icr[0] >>  8) & 7, (apic->icr[0] & 0xff),
    722                          (apic->icr[0] >> 14) & 1, (apic->icr[0] >> 15) & 1);
     720            rv = apic_deliver(dev, apic, (apic->icr[1] >> 24) & 0xff, (apic->icr[0] >> 11) & 1,
     721                             (apic->icr[0] >>  8) & 7, (apic->icr[0] & 0xff),
     722                             (apic->icr[0] >> 14) & 1, (apic->icr[0] >> 15) & 1);
    723723            break;
    724724        case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
     
    764764    }
    765765
    766     return VINF_SUCCESS;
     766    return rv;
    767767}
    768768PDMBOTHCBDECL(int) apicReadMSR(PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t u32Reg, uint64_t *pu64Value)
     
    774774
    775775    uint32_t index = (u32Reg - MSR_IA32_APIC_START) & 0xff;
    776     //LogRel(("nike: RDMSR on %d: read from %x\n", idCpu, index));
    777776    APICState* apic = getLapicById(dev, idCpu);
    778777    uint64_t val = 0;
     
    10811080}
    10821081
    1083 
     1082#ifdef IN_RING3
    10841083/* send a SIPI message to the CPU to start it */
    10851084static void apic_startup(APICDeviceInfo* dev, APICState *s, int vector_num)
     
    10991098#endif
    11001099}
    1101 static void apic_deliver(APICDeviceInfo* dev, APICState *s,
     1100#endif
     1101
     1102static int  apic_deliver(APICDeviceInfo* dev, APICState *s,
    11021103                         uint8_t dest, uint8_t dest_mode,
    11031104                         uint8_t delivery_mode, uint8_t vector_num,
     
    11441145                    foreach_apic(dev, deliver_bitmask,
    11451146                                       apic->arb_id = apic->id);
     1147                    return VINF_SUCCESS;
    11461148#else /* !VBOX */
    11471149                    for (apic_iter = first_local_apic; apic_iter != NULL;
     
    11511153                        }
    11521154                    }
     1155                    return;
    11531156#endif /* !VBOX */
    1154                     return;
    11551157                }
    11561158            }
     
    11661168                }
    11671169            }
     1170            return;
    11681171#else
     1172# ifdef IN_RING3
     1173           
    11691174            foreach_apic(dev, deliver_bitmask,
    11701175                         apic_startup(dev, apic, vector_num));
     1176            return VINF_SUCCESS;
     1177# else
     1178            /* We shall send SIPI only in R3, R0 calls should be
     1179               rescheduled to R3 */
     1180            return  VINF_IOM_HC_MMIO_WRITE;
     1181# endif
    11711182#endif /* !VBOX */
    1172             return;
    11731183    }
    11741184
     
    11791189    apic_bus_deliver(dev, deliver_bitmask, delivery_mode, vector_num, polarity,
    11801190                     trigger_mode);
     1191    return VINF_SUCCESS;
    11811192#endif /* VBOX */
    11821193}
     
    14451456static int apic_mem_writel(APICDeviceInfo* dev, APICState *s, target_phys_addr_t addr, uint32_t val)
    14461457{
     1458    int rv = VINF_SUCCESS;
    14471459#endif /* VBOX */
    14481460    int index;
     
    15081520    case 0x30:
    15091521        s->icr[0] = val;
    1510         apic_deliver(dev, s, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1,
    1511                      (s->icr[0] >> 8) & 7, (s->icr[0] & 0xff),
    1512                      (s->icr[0] >> 14) & 1, (s->icr[0] >> 15) & 1);
     1522        rv = apic_deliver(dev, s, (s->icr[1] >> 24) & 0xff,
     1523                          (s->icr[0] >> 11) & 1,
     1524                          (s->icr[0] >> 8) & 7, (s->icr[0] & 0xff),
     1525                          (s->icr[0] >> 14) & 1, (s->icr[0] >> 15) & 1);
    15131526        break;
    15141527    case 0x31:
     
    15571570    }
    15581571#ifdef VBOX
    1559     return VINF_SUCCESS;
     1572    return rv;
    15601573#endif
    15611574}
     
    21622175{
    21632176    APICDeviceInfo *dev = PDMINS_2_DATA(pDevIns, APICDeviceInfo *);
    2164 #ifdef VBOX_WITH_SMP_GUESTS
    2165     LogRel(("[SMP]: relocate apic on %llx\n", offDelta));
    2166 #endif
    21672177    dev->pDevInsRC  = PDMDEVINS_2_RCPTR(pDevIns);
    21682178    dev->pApicHlpRC = dev->pApicHlpR3->pfnGetRCHelpers(pDevIns);
     
    27372747#endif /* IN_RING3 */
    27382748#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
    2739 
  • trunk/src/VBox/VMM/PDMDevMiscHlp.cpp

    r19456 r19468  
    232232
    233233/** @copydoc PDMAPICHLPR3::pfnSendSipi */
    234 static DECLCALLBACK(void) pdmR3ApicHlp_SendSipi(PPDMDEVINS pDevIns, VMCPUID idCpu, int iVector) /** @todo why signed? */
    235 {
    236     PDMDEV_ASSERT_DEVINS(pDevIns);
    237     VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
    238 
    239     PVM pVM = pDevIns->Internal.s.pVMR3;
    240     PVMCPU pCpu = VMMGetCpuById(pVM, idCpu);
    241     CPUMSetGuestCS(pCpu, iVector * 0x100);
    242     CPUMSetGuestEIP(pCpu, 0);
    243     /** @todo: how do I unhalt VCPU?
    244      *  bird: See VMMSendSipi. */
    245 
     234static DECLCALLBACK(void) pdmR3ApicHlp_SendSipi(PPDMDEVINS pDevIns, VMCPUID idCpu, uint32_t uVector)
     235{
     236    PDMDEV_ASSERT_DEVINS(pDevIns);
     237    VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
     238    VMMR3SendSipi(pDevIns->Internal.s.pVMR3, idCpu, uVector);
    246239}
    247240
  • trunk/src/VBox/VMM/VMMAll/VMMAll.cpp

    r19450 r19468  
    9999# endif
    100100}
    101 #endif /* IN_RING3 */
    102 
    103101
    104102/**
     
    108106 * @param   pVM         The VM to operate on.
    109107 * @param   idCpu       Virtual CPU to perform SIPI on
    110  * @param   iVector     SIPI vector
    111  */
    112 VMMDECL(void) VMMSendSipi(PVM pVM, VMCPUID idCpu, int iVector) /** @todo why is iVector signed? */
     108 * @param   uVector     SIPI vector
     109 */
     110VMMR3DECL(void) VMMR3SendSipi(PVM pVM, VMCPUID idCpu,  uint32_t uVector)
    113111{
    114112    AssertReturnVoid(idCpu < pVM->cCPUs);
    115113
    116 #ifdef IN_RING3
    117114    PVMREQ pReq;
    118115    int rc = VMR3ReqCallU(pVM->pUVM, idCpu, &pReq, RT_INDEFINITE_WAIT, 0,
    119                           (PFNRT)vmmR3SendSipi, 3, pVM, idCpu, (uint32_t)iVector);
     116                          (PFNRT)vmmR3SendSipi, 3, pVM, idCpu, uVector);
    120117    AssertRC(rc);
    121118    VMR3ReqFree(pReq);
    122 #else
    123     AssertMsgFailed(("has to be done in ring-3, fix the code.\n"));
    124 #endif
    125 }
     119}
     120#endif /* IN_RING3 */
    126121
    127122
  • trunk/src/VBox/VMM/VMMGC/PDMGCDevice.cpp

    r19447 r19468  
    9292static DECLCALLBACK(void) pdmRCApicHlp_Unlock(PPDMDEVINS pDevIns);
    9393static DECLCALLBACK(VMCPUID) pdmRCApicHlp_GetCpuId(PPDMDEVINS pDevIns);
    94 static DECLCALLBACK(void) pdmRCApicHlp_SendSipi(PPDMDEVINS pDevIns, VMCPUID idCpu, int iVector);
    9594/** @} */
    9695
     
    168167    pdmRCApicHlp_Unlock,
    169168    pdmRCApicHlp_GetCpuId,
    170     pdmRCApicHlp_SendSipi,
    171169    PDM_APICHLPRC_VERSION
    172170};
     
    490488    return VMMGetCpuId(pDevIns->Internal.s.pVMRC);
    491489}
    492 
    493 
    494 /** @copydoc PDMAPICHLPRC::pfnSendSipi */
    495 static DECLCALLBACK(void) pdmRCApicHlp_SendSipi(PPDMDEVINS pDevIns, VMCPUID idCpu, int iVector)
    496 {
    497     /* we shall never send a SIPI in raw mode */
    498     AssertFailed();
    499 }
    500 
    501 
    502 
    503490
    504491/** @copydoc PDMIOAPICHLPRC::pfnApicBusDeliver */
  • trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp

    r19446 r19468  
    9494static DECLCALLBACK(void) pdmR0ApicHlp_Unlock(PPDMDEVINS pDevIns);
    9595static DECLCALLBACK(VMCPUID) pdmR0ApicHlp_GetCpuId(PPDMDEVINS pDevIns);
    96 static DECLCALLBACK(void) pdmR0ApicHlp_SendSipi(PPDMDEVINS pDevIns, VMCPUID idCpu, int iVector);
    9796/** @} */
    9897
     
    171170    pdmR0ApicHlp_Unlock,
    172171    pdmR0ApicHlp_GetCpuId,
    173     pdmR0ApicHlp_SendSipi,
    174172    PDM_APICHLPR0_VERSION
    175173};
     
    504502    return VMMGetCpuId(pDevIns->Internal.s.pVMR0);
    505503}
    506 
    507 
    508 /** @copydoc PDMAPICHLPR0::pfnSendSipi */
    509 static DECLCALLBACK(void) pdmR0ApicHlp_SendSipi(PPDMDEVINS pDevIns, VMCPUID idCpu, int iVector)
    510 {
    511     PDMDEV_ASSERT_DEVINS(pDevIns);
    512     return VMMSendSipi(pDevIns->Internal.s.pVMR0, idCpu, iVector);
    513 }
    514 
    515 
    516 
    517 
    518504
    519505/** @copydoc PDMIOAPICHLPR0::pfnApicBusDeliver */
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