From: Don Slutz <dslutz@verizon.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
Don Slutz <dslutz@verizon.com>,
xen-devel@lists.xen.org
Cc: Kevin Tian <kevin.tian@intel.com>, Keir Fraser <keir@xen.org>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Eddie Dong <eddie.dong@intel.com>,
Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>,
Jan Beulich <jbeulich@suse.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Subject: Re: [PATCH for-4.5 v6 01/16] xen: Add support for VMware cpuid leaves
Date: Mon, 22 Sep 2014 12:53:28 -0400 [thread overview]
Message-ID: <54205408.30901@terremark.com> (raw)
In-Reply-To: <54200CB0.80409@citrix.com>
On 09/22/14 07:49, Andrew Cooper wrote:
> On 20/09/14 19:07, Don Slutz wrote:
>> This is done by adding HVM_PARAM_VMWARE_HW. It is set to the VMware
>> virtual hardware version.
>>
>> Currently 0, 3-4, 6-11 are good values. However the
>> code only checks for == 0 or != 0.
>>
Sigh, need to fix this statement, 7 is now checked for.
...
>> @@ -5692,6 +5701,29 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
>>
>> break;
>> }
>> + case HVM_PARAM_VMWARE_HW:
>> + /*
>> + * This should only ever be set non-zero one time by
>> + * the tools and is read only by the guest.
>> + */
>> + if ( d == current->domain )
> curr_d instead of current->domain
Will do.
>> + {
>> + rc = -EPERM;
>> + break;
>> + }
>> + if ( d->arch.hvm_domain.params[HVM_PARAM_VIRIDIAN] )
>> + {
>> + rc = -EXDEV;
>> + break;
>> + }
>> + if ( d->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW] &&
> This check is redundant. Repeatedly setting 0 is still permitted
> because of the break after this if().
No at all sure this is right. If it is set to 7, setting to 0 is not
allowed. Which is
what this if is checking for. This also allow multiple setting to 7
without error.
But setting to 7 and then 8 is not allowed.
>> + d->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW] !=
>> + a.value )
>> + {
>> + rc = -EEXIST;
>> + break;
>> + }
>> + break;
>> }
>>
>> +/*
>> + * VMware hardware version 7 defines some of these cpuid levels,
>> + * below is a brief description about those.
>> + *
>> + * Leaf 0x40000000, Hypervisor CPUID information
>> + * # EAX: The maximum input value for hypervisor CPUID info (0x40000010).
>> + * # EBX, ECX, EDX: Hypervisor vendor ID signature. E.g. "VMwareVMware"
>> + *
>> + * Leaf 0x40000010, Timing information.
>> + * # EAX: (Virtual) TSC frequency in kHz.
>> + * # EBX: (Virtual) Bus (local apic timer) frequency in kHz.
>> + * # ECX, EDX: RESERVED
>> + */
>> +
>> +int cpuid_vmware_leaves(uint32_t idx, uint32_t *eax, uint32_t *ebx,
>> + uint32_t *ecx, uint32_t *edx)
>> +{
>> + struct domain *d = current->domain;
>> +
>> + if ( !is_vmware_domain(d) )
>> + return 0;
>> +
>> + switch ( idx - 0x40000000 )
>> + {
>> + case 0x0:
>> + if ( d->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW] >= 7 )
> You are going to need some reference about VMWare versions. The comment
> for this function is fine for describing what "version 7" constitutes,
> but how did you come about it? What is supposed to be visible in the
> leaves of a version less than 7 is selected by the toolstack, because I
> doubt its all zeroes including the root leaf?
I was unable to find any clear statements on the VMware web site. This
statement (from 2008)
can be found via google. The best statement is from:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458
(Which is listed in the commit message). I have included part of that
page here:
...
Testing the CPUID hypervisor present bit
Intel and AMD CPUs have reserved bit 31 of ECX of CPUID leaf 0x1 as the
hypervisor present bit. This bit allows hypervisors to indicate their
presence to the guest operating system. Hypervisors set this bit and
physical CPUs (all existing and future CPUs) set this bit to zero. Guest
operating systems can test bit 31 to detect if they are running inside a
virtual machine.
Intel and AMD have also reserved CPUID leaves 0x40000000 - 0x400000FF
for software use. Hypervisors can use these leaves to provide an
interface to pass information from the hypervisor to the guest operating
system running inside a virtual machine. The hypervisor bit indicates
the presence of a hypervisor and that it is safe to test these
additional software leaves. VMware defines the 0x40000000 leaf as the
hypervisor CPUID information leaf. Code running on a VMware hypervisor
can test the CPUID information leaf for the hypervisor signature. VMware
stores the string "VMwareVMware" in EBX, ECX, EDX of CPUID leaf 0x40000000.
*Sample code*
int cpuid_check()
{
unsigned int eax, ebx, ecx, edx;
char hyper_vendor_id[13];
cpuid(0x1, &eax, &ebx, &ecx, &edx);
if (bit 31 of ecx is set) {
cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
memcpy(hyper_vendor_id + 0, &ebx, 4);
memcpy(hyper_vendor_id + 4, &ecx, 4);
memcpy(hyper_vendor_id + 8, &edx, 4);
hyper_vendor_id[12] = '\0';
if (!strcmp(hyper_vendor_id, "VMwareVMware"))
return 1; // Success - running under VMware
}
return 0;
}
Testing the virtual BIOS DMI information and the hypervisor port
Apart from the CPUID-based method for VMware virtual machine detection,
VMware also provides a fallback mechanism for the following reasons:
* This CPUID-based technique will not work for guest code running at
CPL3 when VT/AMD-V is not available or not enabled.
* The hypervisor present bit and hypervisor information leaf are only
defined for products based on VMware hardware version 7.
Virtual BIOS DMI information
The VMware virtual BIOS has many VMware-specific identifiers which
programs can use to detect hypervisors. For the DMI string check, use
the BIOS serial number and check for either string "VMware-" or "VMW"
(for Mac OS X guests running on Fusion)
...
I tested it for 3, 4, 7, and 8 (the versions that I have easy access to)
and 3 & 4 are all zero
(including root leaf) and 7 & 8 follow the above.
I just noticed that bit 31 of ECX of CPUID leaf 0x1 should also be zero
(not yet tested) for
vmware_hw < 7. Not at all sure what happens if I do this.
The best web pages I have found are:
http://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.vsphere.vm_admin.doc%2FGUID-789C3913-1053-4850-A0F0-E29C3D32B6DA.html
Which is all about other features like "Max number of cores", etc.
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2007240
Which is about what VMware products can use what versions.
(I can add these to the commit message; they do give some clues about
vmware_hw
but none of which apply to the code in Xen.)
-Don Slutz
> ~Andrew
>
>
next prev parent reply other threads:[~2014-09-22 16:53 UTC|newest]
Thread overview: 93+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-20 18:07 [PATCH for-4.5 v6 00/16] Xen VMware tools support Don Slutz
2014-09-20 18:07 ` [PATCH for-4.5 v6 01/16] xen: Add support for VMware cpuid leaves Don Slutz
2014-09-22 11:49 ` Andrew Cooper
2014-09-22 16:53 ` Don Slutz [this message]
2014-09-24 14:33 ` George Dunlap
2014-09-20 18:07 ` [PATCH for-4.5 v6 02/16] tools: Add vmware_hw support Don Slutz
2014-09-22 13:34 ` Ian Campbell
2014-09-22 22:08 ` Don Slutz
2014-09-24 14:44 ` George Dunlap
2014-09-24 21:06 ` Don Slutz
2014-09-20 18:07 ` [PATCH for-4.5 v6 03/16] vmware: Add VMware provided include files Don Slutz
2014-09-20 18:07 ` [PATCH for-4.5 v6 04/16] xen: Add vmware_port support Don Slutz
2014-09-23 17:16 ` Boris Ostrovsky
2014-09-24 8:28 ` Jan Beulich
2014-09-26 19:09 ` Don Slutz
2014-09-24 16:01 ` George Dunlap
2014-09-24 16:48 ` Don Slutz
2014-09-24 17:42 ` Andrew Cooper
2014-09-20 18:07 ` [PATCH for-4.5 v6 05/16] tools: " Don Slutz
2014-09-22 13:41 ` Ian Campbell
2014-09-22 16:34 ` Andrew Cooper
2014-09-22 21:22 ` Don Slutz
2014-09-24 16:24 ` George Dunlap
2014-09-24 18:25 ` Don Slutz
2014-09-22 16:42 ` Don Slutz
2014-09-23 12:20 ` Ian Campbell
2014-09-24 16:31 ` Don Slutz
2014-09-24 16:44 ` George Dunlap
2014-09-24 18:29 ` Don Slutz
2014-09-25 11:24 ` Ian Campbell
2014-09-25 14:17 ` George Dunlap
2014-09-25 14:21 ` Ian Campbell
2014-09-26 19:19 ` Don Slutz
2014-09-20 18:07 ` [PATCH for-4.5 v6 06/16] xen: Convert vmware_port to xentrace usage Don Slutz
2014-09-24 17:27 ` George Dunlap
2014-09-24 19:07 ` Don Slutz
2014-09-25 15:14 ` George Dunlap
2014-09-29 18:10 ` Don Slutz
2014-09-20 18:07 ` [PATCH for-4.5 v6 07/16] tools: " Don Slutz
2014-09-25 15:18 ` George Dunlap
2014-09-20 18:07 ` [PATCH for-4.5 v6 08/16] xen: Add limited support of VMware's hyper-call rpc Don Slutz
2014-09-22 13:47 ` Ian Campbell
2014-09-22 21:18 ` Don Slutz
2014-09-23 12:34 ` Ian Campbell
2014-09-23 22:03 ` Slutz, Donald Christopher
2014-09-25 16:28 ` George Dunlap
2014-09-20 18:07 ` [PATCH for-4.5 v6 09/16] tools: " Don Slutz
2014-09-22 13:52 ` Ian Campbell
2014-09-22 21:32 ` Don Slutz
2014-09-23 12:35 ` Ian Campbell
2014-09-20 18:07 ` [PATCH for-4.5 v6 10/16] Add VMware tool's triggers Don Slutz
2014-09-20 18:07 ` [PATCH for-4.5 v6 11/16] Add live migration of VMware's hyper-call RPC Don Slutz
2014-09-20 18:07 ` [PATCH for-4.5 v6 12/16] Add dump of HVM_SAVE_CODE(VMPORT) to xen-hvmctx Don Slutz
2014-09-20 18:07 ` [OPTIONAL][PATCH for-4.5 v6 13/16] Add xen-hvm-param Don Slutz
2014-09-20 18:07 ` [OPTIONAL][PATCH for-4.5 v6 14/16] Add xen-vmware-guestinfo Don Slutz
2014-09-20 18:07 ` [OPTIONAL][PATCH for-4.5 v6 15/16] Add xen-list-vmware-guestinfo Don Slutz
2014-09-20 18:07 ` [OPTIONAL][PATCH for-4.5 v6 16/16] Add xen-hvm-send-trigger Don Slutz
2014-09-22 13:56 ` [PATCH for-4.5 v6 00/16] Xen VMware tools support Ian Campbell
2014-09-22 15:19 ` George Dunlap
2014-09-22 15:34 ` Ian Campbell
2014-09-22 15:38 ` George Dunlap
2014-09-22 15:50 ` Ian Campbell
2014-09-22 15:55 ` George Dunlap
2014-09-22 17:19 ` Don Slutz
2014-09-22 22:00 ` Tian, Kevin
2014-09-23 12:30 ` Ian Campbell
2014-09-23 12:35 ` George Dunlap
2014-09-23 12:40 ` Ian Campbell
2014-09-24 15:52 ` George Dunlap
2014-09-24 18:09 ` Don Slutz
2014-09-24 17:19 ` Don Slutz
2014-09-24 20:21 ` Konrad Rzeszutek Wilk
2014-09-26 19:03 ` Don Slutz
2014-09-26 19:28 ` Konrad Rzeszutek Wilk
2014-09-25 11:35 ` Ian Campbell
2014-09-22 16:18 ` Jan Beulich
2014-09-22 18:32 ` Don Slutz
2014-09-25 10:37 ` Tim Deegan
2014-09-26 20:00 ` Don Slutz
2014-09-29 6:50 ` Jan Beulich
2014-09-29 13:27 ` George Dunlap
2014-09-29 13:49 ` Jan Beulich
2014-09-29 23:13 ` Don Slutz
2014-09-30 7:05 ` Jan Beulich
2014-09-30 10:02 ` George Dunlap
2014-09-30 22:11 ` Slutz, Donald Christopher
2014-09-30 10:09 ` George Dunlap
2014-09-30 22:23 ` Slutz, Donald Christopher
2014-10-02 10:05 ` Tim Deegan
2014-10-02 19:20 ` Don Slutz
2014-10-03 7:09 ` Tim Deegan
2014-09-22 15:52 ` Andrew Cooper
2014-09-22 18:39 ` Don Slutz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54205408.30901@terremark.com \
--to=dslutz@verizon.com \
--cc=Aravind.Gopalakrishnan@amd.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=eddie.dong@intel.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=keir@xen.org \
--cc=kevin.tian@intel.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).