VirtualBox

Changeset 14901 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 2, 2008 2:23:22 PM (16 years ago)
Author:
vboxsync
Message:

SUPDrv,SUPLib: SUPR0NativeEnableHwVirtExt -> SUPR0EnableVTx and darwin implementation - version changed again.

Location:
trunk/src/VBox/HostDrivers/Support
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r14836 r14901  
    311311    { "SUPR0Printf",                            (void *)SUPR0Printf }, /** @todo needs wrapping? */
    312312    { "SUPR0GetPagingMode",                     (void *)UNWIND_WRAP(SUPR0GetPagingMode) },
    313     { "SUPR0NativeEnableHwVirtExt",             (void *)SUPR0NativeEnableHwVirtExt },
     313    { "SUPR0EnableVTx",                         (void *)SUPR0EnableVTx },
    314314    { "RTMemAlloc",                             (void *)UNWIND_WRAP(RTMemAlloc) },
    315315    { "RTMemAllocZ",                            (void *)UNWIND_WRAP(RTMemAllocZ) },
     
    40594059 * @retval  VERR_NOT_SUPPORTED if not supported by the native OS.
    40604060 *
    4061  * @param   pSession        The calling session.
    40624061 * @param   fEnable         Whether to enable or disable.
    40634062 */
    4064 SUPR0DECL(int) SUPR0NativeEnableHwVirtExt(PSUPDRVSESSION pSession, bool fEnable)
    4065 {
     4063SUPR0DECL(int) SUPR0EnableVTx(bool fEnable)
     4064{
     4065#ifdef RT_OS_DARWIN
     4066    return supdrvOSEnableVTx(fEnable);
     4067#else
    40664068    return VERR_NOT_SUPPORTED;
     4069#endif
    40674070}
    40684071
  • trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h

    r14825 r14901  
    188188 *            and renaming the related IOCtls too.
    189189 */
    190 #define SUPDRV_IOC_VERSION                              0x000a0006
     190#define SUPDRV_IOC_VERSION                              0x000a0007
    191191
    192192/** SUP_IOCTL_COOKIE. */
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r14575 r14901  
    599599bool VBOXCALL   supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
    600600bool VBOXCALL   supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt);
     601int  VBOXCALL   supdrvOSEnableVTx(bool fEnabled);
    601602
    602603/*******************************************************************************
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r14825 r14901  
    261261        CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION;
    262262        const uint32_t MinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x000a0000
    263                                   ? 0x000a0006
     263                                  ? 0x000a0007
    264264                                  :  SUPDRV_IOC_VERSION & 0xffff0000;
    265265        CookieReq.u.In.u32MinVersion = MinVersion;
     
    400400        { "SUPR0Printf",                            0xefef000b },
    401401        { "SUPR0GetPagingMode",                     0xefef000c },
    402         { "SUPR0NativeEnableHwVirtExt",             0xefef000c },
     402        { "SUPR0EnableVTx",                         0xefef000c },
    403403        { "RTMemAlloc",                             0xefef000d },
    404404        { "RTMemAllocZ",                            0xefef000e },
  • trunk/src/VBox/HostDrivers/Support/SUPR0.def

    r14801 r14901  
    5454    SUPR0Printf
    5555    SUPR0GetPagingMode
    56     SUPR0NativeEnableHwVirtExt
     56    SUPR0EnableVTx
    5757    RTMemAlloc
    5858    RTMemAllocZ
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

    r13866 r14901  
    5454#include <iprt/process.h>
    5555#include <iprt/alloc.h>
    56 #include <iprt/err.h>
     56#include <VBox/err.h>
    5757#include <VBox/log.h>
    5858
     
    240240                if (g_iMajorDeviceNo >= 0)
    241241                {
    242                     /** @todo the UID, GID and mode mask should be configurable! This isn't very secure... */
    243242#ifdef VBOX_WITH_HARDENING
    244243                    g_hDevFsDevice = devfs_make_node(makedev(g_iMajorDeviceNo, 0), DEVFS_CHAR,
     
    662661
    663662
    664 bool VBOXCALL   supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt)
     663/*
     664 * The following is a weak symbol hack to deal with the lack of
     665 * host_vmxon & host_vmxoff in Tiger.
     666 */
     667static int g_fWeakHostVmxOnOff = false;
     668
     669__BEGIN_DECLS
     670int host_vmxon(int exclusive) __attribute__((weak));
     671void host_vmxoff(void) __attribute__((weak));
     672__END_DECLS
     673
     674/* weak version for Tiger. */
     675int host_vmxon(int exclusive)
     676{
     677    NOREF(exclusive);
     678    g_fWeakHostVmxOnOff = true;
     679    return 42;
     680}
     681
     682/* weak version for Tiger. */
     683void host_vmxoff(void)
     684{
     685    g_fWeakHostVmxOnOff = true;
     686}
     687
     688
     689/**
     690 * Enables or disables VT-x using kernel functions.
     691 *
     692 * @returns VBox status code. VERR_NOT_SUPPORTED has a special meaning.
     693 * @param   fEnable     Whether to enable or disable.
     694 */
     695int VBOXCALL supdrvOSEnableVTx(bool fEnable)
     696{
     697    if (g_fWeakHostVmxOnOff)
     698        return VERR_NOT_SUPPORTED;
     699
     700    int rc;
     701    if (fEnable)
     702    {
     703printf("calling host_vmxon\n");
     704        rc = host_vmxon(false /* exclusive */);
     705printf("host_vmxon: %d\n", rc);
     706        if (rc == 42)
     707            rc = VERR_NOT_SUPPORTED;
     708        else
     709        {
     710            AssertReturn(!g_fWeakHostVmxOnOff, VERR_NOT_SUPPORTED);
     711            if (rc == 0 /* all ok */)
     712                rc = VINF_SUCCESS;
     713            else if (rc == 1 /* unsupported */)
     714                rc = VERR_VMX_NO_VMX;
     715            else if (rc == 2 /* exclusive user */)
     716                rc = VERR_VMX_IN_VMX_ROOT_MODE;
     717            else
     718                rc = VERR_UNRESOLVED_ERROR;
     719        }
     720    }
     721    else
     722    {
     723printf("calling host_vmxoff\n");
     724        host_vmxoff();
     725printf("host_vmxoff returned\n");
     726        AssertReturn(!g_fWeakHostVmxOnOff, VERR_NOT_SUPPORTED);
     727        rc = VINF_SUCCESS;
     728    }
     729    return rc;
     730}
     731
     732
     733bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt)
    665734{
    666735    NOREF(pDevExt);
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