Changeset 13013 in vbox
- Timestamp:
- Oct 6, 2008 2:48:49 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 37452
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmapi.h
r12989 r13013 51 51 VMMDECL(int) PDMApicSetTPR(PVM pVM, uint8_t u8TPR); 52 52 VMMDECL(int) PDMApicGetTPR(PVM pVM, uint8_t *pu8TPR, bool *pfPending); 53 VMMDECL(int) PDMApicWRMSR(PVM pVM, VMCPUID iCpu, uint32_t u32Reg, uint64_t u64Value); 54 VMMDECL(int) PDMApicRDMSR(PVM pVM, VMCPUID iCpu, uint32_t u32Reg, uint64_t *pu64Value); 53 55 VMMDECL(int) PDMVMMDevHeapR3ToGCPhys(PVM pVM, RTR3PTR pv, RTGCPHYS *pGCPhys); 54 56 -
trunk/include/VBox/pdmdev.h
r13005 r13013 992 992 993 993 /** 994 * WRMSR in APIC range. 995 * 996 * @returns VBox status code. 997 * @param pDevIns Device instance of the APIC. 998 * @param iCpu Target CPU. 999 * @param u32Reg MSR to write. 1000 * @param u64Value Value to write. 1001 */ 1002 DECLR3CALLBACKMEMBER(uint32_t, pfnWRMSRR3, (PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t u64Value)); 1003 1004 /** 1005 * RDMSR in APIC range. 1006 * 1007 * @returns VBox status code. 1008 * @param pDevIns Device instance of the APIC. 1009 * @param iCpu Target CPU. 1010 * @param u32Reg MSR to read. 1011 * @param pu64Value Value read. 1012 */ 1013 DECLR3CALLBACKMEMBER(uint32_t, pfnRDMSRR3, (PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t *pu64Value)); 1014 1015 /** 994 1016 * Private interface between the IOAPIC and APIC. 995 1017 * … … 1024 1046 /** The name of the RC GetTPR entry point. */ 1025 1047 const char *pszGetTPRRC; 1048 /** The name of the RC WRMSR entry point. */ 1049 const char *pszWRMSRRC; 1050 /** The name of the RC RDMSR entry point. */ 1051 const char *pszRDMSRRC; 1026 1052 /** The name of the RC BusDeliver entry point. */ 1027 1053 const char *pszBusDeliverRC; … … 1039 1065 /** The name of the R0 GetTPR entry point. */ 1040 1066 const char *pszGetTPRR0; 1067 /** The name of the R0 WRMSR entry point. */ 1068 const char *pszWRMSRR0; 1069 /** The name of the R0 RDMSR entry point. */ 1070 const char *pszRDMSRR0; 1041 1071 /** The name of the R0 BusDeliver entry point. */ 1042 1072 const char *pszBusDeliverR0; -
trunk/include/VBox/x86.h
r12971 r13013 820 820 /** EPT capabilities. */ 821 821 #define MSR_IA32_VMX_EPT_CAPS 0x48C 822 /** X2APIC MSR ranges. */ 823 #define MSR_IA32_APIC_START 0x800 824 #define MSR_IA32_APIC_END 0x900 822 825 823 826 /** K6 EFER - Extended Feature Enable Register. */ -
trunk/src/VBox/Devices/PC/DevAPIC.cpp
r12977 r13013 307 307 } APICDeviceInfo; 308 308 309 DECLINLINE(APICState*) getLapicById(APICDeviceInfo* dev, VMCPUID id) 310 { 311 AssertFatalMsg(id < dev->cCpus, ("CPU id %d out of range\n", id)); 312 return LAPIC_BASE(dev) + id; 313 } 314 309 315 DECLINLINE(APICState*) getLapic(APICDeviceInfo* dev) 310 316 { 311 317 /* LAPIC's array is indexed by CPU id */ 312 318 VMCPUID id = dev->CTX_SUFF(pApicHlp)->pfnGetCpuId(dev->CTX_SUFF(pDevIns)); 313 return LAPIC_BASE(dev) + id;319 return getLapicById(dev, id); 314 320 } 315 321 … … 360 366 uint8_t u8DeliveryMode, uint8_t iVector, uint8_t u8Polarity, 361 367 uint8_t u8TriggerMode); 368 PDMBOTHCBDECL(uint32_t) apicWRMSR(PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t u64Value); 369 PDMBOTHCBDECL(uint32_t) apicRDMSR(PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t *pu64Value); 362 370 PDMBOTHCBDECL(int) ioapicMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb); 363 371 PDMBOTHCBDECL(int) ioapicMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb); … … 571 579 Log2(("apicGetTPR: returns %#x\n", s->tpr >> 4)); 572 580 return s->tpr >> 4; 581 } 582 583 PDMBOTHCBDECL(uint32_t) apicWRMSR(PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t u64Value) 584 { 585 return 0; 586 } 587 PDMBOTHCBDECL(uint32_t) apicRDMSR(PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t *pu64Value) 588 { 589 return 0; 573 590 } 574 591 … … 1951 1968 ApicReg.pfnSetTPRR3 = apicSetTPR; 1952 1969 ApicReg.pfnGetTPRR3 = apicGetTPR; 1970 ApicReg.pfnWRMSRR3 = apicWRMSR; 1971 ApicReg.pfnRDMSRR3 = apicRDMSR; 1953 1972 ApicReg.pfnBusDeliverR3 = apicBusDeliverCallback; 1954 1973 if (fGCEnabled) { … … 1959 1978 ApicReg.pszSetTPRRC = "apicSetTPR"; 1960 1979 ApicReg.pszGetTPRRC = "apicGetTPR"; 1980 ApicReg.pszWRMSRRC = "apicWRMSR"; 1981 ApicReg.pszRDMSRRC = "apicRDMSR"; 1961 1982 ApicReg.pszBusDeliverRC = "apicBusDeliverCallback"; 1962 1983 } else { … … 1967 1988 ApicReg.pszSetTPRRC = NULL; 1968 1989 ApicReg.pszGetTPRRC = NULL; 1990 ApicReg.pszWRMSRRC = NULL; 1991 ApicReg.pszRDMSRRC = NULL; 1969 1992 ApicReg.pszBusDeliverRC = NULL; 1970 1993 } … … 1976 1999 ApicReg.pszSetTPRR0 = "apicSetTPR"; 1977 2000 ApicReg.pszGetTPRR0 = "apicGetTPR"; 2001 ApicReg.pszWRMSRR0 = "apicWRMSR"; 2002 ApicReg.pszRDMSRR0 = "apicRDMSR"; 1978 2003 ApicReg.pszBusDeliverR0 = "apicBusDeliverCallback"; 1979 2004 } else { … … 1984 2009 ApicReg.pszSetTPRR0 = NULL; 1985 2010 ApicReg.pszGetTPRR0 = NULL; 2011 ApicReg.pszWRMSRR0 = NULL; 2012 ApicReg.pszRDMSRR0 = NULL; 1986 2013 ApicReg.pszBusDeliverR0 = NULL; 1987 2014 } -
trunk/src/VBox/VMM/PDM.cpp
r13005 r13013 432 432 pVM->pdm.s.Apic.pfnGetTPRRC += offDelta; 433 433 pVM->pdm.s.Apic.pfnBusDeliverRC += offDelta; 434 pVM->pdm.s.Apic.pfnWRMSRRC += offDelta; 435 pVM->pdm.s.Apic.pfnRDMSRRC += offDelta; 434 436 } 435 437 -
trunk/src/VBox/VMM/PDMDevHlp.cpp
r12984 r13013 1489 1489 VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3); 1490 1490 LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: pApicReg=%p:{.u32Version=%#x, .pfnGetInterruptR3=%p, .pfnSetBaseR3=%p, .pfnGetBaseR3=%p, " 1491 ".pfnSetTPRR3=%p, .pfnGetTPRR3=%p, .pfn BusDeliverR3=%p, pszGetInterruptRC=%p:{%s}, pszSetBaseRC=%p:{%s}, pszGetBaseRC=%p:{%s}, "1492 ".pszSetTPRRC=%p:{%s}, .pszGetTPRRC=%p:{%s}, .psz BusDeliverRC=%p:{%s}} ppApicHlpR3=%p\n",1491 ".pfnSetTPRR3=%p, .pfnGetTPRR3=%p, .pfnWRMSR3=%p, .pfnRDMSR3=%p, .pfnBusDeliverR3=%p, pszGetInterruptRC=%p:{%s}, pszSetBaseRC=%p:{%s}, pszGetBaseRC=%p:{%s}, " 1492 ".pszSetTPRRC=%p:{%s}, .pszGetTPRRC=%p:{%s}, .pszWRMSRRC=%p:{%s}, .pszRDMSRRC=%p:{%s}, .pszBusDeliverRC=%p:{%s}} ppApicHlpR3=%p\n", 1493 1493 pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pApicReg, pApicReg->u32Version, pApicReg->pfnGetInterruptR3, pApicReg->pfnSetBaseR3, 1494 pApicReg->pfnGetBaseR3, pApicReg->pfnSetTPRR3, pApicReg->pfnGetTPRR3, pApicReg->pfn BusDeliverR3, pApicReg->pszGetInterruptRC,1494 pApicReg->pfnGetBaseR3, pApicReg->pfnSetTPRR3, pApicReg->pfnGetTPRR3, pApicReg->pfnWRMSRR3, pApicReg->pfnRDMSRR3, pApicReg->pfnBusDeliverR3, pApicReg->pszGetInterruptRC, 1495 1495 pApicReg->pszGetInterruptRC, pApicReg->pszSetBaseRC, pApicReg->pszSetBaseRC, pApicReg->pszGetBaseRC, pApicReg->pszGetBaseRC, 1496 pApicReg->pszSetTPRRC, pApicReg->pszSetTPRRC, pApicReg->pszGetTPRRC, pApicReg->pszGetTPRRC, pApicReg->psz BusDeliverRC,1496 pApicReg->pszSetTPRRC, pApicReg->pszSetTPRRC, pApicReg->pszGetTPRRC, pApicReg->pszGetTPRRC, pApicReg->pszWRMSRRC, pApicReg->pszWRMSRRC, pApicReg->pszRDMSRRC, pApicReg->pszRDMSRRC, pApicReg->pszBusDeliverRC, 1497 1497 pApicReg->pszBusDeliverRC, ppApicHlpR3)); 1498 1498 … … 1512 1512 || !pApicReg->pfnSetTPRR3 1513 1513 || !pApicReg->pfnGetTPRR3 1514 || !pApicReg->pfnWRMSRR3 1515 || !pApicReg->pfnRDMSRR3 1514 1516 || !pApicReg->pfnBusDeliverR3) 1515 1517 { … … 1520 1522 Assert(pApicReg->pfnSetTPRR3); 1521 1523 Assert(pApicReg->pfnGetTPRR3); 1524 Assert(pApicReg->pfnWRMSRR3); 1525 Assert(pApicReg->pfnRDMSRR3); 1522 1526 Assert(pApicReg->pfnBusDeliverR3); 1523 1527 LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc (R3 callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); … … 1530 1534 || pApicReg->pszSetTPRRC 1531 1535 || pApicReg->pszGetTPRRC 1536 || pApicReg->pszWRMSRRC 1537 || pApicReg->pszRDMSRRC 1532 1538 || pApicReg->pszBusDeliverRC) 1533 1539 && ( !VALID_PTR(pApicReg->pszGetInterruptRC) … … 1537 1543 || !VALID_PTR(pApicReg->pszSetTPRRC) 1538 1544 || !VALID_PTR(pApicReg->pszGetTPRRC) 1545 || !VALID_PTR(pApicReg->pszWRMSRRC) 1546 || !VALID_PTR(pApicReg->pszRDMSRRC) 1539 1547 || !VALID_PTR(pApicReg->pszBusDeliverRC)) 1540 1548 ) … … 1546 1554 Assert(VALID_PTR(pApicReg->pszSetTPRRC)); 1547 1555 Assert(VALID_PTR(pApicReg->pszGetTPRRC)); 1556 Assert(VALID_PTR(pApicReg->pszRDMSRRC)); 1557 Assert(VALID_PTR(pApicReg->pszWRMSRRC)); 1548 1558 Assert(VALID_PTR(pApicReg->pszBusDeliverRC)); 1549 1559 LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc (RC callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); … … 1556 1566 || pApicReg->pszSetTPRR0 1557 1567 || pApicReg->pszGetTPRR0 1568 || pApicReg->pszWRMSRR0 1569 || pApicReg->pszRDMSRR0 1558 1570 || pApicReg->pszBusDeliverR0) 1559 1571 && ( !VALID_PTR(pApicReg->pszGetInterruptR0) … … 1563 1575 || !VALID_PTR(pApicReg->pszSetTPRR0) 1564 1576 || !VALID_PTR(pApicReg->pszGetTPRR0) 1577 || !VALID_PTR(pApicReg->pszRDMSRR0) 1578 || !VALID_PTR(pApicReg->pszWRMSRR0) 1565 1579 || !VALID_PTR(pApicReg->pszBusDeliverR0)) 1566 1580 ) … … 1572 1586 Assert(VALID_PTR(pApicReg->pszSetTPRR0)); 1573 1587 Assert(VALID_PTR(pApicReg->pszGetTPRR0)); 1588 Assert(VALID_PTR(pApicReg->pszRDMSRR0)); 1589 Assert(VALID_PTR(pApicReg->pszWRMSRR0)); 1574 1590 Assert(VALID_PTR(pApicReg->pszBusDeliverR0)); 1575 1591 LogFlow(("pdmR3DevHlp_APICRegister: caller='%s'/%d: returns %Vrc (R0 callbacks)\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, VERR_INVALID_PARAMETER)); … … 1584 1600 1585 1601 /* 1586 * Only one APIC device. (malc: only in UP case actually) 1602 * Only one APIC device. On SMP we have single logical device covering all LAPICs, 1603 * as they need to communicate and share state easily. 1587 1604 */ 1588 1605 PVM pVM = pDevIns->Internal.s.pVMR3; … … 1625 1642 rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszGetTPRRC, &pVM->pdm.s.Apic.pfnGetTPRRC); 1626 1643 AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszGetTPRRC, rc)); 1644 } 1645 if (RT_SUCCESS(rc)) 1646 { 1647 rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszWRMSRRC, &pVM->pdm.s.Apic.pfnWRMSRRC); 1648 AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszWRMSRRC, rc)); 1649 } 1650 if (RT_SUCCESS(rc)) 1651 { 1652 rc = PDMR3LdrGetSymbolRCLazy(pVM, pDevIns->pDevReg->szRCMod, pApicReg->pszRDMSRRC, &pVM->pdm.s.Apic.pfnRDMSRRC); 1653 AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szRCMod, pApicReg->pszRDMSRRC, rc)); 1627 1654 } 1628 1655 if (RT_SUCCESS(rc)) … … 1647 1674 pVM->pdm.s.Apic.pfnSetTPRRC = 0; 1648 1675 pVM->pdm.s.Apic.pfnGetTPRRC = 0; 1676 pVM->pdm.s.Apic.pfnWRMSRRC = 0; 1677 pVM->pdm.s.Apic.pfnRDMSRRC = 0; 1649 1678 pVM->pdm.s.Apic.pfnBusDeliverRC = 0; 1650 1679 } … … 1681 1710 rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszGetTPRR0, &pVM->pdm.s.Apic.pfnGetTPRR0); 1682 1711 AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszGetTPRR0, rc)); 1712 } 1713 if (RT_SUCCESS(rc)) 1714 { 1715 rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszWRMSRR0, &pVM->pdm.s.Apic.pfnWRMSRR0); 1716 AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszWRMSRR0, rc)); 1717 } 1718 if (RT_SUCCESS(rc)) 1719 { 1720 rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pDevReg->szR0Mod, pApicReg->pszRDMSRR0, &pVM->pdm.s.Apic.pfnRDMSRR0); 1721 AssertMsgRC(rc, ("%s::%s rc=%Vrc\n", pDevIns->pDevReg->szR0Mod, pApicReg->pszRDMSRR0, rc)); 1683 1722 } 1684 1723 if (RT_SUCCESS(rc)) … … 1703 1742 pVM->pdm.s.Apic.pfnSetTPRR0 = 0; 1704 1743 pVM->pdm.s.Apic.pfnGetTPRR0 = 0; 1744 pVM->pdm.s.Apic.pfnWRMSRR0 = 0; 1745 pVM->pdm.s.Apic.pfnRDMSRR0 = 0; 1705 1746 pVM->pdm.s.Apic.pfnBusDeliverR0 = 0; 1706 1747 pVM->pdm.s.Apic.pDevInsR0 = 0; … … 1717 1758 pVM->pdm.s.Apic.pfnSetTPRR3 = pApicReg->pfnSetTPRR3; 1718 1759 pVM->pdm.s.Apic.pfnGetTPRR3 = pApicReg->pfnGetTPRR3; 1760 pVM->pdm.s.Apic.pfnWRMSRR3 = pApicReg->pfnWRMSRR3; 1761 pVM->pdm.s.Apic.pfnRDMSRR3 = pApicReg->pfnRDMSRR3; 1719 1762 pVM->pdm.s.Apic.pfnBusDeliverR3 = pApicReg->pfnBusDeliverR3; 1720 1763 Log(("PDM: Registered APIC device '%s'/%d pDevIns=%p\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pDevIns)); -
trunk/src/VBox/VMM/PDMInternal.h
r12985 r13013 409 409 /** @copydoc PDMAPICREG::pfnGetTPRR3 */ 410 410 DECLR3CALLBACKMEMBER(uint8_t, pfnGetTPRR3,(PPDMDEVINS pDevIns)); 411 /** @copydoc PDMAPICREG::pfnWRMSRR3 */ 412 DECLR3CALLBACKMEMBER(uint32_t, pfnWRMSRR3, (PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t u64Value)); 413 /** @copydoc PDMAPICREG::pfnRDMSRR3 */ 414 DECLR3CALLBACKMEMBER(uint32_t, pfnRDMSRR3, (PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t *pu64Value)); 411 415 /** @copydoc PDMAPICREG::pfnBusDeliverR3 */ 412 416 DECLR3CALLBACKMEMBER(void, pfnBusDeliverR3,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode, … … 427 431 /** @copydoc PDMAPICREG::pfnGetTPRR3 */ 428 432 DECLR0CALLBACKMEMBER(uint8_t, pfnGetTPRR0,(PPDMDEVINS pDevIns)); 433 /** @copydoc PDMAPICREG::pfnWRMSRR3 */ 434 DECLR0CALLBACKMEMBER(uint32_t, pfnWRMSRR0, (PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t u64Value)); 435 /** @copydoc PDMAPICREG::pfnRDMSRR3 */ 436 DECLR0CALLBACKMEMBER(uint32_t, pfnRDMSRR0, (PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t *pu64Value)); 429 437 /** @copydoc PDMAPICREG::pfnBusDeliverR3 */ 430 438 DECLR0CALLBACKMEMBER(void, pfnBusDeliverR0,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode, … … 445 453 /** @copydoc PDMAPICREG::pfnGetTPRR3 */ 446 454 DECLRCCALLBACKMEMBER(uint8_t, pfnGetTPRRC,(PPDMDEVINS pDevIns)); 455 /** @copydoc PDMAPICREG::pfnWRMSRR3 */ 456 DECLRCCALLBACKMEMBER(uint32_t, pfnWRMSRRC, (PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t u64Value)); 457 /** @copydoc PDMAPICREG::pfnRDMSRR3 */ 458 DECLRCCALLBACKMEMBER(uint32_t, pfnRDMSRRC, (PPDMDEVINS pDevIns, VMCPUID iCpu, uint32_t u32Reg, uint64_t *pu64Value)); 447 459 /** @copydoc PDMAPICREG::pfnBusDeliverR3 */ 448 460 DECLRCCALLBACKMEMBER(void, pfnBusDeliverRC,(PPDMDEVINS pDevIns, uint8_t u8Dest, uint8_t u8DestMode, uint8_t u8DeliveryMode, -
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r12989 r13013 34 34 #include "EMInternal.h" 35 35 #include <VBox/vm.h> 36 #include <VBox/vmm.h> 36 37 #include <VBox/hwaccm.h> 37 38 #include <VBox/tm.h> … … 2576 2577 #endif 2577 2578 default: 2578 /* We should actually trigger a #GP here, but don't as that might cause more trouble. */ 2579 val = 0; 2580 break; 2579 /* In X2APIC specification this range is reserved for APIC control. */ 2580 if ((pRegFrame->ecx >= MSR_IA32_APIC_START) && (pRegFrame->ecx < MSR_IA32_APIC_END)) 2581 { 2582 rc = PDMApicRDMSR(pVM, VMMGetCpuId(pVM), pRegFrame->ecx, &val); 2583 } 2584 else 2585 { 2586 /* We should actually trigger a #GP here, but don't as that might cause more trouble. */ 2587 val = 0; 2588 break; 2589 } 2581 2590 } 2582 2591 Log(("EMInterpretRdmsr %s (%x) -> val=%VX64\n", emMSRtoString(pRegFrame->ecx), pRegFrame->ecx, val)); 2583 pRegFrame->eax = (uint32_t) val; 2584 pRegFrame->edx = (uint32_t) (val >> 32ULL); 2585 return VINF_SUCCESS; 2592 if (rc == VINF_SUCCESS) 2593 { 2594 pRegFrame->eax = (uint32_t) val; 2595 pRegFrame->edx = (uint32_t) (val >> 32ULL); 2596 } 2597 return rc; 2586 2598 } 2587 2599 … … 2714 2726 2715 2727 default: 2728 /* In X2APIC specification this range is reserved for APIC control. */ 2729 if ((pRegFrame->ecx >= MSR_IA32_APIC_START) && (pRegFrame->ecx < MSR_IA32_APIC_END)) 2730 { 2731 return PDMApicWRMSR(pVM, VMMGetCpuId(pVM), pRegFrame->ecx, val); 2732 } 2716 2733 /* We should actually trigger a #GP here, but don't as that might cause more trouble. */ 2717 2734 break; -
trunk/src/VBox/VMM/VMMAll/PDMAll.cpp
r12989 r13013 253 253 } 254 254 255 /** 256 * WRMSR in APIC range. 257 * 258 * @returns VBox status code. 259 * @param pVM VM handle. 260 * @param iCpu Target CPU. 261 * @param u32Reg MSR to write. 262 * @param u64Value Value to write. 263 */ 264 VMMDECL(int) PDMApicWRMSR(PVM pVM, VMCPUID iCpu, uint32_t u32Reg, uint64_t u64Value) 265 { 266 if (pVM->pdm.s.Apic.CTX_SUFF(pDevIns)) 267 { 268 Assert(pVM->pdm.s.Apic.CTX_SUFF(pfnWRMSR)); 269 pdmLock(pVM); 270 pVM->pdm.s.Apic.CTX_SUFF(pfnWRMSR)(pVM->pdm.s.Apic.CTX_SUFF(pDevIns), iCpu, u32Reg, u64Value); 271 pdmUnlock(pVM); 272 return VINF_SUCCESS; 273 } 274 return VERR_PDM_NO_APIC_INSTANCE; 275 } 276 277 /** 278 * RDMSR in APIC range. 279 * 280 * @returns VBox status code. 281 * @param pVM VM handle. 282 * @param iCpu Target CPU. 283 * @param u32Reg MSR to read. 284 * @param pu64Value Value read. 285 */ 286 VMMDECL(int) PDMApicRDMSR(PVM pVM, VMCPUID iCpu, uint32_t u32Reg, uint64_t *pu64Value) 287 { 288 if (pVM->pdm.s.Apic.CTX_SUFF(pDevIns)) 289 { 290 Assert(pVM->pdm.s.Apic.CTX_SUFF(pfnRDMSR)); 291 pdmLock(pVM); 292 pVM->pdm.s.Apic.CTX_SUFF(pfnRDMSR)(pVM->pdm.s.Apic.CTX_SUFF(pDevIns), iCpu, u32Reg, pu64Value); 293 pdmUnlock(pVM); 294 return VINF_SUCCESS; 295 } 296 return VERR_PDM_NO_APIC_INSTANCE; 297 } 298 255 299 256 300 /** -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r12985 r13013 275 275 GEN_CHECK_OFF(PDM, Apic.pfnGetBaseR3); 276 276 GEN_CHECK_OFF(PDM, Apic.pfnSetTPRR3); 277 GEN_CHECK_OFF(PDM, Apic.pfnWRMSRR3); 278 GEN_CHECK_OFF(PDM, Apic.pfnRDMSRR3); 277 279 GEN_CHECK_OFF(PDM, Apic.pfnGetTPRR3); 278 280 GEN_CHECK_OFF(PDM, Apic.pfnBusDeliverR3); … … 283 285 GEN_CHECK_OFF(PDM, Apic.pfnSetTPRR0); 284 286 GEN_CHECK_OFF(PDM, Apic.pfnGetTPRR0); 287 GEN_CHECK_OFF(PDM, Apic.pfnWRMSRR0); 288 GEN_CHECK_OFF(PDM, Apic.pfnRDMSRR0); 285 289 GEN_CHECK_OFF(PDM, Apic.pfnBusDeliverR0); 286 290 GEN_CHECK_OFF(PDM, Apic.pDevInsRC); … … 290 294 GEN_CHECK_OFF(PDM, Apic.pfnSetTPRRC); 291 295 GEN_CHECK_OFF(PDM, Apic.pfnGetTPRRC); 296 GEN_CHECK_OFF(PDM, Apic.pfnWRMSRRC); 297 GEN_CHECK_OFF(PDM, Apic.pfnRDMSRRC); 292 298 GEN_CHECK_OFF(PDM, Apic.pfnBusDeliverRC); 293 299 GEN_CHECK_OFF(PDM, IoApic); -
trunk/src/recompiler/VBoxREMWrapper.cpp
r12655 r13013 645 645 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL } 646 646 }; 647 static const REMPARMDESC g_aArgsPDMApicWRMSR[] = 648 { 649 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, 650 { REMPARMDESC_FLAGS_INT, sizeof(VMCPUID), NULL }, 651 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }, 652 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL } 653 }; 654 static const REMPARMDESC g_aArgsPDMApicRDMSR[] = 655 { 656 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, 657 { REMPARMDESC_FLAGS_INT, sizeof(VMCPUID), NULL }, 658 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }, 659 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t *), NULL } 660 }; 647 661 static const REMPARMDESC g_aArgsPDMGetInterrupt[] = 648 662 { … … 1004 1018 { "REMR3NotifyInterruptClear", (void *)&pfnREMR3NotifyInterruptClear, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1005 1019 { "REMR3NotifyTimerPending", (void *)&pfnREMR3NotifyTimerPending, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1006 1020 { "REMR3NotifyDmaPending", (void *)&pfnREMR3NotifyDmaPending, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1007 1021 { "REMR3NotifyQueuePending", (void *)&pfnREMR3NotifyQueuePending, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1008 1022 { "REMR3NotifyFF", (void *)&pfnREMR3NotifyFF, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, … … 1065 1079 { "PDMApicSetBase", (void *)(uintptr_t)&PDMApicSetBase, &g_aArgsPDMApicSetBase[0], RT_ELEMENTS(g_aArgsPDMApicSetBase), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1066 1080 { "PDMApicSetTPR", (void *)(uintptr_t)&PDMApicSetTPR, &g_aArgsPDMApicSetTPR[0], RT_ELEMENTS(g_aArgsPDMApicSetTPR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1081 { "PDMApicWRMSR", (void *)(uintptr_t)&PDMApicWRMSR, &g_aArgsPDMApicWRMSR[0], RT_ELEMENTS(g_aArgsPDMApicWRMSR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1082 { "PDMApicRDMSR", (void *)(uintptr_t)&PDMApicRDMSR, &g_aArgsPDMApicRDMSR[0], RT_ELEMENTS(g_aArgsPDMApicRDMSR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1067 1083 { "PDMR3DmaRun", (void *)(uintptr_t)&PDMR3DmaRun, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, 1068 1084 { "PDMGetInterrupt", (void *)(uintptr_t)&PDMGetInterrupt, &g_aArgsPDMGetInterrupt[0], RT_ELEMENTS(g_aArgsPDMGetInterrupt), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, -
trunk/src/recompiler/VBoxRecompiler.c
r12828 r13013 4087 4087 4088 4088 4089 uint64_t cpu_apic_rdmsr(CPUX86State *env, uint32_t reg) 4090 { 4091 uint64_t value; 4092 int rc = PDMApicRDMSR(env->pVM, 0/* cpu */, reg, &value); 4093 if (rc != VINF_SUCCESS) 4094 { 4095 /** @todo: exception ? */ 4096 value = 0; 4097 } 4098 return value; 4099 } 4100 4101 void cpu_apic_wrmsr(CPUX86State *env, uint32_t reg, uint64_t value) 4102 { 4103 int rc = PDMApicWRMSR(env->pVM, 0 /* cpu */, reg, value); 4104 if (rc != VINF_SUCCESS) 4105 { 4106 /** @todo: exception ? */ 4107 } 4108 } 4089 4109 /* -+- I/O Ports -+- */ 4090 4110 -
trunk/src/recompiler/target-i386/cpu.h
r11982 r13013 260 260 #define MSR_EFER_NXE (1 << 11) 261 261 #define MSR_EFER_FFXSR (1 << 14) 262 #define MSR_APIC_RANGE_START 0x800 263 #define MSR_APIC_RANGE_END 0x900 262 264 263 265 #define MSR_STAR 0xc0000081 … … 851 853 uint8_t cpu_get_apic_tpr(CPUX86State *env); 852 854 #endif 855 uint64_t cpu_apic_rdmsr(CPUX86State *env, uint32_t reg); 856 void cpu_apic_wrmsr(CPUX86State *env, uint32_t reg, uint64_t value); 853 857 void cpu_smm_update(CPUX86State *env); 854 858 -
trunk/src/recompiler/target-i386/helper.c
r12679 r13013 3073 3073 #endif 3074 3074 default: 3075 /* XXX: exception ? */ 3076 break; 3075 { 3076 uint32_t ecx = (uint32_t)ECX; 3077 /* In X2APIC specification this range is reserved for APIC control. */ 3078 if ((ecx >= MSR_APIC_RANGE_START) && (ecx < MSR_APIC_RANGE_END)) 3079 { 3080 cpu_apic_wrmsr(env, ecx, val); 3081 } 3082 else 3083 { 3084 /* @todo: exception ? */ 3085 } 3086 break; 3087 } 3077 3088 } 3078 3089 } … … 3124 3135 #endif 3125 3136 default: 3126 /* XXX: exception ? */ 3127 val = 0; 3128 break; 3137 { 3138 uint32_t ecx = (uint32_t)ECX; 3139 /* In X2APIC specification this range is reserved for APIC control. */ 3140 if ((ecx >= MSR_APIC_RANGE_START) && (ecx < MSR_APIC_RANGE_END)) 3141 { 3142 val = cpu_apic_rdmsr(env, ecx); 3143 } 3144 else 3145 { 3146 /** @todo: exception ? */ 3147 val = 0; 3148 break; 3149 } 3150 } 3129 3151 } 3130 3152 EAX = (uint32_t)(val);
Note:
See TracChangeset
for help on using the changeset viewer.