From: VMware, Inc <> Date: Wed, 24 Feb 2010 22:16:32 +0000 (-0800) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2010.02.23-236320~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8f6145eb4d845be1fcf170e3a8f23fc03965871;p=thirdparty%2Fopen-vm-tools.git Changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/include/hostinfo.h b/open-vm-tools/lib/include/hostinfo.h index 1586961bd..72c55edb0 100644 --- a/open-vm-tools/lib/include/hostinfo.h +++ b/open-vm-tools/lib/include/hostinfo.h @@ -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); diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index b72ce9322..53a7b1948 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -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 +} + + /* *---------------------------------------------------------------------- *