aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-12-30 17:07:34 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-12-30 17:07:34 +0100
commit0129e126c463c8624316e816ee13726c95e166fa (patch)
tree54d6170557c14fa0f825f248082b042a0f9a3627
parente9ac3bbccab099e2079da5201a05a448da1978ce (diff)
downloadxen-0129e126c463c8624316e816ee13726c95e166fa.tar.gz
xen-0129e126c463c8624316e816ee13726c95e166fa.tar.bz2
xen-0129e126c463c8624316e816ee13726c95e166fa.zip
Avoid xen crash if there is no VMX support. If a platform
doesn't support VMX, creating VMX domain will crash xen HV. Signed-off-by: Xin Li <xin.b.li@intel.com>
-rw-r--r--tools/libxc/xc_vmx_build.c35
-rw-r--r--tools/python/xen/xend/image.py4
-rw-r--r--xen/arch/x86/domain.c3
3 files changed, 16 insertions, 26 deletions
diff --git a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c
index 9d0fbc18d5..e3a6c88b6e 100644
--- a/tools/libxc/xc_vmx_build.c
+++ b/tools/libxc/xc_vmx_build.c
@@ -574,29 +574,6 @@ static int setup_guest(int xc_handle,
return -1;
}
-#define VMX_FEATURE_FLAG 0x20
-
-static int vmx_identify(void)
-{
- int eax, ecx;
-
- __asm__ __volatile__ (
-#if defined(__i386__)
- "push %%ebx; cpuid; pop %%ebx"
-#elif defined(__x86_64__)
- "push %%rbx; cpuid; pop %%rbx"
-#endif
- : "=a" (eax), "=c" (ecx)
- : "0" (1)
- : "dx");
-
- if (!(ecx & VMX_FEATURE_FLAG)) {
- return -1;
- }
-
- return 0;
-}
-
int xc_vmx_build(int xc_handle,
uint32_t domid,
int memsize,
@@ -613,10 +590,18 @@ int xc_vmx_build(int xc_handle,
unsigned long nr_pages;
char *image = NULL;
unsigned long image_size;
+ xen_capabilities_info_t xen_caps;
+
+ if ( (rc = xc_version(xc_handle, XENVER_capabilities, &xen_caps)) != 0 )
+ {
+ PERROR("Failed to get xen version info");
+ goto error_out;
+ }
- if ( vmx_identify() < 0 )
+ if ( !strstr(xen_caps, "hvm") )
{
- PERROR("CPU doesn't support VMX Extensions");
+ PERROR("CPU doesn't support VMX Extensions or "
+ "CPU VMX Extensions are not turned on");
goto error_out;
}
diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py
index b8ebc7a2aa..94995213fe 100644
--- a/tools/python/xen/xend/image.py
+++ b/tools/python/xen/xend/image.py
@@ -189,6 +189,10 @@ class VmxImageHandler(ImageHandler):
def configure(self, imageConfig, deviceConfig):
ImageHandler.configure(self, imageConfig, deviceConfig)
+ info = xc.xeninfo()
+ if not 'hvm' in info['xen_caps']:
+ raise VmError("vmx: not an Intel VT platform, we stop creating!")
+
self.dmargs = self.parseDeviceModelArgs(imageConfig, deviceConfig)
self.device_model = sxp.child_value(imageConfig, 'device_model')
if not self.device_model:
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 850b88d141..2c89207e1b 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -35,7 +35,6 @@
#include <xen/console.h>
#include <xen/elf.h>
#include <asm/vmx.h>
-#include <asm/vmx_vmcs.h>
#include <asm/msr.h>
#include <asm/physdev.h>
#include <xen/kernel.h>
@@ -348,6 +347,8 @@ int arch_set_info_guest(
((c->user_regs.ss & 3) == 0) )
return -EINVAL;
}
+ else if ( !hvm_enabled )
+ return -EINVAL;
clear_bit(_VCPUF_fpu_initialised, &v->vcpu_flags);
if ( c->flags & VGCF_I387_VALID )