]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes in shared code that don't affect open-vm-tools functionality.
authorVMware, Inc <>
Wed, 24 Feb 2010 22:16:32 +0000 (14:16 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Wed, 24 Feb 2010 22:16:32 +0000 (14:16 -0800)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/include/hostinfo.h
open-vm-tools/lib/misc/hostinfoPosix.c

index 1586961bd97bc2f231edb752d39705c7bfc6c2b3..72c55edb091ed9b7cabbe48344514cf93b6ca011 100644 (file)
@@ -75,6 +75,7 @@ extern Bool Hostinfo_OSIsWow64(void);
 #endif
 extern Bool Hostinfo_NestingSupported(void);
 extern Bool Hostinfo_TouchBackDoor(void);
+extern Bool Hostinfo_TouchVirtualPC(void);
 extern Bool Hostinfo_TouchXen(void);
 extern char *Hostinfo_HypervisorCPUIDSig(void);
 
index b72ce93221dff3528c7cbf1d7df8b3ac9aceeb91..53a7b1948cc75ef4978901c7864349ac1e58b022 100644 (file)
@@ -1680,6 +1680,57 @@ Hostinfo_TouchBackDoor(void)
 }
 
 
+/*
+ *----------------------------------------------------------------------
+ *
+ *  Hostinfo_TouchVirtualPC --
+ *
+ *      Access MS Virtual PC's backdoor. This is used to determine if 
+ *      we are running in a MS Virtual PC or on a physical host.  Works
+ *      the same as Hostinfo_TouchBackDoor, except the entry to MS VPC
+ *      is an invalid opcode instead or writing to a port.  Since
+ *      MS VPC is 32-bit only, the 64-bit path returns FALSE.
+ *      See: http://www.codeproject.com/KB/system/VmDetect.aspx
+ *
+ * Results:
+ *      TRUE if we succesfully accessed MS Virtual PC, FALSE or 
+ *      segfault if not.
+ *
+ * Side effects:
+ *      Exception if not in a VM.
+ *
+ *----------------------------------------------------------------------
+ */
+
+Bool
+Hostinfo_TouchVirtualPC(void)
+{
+#if defined vm_x86_64
+   return FALSE;
+#else
+
+   uint32 ebxval;
+
+   __asm__ __volatile__ (
+#  if defined __PIC__        // %ebx is reserved by the compiler.
+     "xchgl %%ebx, %1" "\n\t"
+     ".long 0x0B073F0F" "\n\t"
+     "xchgl %%ebx, %1"
+     : "=&rm" (ebxval)
+     : "a" (1),
+       "0" (0)
+#  else
+     ".long 0x0B073F0F"
+     : "=b" (ebxval)
+     : "a" (1),
+       "b" (0)
+#  endif
+  );
+  return !ebxval; // %%ebx is zero if inside Virtual PC
+#endif
+}
+
+
 /*
  *----------------------------------------------------------------------
  *