WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Avoid xen crash if there is no VMX support. If a platfor

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Avoid xen crash if there is no VMX support. If a platform
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 30 Dec 2005 18:22:06 +0000
Delivery-date: Fri, 30 Dec 2005 18:26:42 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 02cfa3beabba1de2b6dc864a71d10f0776c7aa99
# Parent  4299f983e8fe19187873062e1e2da32933f88292
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@xxxxxxxxx>

diff -r 4299f983e8fe -r 02cfa3beabba tools/libxc/xc_vmx_build.c
--- a/tools/libxc/xc_vmx_build.c        Fri Dec 30 16:02:30 2005
+++ b/tools/libxc/xc_vmx_build.c        Fri Dec 30 16:07:34 2005
@@ -574,29 +574,6 @@
     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 @@
     unsigned long nr_pages;
     char         *image = NULL;
     unsigned long image_size;
-
-    if ( vmx_identify() < 0 )
-    {
-        PERROR("CPU doesn't support VMX Extensions");
+    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 ( !strstr(xen_caps, "hvm") )
+    {
+        PERROR("CPU doesn't support VMX Extensions or "
+               "CPU VMX Extensions are not turned on");
         goto error_out;
     }
 
diff -r 4299f983e8fe -r 02cfa3beabba tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Fri Dec 30 16:02:30 2005
+++ b/tools/python/xen/xend/image.py    Fri Dec 30 16:07:34 2005
@@ -188,6 +188,10 @@
 
     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')
diff -r 4299f983e8fe -r 02cfa3beabba xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Fri Dec 30 16:02:30 2005
+++ b/xen/arch/x86/domain.c     Fri Dec 30 16:07:34 2005
@@ -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 @@
              ((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 )

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Avoid xen crash if there is no VMX support. If a platform, Xen patchbot -unstable <=