From: John Wolfe Date: Thu, 4 Mar 2021 21:48:46 +0000 (-0800) Subject: Common source file changes not applicable to open-vm-tools. X-Git-Tag: stable-11.3.0~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f28bea2dde358e4a12f90f4436d276d9c5e3be77;p=thirdparty%2Fopen-vm-tools.git Common source file changes not applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/include/backdoor_def.h b/open-vm-tools/lib/include/backdoor_def.h index 355e42b90..afe2392ef 100644 --- a/open-vm-tools/lib/include/backdoor_def.h +++ b/open-vm-tools/lib/include/backdoor_def.h @@ -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 /* diff --git a/open-vm-tools/lib/include/hostinfo.h b/open-vm-tools/lib/include/hostinfo.h index 6f7873885..f098f0217 100644 --- a/open-vm-tools/lib/include/hostinfo.h +++ b/open-vm-tools/lib/include/hostinfo.h @@ -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 diff --git a/open-vm-tools/lib/misc/hostinfoHV.c b/open-vm-tools/lib/misc/hostinfoHV.c index 0702efa1b..a3d59f3eb 100644 --- a/open-vm-tools/lib/misc/hostinfoHV.c +++ b/open-vm-tools/lib/misc/hostinfoHV.c @@ -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