VirtualBox

Changeset 22615 in vbox


Ignore:
Timestamp:
Aug 31, 2009 3:59:02 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
51675
Message:

refined r51666

Location:
trunk
Files:
11 edited

Legend:

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

    r22609 r22615  
    926926SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod);
    927927
     928
     929/**
     930 * Check if the host kernel can run in VMX root mode.
     931 *   
     932 * @returns VINF_SUCCESS if supported, error code indicating why if not.
     933 */
     934SUPR3DECL(int) SUPR3QueryVTxSupported(void);
     935
     936
    928937/** @} */
    929938#endif /* IN_RING3 */
     
    9951004SUPR0DECL(SUPPAGINGMODE) SUPR0GetPagingMode(void);
    9961005SUPR0DECL(int) SUPR0EnableVTx(bool fEnable);
    997 SUPR0DECL(int) SUPR0QueryVTxSupport(void);
    9981006
    9991007/** @name Absolute symbols
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r22609 r22615  
    352352    { "SUPR0GetPagingMode",                     (void *)UNWIND_WRAP(SUPR0GetPagingMode) },
    353353    { "SUPR0EnableVTx",                         (void *)SUPR0EnableVTx },
    354     { "SUPR0QueryVTxSupport",                   (void *)SUPR0QueryVTxSupport },
    355354    { "RTMemAlloc",                             (void *)UNWIND_WRAP(RTMemAlloc) },
    356355    { "RTMemAllocZ",                            (void *)UNWIND_WRAP(RTMemAllocZ) },
     
    47954794
    47964795/**
    4797  * Check if the host kernel can run in VMX root mode.
    4798  *
    4799  * @returns VINF_SUCCESS if supported, error code indicating why if not.
    4800  */
    4801 SUPR0DECL(int) SUPR0QueryVTxSupport(void)
    4802 {
    4803 #ifdef RT_OS_LINUX
    4804     return supdrvOSQueryVTxSupport();
    4805 #else
    4806     return VINF_SUCCESS;
    4807 #endif
    4808 }
    4809 
    4810 
    4811 /**
    48124796 * Creates the GIP.
    48134797 *
  • trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h

    r22609 r22615  
    197197 *          - Nothing.
    198198 */
    199 #define SUPDRV_IOC_VERSION                              0x000f0001
     199#define SUPDRV_IOC_VERSION                              0x000f0000
    200200
    201201/** SUP_IOCTL_COOKIE. */
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r22609 r22615  
    632632bool VBOXCALL   supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt);
    633633int  VBOXCALL   supdrvOSEnableVTx(bool fEnabled);
    634 int  VBOXCALL   supdrvOSQueryVTxSupport(void);
    635634
    636635/*******************************************************************************
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r22609 r22615  
    273273        CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION;
    274274        const uint32_t MinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x000f0000
    275                                   ?  0x000f0001
     275                                  ?  0x000f0000
    276276                                  :  SUPDRV_IOC_VERSION & 0xffff0000;
    277277        CookieReq.u.In.u32MinVersion = MinVersion;
     
    413413        { "SUPR0Printf",                            0xefef000b },
    414414        { "SUPR0GetPagingMode",                     0xefef000c },
    415         { "SUPR0QueryVTxSupport",                   0xefef000d },
    416415        { "SUPR0EnableVTx",                         0xefef000e },
    417416        { "RTMemAlloc",                             0xefef000f },
     
    20572056}
    20582057
     2058
     2059SUPR3DECL(int) SUPR3QueryVTxSupported(void)
     2060{
     2061#ifdef RT_OS_LINUX
     2062    return suplibOsQueryVTxSupported();
     2063#else
     2064    return VINF_SUCCESS;
     2065#endif
     2066}
  • trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h

    r20864 r22615  
    251251int     suplibOsPageAlloc(PSUPLIBDATA pThis, size_t cPages, void **ppvPages);
    252252int     suplibOsPageFree(PSUPLIBDATA pThis, void *pvPages, size_t cPages);
     253int     suplibOsQueryVTxSupported(void);
    253254
    254255
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r22609 r22615  
    10061006
    10071007/**
    1008  * Check if the host kernel supports VT-x or not.
    1009  *
    1010  * Older Linux kernels clear the VMXE bit in the CR4 register (function
    1011  * tlb_flush_all()) leading to a host kernel panic.
    1012  *
    1013  * @returns VBox error code
    1014  */
    1015 int VBOXCALL supdrvOSQueryVTxSupport(void)
    1016 {
    1017 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
    1018     return VINF_SUCCESS;
    1019 #else
    1020     return VERR_SUPDRV_KERNEL_TOO_OLD_FOR_VTX;
    1021 #endif
    1022 }
    1023 
    1024 
    1025 /**
    10261008 * Converts a supdrv error code to an linux error code.
    10271009 *
  • trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp

    r16446 r22615  
    5656#include <VBox/types.h>
    5757#include <iprt/string.h>
     58#include <iprt/system.h>
    5859#include <VBox/err.h>
    5960#include <VBox/param.h>
     
    254255#endif /* !IN_SUP_HARDENED_R3 */
    255256
     257
     258/** Check if the host kernel supports VT-x or not.
     259 *
     260 * Older Linux kernels clear the VMXE bit in the CR4 register (function
     261 * tlb_flush_all()) leading to a host kernel panic.
     262 */
     263int suplibOsQueryVTxSupported(void)
     264{
     265    char szBuf[256];
     266    int rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szBuf, sizeof(szBuf));
     267
     268    if (RT_SUCCESS(rc))
     269    {
     270        char *pszNext;
     271        uint32_t uA, uB, uC;
     272
     273        rc = RTStrToUInt32Ex(szBuf, &pszNext, 10, &uA);
     274        if (   RT_SUCCESS(rc)
     275                && *pszNext == '.')
     276        {
     277            rc = RTStrToUInt32Ex(pszNext+1, &pszNext, 10, &uB);
     278            if (   RT_SUCCESS(rc)
     279                    && *pszNext == '.')
     280            {
     281                rc = RTStrToUInt32Ex(pszNext+1, &pszNext, 10, &uC);
     282                if (RT_SUCCESS(rc))
     283                {
     284                    uint32_t uLinuxVersion = (uA << 16) + (uB << 8) + uC;
     285                    if (uLinuxVersion >= (2 << 16) + (6 << 8) + 32)
     286                        return VINF_SUCCESS;
     287                }
     288            }
     289        }
     290    }
     291
     292    return VERR_SUPDRV_KERNEL_TOO_OLD_FOR_VTX;
     293}
  • trunk/src/VBox/Main/HostImpl.cpp

    r22609 r22615  
    135135#include <VBox/err.h>
    136136#include <VBox/settings.h>
     137#include <VBox/sup.h>
    137138
    138139#include <stdio.h>
     
    236237               )
    237238            {
    238 #ifdef RT_OS_LINUX
    239                 /* Linux: VT-x is not supported on Linux < 2.6.13 because older kernels
    240                  * unconditionally disable the VMXE flag */
    241                 char szBuf[64];
    242                 int rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szBuf, sizeof(szBuf));
    243 
     239                int rc = SUPR3QueryVTxSupported();
    244240                if (RT_SUCCESS(rc))
    245                 {
    246                     char *pszNext;
    247                     uint32_t uA, uB, uC;
    248 
    249                     rc = RTStrToUInt32Ex(szBuf, &pszNext, 10, &uA);
    250                     if (   RT_SUCCESS(rc)
    251                         && *pszNext == '.')
    252                     {
    253                         rc = RTStrToUInt32Ex(pszNext+1, &pszNext, 10, &uB);
    254                         if (   RT_SUCCESS(rc)
    255                             && *pszNext == '.')
    256                         {
    257                             rc = RTStrToUInt32Ex(pszNext+1, &pszNext, 10, &uC);
    258                             if (RT_SUCCESS(rc))
    259                             {
    260                                 uint32_t uLinuxVersion = (uA << 16) + (uB << 8) + uC;
    261                                 if (uLinuxVersion >= (2 << 16) + (6 << 8) + 13)
    262                                     fVTxAMDVSupported = true;
    263                             }
    264                         }
    265                     }
    266                 }
    267 #else
    268                 fVTxAMDVSupported = true;
    269 #endif
     241                    fVTxAMDVSupported = true;
    270242            }
    271243        }
  • trunk/src/VBox/VMM/HWACCM.cpp

    r22493 r22615  
    638638    }
    639639
     640    if (pVM->hwaccm.s.vmx.fSupported)
     641    {
     642        rc = SUPR3QueryVTxSupported();
     643        if (RT_FAILURE(rc))
     644        {
     645#ifdef RT_OS_LINUX
     646            LogRel(("HWACCM: The host kernel does not support VT-x -- Linux 2.6.13 or newer required!\n"));
     647#else
     648            LogRel(("HWACCM: The host kernel does not support VT-x!\n"));
     649#endif
     650            return VINF_SUCCESS;
     651        }
     652    }
     653
    640654    if (!pVM->hwaccm.s.fAllowed)
    641655        return VINF_SUCCESS;    /* nothing to do */
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp

    r22609 r22615  
    603603            int     aRc[RTCPUSET_MAX_CPUS];
    604604            RTCPUID idCpu = 0;
    605 
    606             rc = SUPR0QueryVTxSupport();
    607             if (RT_FAILURE(rc))
    608                 return rc;
    609605
    610606            memset(aRc, 0, sizeof(aRc));
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette