SUPDrvAgnostic.c revision 623f56b78e24ab3154f4a00c7bc8bb43579878c5
/* $Revision$ */
/** @file
* VBoxDrv - The VirtualBox Support Driver - Common OS agnostic.
*/
/*
* Copyright (C) 2006-2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_SUP_DRV
#define SUPDRV_AGNOSTIC
#include "SUPDrvInternal.h"
/** @todo trim this down. */
#include <iprt/handletable.h>
#include <iprt/semaphore.h>
#include <iprt/spinlock.h>
#include <VBox/hwacc_svm.h>
#include <VBox/hwacc_vmx.h>
/**
* Internal worker for SUPR0QueryVTCaps.
*
* @returns See QUPR0QueryVTCaps.
* @param pfCaps See QUPR0QueryVTCaps
*/
{
*pfCaps = 0;
if (ASMHasCpuId())
{
/* Query AMD features. */
)
{
if ( (u32FeaturesECX & X86_CPUID_FEATURE_ECX_VMX)
)
{
/*
* Both the LOCK and VMXON bit must be set; otherwise VMXON will generate a #GP.
* Once the lock bit is set, this MSR can no longer be modified.
*/
)
{
*pfCaps |= SUPVTCAPS_VT_X;
{
}
return VINF_SUCCESS;
}
return VERR_VMX_MSR_LOCKED_OR_DISABLED;
}
return VERR_VMX_NO_VMX;
}
if ( u32VendorEBX == X86_CPUID_VENDOR_AMD_EBX
)
{
)
{
/* Check if SVM is disabled */
if (!(val & MSR_K8_VM_CR_SVM_DISABLE))
{
*pfCaps |= SUPVTCAPS_AMD_V;
/* Query AMD features. */
return VINF_SUCCESS;
}
return VERR_SVM_DISABLED;
}
return VERR_SVM_NO_SVM;
}
}
return VERR_UNSUPPORTED_CPU;
}