Changeset 92697 in vbox for trunk/src/VBox/HostDrivers/Support
- Timestamp:
- Dec 2, 2021 12:37:40 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 148596
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
r92613 r92697 100 100 { 101 101 /*.hDevice = */ SUP_HDEVICE_NIL, 102 /*.fUnrestricted = */ true 102 /*.fUnrestricted = */ true, 103 /*.fDriverless = */ false 103 104 #if defined(RT_OS_DARWIN) 104 105 ,/* .uConnection = */ 0 … … 263 264 SUPINITOP enmWhat = kSupInitOp_Driver; 264 265 int rc = suplibOsInit(&g_supLibData, g_fPreInited, fFlags, &enmWhat, NULL); 265 if (RT_SUCCESS(rc) )266 if (RT_SUCCESS(rc) && !g_supLibData.fDriverless) 266 267 { 267 268 /* … … 390 391 suplibOsTerm(&g_supLibData); 391 392 } 393 else if (RT_SUCCESS(rc)) 394 { 395 /* 396 * Driverless initialization. 397 */ 398 Assert(fFlags & SUPR3INIT_F_DRIVERLESS_MASK); 399 LogRel(("SUP: In driverless mode.\n")); 400 return VINF_SUCCESS; 401 } 402 392 403 g_cInits--; 393 404 … … 560 571 return rc; 561 572 562 g_u32Cookie = 0; 563 g_u32SessionCookie = 0; 564 g_cInits = 0; 573 g_supLibData.hDevice = SUP_HDEVICE_NIL; 574 g_supLibData.fUnrestricted = true; 575 g_supLibData.fDriverless = false; 576 g_u32Cookie = 0; 577 g_u32SessionCookie = 0; 578 g_cInits = 0; 565 579 } 566 580 else … … 571 585 572 586 587 SUPR3DECL(bool) SUPR3IsDriverless(void) 588 { 589 Assert(g_cInits > 0); 590 return g_supLibData.fDriverless; 591 } 592 593 573 594 SUPR3DECL(SUPPAGINGMODE) SUPR3GetPagingMode(void) 574 595 { 575 /* fake */ 576 if (RT_UNLIKELY(g_uSupFakeMode)) 577 #ifdef RT_ARCH_AMD64 596 /* 597 * Deal with driverless first. 598 */ 599 if (g_supLibData.fDriverless) 600 #if defined(RT_ARCH_AMD64) 578 601 return SUPPAGINGMODE_AMD64_GLOBAL_NX; 602 #elif defined(RT_ARCH_X86) 603 return SUPPAGINGMODE_32_BIT_GLOBAL; 579 604 #else 580 return SUPPAGINGMODE_ 32_BIT_GLOBAL;605 return SUPPAGINGMODE_INVALID; 581 606 #endif 582 607 … … 1099 1124 AssertReturn(!fFlags, VERR_INVALID_FLAGS); 1100 1125 1101 /* fake */ 1102 if (RT_UNLIKELY(g_uSupFakeMode)) 1103 { 1104 void *pv = RTMemPageAllocZ(cPages * PAGE_SIZE); 1105 if (!pv) 1106 return VERR_NO_MEMORY; 1107 *ppvPages = pv; 1126 /* 1127 * Deal with driverless mode first. 1128 */ 1129 if (g_supLibData.fDriverless) 1130 { 1131 int rc = SUPR3PageAlloc(cPages * PAGE_SIZE, 0 /*fFlags*/, ppvPages); 1108 1132 if (pR0Ptr) 1109 *pR0Ptr = (RTR0PTR)pv;1133 *pR0Ptr = NIL_RTR0PTR; 1110 1134 if (paPages) 1111 1135 for (size_t iPage = 0; iPage < cPages; iPage++) 1112 1136 { 1113 1137 paPages[iPage].uReserved = 0; 1114 paPages[iPage].Phys = (iPage + 4321) << PAGE_SHIFT; 1115 Assert(!(paPages[iPage].Phys & ~X86_PTE_PAE_PG_MASK)); 1138 paPages[iPage].Phys = NIL_RTHCPHYS; 1116 1139 } 1117 return VINF_SUCCESS;1140 return rc; 1118 1141 } 1119 1142 … … 1682 1705 *pfCaps = 0; 1683 1706 1684 /* fake */ 1685 if (RT_UNLIKELY(g_uSupFakeMode)) 1686 return VINF_SUCCESS; 1687 1688 /* 1689 * Issue IOCtl to the SUPDRV kernel module. 1690 */ 1691 SUPVTCAPS Req; 1692 Req.Hdr.u32Cookie = g_u32Cookie; 1693 Req.Hdr.u32SessionCookie = g_u32SessionCookie; 1694 Req.Hdr.cbIn = SUP_IOCTL_VT_CAPS_SIZE_IN; 1695 Req.Hdr.cbOut = SUP_IOCTL_VT_CAPS_SIZE_OUT; 1696 Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT; 1697 Req.Hdr.rc = VERR_INTERNAL_ERROR; 1698 Req.u.Out.fCaps = 0; 1699 int rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_VT_CAPS, &Req, SUP_IOCTL_VT_CAPS_SIZE); 1700 if (RT_SUCCESS(rc)) 1701 { 1702 rc = Req.Hdr.rc; 1707 int rc; 1708 if (!g_supLibData.fDriverless) 1709 { 1710 /* 1711 * Issue IOCtl to the SUPDRV kernel module. 1712 */ 1713 SUPVTCAPS Req; 1714 Req.Hdr.u32Cookie = g_u32Cookie; 1715 Req.Hdr.u32SessionCookie = g_u32SessionCookie; 1716 Req.Hdr.cbIn = SUP_IOCTL_VT_CAPS_SIZE_IN; 1717 Req.Hdr.cbOut = SUP_IOCTL_VT_CAPS_SIZE_OUT; 1718 Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT; 1719 Req.Hdr.rc = VERR_INTERNAL_ERROR; 1720 Req.u.Out.fCaps = 0; 1721 rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_VT_CAPS, &Req, SUP_IOCTL_VT_CAPS_SIZE); 1703 1722 if (RT_SUCCESS(rc)) 1704 *pfCaps = Req.u.Out.fCaps; 1705 } 1723 { 1724 rc = Req.Hdr.rc; 1725 if (RT_SUCCESS(rc)) 1726 *pfCaps = Req.u.Out.fCaps; 1727 } 1728 } 1729 /* 1730 * Fail this call in driverless mode. 1731 */ 1732 else 1733 rc = VERR_SUP_DRIVERLESS; 1706 1734 return rc; 1707 1735 } … … 1724 1752 *uMicrocodeRev = 0; 1725 1753 1726 /* fake */ 1727 if (RT_UNLIKELY(g_uSupFakeMode)) 1728 return VINF_SUCCESS; 1729 1730 /* 1731 * Issue IOCtl to the SUPDRV kernel module. 1732 */ 1733 SUPUCODEREV Req; 1734 Req.Hdr.u32Cookie = g_u32Cookie; 1735 Req.Hdr.u32SessionCookie = g_u32SessionCookie; 1736 Req.Hdr.cbIn = SUP_IOCTL_UCODE_REV_SIZE_IN; 1737 Req.Hdr.cbOut = SUP_IOCTL_UCODE_REV_SIZE_OUT; 1738 Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT; 1739 Req.Hdr.rc = VERR_INTERNAL_ERROR; 1740 Req.u.Out.MicrocodeRev = 0; 1741 int rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_UCODE_REV, &Req, SUP_IOCTL_UCODE_REV_SIZE); 1742 if (RT_SUCCESS(rc)) 1743 { 1744 rc = Req.Hdr.rc; 1754 int rc; 1755 if (!g_supLibData.fDriverless) 1756 { 1757 /* 1758 * Issue IOCtl to the SUPDRV kernel module. 1759 */ 1760 SUPUCODEREV Req; 1761 Req.Hdr.u32Cookie = g_u32Cookie; 1762 Req.Hdr.u32SessionCookie = g_u32SessionCookie; 1763 Req.Hdr.cbIn = SUP_IOCTL_UCODE_REV_SIZE_IN; 1764 Req.Hdr.cbOut = SUP_IOCTL_UCODE_REV_SIZE_OUT; 1765 Req.Hdr.fFlags = SUPREQHDR_FLAGS_DEFAULT; 1766 Req.Hdr.rc = VERR_INTERNAL_ERROR; 1767 Req.u.Out.MicrocodeRev = 0; 1768 rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_UCODE_REV, &Req, SUP_IOCTL_UCODE_REV_SIZE); 1745 1769 if (RT_SUCCESS(rc)) 1746 *uMicrocodeRev = Req.u.Out.MicrocodeRev; 1747 } 1770 { 1771 rc = Req.Hdr.rc; 1772 if (RT_SUCCESS(rc)) 1773 *uMicrocodeRev = Req.u.Out.MicrocodeRev; 1774 } 1775 } 1776 /* 1777 * Just fail the call in driverless mode. 1778 */ 1779 else 1780 rc = VERR_SUP_DRIVERLESS; 1748 1781 return rc; 1749 1782 } -
trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h
r92613 r92697 256 256 * support device. */ 257 257 bool fUnrestricted; 258 /** Set if we're in driverless mode. */ 259 bool fDriverless; 258 260 #if defined(RT_OS_DARWIN) 259 261 /** The connection to the VBoxSupDrv service. */ -
trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp
r92613 r92697 95 95 pThis->fSysMadviseWorks = (0 == madvise(pv, PAGE_SIZE, MADV_DONTFORK)); 96 96 munmap(pv, PAGE_SIZE); 97 98 /* 99 * Driverless? 100 */ 101 if (fFlags & SUPR3INIT_F_DRIVERLESS) 102 { 103 pThis->fDriverless = true; 104 return VINF_SUCCESS; 105 } 97 106 98 107 /* … … 118 127 case ENOENT: rc = VERR_VM_DRIVER_NOT_INSTALLED; break; 119 128 default: rc = VERR_VM_DRIVER_OPEN_ERROR; break; 129 } 130 if (fFlags & SUPR3INIT_F_DRIVERLESS_MASK) 131 { 132 LogRel(("Failed to open \"%s\", errno=%d, rc=%Rrc - Switching to driverless mode.\n", pszDeviceNm, errno, rc)); 133 pThis->fDriverless = true; 134 return VINF_SUCCESS; 120 135 } 121 136 LogRel(("Failed to open \"%s\", errno=%d, rc=%Rrc\n", pszDeviceNm, errno, rc));
Note:
See TracChangeset
for help on using the changeset viewer.