]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Common source file changes not applicable to open-vm-tools.
authorJohn Wolfe <jwolfe@vmware.com>
Thu, 4 Mar 2021 21:48:46 +0000 (13:48 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Thu, 4 Mar 2021 21:48:46 +0000 (13:48 -0800)
open-vm-tools/lib/include/backdoor_def.h
open-vm-tools/lib/include/hostinfo.h
open-vm-tools/lib/misc/hostinfoHV.c

index 355e42b9076a5c0abd750003fb614ab8b70cee97..afe2392ef519f507dcd0c9dd3210f2dca86f54b5 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -274,7 +274,8 @@ extern "C" {
 #  define BDOOR_CMD_PRECISIONCLOCK_NUMCMDS    4
 #define   BDOOR_CMD_COREDUMP_UNSYNC          98 /* Devel only. For VMM cores */
 #define   BDOOR_CMD_APPLE_GPU_RES_SET        99
-#define   BDOOR_CMD_MAX                     100
+#define   BDOOR_CMD_GETBUILDNUM             100
+#define   BDOOR_CMD_MAX                     101
 
 
 /*
index 6f7873885f9f74e62a340a95fbde714fe1724431..f098f0217e06398246b471ced6efea76674434db 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -163,6 +163,7 @@ Bool Hostinfo_TouchXen(void);
 char *Hostinfo_HypervisorCPUIDSig(void);
 void Hostinfo_LogHypervisorCPUID(void);
 char *Hostinfo_HypervisorInterfaceSig(void);
+uint32 Hostinfo_GetNestedBuildNum(void);
 
 #define HGMP_PRIVILEGE    0
 #define HGMP_NO_PRIVILEGE 1
index 0702efa1b75df8770284107f16d829b808d29042..a3d59f3eb237247a1bd7b19da41db05ece995e45 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2011-2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2021 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -681,6 +681,56 @@ Hostinfo_VCPUInfoBackdoor(unsigned bit)
 }
 
 
+/*
+ *----------------------------------------------------------------------
+ *
+ *  Hostinfo_GetNestedBuildNum --
+ *
+ *      Perform a backdoor call to query the build number of the
+ *      outer VMware hypervisor.
+ *
+ * Results:
+ *      The build number of the outer VMware hypervisor, or -1 if
+ *      the backdoor call is not supported.
+ *
+ * Side effects:
+ *      Exception if not in a VM, so don't do that!
+ *
+ *----------------------------------------------------------------------
+ */
+
+uint32
+Hostinfo_GetNestedBuildNum(void)
+{
+   uint32 cmd = BDOOR_CMD_GETBUILDNUM;
+   int32 result;
+
+#if defined(_WIN64)
+   Backdoor_proto bp;
+
+   bp.in.ax.quad = BDOOR_MAGIC;
+   bp.in.cx.quad = cmd;
+   bp.in.dx.quad = BDOOR_PORT;
+
+   Hostinfo_BackdoorInOut(&bp);
+
+   result = bp.out.ax.words.low;
+#else
+   _asm {
+         push edx
+         push ecx
+         mov ecx, cmd
+         mov eax, BDOOR_MAGIC
+         mov dx, BDOOR_PORT
+         in eax, dx
+         mov result, eax
+         pop ecx
+         pop edx
+   }
+#endif
+   return result;
+}
+
 #else // !defined(_WIN32)
 
 /*
@@ -921,5 +971,48 @@ Hostinfo_VCPUInfoBackdoor(unsigned bit)
    return FALSE;
 }
 
+
+/*
+ *----------------------------------------------------------------------
+ *
+ *  Hostinfo_GetNestedBuildNum --
+ *
+ *      Perform a backdoor call to query the build number of the
+ *      outer VMware hypervisor.
+ *
+ * Results:
+ *      The build number of the outer VMware hypervisor, or -1 if
+ *      the backdoor call is not supported.
+ *
+ * Side effects:
+ *      Exception if not in a VM, so don't do that!
+ *
+ *----------------------------------------------------------------------
+ */
+
+uint32
+Hostinfo_GetNestedBuildNum(void)
+{
+#if defined(__i386__) || defined(__x86_64__)
+   uint32 result;
+   uint32 cmd = BDOOR_CMD_GETBUILDNUM;
+
+   switch (HostinfoBackdoorGetInterface()) {
+#  if defined(USE_HYPERCALL)
+   case BACKDOOR_INTERFACE_VMCALL:
+      Vmcall(cmd, result);
+      break;
+   case BACKDOOR_INTERFACE_VMMCALL:
+      Vmmcall(cmd, result);
+      break;
+#  endif
+   default:
+      Ioportcall(cmd, result);
+      break;
+   }
+   return result;
+#endif
+   return 0;
+}
 #endif