Skip to contentSkip to conversation

Xen VMware tools support

PATCH Superseded Don Slutz 7 participants 32 messages Sep 8, 2014 – Sep 20, 2014

v3 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Don Slutz

author
#0 lore raw

v3 cover Xen VMware tools support

Changes v2 to v3:

Add optional unit test tools.
Re-worked split of changes.

Jan Beulich:
for #0:
I don't think you should be adding a new fine in hvm/ _and_ a new subdirectory.
Moved all files to hvm/vmware that contain code.
for old #1 (now #1 & #2):
Is there really a point in enabling both Viridian and VMware extensions?
I still think so.
hvmloader change: This needs an explanation
Dropped as not need now.
Can you make vmware_hw similar to Viridian, returning success when setting the value to what it already is.
Done.
You don't seem to be using sub_idx: ...
Dropped.
Extra changes...
Dropped.
for old #2 (now #3):
... these guards have the (theoretical at this point) risk of clashing ... the patch is obviously incomplete without this header...
Did not fix any of these issues. I will stick with this needs to be a 2nd patch that changes the include files to better fit in Xen coding. For now these files are in a sub directory which is not part of the normal include search.
Moved the includeCheck.h file into this patch.
for old #3 (now #4, #5, #6, #7, #8, #9, #10, #11)
As I think was said on v1 already - this should be split into smaller pieces ...
Done.
All this would very likely better go into a separate function placed in vmport.c.
Moved most of the code into vmport.c or vmport_rpc.c.
In any event I'm rather uncomfortable about vmware_port getting enabled unconditionally, ...
Added vmware_port (done in new patches #4, #5) as an xl.cfg option.
You'll have to go through and fix coding style issues.
I think I have found all these, but since they do not stand out for me, let me know of any left.
"MAKE_INSTR(IN," name is ambiguous.
Added all 4 opcodes for in and out that can access this port: INB_DX, INL_DX, OUTB_DX, OUTL_DX.
A VMX-specific function shouldn't be named this way...
Added new common routine vmport_gp_check() that is called from both vmx.c and svm.c which is where all the logic about checking for IN ans OUT is done.
Also fixed naming and added static.
Ah, here we go (as to using HVM_DBG_LOG()): Isn't this _way_ too fine grained?
I have reduced the number of bits used. Partialy by switching some to xentrace (new patch #6 and #7).
Right, and zero is an indication that it wasn't found. Also I just noticed there's a gdprintk() in that event, which for all other ...
Made the gdprintk() optional.

End of v3 changes.

This is a small part of the changes needed to allow running Linux and windows (and others) guests that were built on VMware and run run them unchanged on Xen.

This small part is the start of Xen support of VMware backdoor I/O port which is how VMware tools (a standard addition installed on a guest) communicates to the hypervisor.

I picked this subset to start with because it only has changes in Xen.

Some of this code is already in QEMU and so KVM has some of this already. QEMU supported backdoor commands include VMware mouse support. A later patch set exists that links these changes, new code and Xen changes to QEMU to provide VMware mouse support under Xen. The important part is that VMware mouse is an absolute position mouse and so network delays do not effect usage of the virtual mouse.

For example from the guest:

[root@C63-min-tools ~]# vmtoolsd --cmd "info-get guestinfo.joejoel" No value found
[root@C63-min-tools ~]# vmtoolsd --cmd "info-set guestinfo.joejoel short"

[root@C63-min-tools ~]# vmtoolsd --cmd "info-get guestinfo.joejoel"
short
[root@C63-min-tools ~]# vmtoolsd --cmd "info-set guestinfo.joejoel long222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000joel"

[root@C63-min-tools ~]# vmtoolsd --cmd "info-get guestinfo.key1" data1
[root@C63-min-tools ~]# vmtoolsd --cmd "info-get guestinfo.key2" No value found
[root@C63-min-tools ~]# vmtoolsd --cmd "info-get guestinfo.key2" data2
[root@C63-min-tools ~]#

Most of this code has been reverse engineered by looking at source code for Linux and open VMware tools.

http://open-vm-tools.sourceforge.net

changes RFC to v2:

Jan Beulich:
Add xen/arch/x86/hvm/vmware.c for cpuid_vmware_leaves Fewer patches

Andrew Cooper:
use the proper constant for apic_khz
Follow 839b966e3f587bbb1a0d954230fb3904330dccb6 style changes. Changed HVM_PARAM_VMWARE_HW to write once (make is_vmware_domain()
more static).
Dropped vmport status stuff.
Added checks for xzalloc() having failed.
You should include backdoor_def.h ...
Every thing I tried did not work better. So I did not change VMPORT_PORT and BDOOR_PORT being the same value. I did not try and adjust VMware's include file backdoor_def.h to working in other xen source files.
Switching to s_time_t is not valid. get_sec() is defined:

    unsigned long get_sec(void);

and so my uses of it should be using unsigned long. However since that is not a fixed width type, I used the uint64_t data type which is almost the same, but does allow the 32 bit build of libxc, libxl to do the correct thing.

Konrad Rzeszutek Wilk:
Please don't include the address. It should be, etc
about the Vmware provided include files.
I went with no changes to these files. Even if the files should be changed to match xen coding style, etc I still feel that the original ones should be added via a patch, and then adjusted in a 2nd patch.
Can you use XenBus?
I would say no. XenBus (and XenStore) is about domain to domain communication. This is about VMware's hyper-call and providing access to VMware's guest info very low speed access.

Olaf Hering:
Dropped changing of bios-strings. Still needs some documentation about this may be needed to do in a tool stack or set of commands.

Boris Ostrovsky:
Use svm_nextrip_insn_length()
Looks like __get_instruction_length() does this, so switched to __get_instruction_length().

RFC:

See

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

for info on detecting VMware.

Linux does not follow this exactly. It checks for CPUID 1st. If that fails, it checks for SMBIOS containing "VMware" (not VMware- or VMW).

So this patch set provides:

SMBIOS -- Add string VMware-
CPUID -- Add VMware's CPUID (Note: currently HyperV (viridian support) breaks this check.) Add the magic VMware port
Allow VMware tools poweroff and reboot
Enable access to VMware's guest info
Provide the VMware tools build number

Don Slutz (16):
hypervisor part of add vmware_hw to xl.cfg
tools part of add vmware_hw to xl.cfg
vmware: Add VMware provided include files.
hypervisor part of add vmware_port to xl.cfg
tools part of add vmware_port to xl.cfg
hypervisor part of convert vmware_port to xentrace usage tools part of convert vmware_port to xentrace usage hypervisor part of add limited support of VMware's hyper-call rpc tools part of add limited support of VMware's hyper-call rpc Add VMware tool's triggers
Add live migration of VMware's hyper-call RPC
Add dump of HVM_SAVE_CODE(VMPORT) to xen-hvmctx.
Add xen-hvm-param
Add xen-vmware-guestinfo
Add xen-list-vmware-guestinfo
Add xen-hvm-send-trigger

 .gitignore                                   |    4 +
 docs/man/xl.cfg.pod.5                        |   13 +
 tools/libxc/xc_domain.c                      |  115 ++
 tools/libxc/xc_domain_restore.c              |   25 +
 tools/libxc/xc_domain_save.c                 |   22 +
 tools/libxc/xenctrl.h                        |   24 +
 tools/libxc/xg_save_restore.h                |    3 +
 tools/libxl/libxl_create.c                   |    7 +-
 tools/libxl/libxl_dm.c                       |   33 +-
 tools/libxl/libxl_dom.c                      |    4 +
 tools/libxl/libxl_types.idl                  |    2 +
 tools/libxl/xl_cmdimpl.c                     |    4 +
 tools/misc/Makefile                          |   16 +-
 tools/misc/xen-hvm-param.c                   |  166 +++
 tools/misc/xen-hvm-send-trigger.c            |  103 ++
 tools/misc/xen-hvmctx.c                      |  229 ++++
 tools/misc/xen-list-vmware-guestinfo.c       |   88 ++
 tools/misc/xen-vmware-guestinfo.c            |   97 ++
 tools/xentrace/formats                       |   13 +
 xen/arch/x86/domctl.c                        |   34 +
 xen/arch/x86/hvm/Makefile                    |    3 +-
 xen/arch/x86/hvm/hvm.c                       |   91 ++
 xen/arch/x86/hvm/svm/emulate.c               |   26 +-
 xen/arch/x86/hvm/svm/svm.c                   |   44 +-
 xen/arch/x86/hvm/svm/vmcb.c                  |    1 +
 xen/arch/x86/hvm/vmware/Makefile             |    3 +
 xen/arch/x86/hvm/vmware/backdoor_def.h       |  167 +++
 xen/arch/x86/hvm/vmware/cpuid.c              |   71 ++
 xen/arch/x86/hvm/vmware/guest_msg_def.h      |   87 ++
 xen/arch/x86/hvm/vmware/includeCheck.h       |   17 +
 xen/arch/x86/hvm/vmware/vmport.c             |  324 ++++++
 xen/arch/x86/hvm/vmware/vmport_rpc.c         | 1581 ++++++++++++++++++++++++++
 xen/arch/x86/hvm/vmx/vmcs.c                  |    1 +
 xen/arch/x86/hvm/vmx/vmx.c                   |   64 ++
 xen/arch/x86/hvm/vmx/vvmx.c                  |   14 +
 xen/arch/x86/traps.c                         |    7 +-
 xen/include/asm-x86/hvm/domain.h             |    4 +
 xen/include/asm-x86/hvm/hvm.h                |    3 +
 xen/include/asm-x86/hvm/io.h                 |    2 +-
 xen/include/asm-x86/hvm/svm/emulate.h        |   13 +-
 xen/include/asm-x86/hvm/trace.h              |   38 +
 xen/include/asm-x86/hvm/vmport.h             |   71 ++
 xen/include/asm-x86/hvm/vmware.h             |   31 +
 xen/include/public/arch-x86/hvm/save.h       |   39 +-
 xen/include/public/arch-x86/hvm/vmporttype.h |  118 ++
 xen/include/public/domctl.h                  |    3 +
 xen/include/public/hvm/hvm_op.h              |   18 +
 xen/include/public/hvm/params.h              |    9 +-
 xen/include/public/trace.h                   |   12 +
 49 files changed, 3834 insertions(+), 30 deletions(-)
 create mode 100644 tools/misc/xen-hvm-param.c
 create mode 100644 tools/misc/xen-hvm-send-trigger.c
 create mode 100644 tools/misc/xen-list-vmware-guestinfo.c
 create mode 100644 tools/misc/xen-vmware-guestinfo.c
 create mode 100644 xen/arch/x86/hvm/vmware/Makefile
 create mode 100644 xen/arch/x86/hvm/vmware/backdoor_def.h
 create mode 100644 xen/arch/x86/hvm/vmware/cpuid.c
 create mode 100644 xen/arch/x86/hvm/vmware/guest_msg_def.h
 create mode 100644 xen/arch/x86/hvm/vmware/includeCheck.h
 create mode 100644 xen/arch/x86/hvm/vmware/vmport.c
 create mode 100644 xen/arch/x86/hvm/vmware/vmport_rpc.c
 create mode 100644 xen/include/asm-x86/hvm/vmport.h
 create mode 100644 xen/include/asm-x86/hvm/vmware.h
 create mode 100644 xen/include/public/arch-x86/hvm/vmporttype.h
Signature · 1 line
1.8.4
author
#1 lore raw

PATCH v3 1/16 hypervisor part of add vmware_hw to xl.cfg

If non-zero then
Return VMware's cpuid leaves.

The support of hypervisor cpuid leaves has not been agreed to.

MicroSoft Hyper-V (AKA viridian) currently must be at 0x40000000.

VMware currently must be at 0x40000000.

KVM currently must be at 0x40000000 (from Seabios).

Seabios will find xen at 0x40000000, 0x40000100, 0x40000200 .. 0x40010000.

http://download.microsoft.com/download/F/B/0/FB0D01A3-8E3A-4F5F-AA59-08C8026D3B8A/requirements-for-implementing-microsoft-hypervisor-interface.docx

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

http://lwn.net/Articles/301888/
Attempted to get this cleaned up.

So based on this, I picked the order:

0x40000000 is viridian, vmware or xen
0x40000100 is vmware or xen
0x40000200 is xen

---
 xen/arch/x86/hvm/Makefile        |  3 +-
 xen/arch/x86/hvm/hvm.c           | 22 +++++++++++++
 xen/arch/x86/hvm/vmware/Makefile |  1 +
 xen/arch/x86/hvm/vmware/cpuid.c  | 71 ++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/traps.c             |  7 +++-
 xen/include/asm-x86/hvm/hvm.h    |  3 ++
 xen/include/asm-x86/hvm/vmware.h | 31 ++++++++++++++++++
 xen/include/public/hvm/params.h  |  5 ++-
 8 files changed, 140 insertions(+), 3 deletions(-)
 create mode 100644 xen/arch/x86/hvm/vmware/Makefile
 create mode 100644 xen/arch/x86/hvm/vmware/cpuid.c
 create mode 100644 xen/include/asm-x86/hvm/vmware.h
xen/arch/x86/hvm/Makefile +2 -1
index eea5555..77598a6 100644
@@ -1,5 +1,6 @@
 subdir-y += svm
 subdir-y += vmx
+subdir-y += vmware
 
 obj-y += asid.o
 obj-y += emulate.o
@@ -22,4 +23,4 @@ obj-y += vlapic.o
 obj-y += vmsi.o
 obj-y += vpic.o
 obj-y += vpt.o
-obj-y += vpmu.o
\ No newline at end of file
+obj-y += vpmu.o
xen/arch/x86/hvm/hvm.c +22 -0
index 8d905d3..365331a 100644
@@ -57,6 +57,7 @@
 #include <asm/hvm/cacheattr.h>
 #include <asm/hvm/trace.h>
 #include <asm/hvm/nestedhvm.h>
+#include <asm/hvm/vmware.h>
 #include <asm/mtrr.h>
 #include <asm/apic.h>
 #include <public/sched.h>
@@ -4228,6 +4229,9 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
     if ( cpuid_viridian_leaves(input, eax, ebx, ecx, edx) )
         return;
 
+    if ( cpuid_vmware_leaves(input, eax, ebx, ecx, edx) )
+        return;
+
     if ( cpuid_hypervisor_leaves(input, count, eax, ebx, ecx, edx) )
         return;
 
@@ -5692,6 +5696,24 @@ 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 )
+                {
+                    rc = -EPERM;
+                    break;
+                }
+                if ( d->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW] &&
+                     d->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW] !=
+                     a.value )
+                {
+                    rc = -EEXIST;
+                    break;
+                }
+                break;
             }
 
             if ( rc == 0 ) 
xen/arch/x86/hvm/vmware/Makefile new file +1 -0
new file mode 100644
index 0000000..3fb2e0b
@@ -0,0 +1 @@
+obj-y += cpuid.o
xen/arch/x86/hvm/vmware/cpuid.c new file +71 -0

71 lines not on this page · raw message

xen/arch/x86/traps.c +6 -1
index 10fc2ca..932cd3d 100644
@@ -686,9 +686,14 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
 {
     struct domain *d = current->domain;
     /* Optionally shift out of the way of Viridian architectural leaves. */
-    uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000;
+    uint32_t base = 0x40000000;
     uint32_t limit, dummy;
 
+    if ( is_viridian_domain(d) )
+        base += 0x100;
+    if ( is_vmware_domain(d) )
+        base += 0x100;
+
     idx -= base;
     if ( idx > XEN_CPUID_MAX_NUM_LEAVES )
         return 0; /* Avoid unnecessary pass through domain_cpuid() */
xen/include/asm-x86/hvm/hvm.h +3 -0
index 1123857..546210a 100644
@@ -347,6 +347,9 @@ static inline unsigned long hvm_get_shadow_gs_base(struct vcpu *v)
 #define is_viridian_domain(_d)                                             \
  (is_hvm_domain(_d) && ((_d)->arch.hvm_domain.params[HVM_PARAM_VIRIDIAN]))
 
+#define is_vmware_domain(_d)                                             \
+ (is_hvm_domain(_d) && ((_d)->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW]))
+
 void hvm_hypervisor_cpuid_leaf(uint32_t sub_idx,
                                uint32_t *eax, uint32_t *ebx,
                                uint32_t *ecx, uint32_t *edx);
xen/include/asm-x86/hvm/vmware.h new file +31 -0
new file mode 100644
index 0000000..f254106
@@ -0,0 +1,31 @@
+/*
+ * asm-x86/hvm/vmware.h
+ *
+ * Copyright (C) 2012 Verizon Corporation
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License Version 2 (GPLv2)
+ * as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details. <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ASM_X86_HVM_VMWARE_H__
+#define ASM_X86_HVM_VMWARE_H__
+
+int cpuid_vmware_leaves(uint32_t idx, uint32_t *eax, uint32_t *ebx,
+                        uint32_t *ecx, uint32_t *edx);
+
+#endif /* ASM_X86_HVM_VMWARE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/include/public/hvm/params.h +4 -1
index 614ff5f..dee6d68 100644
@@ -151,6 +151,9 @@
 /* Location of the VM Generation ID in guest physical address space. */
 #define HVM_PARAM_VM_GENERATION_ID_ADDR 34
 
-#define HVM_NR_PARAMS          35
+/* Params for VMware */
+#define HVM_PARAM_VMWARE_HW                 35
+
+#define HVM_NR_PARAMS          36
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
Signature · 1 line
1.8.4
#2 lore raw

Re: [PATCH v3 01/16] hypervisor part of add vmware_hw to xl.cfg

Quoted 21 lines · Don Slutz

If non-zero then
Return VMware's cpuid leaves.

The support of hypervisor cpuid leaves has not been agreed to.

MicroSoft Hyper-V (AKA viridian) currently must be at 0x40000000.

VMware currently must be at 0x40000000.

KVM currently must be at 0x40000000 (from Seabios).

Seabios will find xen at 0x40000000, 0x40000100, 0x40000200 .. 0x40010000.

http://download.microsoft.com/download/F/B/0/FB0D01A3-8E3A-4F5F-AA59-08C8026D3B8A/requirements-for-implementing-microsoft-hypervisor-interface.docx

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

http://lwn.net/Articles/301888/
Attempted to get this cleaned up.

Quoted 7 lines

So based on this, I picked the order:

0x40000000 is viridian, vmware or xen
0x40000100 is vmware or xen
0x40000200 is xen

It looks like you need to update the description here. The subject / first line should be "xen: Add support for VMWare cpuid leaves" (since you're doing stuff in the hypervisor and not in xl.cfg). The description should say that you're introducing HVM_PARAM_VMWARE_HW.

Re the viridian / vmware coexisting thing:

If the vmware tools supported looking for the cpuid leaf at 0x40000100, then I'd say we should allow them both to be set: after all, at some point in the future vmware might enable viridian support, at which case a guest running in vmware might expect to find both viridian and vmware leaves.

But if they don't, then there's really not much point in allowing the vmware leaf to be at 0x40000100, because no one will read it. In that case we should disallow setting both.

Patch looks fine to me otherwise.

-George

Quoted 257 lines
---
 xen/arch/x86/hvm/Makefile        |  3 +-
 xen/arch/x86/hvm/hvm.c           | 22 +++++++++++++
 xen/arch/x86/hvm/vmware/Makefile |  1 +
 xen/arch/x86/hvm/vmware/cpuid.c  | 71 ++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/traps.c             |  7 +++-
 xen/include/asm-x86/hvm/hvm.h    |  3 ++
 xen/include/asm-x86/hvm/vmware.h | 31 ++++++++++++++++++
 xen/include/public/hvm/params.h  |  5 ++-
 8 files changed, 140 insertions(+), 3 deletions(-)
 create mode 100644 xen/arch/x86/hvm/vmware/Makefile
 create mode 100644 xen/arch/x86/hvm/vmware/cpuid.c
 create mode 100644 xen/include/asm-x86/hvm/vmware.h
xen/arch/x86/hvm/Makefile +2 -1
index eea5555..77598a6 100644
@@ -1,5 +1,6 @@
 subdir-y += svm
 subdir-y += vmx
+subdir-y += vmware
 
 obj-y += asid.o
 obj-y += emulate.o
@@ -22,4 +23,4 @@ obj-y += vlapic.o
 obj-y += vmsi.o
 obj-y += vpic.o
 obj-y += vpt.o
-obj-y += vpmu.o
\ No newline at end of file
+obj-y += vpmu.o
xen/arch/x86/hvm/hvm.c +22 -0
index 8d905d3..365331a 100644
@@ -57,6 +57,7 @@
 #include <asm/hvm/cacheattr.h>
 #include <asm/hvm/trace.h>
 #include <asm/hvm/nestedhvm.h>
+#include <asm/hvm/vmware.h>
 #include <asm/mtrr.h>
 #include <asm/apic.h>
 #include <public/sched.h>
@@ -4228,6 +4229,9 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
     if ( cpuid_viridian_leaves(input, eax, ebx, ecx, edx) )
         return;
 
+    if ( cpuid_vmware_leaves(input, eax, ebx, ecx, edx) )
+        return;
+
     if ( cpuid_hypervisor_leaves(input, count, eax, ebx, ecx, edx) )
         return;
 
@@ -5692,6 +5696,24 @@ 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 )
+                {
+                    rc = -EPERM;
+                    break;
+                }
+                if ( d->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW] &&
+                     d->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW] !=
+                     a.value )
+                {
+                    rc = -EEXIST;
+                    break;
+                }
+                break;
             }
 
             if ( rc == 0 )
xen/arch/x86/hvm/vmware/Makefile new file +1 -0
new file mode 100644
index 0000000..3fb2e0b
@@ -0,0 +1 @@
+obj-y += cpuid.o
xen/arch/x86/hvm/vmware/cpuid.c new file +71 -0
new file mode 100644
index 0000000..03b74bf
@@ -0,0 +1,71 @@
+/*
+ * arch/x86/hvm/vmware/cpuid.c
+ *
+ * Copyright (C) 2012 Verizon Corporation
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License Version 2 (GPLv2)
+ * as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details. <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/sched.h>
+
+#include <asm/hvm/hvm.h>
+#include <asm/hvm/vmware.h>
+
+int cpuid_vmware_leaves(uint32_t idx, uint32_t *eax, uint32_t *ebx,
+                        uint32_t *ecx, uint32_t *edx)
+{
+    struct domain *d = current->domain;
+    /* Optionally shift out of the way of Viridian architectural leaves. */
+    uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000;
+
+    if ( !is_vmware_domain(d) )
+        return 0;
+
+    switch ( idx - base )
+    {
+    case 0x0:
+        *eax = base + 0x10; /* Largest leaf */
+        *ebx = 0x61774d56;  /* "VMwa" */
+        *ecx = 0x4d566572;  /* "reVM" */
+        *edx = 0x65726177;  /* "ware" */
+        break;
+
+    case 0x1 ... 0xf:
+        *eax = 0;          /* Reserved */
+        *ebx = 0;          /* Reserved */
+        *ecx = 0;          /* Reserved */
+        *edx = 0;          /* Reserved */
+        break;
+
+    case 0x10:
+        /* (Virtual) TSC frequency in kHz. */
+        *eax =  d->arch.tsc_khz;
+        /* (Virtual) Bus (local apic timer) frequency in kHz. */
+        *ebx = 1000000000ull / APIC_BUS_CYCLE_NS / 1000ull;
+        *ecx = 0;          /* Reserved */
+        *edx = 0;          /* Reserved */
+        break;
+
+    default:
+        return 0;
+    }
+
+    return 1;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/arch/x86/traps.c +6 -1
index 10fc2ca..932cd3d 100644
@@ -686,9 +686,14 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
 {
     struct domain *d = current->domain;
     /* Optionally shift out of the way of Viridian architectural leaves. */
-    uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000;
+    uint32_t base = 0x40000000;
     uint32_t limit, dummy;
 
+    if ( is_viridian_domain(d) )
+        base += 0x100;
+    if ( is_vmware_domain(d) )
+        base += 0x100;
+
     idx -= base;
     if ( idx > XEN_CPUID_MAX_NUM_LEAVES )
         return 0; /* Avoid unnecessary pass through domain_cpuid() */
xen/include/asm-x86/hvm/hvm.h +3 -0
index 1123857..546210a 100644
@@ -347,6 +347,9 @@ static inline unsigned long hvm_get_shadow_gs_base(struct vcpu *v)
 #define is_viridian_domain(_d)                                             \
  (is_hvm_domain(_d) && ((_d)->arch.hvm_domain.params[HVM_PARAM_VIRIDIAN]))
 
+#define is_vmware_domain(_d)                                             \
+ (is_hvm_domain(_d) && ((_d)->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW]))
+
 void hvm_hypervisor_cpuid_leaf(uint32_t sub_idx,
                                uint32_t *eax, uint32_t *ebx,
                                uint32_t *ecx, uint32_t *edx);
xen/include/asm-x86/hvm/vmware.h new file +31 -0
new file mode 100644
index 0000000..f254106
@@ -0,0 +1,31 @@
+/*
+ * asm-x86/hvm/vmware.h
+ *
+ * Copyright (C) 2012 Verizon Corporation
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License Version 2 (GPLv2)
+ * as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details. <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ASM_X86_HVM_VMWARE_H__
+#define ASM_X86_HVM_VMWARE_H__
+
+int cpuid_vmware_leaves(uint32_t idx, uint32_t *eax, uint32_t *ebx,
+                        uint32_t *ecx, uint32_t *edx);
+
+#endif /* ASM_X86_HVM_VMWARE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/include/public/hvm/params.h +4 -2
index 614ff5f..dee6d68 100644
@@ -151,6 +151,9 @@
 /* Location of the VM Generation ID in guest physical address space. */
 #define HVM_PARAM_VM_GENERATION_ID_ADDR 34
 
-#define HVM_NR_PARAMS          35
+/* Params for VMware */
+#define HVM_PARAM_VMWARE_HW                 35
+
+#define HVM_NR_PARAMS          36
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
--

1.8.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#3 lore raw

Re: [PATCH v3 01/16] hypervisor part of add vmware_hw to xl.cfg

Quoted 28 lines · George Dunlap
Quoted 27 lines · Don Slutz

If non-zero then
Return VMware's cpuid leaves.

The support of hypervisor cpuid leaves has not been agreed to.

MicroSoft Hyper-V (AKA viridian) currently must be at 0x40000000.

VMware currently must be at 0x40000000.

KVM currently must be at 0x40000000 (from Seabios).

Seabios will find xen at 0x40000000, 0x40000100, 0x40000200 .. 0x40010000.

http://download.microsoft.com/download/F/B/0/FB0D01A3-8E3A-4F5F-AA59-08C8026D3B8A/requirements-for-implementing-microsoft-hypervisor-interface.docx

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

http://lwn.net/Articles/301888/
Attempted to get this cleaned up.

So based on this, I picked the order:

0x40000000 is viridian, vmware or xen
0x40000100 is vmware or xen
0x40000200 is xen

Quoted 5 lines
Quoted 1 line

It looks like you need to update the description here. The subject / first line should be "xen: Add support for VMWare cpuid leaves" (since you're doing stuff in the hypervisor and not in xl.cfg). The description should say that you're introducing HVM_PARAM_VMWARE_HW.

Will fix subject.

Quoted 11 lines

Re the viridian / vmware coexisting thing:

If the vmware tools supported looking for the cpuid leaf at 0x40000100, then I'd say we should allow them both to be set: after all, at some point in the future vmware might enable viridian support, at which case a guest running in vmware might expect to find both viridian and vmware leaves.

But if they don't, then there's really not much point in allowing the vmware leaf to be at 0x40000100, because no one will read it. In that case we should disallow setting both.

on v2 after v3 posted it was decided to go with only one of

viridian or vmware. Code change don in v4 (out soon).

-Don Slutz

Quoted 261 lines

Patch looks fine to me otherwise.

-George

Quoted 257 lines
---
  xen/arch/x86/hvm/Makefile        |  3 +-
  xen/arch/x86/hvm/hvm.c           | 22 +++++++++++++
  xen/arch/x86/hvm/vmware/Makefile |  1 +
  xen/arch/x86/hvm/vmware/cpuid.c  | 71 ++++++++++++++++++++++++++++++++++++++++
  xen/arch/x86/traps.c             |  7 +++-
  xen/include/asm-x86/hvm/hvm.h    |  3 ++
  xen/include/asm-x86/hvm/vmware.h | 31 ++++++++++++++++++
  xen/include/public/hvm/params.h  |  5 ++-
  8 files changed, 140 insertions(+), 3 deletions(-)

create mode 100644 xen/arch/x86/hvm/vmware/Makefile create mode 100644 xen/arch/x86/hvm/vmware/cpuid.c create mode 100644 xen/include/asm-x86/hvm/vmware.h

xen/arch/x86/hvm/Makefile +2 -1
index eea5555..77598a6 100644
@@ -1,5 +1,6 @@
  subdir-y += svm
  subdir-y += vmx
+subdir-y += vmware
 
  obj-y += asid.o
  obj-y += emulate.o
@@ -22,4 +23,4 @@ obj-y += vlapic.o
  obj-y += vmsi.o
  obj-y += vpic.o
  obj-y += vpt.o
-obj-y += vpmu.o
\ No newline at end of file
+obj-y += vpmu.o
xen/arch/x86/hvm/hvm.c +22 -0
index 8d905d3..365331a 100644
@@ -57,6 +57,7 @@
  #include <asm/hvm/cacheattr.h>
  #include <asm/hvm/trace.h>
  #include <asm/hvm/nestedhvm.h>
+#include <asm/hvm/vmware.h>
  #include <asm/mtrr.h>
  #include <asm/apic.h>
  #include <public/sched.h>
@@ -4228,6 +4229,9 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
      if ( cpuid_viridian_leaves(input, eax, ebx, ecx, edx) )
          return;
 
+    if ( cpuid_vmware_leaves(input, eax, ebx, ecx, edx) )
+        return;
+
      if ( cpuid_hypervisor_leaves(input, count, eax, ebx, ecx, edx) )
          return;
 
@@ -5692,6 +5696,24 @@ 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 )
+                {
+                    rc = -EPERM;
+                    break;
+                }
+                if ( d->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW] &&
+                     d->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW] !=
+                     a.value )
+                {
+                    rc = -EEXIST;
+                    break;
+                }
+                break;
              }
 
              if ( rc == 0 )
xen/arch/x86/hvm/vmware/Makefile new file +1 -0
new file mode 100644
index 0000000..3fb2e0b
@@ -0,0 +1 @@
+obj-y += cpuid.o
xen/arch/x86/hvm/vmware/cpuid.c new file +71 -0
new file mode 100644
index 0000000..03b74bf
@@ -0,0 +1,71 @@
+/*
+ * arch/x86/hvm/vmware/cpuid.c
+ *
+ * Copyright (C) 2012 Verizon Corporation
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License Version 2 (GPLv2)
+ * as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details. <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/sched.h>
+
+#include <asm/hvm/hvm.h>
+#include <asm/hvm/vmware.h>
+
+int cpuid_vmware_leaves(uint32_t idx, uint32_t *eax, uint32_t *ebx,
+                        uint32_t *ecx, uint32_t *edx)
+{
+    struct domain *d = current->domain;
+    /* Optionally shift out of the way of Viridian architectural leaves. */
+    uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000;
+
+    if ( !is_vmware_domain(d) )
+        return 0;
+
+    switch ( idx - base )
+    {
+    case 0x0:
+        *eax = base + 0x10; /* Largest leaf */
+        *ebx = 0x61774d56;  /* "VMwa" */
+        *ecx = 0x4d566572;  /* "reVM" */
+        *edx = 0x65726177;  /* "ware" */
+        break;
+
+    case 0x1 ... 0xf:
+        *eax = 0;          /* Reserved */
+        *ebx = 0;          /* Reserved */
+        *ecx = 0;          /* Reserved */
+        *edx = 0;          /* Reserved */
+        break;
+
+    case 0x10:
+        /* (Virtual) TSC frequency in kHz. */
+        *eax =  d->arch.tsc_khz;
+        /* (Virtual) Bus (local apic timer) frequency in kHz. */
+        *ebx = 1000000000ull / APIC_BUS_CYCLE_NS / 1000ull;
+        *ecx = 0;          /* Reserved */
+        *edx = 0;          /* Reserved */
+        break;
+
+    default:
+        return 0;
+    }
+
+    return 1;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/arch/x86/traps.c +6 -1
index 10fc2ca..932cd3d 100644
@@ -686,9 +686,14 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
  {
      struct domain *d = current->domain;
      /* Optionally shift out of the way of Viridian architectural leaves. */
-    uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000;
+    uint32_t base = 0x40000000;
      uint32_t limit, dummy;
 
+    if ( is_viridian_domain(d) )
+        base += 0x100;
+    if ( is_vmware_domain(d) )
+        base += 0x100;
+
      idx -= base;
      if ( idx > XEN_CPUID_MAX_NUM_LEAVES )
          return 0; /* Avoid unnecessary pass through domain_cpuid() */
xen/include/asm-x86/hvm/hvm.h +3 -0
index 1123857..546210a 100644
@@ -347,6 +347,9 @@ static inline unsigned long hvm_get_shadow_gs_base(struct vcpu *v)
  #define is_viridian_domain(_d)                                             \
   (is_hvm_domain(_d) && ((_d)->arch.hvm_domain.params[HVM_PARAM_VIRIDIAN]))
 
+#define is_vmware_domain(_d)                                             \
+ (is_hvm_domain(_d) && ((_d)->arch.hvm_domain.params[HVM_PARAM_VMWARE_HW]))
+
  void hvm_hypervisor_cpuid_leaf(uint32_t sub_idx,
                                 uint32_t *eax, uint32_t *ebx,
                                 uint32_t *ecx, uint32_t *edx);
xen/include/asm-x86/hvm/vmware.h new file +31 -0
new file mode 100644
index 0000000..f254106
@@ -0,0 +1,31 @@
+/*
+ * asm-x86/hvm/vmware.h
+ *
+ * Copyright (C) 2012 Verizon Corporation
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License Version 2 (GPLv2)
+ * as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details. <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ASM_X86_HVM_VMWARE_H__
+#define ASM_X86_HVM_VMWARE_H__
+
+int cpuid_vmware_leaves(uint32_t idx, uint32_t *eax, uint32_t *ebx,
+                        uint32_t *ecx, uint32_t *edx);
+
+#endif /* ASM_X86_HVM_VMWARE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/include/public/hvm/params.h +4 -2
index 614ff5f..dee6d68 100644
@@ -151,6 +151,9 @@
  /* Location of the VM Generation ID in guest physical address space. */
  #define HVM_PARAM_VM_GENERATION_ID_ADDR 34
 
-#define HVM_NR_PARAMS          35
+/* Params for VMware */
+#define HVM_PARAM_VMWARE_HW                 35
+
+#define HVM_NR_PARAMS          36
 
  #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
--

1.8.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#4 lore raw

PATCH v3 2/16 tools part of add vmware_hw to xl.cfg

In reply to Don Slutz

If non-zero then
Force use of VMware's VGA in QEMU.

---
 docs/man/xl.cfg.pod.5           |  6 ++++++
 tools/libxc/xc_domain_restore.c | 14 ++++++++++++++
 tools/libxc/xc_domain_save.c    | 11 +++++++++++
 tools/libxc/xg_save_restore.h   |  2 ++
 tools/libxl/libxl_create.c      |  4 +++-
 tools/libxl/libxl_dm.c          | 33 +++++++++++++++++++++------------
 tools/libxl/libxl_dom.c         |  2 ++
 tools/libxl/libxl_types.idl     |  1 +
 tools/libxl/xl_cmdimpl.c        |  2 ++
 9 files changed, 62 insertions(+), 13 deletions(-)
docs/man/xl.cfg.pod.5 +6 -0
index 517ae2f..7f7319a 100644
@@ -1147,6 +1147,12 @@ some other Operating Systems and in some circumstance can prevent
 Xen's own paravirtualisation interfaces for HVM guests from being
 used.
 
+=item B<vmware_hw=NUMBER>
+
+Turns on or off the exposure of VMware cpuid.  The number is the
+VMware's hardware version number, where 0 is off.  If on it also
+forces the use of VMware's VGA in QEMU.
+
 =back
 
 =head3 Emulated VGA Graphics Device
tools/libxc/xc_domain_restore.c +14 -0
index b9a56d5..bc5cd57 100644
@@ -743,6 +743,7 @@ typedef struct {
     uint64_t vm_generationid_addr;
     uint64_t ioreq_server_pfn;
     uint64_t nr_ioreq_server_pages;
+    uint64_t vmware_hw;
 
     struct toolstack_data_t tdata;
 } pagebuf_t;
@@ -927,6 +928,16 @@ static int pagebuf_get_one(xc_interface *xch, struct restore_ctx *ctx,
         }
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
 
+    case XC_SAVE_ID_HVM_VMWARE_HW:
+        /* Skip padding 4 bytes then read the vmware hw version. */
+        if ( RDEXACT(fd, &buf->vmware_hw, sizeof(uint32_t)) ||
+             RDEXACT(fd, &buf->vmware_hw, sizeof(uint64_t)) )
+        {
+            PERROR("error read the vmware_hw value");
+            return -1;
+        }
+        return pagebuf_get_one(xch, ctx, buf, fd, dom);
+
     case XC_SAVE_ID_TOOLSTACK:
         {
             if ( RDEXACT(fd, &buf->tdata.len, sizeof(buf->tdata.len)) )
@@ -1760,6 +1771,9 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
         }
     }
 
+    if (pagebuf.vmware_hw != 0)
+        xc_set_hvm_param(xch, dom, HVM_PARAM_VMWARE_HW, pagebuf.vmware_hw);
+
     if (pagebuf.acpi_ioport_location == 1) {
         DBGPRINTF("Use new firmware ioport from the checkpoint\n");
         xc_hvm_param_set(xch, dom, HVM_PARAM_ACPI_IOPORTS_LOCATION, 1);
tools/libxc/xc_domain_save.c +11 -0
index 254fdb3..76dc307 100644
@@ -1750,6 +1750,17 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
             PERROR("Error when writing the ioreq server gmfn count");
             goto out;
         }
+
+        chunk.id = XC_SAVE_ID_HVM_VMWARE_HW;
+        chunk.data = 0;
+        xc_hvm_param_get(xch, dom, HVM_PARAM_VMWARE_HW, &chunk.data);
+
+        if ( (chunk.data != 0) &&
+             wrexact(io_fd, &chunk, sizeof(chunk)) )
+        {
+            PERROR("Error when writing the vmware_hw value");
+            goto out;
+        }
     }
 
     if ( callbacks != NULL && callbacks->toolstack_save != NULL )
tools/libxc/xg_save_restore.h +2 -0
index bdd9009..d185ba9 100644
@@ -262,6 +262,8 @@
 /* These are a pair; it is an error for one to exist without the other */
 #define XC_SAVE_ID_HVM_IOREQ_SERVER_PFN -19
 #define XC_SAVE_ID_HVM_NR_IOREQ_SERVER_PAGES -20
+/* VMware data */
+#define XC_SAVE_ID_HVM_VMWARE_HW      -21
 
 /*
 ** We process save/restore/migrate in batches of pages; the below
tools/libxl/libxl_create.c +3 -1
index ee328e9..54842ee 100644
@@ -428,13 +428,15 @@ int libxl__domain_build(libxl__gc *gc,
         vments[4] = "start_time";
         vments[5] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
 
-        localents = libxl__calloc(gc, 7, sizeof(char *));
+        localents = libxl__calloc(gc, 9, sizeof(char *));
         localents[0] = "platform/acpi";
         localents[1] = libxl_defbool_val(info->u.hvm.acpi) ? "1" : "0";
         localents[2] = "platform/acpi_s3";
         localents[3] = libxl_defbool_val(info->u.hvm.acpi_s3) ? "1" : "0";
         localents[4] = "platform/acpi_s4";
         localents[5] = libxl_defbool_val(info->u.hvm.acpi_s4) ? "1" : "0";
+        localents[6] = "platform/vmware_hw";
+        localents[7] = libxl__sprintf(gc, "%"PRId64, info->u.hvm.vmware_hw);
 
         break;
     case LIBXL_DOMAIN_TYPE_PV:
tools/libxl/libxl_dm.c +21 -12
index 103cbca..c79274b 100644
@@ -542,19 +542,28 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
             }
         }
 
-        switch (b_info->u.hvm.vga.kind) {
-        case LIBXL_VGA_INTERFACE_TYPE_STD:
-            flexarray_append_pair(dm_args, "-device",
-                GCSPRINTF("VGA,vgamem_mb=%d",
-                libxl__sizekb_to_mb(b_info->video_memkb)));
-            break;
-        case LIBXL_VGA_INTERFACE_TYPE_CIRRUS:
+        if (b_info->u.hvm.vmware_hw) {
             flexarray_append_pair(dm_args, "-device",
-                GCSPRINTF("cirrus-vga,vgamem_mb=%d",
-                libxl__sizekb_to_mb(b_info->video_memkb)));
-            break;
-        case LIBXL_VGA_INTERFACE_TYPE_NONE:
-            break;
+                                  GCSPRINTF("vmware-svga,vgamem_mb=%d",
+                                            libxl__sizekb_to_mb(
+                                                b_info->video_memkb)));
+        } else {
+            switch (b_info->u.hvm.vga.kind) {
+            case LIBXL_VGA_INTERFACE_TYPE_STD:
+                flexarray_append_pair(dm_args, "-device",
+                                      GCSPRINTF("VGA,vgamem_mb=%d",
+                                                libxl__sizekb_to_mb(
+                                                    b_info->video_memkb)));
+                break;
+            case LIBXL_VGA_INTERFACE_TYPE_CIRRUS:
+                flexarray_append_pair(dm_args, "-device",
+                                      GCSPRINTF("cirrus-vga,vgamem_mb=%d",
+                                                libxl__sizekb_to_mb(
+                                                    b_info->video_memkb)));
+                break;
+            case LIBXL_VGA_INTERFACE_TYPE_NONE:
+                break;
+            }
         }
 
         if (b_info->u.hvm.boot) {
tools/libxl/libxl_dom.c +2 -0
index c944804..63ae4c5 100644
@@ -219,6 +219,8 @@ static void hvm_set_conf_params(xc_interface *handle, uint32_t domid,
                     libxl_defbool_val(info->u.hvm.viridian));
     xc_hvm_param_set(handle, domid, HVM_PARAM_HPET_ENABLED,
                     libxl_defbool_val(info->u.hvm.hpet));
+    xc_set_hvm_param(handle, domid, HVM_PARAM_VMWARE_HW,
+                     info->u.hvm.vmware_hw);
 #endif
     xc_hvm_param_set(handle, domid, HVM_PARAM_TIMER_MODE, timer_mode(info));
     xc_hvm_param_set(handle, domid, HVM_PARAM_VPT_ALIGN,
tools/libxl/libxl_types.idl +1 -0
index 931c9e9..d0bd657 100644
@@ -375,6 +375,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                        ("timeoffset",       string),
                                        ("hpet",             libxl_defbool),
                                        ("vpt_align",        libxl_defbool),
+                                       ("vmware_hw",        UInt(64, init_val = 0)),
                                        ("timer_mode",       libxl_timer_mode),
                                        ("nested_hvm",       libxl_defbool),
                                        ("smbios_firmware",  string),
tools/libxl/xl_cmdimpl.c +2 -0
index 8a38077..c30341a 100644
@@ -1033,6 +1033,8 @@ static void parse_config_data(const char *config_source,
         xlu_cfg_get_defbool(config, "acpi_s4", &b_info->u.hvm.acpi_s4, 0);
         xlu_cfg_get_defbool(config, "nx", &b_info->u.hvm.nx, 0);
         xlu_cfg_get_defbool(config, "viridian", &b_info->u.hvm.viridian, 0);
+        if (!xlu_cfg_get_long(config, "vmware_hw",  &l, 1))
+            b_info->u.hvm.vmware_hw = l;
         xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
         xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);
 
Signature · 1 line
1.8.4
#5 lore raw

Re: [PATCH v3 02/16] tools part of add vmware_hw to xl.cfg

Quoted 4 lines · Don Slutz

If non-zero then
Force use of VMware's VGA in QEMU.

I think the title would be better "tools: Add vmware_hw support"

Quoted 17 lines
---
 docs/man/xl.cfg.pod.5           |  6 ++++++
 tools/libxc/xc_domain_restore.c | 14 ++++++++++++++
 tools/libxc/xc_domain_save.c    | 11 +++++++++++
 tools/libxc/xg_save_restore.h   |  2 ++
 tools/libxl/libxl_create.c      |  4 +++-
 tools/libxl/libxl_dm.c          | 33 +++++++++++++++++++++------------
 tools/libxl/libxl_dom.c         |  2 ++
 tools/libxl/libxl_types.idl     |  1 +
 tools/libxl/xl_cmdimpl.c        |  2 ++
 9 files changed, 62 insertions(+), 13 deletions(-)
docs/man/xl.cfg.pod.5 +0 -0
index 517ae2f..7f7319a 100644

docs/man/xl.cfg.pod.5 some other Operating Systems and in some circumstance can prevent · line 1154

Quoted 8 lines
docs/man/xl.cfg.pod.5 +5 -0
@@ -1147,6 +1147,12 @@ some other Operating Systems and in some circumstance can prevent
 Xen's own paravirtualisation interfaces for HVM guests from being
 used.
 
+=item B<vmware_hw=NUMBER>
+
+Turns on or off the exposure of VMware cpuid.  The number is the
+VMware's hardware version number, where 0 is off.  If on it also
+forces the use of VMware's VGA in QEMU.

You should also say what values are supported.

Quoted 33 lines
tools/libxl/libxl_dm.c +12 -12
index 103cbca..c79274b 100644
@@ -542,19 +542,28 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
             }
         }
 
-        switch (b_info->u.hvm.vga.kind) {
-        case LIBXL_VGA_INTERFACE_TYPE_STD:
-            flexarray_append_pair(dm_args, "-device",
-                GCSPRINTF("VGA,vgamem_mb=%d",
-                libxl__sizekb_to_mb(b_info->video_memkb)));
-            break;
-        case LIBXL_VGA_INTERFACE_TYPE_CIRRUS:
+        if (b_info->u.hvm.vmware_hw) {
             flexarray_append_pair(dm_args, "-device",
-                GCSPRINTF("cirrus-vga,vgamem_mb=%d",
-                libxl__sizekb_to_mb(b_info->video_memkb)));
-            break;
-        case LIBXL_VGA_INTERFACE_TYPE_NONE:
-            break;
+                                  GCSPRINTF("vmware-svga,vgamem_mb=%d",
+                                            libxl__sizekb_to_mb(
+                                                b_info->video_memkb)));
+        } else {
+            switch (b_info->u.hvm.vga.kind) {
+            case LIBXL_VGA_INTERFACE_TYPE_STD:
+                flexarray_append_pair(dm_args, "-device",
+                                      GCSPRINTF("VGA,vgamem_mb=%d",
+                                                libxl__sizekb_to_mb(
+                                                    b_info->video_memkb)));
+                break;

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 567

Quoted 10 lines
tools/libxl/libxl_dm.c +9 -0
+            case LIBXL_VGA_INTERFACE_TYPE_CIRRUS:
+                flexarray_append_pair(dm_args, "-device",
+                                      GCSPRINTF("cirrus-vga,vgamem_mb=%d",
+                                                libxl__sizekb_to_mb(
+                                                    b_info->video_memkb)));
+                break;
+            case LIBXL_VGA_INTERFACE_TYPE_NONE:
+                break;
+            }
         }

So if we set vmware_hw, then we:
1. always add a vmware-svga device, regargless of whether vga has been requested
2. Ignore the vga parameter and only add vmware-svga, even if someone may want something else?

I think at the libxl level, we should add a VMWARE interface type. Then in xl_cmdimpl.c, we should:
* Add a vga="vmware" type in xl.cfg
* honor the vga= setting (perhaps with a warning if vmware_hw is true?)
* if vga is not set, and vmware_hw is true, default to vga=VMWARE

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char *config_source, · line 1039

Quoted 12 lines
tools/libxl/xl_cmdimpl.c +2 -0
index 8a38077..c30341a 100644
@@ -1033,6 +1033,8 @@ static void parse_config_data(const char *config_source,
         xlu_cfg_get_defbool(config, "acpi_s4", &b_info->u.hvm.acpi_s4, 0);
         xlu_cfg_get_defbool(config, "nx", &b_info->u.hvm.nx, 0);
         xlu_cfg_get_defbool(config, "viridian", &b_info->u.hvm.viridian, 0);
+        if (!xlu_cfg_get_long(config, "vmware_hw",  &l, 1))
+            b_info->u.hvm.vmware_hw = l;
         xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
         xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);

This is a really minor thing, but is there a reason you put this in the middle of a bunch of other get_defbool()s, instead of putting it just after? It makes the code just look a bit more ugly. :-)

-George

author
#6 lore raw

Re: [PATCH v3 02/16] tools part of add vmware_hw to xl.cfg

Quoted 6 lines · George Dunlap
Quoted 4 lines · Don Slutz

If non-zero then
Force use of VMware's VGA in QEMU.

I think the title would be better "tools: Add vmware_hw support"

Ok.

Quoted 20 lines
Quoted 20 lines
---
  docs/man/xl.cfg.pod.5           |  6 ++++++
  tools/libxc/xc_domain_restore.c | 14 ++++++++++++++
  tools/libxc/xc_domain_save.c    | 11 +++++++++++
  tools/libxc/xg_save_restore.h   |  2 ++
  tools/libxl/libxl_create.c      |  4 +++-
  tools/libxl/libxl_dm.c          | 33 +++++++++++++++++++++------------
  tools/libxl/libxl_dom.c         |  2 ++
  tools/libxl/libxl_types.idl     |  1 +
  tools/libxl/xl_cmdimpl.c        |  2 ++
  9 files changed, 62 insertions(+), 13 deletions(-)
docs/man/xl.cfg.pod.5 +0 -0
index 517ae2f..7f7319a 100644
@@ -1147,6 +1147,12 @@ some other Operating Systems and in some circumstance can prevent
  Xen's own paravirtualisation interfaces for HVM guests from being
  used.
 
Quoted 6 lines

docs/man/xl.cfg.pod.5 some other Operating Systems and in some circumstance can prevent · line 1154

Quoted 5 lines
docs/man/xl.cfg.pod.5 +5 -0
+=item B<vmware_hw=NUMBER>
+
+Turns on or off the exposure of VMware cpuid.  The number is the
+VMware's hardware version number, where 0 is off.  If on it also
+forces the use of VMware's VGA in QEMU.

You should also say what values are supported.

Here is what I have in v4:

=item B<vmware_hw=NUMBER>

Turns on or off the exposure of VMware cpuid. The number is the VMware's hardware version number, where 0 is off. If not zero it changes the default VGA to VMware's VGA.

The hardware version number (vmware_hw) come from VMware config files.

=over 4

In a .vmx it is virtualHW.version

In a .ovf it is part of the value of vssd:VirtualSystemType. For vssd:VirtualSystemType == vmx-07, vmware_hw = 7.

=back

There is a lot in the different thread:

Message-ID: <[email protected]>
Date: Wed, 10 Sep 2014 13:44:27 -0400
User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
To: Ian Campbell <[email protected]>, Don Slutz <[email protected]>
CC: Andrew Cooper <[email protected]>, Tim Deegan <[email protected]>, Kevin
Tian <[email protected]>, Keir Fraser <[email protected]>, Jun Nakajima
<[email protected]>, Stefano Stabellini <[email protected]>, Ian Jackson <[email protected]>, Eddie Dong <[email protected]>, <[email protected]>, "Aravind
Gopalakrishnan" <[email protected]>, Jan Beulich
<[email protected]>, Boris Ostrovsky <[email protected]>, "Suravee
Suthikulpanit" <[email protected]>
Subject: Re: [Xen-devel] [PATCH v2 1/3] Add vmware_hw to xl.cfg
References: <[email protected]>
<[email protected]> <[email protected]> <[email protected]> <[email protected]> <[email protected]> <[email protected]>
In-Reply-To: <[email protected]>

Quoted 48 lines
Quoted 33 lines
tools/libxl/libxl_dm.c +12 -12
index 103cbca..c79274b 100644
@@ -542,19 +542,28 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
              }
          }
 
-        switch (b_info->u.hvm.vga.kind) {
-        case LIBXL_VGA_INTERFACE_TYPE_STD:
-            flexarray_append_pair(dm_args, "-device",
-                GCSPRINTF("VGA,vgamem_mb=%d",
-                libxl__sizekb_to_mb(b_info->video_memkb)));
-            break;
-        case LIBXL_VGA_INTERFACE_TYPE_CIRRUS:
+        if (b_info->u.hvm.vmware_hw) {
              flexarray_append_pair(dm_args, "-device",
-                GCSPRINTF("cirrus-vga,vgamem_mb=%d",
-                libxl__sizekb_to_mb(b_info->video_memkb)));
-            break;
-        case LIBXL_VGA_INTERFACE_TYPE_NONE:
-            break;
+                                  GCSPRINTF("vmware-svga,vgamem_mb=%d",
+                                            libxl__sizekb_to_mb(
+                                                b_info->video_memkb)));
+        } else {
+            switch (b_info->u.hvm.vga.kind) {
+            case LIBXL_VGA_INTERFACE_TYPE_STD:
+                flexarray_append_pair(dm_args, "-device",
+                                      GCSPRINTF("VGA,vgamem_mb=%d",
+                                                libxl__sizekb_to_mb(
+                                                    b_info->video_memkb)));
+                break;

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 567

Quoted 10 lines
tools/libxl/libxl_dm.c +9 -0
+            case LIBXL_VGA_INTERFACE_TYPE_CIRRUS:
+                flexarray_append_pair(dm_args, "-device",
+                                      GCSPRINTF("cirrus-vga,vgamem_mb=%d",
+                                                libxl__sizekb_to_mb(
+                                                    b_info->video_memkb)));
+                break;
+            case LIBXL_VGA_INTERFACE_TYPE_NONE:
+                break;
+            }
          }

So if we set vmware_hw, then we:
1. always add a vmware-svga device, regargless of whether vga has been requested
2. Ignore the vga parameter and only add vmware-svga, even if someone may want something else?

Quoted 5 lines

I think at the libxl level, we should add a VMWARE interface type. Then in xl_cmdimpl.c, we should:
* Add a vga="vmware" type in xl.cfg
* honor the vga= setting (perhaps with a warning if vmware_hw is true?)
* if vga is not set, and vmware_hw is true, default to vga=VMWARE

In v2 and v3 yes. In v4 no. What you are suggesting I have already coded.

Quoted 7 lines
Quoted 7 lines
tools/libxl/xl_cmdimpl.c +0 -0
index 8a38077..c30341a 100644
@@ -1033,6 +1033,8 @@ static void parse_config_data(const char *config_source,
          xlu_cfg_get_defbool(config, "acpi_s4", &b_info->u.hvm.acpi_s4, 0);
          xlu_cfg_get_defbool(config, "nx", &b_info->u.hvm.nx, 0);
Quoted 8 lines

tools/libxl/xl_cmdimpl.c static void parse_config_data(const char *config_source, · line 1039

Quoted 5 lines
tools/libxl/xl_cmdimpl.c +2 -0
          xlu_cfg_get_defbool(config, "viridian", &b_info->u.hvm.viridian, 0);
+        if (!xlu_cfg_get_long(config, "vmware_hw",  &l, 1))
+            b_info->u.hvm.vmware_hw = l;
          xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
          xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);

This is a really minor thing, but is there a reason you put this in the middle of a bunch of other get_defbool()s, instead of putting it just after? It makes the code just look a bit more ugly. :-)

Not a good one, I was just following where viridian was done. Will move it down a few lines.

-Don Slutz

Quoted 1 line

-George

author
#7 lore raw

PATCH v3 3/16 vmware: Add VMware provided include files.

In reply to Don Slutz

These 2 files: backdoor_def.h and guest_msg_def.h come from:

http://packages.vmware.com/tools/esx/3.5latest/rhel4/SRPMS/index.html
open-vm-tools-kmod-7.4.8-396269.423167.src.rpm
open-vm-tools-kmod-7.4.8.tar.gz
vmhgfs/backdoor_def.h
vmhgfs/guest_msg_def.h

and are unchanged.

Added the badly named include file includeCheck.h also. It only has comments and is provided so that backdoor_def.h and guest_msg_def.h can be used without change.

---
 xen/arch/x86/hvm/vmware/backdoor_def.h  | 167 ++++++++++++++++++++++++++++++++
 xen/arch/x86/hvm/vmware/guest_msg_def.h |  87 +++++++++++++++++
 xen/arch/x86/hvm/vmware/includeCheck.h  |  17 ++++
 3 files changed, 271 insertions(+)
 create mode 100644 xen/arch/x86/hvm/vmware/backdoor_def.h
 create mode 100644 xen/arch/x86/hvm/vmware/guest_msg_def.h
 create mode 100644 xen/arch/x86/hvm/vmware/includeCheck.h
xen/arch/x86/hvm/vmware/backdoor_def.h new file +167 -0
new file mode 100644
index 0000000..e76795f
@@ -0,0 +1,167 @@
+/* **********************************************************
+ * Copyright 1998 VMware, Inc.  All rights reserved. 
+ * **********************************************************
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+/*
+ * backdoor_def.h --
+ *
+ * This contains backdoor defines that can be included from
+ * an assembly language file.
+ */
+
+
+
+#ifndef _BACKDOOR_DEF_H_
+#define _BACKDOOR_DEF_H_
+
+#define INCLUDE_ALLOW_MODULE
+#define INCLUDE_ALLOW_USERLEVEL
+#define INCLUDE_ALLOW_VMMEXT
+#define INCLUDE_ALLOW_VMCORE
+#define INCLUDE_ALLOW_VMKERNEL
+#include "includeCheck.h"
+
+/*
+ * If you want to add a new low-level backdoor call for a guest userland
+ * application, please consider using the GuestRpc mechanism instead. --hpreg
+ */
+
+#define BDOOR_MAGIC 0x564D5868
+
+/* Low-bandwidth backdoor port. --hpreg */
+
+#define BDOOR_PORT 0x5658
+
+#define BDOOR_CMD_GETMHZ      		   1
+/*
+ * BDOOR_CMD_APMFUNCTION is used by:
+ *
+ * o The FrobOS code, which instead should either program the virtual chipset
+ *   (like the new BIOS code does, matthias offered to implement that), or not
+ *   use any VM-specific code (which requires that we correctly implement
+ *   "power off on CLI HLT" for SMP VMs, boris offered to implement that)
+ *
+ * o The old BIOS code, which will soon be jettisoned
+ *
+ *  --hpreg
+ */
+#define BDOOR_CMD_APMFUNCTION 		   2
+#define BDOOR_CMD_GETDISKGEO  		   3
+#define BDOOR_CMD_GETPTRLOCATION	      4
+#define BDOOR_CMD_SETPTRLOCATION	      5
+#define BDOOR_CMD_GETSELLENGTH		   6
+#define BDOOR_CMD_GETNEXTPIECE		   7
+#define BDOOR_CMD_SETSELLENGTH		   8
+#define BDOOR_CMD_SETNEXTPIECE		   9
+#define BDOOR_CMD_GETVERSION		      10
+#define BDOOR_CMD_GETDEVICELISTELEMENT	11
+#define BDOOR_CMD_TOGGLEDEVICE		   12
+#define BDOOR_CMD_GETGUIOPTIONS		   13
+#define BDOOR_CMD_SETGUIOPTIONS		   14
+#define BDOOR_CMD_GETSCREENSIZE		   15
+#define BDOOR_CMD_MONITOR_CONTROL       16
+#define BDOOR_CMD_GETHWVERSION          17
+#define BDOOR_CMD_OSNOTFOUND            18
+#define BDOOR_CMD_GETUUID               19
+#define BDOOR_CMD_GETMEMSIZE            20
+#define BDOOR_CMD_HOSTCOPY              21 /* Devel only */
+/* BDOOR_CMD_GETOS2INTCURSOR, 22, is very old and defunct. Reuse. */
+#define BDOOR_CMD_GETTIME               23 /* Deprecated. Use GETTIMEFULL. */
+#define BDOOR_CMD_STOPCATCHUP           24
+#define BDOOR_CMD_PUTCHR	        25 /* Devel only */
+#define BDOOR_CMD_ENABLE_MSG	        26 /* Devel only */
+#define BDOOR_CMD_GOTO_TCL	        27 /* Devel only */
+#define BDOOR_CMD_INITPCIOPROM		28
+#define BDOOR_CMD_INT13			29
+#define BDOOR_CMD_MESSAGE               30
+#define BDOOR_CMD_RSVD0                 31
+#define BDOOR_CMD_RSVD1                 32
+#define BDOOR_CMD_RSVD2                 33
+#define BDOOR_CMD_ISACPIDISABLED	34
+#define BDOOR_CMD_TOE			35 /* Not in use */
+/* BDOOR_CMD_INITLSIOPROM, 36, was merged with 28. Reuse. */
+#define BDOOR_CMD_PATCH_SMBIOS_STRUCTS  37
+#define BDOOR_CMD_MAPMEM                38 /* Devel only */
+#define BDOOR_CMD_ABSPOINTER_DATA	39
+#define BDOOR_CMD_ABSPOINTER_STATUS	40
+#define BDOOR_CMD_ABSPOINTER_COMMAND	41
+#define BDOOR_CMD_TIMER_SPONGE          42
+#define BDOOR_CMD_PATCH_ACPI_TABLES	43
+/* Catch-all to allow synchronous tests */
+#define BDOOR_CMD_DEVEL_FAKEHARDWARE	44 /* Debug only - needed in beta */
+#define BDOOR_CMD_GETHZ      		45
+#define BDOOR_CMD_GETTIMEFULL           46
+#define BDOOR_CMD_STATELOGGER           47
+#define BDOOR_CMD_CHECKFORCEBIOSSETUP	48
+#define BDOOR_CMD_LAZYTIMEREMULATION    49
+#define BDOOR_CMD_BIOSBBS               50
+#define BDOOR_CMD_MAX                   51
+
+/* 
+ * IMPORTANT NOTE: When modifying the behavior of an existing backdoor command,
+ * you must adhere to the semantics expected by the oldest Tools who use that
+ * command. Specifically, do not alter the way in which the command modifies 
+ * the registers. Otherwise backwards compatibility will suffer.
+ */
+
+/* High-bandwidth backdoor port. --hpreg */
+
+#define BDOORHB_PORT 0x5659
+
+#define BDOORHB_CMD_MESSAGE 0
+#define BDOORHB_CMD_MAX 1
+
+/*
+ * There is another backdoor which allows access to certain TSC-related
+ * values using otherwise illegal PMC indices when the pseudo_perfctr
+ * control flag is set.
+ */
+
+#define BDOOR_PMC_HW_TSC      0x10000
+#define BDOOR_PMC_REAL_NS     0x10001
+#define BDOOR_PMC_APPARENT_NS 0x10002
+
+#define IS_BDOOR_PMC(index)  (((index) | 3) == 0x10003)
+#define BDOOR_CMD(ecx)       ((ecx) & 0xffff)
+
+
+#ifdef VMM
+/*
+ *----------------------------------------------------------------------
+ *
+ * Backdoor_CmdRequiresFullyValidVCPU --
+ *
+ *    A few backdoor commands require the full VCPU to be valid
+ *    (including GDTR, IDTR, TR and LDTR). The rest get read/write
+ *    access to GPRs and read access to Segment registers (selectors).
+ *
+ * Result:
+ *    True iff VECX contains a command that require the full VCPU to
+ *    be valid.
+ *
+ *----------------------------------------------------------------------
+ */
+static INLINE Bool
+Backdoor_CmdRequiresFullyValidVCPU(unsigned cmd)
+{
+   return cmd == BDOOR_CMD_RSVD0 ||
+          cmd == BDOOR_CMD_RSVD1 ||
+          cmd == BDOOR_CMD_RSVD2;
+}
+#endif
+
+#endif
xen/arch/x86/hvm/vmware/guest_msg_def.h new file +87 -0

87 lines not on this page · raw message

xen/arch/x86/hvm/vmware/includeCheck.h new file +17 -0
new file mode 100644
index 0000000..26e0d59
@@ -0,0 +1,17 @@
+/*
+ * includeCheck.h
+ *
+ * Copyright (C) 2012 Verizon Corporation
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License Version 2 (GPLv2)
+ * as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details. <http://www.gnu.org/licenses/>.
+ */
+/*
+ * Nothing here.  Just to use backdoor_def.h without change.
+ */
Signature · 1 line
1.8.4
author
#8 lore raw

PATCH v3 4/16 hypervisor part of add vmware_port to xl.cfg

In reply to Don Slutz

Limited support of VMware's hyper-call.

This is both a more complete support then in currently provided by QEMU and/or KVM and less. The missing part requires QEMU changes and has been left out until the QEMU patches are accepted upstream.

VMware's hyper-call is also known as VMware Backdoor I/O Port.

Note: this support does not depend on vmware_hw being non-zero.

Summary is that VMware treats "IN EAX, DX" (or "OUT DX, EAX"; or "inl %dx, %eax" in AT&T syntax ) to port 0x5658 specially. Note:
since many operations return data in EAX, "OUT DX, EAX" does not work for them on VMware nor with this code.

Also this instruction is allowed to be used from ring 3. To support this the vmexit for GP needs to be enabled. I have not fully tested that nested HVM is doing the right thing for this.

An open source example of using this is:

http://open-vm-tools.sourceforge.net/

Which only uses "IN EAX, DX". Also

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

Lists just "inl (%%dx)" (I assume this is AT&T syntax and is the same as "inl %dx, %eax").

The support included is enough to allow VMware tools to install in a HVM domU.

For a debug=y build there is a new command line option vmport_debug=. It enabled output to the console of various stages of handling the "IN EAX, DX" instruction.

---
 xen/arch/x86/hvm/hvm.c                |  27 +++
 xen/arch/x86/hvm/svm/emulate.c        |  26 ++-
 xen/arch/x86/hvm/svm/svm.c            |  39 ++++-
 xen/arch/x86/hvm/svm/vmcb.c           |   1 +
 xen/arch/x86/hvm/vmware/Makefile      |   1 +
 xen/arch/x86/hvm/vmware/vmport.c      | 311 ++++++++++++++++++++++++++++++++++
 xen/arch/x86/hvm/vmx/vmcs.c           |   1 +
 xen/arch/x86/hvm/vmx/vmx.c            |  60 +++++++
 xen/arch/x86/hvm/vmx/vvmx.c           |  14 ++
 xen/include/asm-x86/hvm/io.h          |   2 +-
 xen/include/asm-x86/hvm/svm/emulate.h |  13 +-
 xen/include/asm-x86/hvm/vmport.h      |  61 +++++++
 xen/include/public/hvm/params.h       |   3 +-
 13 files changed, 547 insertions(+), 12 deletions(-)
 create mode 100644 xen/arch/x86/hvm/vmware/vmport.c
 create mode 100644 xen/include/asm-x86/hvm/vmport.h
xen/arch/x86/hvm/hvm.c +27 -0
index 365331a..67ad37f 100644
@@ -58,6 +58,7 @@
 #include <asm/hvm/trace.h>
 #include <asm/hvm/nestedhvm.h>
 #include <asm/hvm/vmware.h>
+#include <asm/hvm/vmport.h>
 #include <asm/mtrr.h>
 #include <asm/apic.h>
 #include <public/sched.h>
@@ -5714,6 +5715,32 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
                     break;
                 }
                 break;
+            case HVM_PARAM_VMWARE_PORT:
+                /*
+                 * This should only ever be set non-zero one time by
+                 * the tools and is read only by the guest.
+                 */
+                if ( d == current->domain )
+                {
+                    rc = -EPERM;
+                    break;
+                }
+                if ( a.value > 1 )
+                {
+                    rc = -EINVAL;
+                    break;
+                }
+                if ( a.value )
+                {
+                    if ( !d->arch.hvm_domain.params[HVM_PARAM_VMWARE_PORT] )
+                        vmport_register(d);
+                }
+                else if ( d->arch.hvm_domain.params[HVM_PARAM_VMWARE_PORT] )
+                {
+                    rc = -EEXIST;
+                    break;
+                }
+                break;
             }
 
             if ( rc == 0 ) 
xen/arch/x86/hvm/svm/emulate.c +20 -6
index 37a1ece..2446eb7 100644
@@ -50,7 +50,7 @@ static unsigned int is_prefix(u8 opc)
     return 0;
 }
 
-static unsigned long svm_rip2pointer(struct vcpu *v)
+unsigned long svm_rip2pointer(struct vcpu *v)
 {
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
     unsigned long p = vmcb->cs.base + guest_cpu_user_regs()->eip;
@@ -78,6 +78,7 @@ static unsigned long svm_nextrip_insn_length(struct vcpu *v)
         /* ...and the rest of the #VMEXITs */
     case VMEXIT_CR0_SEL_WRITE:
     case VMEXIT_EXCEPTION_BP:
+    case VMEXIT_EXCEPTION_GP:
         break;
     default:
         BUG();
@@ -95,6 +96,10 @@ MAKE_INSTR(CPUID,  2, 0x0f, 0xa2);
 MAKE_INSTR(RDMSR,  2, 0x0f, 0x32);
 MAKE_INSTR(WRMSR,  2, 0x0f, 0x30);
 MAKE_INSTR(VMCALL, 3, 0x0f, 0x01, 0xd9);
+MAKE_INSTR(INB_DX, 1, 0xec);
+MAKE_INSTR(INL_DX, 1, 0xed);
+MAKE_INSTR(OUTB_DX,1, 0xee);
+MAKE_INSTR(OUTL_DX,1, 0xef);
 MAKE_INSTR(HLT,    1, 0xf4);
 MAKE_INSTR(INT3,   1, 0xcc);
 MAKE_INSTR(RDTSC,  2, 0x0f, 0x31);
@@ -115,6 +120,10 @@ static const u8 *const opc_bytes[INSTR_MAX_COUNT] =
     [INSTR_RDMSR]  = OPCODE_RDMSR,
     [INSTR_WRMSR]  = OPCODE_WRMSR,
     [INSTR_VMCALL] = OPCODE_VMCALL,
+    [INSTR_INB_DX] = OPCODE_INB_DX,
+    [INSTR_INL_DX] = OPCODE_INL_DX,
+    [INSTR_OUTB_DX] = OPCODE_OUTB_DX,
+    [INSTR_OUTL_DX] = OPCODE_OUTL_DX,
     [INSTR_HLT]    = OPCODE_HLT,
     [INSTR_INT3]   = OPCODE_INT3,
     [INSTR_RDTSC]  = OPCODE_RDTSC,
@@ -152,7 +161,9 @@ static int fetch(struct vcpu *v, u8 *buf, unsigned long addr, int len)
 }
 
 int __get_instruction_length_from_list(struct vcpu *v,
-        const enum instruction_index *list, unsigned int list_count)
+                                       const enum instruction_index *list,
+                                       unsigned int list_count,
+                                       bool_t err_rpt)
 {
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
     unsigned int i, j, inst_len = 0;
@@ -211,10 +222,13 @@ int __get_instruction_length_from_list(struct vcpu *v,
     mismatch: ;
     }
 
-    gdprintk(XENLOG_WARNING,
-             "%s: Mismatch between expected and actual instruction bytes: "
-             "eip = %lx\n",  __func__, (unsigned long)vmcb->rip);
-    hvm_inject_hw_exception(TRAP_gp_fault, 0);
+    if ( err_rpt )
+    {
+        gdprintk(XENLOG_WARNING,
+                 "%s: Mismatch between expected and actual instruction bytes: "
+                 "eip = %lx\n",  __func__, (unsigned long)vmcb->rip);
+        hvm_inject_hw_exception(TRAP_gp_fault, 0);
+    }
     return 0;
 
  done:
xen/arch/x86/hvm/svm/svm.c +38 -1
index b5188e6..12079be 100644
@@ -59,6 +59,7 @@
 #include <public/sched.h>
 #include <asm/hvm/vpt.h>
 #include <asm/hvm/trace.h>
+#include <asm/hvm/vmport.h>
 #include <asm/hap.h>
 #include <asm/apic.h>
 #include <asm/debugger.h>
@@ -2065,6 +2066,38 @@ svm_vmexit_do_vmsave(struct vmcb_struct *vmcb,
     return;
 }
 
+static void svm_vmexit_gp_intercept(struct cpu_user_regs *regs,
+                                    struct vcpu *v)
+{
+    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+    unsigned long inst_len;
+    unsigned long inst_addr = svm_rip2pointer(v);
+    int rc;
+    static const enum instruction_index list[] = {
+        INSTR_INL_DX, INSTR_INB_DX, INSTR_OUTL_DX, INSTR_OUTB_DX
+    };
+
+    regs->error_code = vmcb->exitinfo1;
+    inst_len = __get_instruction_length_from_list(
+        v, list, ARRAY_SIZE(list), 0);
+
+    rc = vmport_gp_check(regs, v, inst_len, inst_addr, vmcb->exitinfo2);
+    if ( !rc )
+        __update_guest_eip(regs, inst_len);
+    else
+    {
+        VMPORT_DBG_LOG(VMPORT_LOG_GP_UNKNOWN,
+                       "gp: rc=%d e2=%lx ec=%lx ip=%"PRIx64" (%ld) ax=%"PRIx64
+                       " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64
+                       " di=%"PRIx64, rc,
+                       (unsigned long)vmcb->exitinfo2,
+                       (unsigned long)regs->error_code,
+                       regs->rip, inst_len, regs->rax, regs->rbx, regs->rcx,
+                       regs->rdx, regs->rsi, regs->rdi);
+        hvm_inject_hw_exception(TRAP_gp_fault, regs->error_code);
+    }
+}
+
 static void svm_vmexit_ud_intercept(struct cpu_user_regs *regs)
 {
     struct hvm_emulate_ctxt ctxt;
@@ -2140,7 +2173,7 @@ static void svm_vmexit_do_invalidate_cache(struct cpu_user_regs *regs)
     int inst_len;
 
     inst_len = __get_instruction_length_from_list(
-        current, list, ARRAY_SIZE(list));
+        current, list, ARRAY_SIZE(list), 1);
     if ( inst_len == 0 )
         return;
 
@@ -2412,6 +2445,10 @@ void svm_vmexit_handler(struct cpu_user_regs *regs)
         break;
     }
 
+    case VMEXIT_EXCEPTION_GP:
+        svm_vmexit_gp_intercept(regs, v);
+        break;
+
     case VMEXIT_EXCEPTION_UD:
         svm_vmexit_ud_intercept(regs);
         break;
xen/arch/x86/hvm/svm/vmcb.c +1 -0
index 21292bb..791c045 100644
@@ -193,6 +193,7 @@ static int construct_vmcb(struct vcpu *v)
 
     vmcb->_exception_intercepts =
         HVM_TRAP_MASK
+        | (1U << TRAP_gp_fault)
         | (1U << TRAP_no_device);
 
     if ( paging_mode_hap(v->domain) )
xen/arch/x86/hvm/vmware/Makefile +1 -0
index 3fb2e0b..cd8815b 100644
@@ -1 +1,2 @@
 obj-y += cpuid.o
+obj-y += vmport.o
xen/arch/x86/hvm/vmware/vmport.c new file +311 -0

311 lines not on this page · raw message

xen/arch/x86/hvm/vmx/vmcs.c +1 -0
index 4a4f4e1..fa1f69a 100644
@@ -1077,6 +1077,7 @@ static int construct_vmcs(struct vcpu *v)
 
     v->arch.hvm_vmx.exception_bitmap = HVM_TRAP_MASK
               | (paging_mode_hap(d) ? 0 : (1U << TRAP_page_fault))
+              | (1U << TRAP_gp_fault)
               | (1U << TRAP_no_device);
     vmx_update_exception_bitmap(v);
 
xen/arch/x86/hvm/vmx/vmx.c +60 -0

90 lines not on this page · raw message

xen/arch/x86/hvm/vmx/vvmx.c +14 -0
index 9ccc03f..51d2336 100644
@@ -24,6 +24,7 @@
 #include <asm/types.h>
 #include <asm/mtrr.h>
 #include <asm/p2m.h>
+#include <asm/hvm/vmport.h>
 #include <asm/hvm/vmx/vmx.h>
 #include <asm/hvm/vmx/vvmx.h>
 #include <asm/hvm/nestedhvm.h>
@@ -2182,6 +2183,19 @@ int nvmx_n2_vmexit_handler(struct cpu_user_regs *regs,
             if ( v->fpu_dirtied )
                 nvcpu->nv_vmexit_pending = 1;
         }
+        else if ( vector == TRAP_gp_fault )
+        {
+#ifndef NDEBUG
+            struct cpu_user_regs *ur = guest_cpu_user_regs();
+            VMPORT_DBG_LOG(VMPORT_LOG_VGP_UNKNOWN,
+                           "Unexpected gp: ip=%"PRIx64" ax=%"PRIx64
+                           " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64
+                           " si=%"PRIx64" di=%"PRIx64,
+                           ur->rip, ur->rax, ur->rbx, ur->rcx, ur->rdx,
+                           ur->rsi, ur->rdi);
+#endif
+            nvcpu->nv_vmexit_pending = 1;
+        }
         else if ( (intr_info & valid_mask) == valid_mask )
         {
             exec_bitmap =__get_vvmcs(nvcpu->nv_vvmcx, EXCEPTION_BITMAP);
xen/include/asm-x86/hvm/io.h +1 -1
index 886a9d6..d257161 100644
@@ -25,7 +25,7 @@
 #include <public/hvm/ioreq.h>
 #include <public/event_channel.h>
 
-#define MAX_IO_HANDLER             16
+#define MAX_IO_HANDLER             17
 
 #define HVM_PORTIO                  0
 #define HVM_BUFFERED_IO             2
xen/include/asm-x86/hvm/svm/emulate.h +10 -3
index ccc2d3c..542b6b8 100644
@@ -39,18 +39,25 @@ enum instruction_index {
     INSTR_STGI,
     INSTR_CLGI,
     INSTR_INVLPGA,
+    INSTR_INL_DX,
+    INSTR_INB_DX,
+    INSTR_OUTL_DX,
+    INSTR_OUTB_DX,
     INSTR_MAX_COUNT /* Must be last - Number of instructions supported */
 };
 
 struct vcpu;
 
-int __get_instruction_length_from_list(
-    struct vcpu *, const enum instruction_index *, unsigned int list_count);
+unsigned long svm_rip2pointer(struct vcpu *v);
+int __get_instruction_length_from_list(struct vcpu *,
+                                       const enum instruction_index *,
+                                       unsigned int list_count,
+                                       bool_t err_rpt);
 
 static inline int __get_instruction_length(
     struct vcpu *v, enum instruction_index instr)
 {
-    return __get_instruction_length_from_list(v, &instr, 1);
+    return __get_instruction_length_from_list(v, &instr, 1, 1);
 }
 
 #endif /* __ASM_X86_HVM_SVM_EMULATE_H__ */
xen/include/asm-x86/hvm/vmport.h new file +61 -0

61 lines not on this page · raw message

xen/include/public/hvm/params.h +2 -1
index dee6d68..77ff539 100644
@@ -153,7 +153,8 @@
 
 /* Params for VMware */
 #define HVM_PARAM_VMWARE_HW                 35
+#define HVM_PARAM_VMWARE_PORT               36
 
-#define HVM_NR_PARAMS          36
+#define HVM_NR_PARAMS          37
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
Signature · 1 line
1.8.4
#9 lore raw

Re: [PATCH v3 04/16] hypervisor part of add vmware_port to xl.cfg

Quoted 18 lines · Don Slutz
xen/arch/x86/hvm/svm/svm.c +3 -0
index b5188e6..12079be 100644
@@ -59,6 +59,7 @@
  #include <public/sched.h>
  #include <asm/hvm/vpt.h>
  #include <asm/hvm/trace.h>
+#include <asm/hvm/vmport.h>
  #include <asm/hap.h>
  #include <asm/apic.h>
  #include <asm/debugger.h>
@@ -2065,6 +2066,38 @@ svm_vmexit_do_vmsave(struct vmcb_struct *vmcb,
      return;
  }
 
+static void svm_vmexit_gp_intercept(struct cpu_user_regs *regs,
+                                    struct vcpu *v)

xen/arch/x86/hvm/svm/svm.c svm_vmexit_do_vmsave(struct vmcb_struct *vmcb, · line 2080

Quoted 10 lines
xen/arch/x86/hvm/svm/svm.c +10 -0
+{
+    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+    unsigned long inst_len;
+    unsigned long inst_addr = svm_rip2pointer(v);
+    int rc;
+    static const enum instruction_index list[] = {
+        INSTR_INL_DX, INSTR_INB_DX, INSTR_OUTL_DX, INSTR_OUTB_DX
+    };
+
+    regs->error_code = vmcb->exitinfo1;

I am not sure this is a good idea. I have a feeling this may mess up fault reporting in case of double faults (e.g. see AMD volume 2 section 15.2, Example paragraph).

Do you really need to save it into regs or can out pass exitinfo1 as error_code argument directly to vmport_gp_check()?

xen/arch/x86/hvm/svm/svm.c svm_vmexit_do_vmsave(struct vmcb_struct *vmcb, · line 2084

Quoted 4 lines
xen/arch/x86/hvm/svm/svm.c +4 -0
+    inst_len = __get_instruction_length_from_list(
+        v, list, ARRAY_SIZE(list), 0);
+
+    rc = vmport_gp_check(regs, v, inst_len, inst_addr, vmcb->exitinfo2);

You probably want to call this only when __get_instruction_length_from_list() succeeded (i.e. instr_len >0)

What happens when you have a non-VMware-aware guest that performs this access? Prior to this patch it would get a #GP but now it will continue happily running, right? This changes user-visible behavior.

I wonder whether we should enable #GP intercepts only when we know that the guest is VMware-aware (which we do as far as I can tell since we have a config option).

-boris

Quoted 17 lines
xen/arch/x86/hvm/svm/svm.c +16 -0
+    if ( !rc )
+        __update_guest_eip(regs, inst_len);
+    else
+    {
+        VMPORT_DBG_LOG(VMPORT_LOG_GP_UNKNOWN,
+                       "gp: rc=%d e2=%lx ec=%lx ip=%"PRIx64" (%ld) ax=%"PRIx64
+                       " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64
+                       " di=%"PRIx64, rc,
+                       (unsigned long)vmcb->exitinfo2,
+                       (unsigned long)regs->error_code,
+                       regs->rip, inst_len, regs->rax, regs->rbx, regs->rcx,
+                       regs->rdx, regs->rsi, regs->rdi);
+        hvm_inject_hw_exception(TRAP_gp_fault, regs->error_code);
+    }
+}
+
 
#10 lore raw

Re: [PATCH v3 04/16] hypervisor part of add vmware_port to xl.cfg

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 08.09.14 at 17:01, <[email protected]> wrote:

I wonder whether we should enable #GP intercepts only when we know that the guest is VMware-aware (which we do as far as I can tell since we have a config option).

I didn't look at the patches themselves yes, but I very much expected this to now be the case considering discussion on the earlier version. If it's not, I'm not even sure looking at the new version is going to be of much use...

Jan

#11 lore raw

Re: [PATCH v3 04/16] hypervisor part of add vmware_port to xl.cfg

Quoted 11 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 08.09.14 at 17:01, <[email protected]> wrote:

I wonder whether we should enable #GP intercepts only when we know that the guest is VMware-aware (which we do as far as I can tell since we have a config option).

I didn't look at the patches themselves yes, but I very much expected this to now be the case considering discussion on the earlier version. If it's not, I'm not even sure looking at the new version is going to be of much use...

Jan

I find it incredibly hard to believe that VMWare do unconditional #GP exits, and looking at the Intel manual, you do not actually need to intercept #GP faults.

The "unconditional I/O exiting" control can be used to cherry-pick specific IO ports in combination with the IO port bitmap, ahead of the #GP fault due to a failure of IOPL. I would expect AMD has a similar option.

~Andrew

#12 lore raw

Re: [PATCH v3 04/16] hypervisor part of add vmware_port to xl.cfg

Quoted 12 lines · Andrew Cooper
Quoted 11 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 08.09.14 at 17:01, <[email protected]> wrote:

I wonder whether we should enable #GP intercepts only when we know that the guest is VMware-aware (which we do as far as I can tell since we have a config option).

I didn't look at the patches themselves yes, but I very much expected this to now be the case considering discussion on the earlier version. If it's not, I'm not even sure looking at the new version is going to be of much use...

Jan

Quoted 8 lines

I find it incredibly hard to believe that VMWare do unconditional #GP exits, and looking at the Intel manual, you do not actually need to intercept #GP faults.

The "unconditional I/O exiting" control can be used to cherry-pick specific IO ports in combination with the IO port bitmap, ahead of the #GP fault due to a failure of IOPL. I would expect AMD has a similar option.

Yes, it does. However, I believe #GP intercept has been added so that IO access can be made from guest's ring 3 as well, not to handle IO access in general.

Having said that, I don't remember seeing updates to IO permissions map in the patch.

-boris

author
#13 lore raw

Re: [PATCH v3 04/16] hypervisor part of add vmware_port to xl.cfg

Quoted 11 lines · Boris Ostrovsky
Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 08.09.14 at 17:01, <[email protected]> wrote:

I wonder whether we should enable #GP intercepts only when we know that the guest is VMware-aware (which we do as far as I can tell since we have a config option).

I didn't look at the patches themselves yes, but I very much expected this to now be the case considering discussion on the earlier version. If it's not, I'm not even sure looking at the new version is going to be of much use...

Getting the adjustment of #GP exits at the time of setting of hvm param vmware_port to 1 is more complex. But I do think that the allowing it to be deferred until the next #VMEXIT would work just fine.

I will see how well that works.

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Jan

I find it incredibly hard to believe that VMWare do unconditional #GP exits, and looking at the Intel manual, you do not actually need to intercept #GP faults.

Quoted 9 lines
Quoted 4 lines

The "unconditional I/O exiting" control can be used to cherry-pick specific IO ports in combination with the IO port bitmap, ahead of the #GP fault due to a failure of IOPL. I would expect AMD has a similar option.

Yes, it does. However, I believe #GP intercept has been added so that IO access can be made from guest's ring 3 as well, not to handle IO access in general.

Having said that, I don't remember seeing updates to IO permissions map in the patch.

There are no updates to IO permissions map. My understanding that it controls access to real hardware, not that it changes the IOPL checking in the in instruction.

Here is what I am looking at:

This control determines whether executions of I/O instructions (IN, INS/INSB/INSW/INSD, OUT, and OUTS/OUTSB/OUTSW/OUTSD) cause VM exits.

Which to me is about #VMEXIT or access host hardware, not "Change a #GP into a #VMEXIT for this port."

The goal is to get #VMEXITs when needed, not to allow domU to access a VMware running Xen under it.

For the non-#GP case (domU ring 0 access to the port), it is handled by register_portio_handler() which would adjust the IO permissions map as needed.

-Don Slutz

Quoted 2 lines

-boris

author
#14 lore raw

Re: [PATCH v3 04/16] hypervisor part of add vmware_port to xl.cfg

In reply to Boris Ostrovsky
Quoted 32 lines · Boris Ostrovsky
Quoted 17 lines · Don Slutz
xen/arch/x86/hvm/svm/svm.c +2 -0
index b5188e6..12079be 100644
@@ -59,6 +59,7 @@
  #include <public/sched.h>
  #include <asm/hvm/vpt.h>
  #include <asm/hvm/trace.h>
+#include <asm/hvm/vmport.h>
  #include <asm/hap.h>
  #include <asm/apic.h>
  #include <asm/debugger.h>
@@ -2065,6 +2066,38 @@ svm_vmexit_do_vmsave(struct vmcb_struct *vmcb,
      return;
  }
  +static void svm_vmexit_gp_intercept(struct cpu_user_regs *regs,
+                                    struct vcpu *v)

xen/arch/x86/hvm/svm/svm.c svm_vmexit_do_vmsave(struct vmcb_struct *vmcb, · line 2079

Quoted 10 lines
xen/arch/x86/hvm/svm/svm.c +10 -0
+{
+    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
+    unsigned long inst_len;
+    unsigned long inst_addr = svm_rip2pointer(v);
+    int rc;
+    static const enum instruction_index list[] = {
+        INSTR_INL_DX, INSTR_INB_DX, INSTR_OUTL_DX, INSTR_OUTB_DX
+    };
+
+    regs->error_code = vmcb->exitinfo1;

I am not sure this is a good idea. I have a feeling this may mess up fault reporting in case of double faults (e.g. see AMD volume 2 section 15.2, Example paragraph).

Quoted 2 lines

Do you really need to save it into regs or can out pass exitinfo1 as error_code argument directly to vmport_gp_check()?

Nope. I can pass this on.

Quoted 8 lines

xen/arch/x86/hvm/svm/svm.c svm_vmexit_do_vmsave(struct vmcb_struct *vmcb,

Quoted 5 lines
xen/arch/x86/hvm/svm/svm.c +4 -0
+    inst_len = __get_instruction_length_from_list(
+        v, list, ARRAY_SIZE(list), 0);
+
+    rc = vmport_gp_check(regs, v, inst_len, inst_addr, 
 vmcb->exitinfo2);

You probably want to call this only when __get_instruction_length_from_list() succeeded (i.e. instr_len >0)

This check is inside the vmport_gp_check(). I can extract it to both callers if that makes sense.

Quoted 2 lines

What happens when you have a non-VMware-aware guest that performs this access? Prior to this patch it would get a #GP but now it will continue happily running, right? This changes user-visible behavior.

It depends on the setting of vmware_port. It will still get a #GP if vmware_port is zero. And yes when the config of a guest is changed to include vmware_port, this changes user-visible behavior.

Quoted 2 lines

I wonder whether we should enable #GP intercepts only when we know that the guest is VMware-aware (which we do as far as I can tell since we have a config option).

This may make sense. The way the code is now, the only change is how long it takes to get a #GP when vmware_port is zero.

I did some looking into enabling and disabling #GP intercepts but did not come up with a simple way at the time. I also thought about it and came to the conclusion and the number of #GPs that a guest takes which is not VMware-aware is very few. So add a lot of complex code seemed to me to be worse. I can look at it again.

-Don Slutz

Quoted 24 lines

-boris

Quoted 20 lines
xen/arch/x86/hvm/svm/svm.c +6 -0
+    if ( !rc )
+        __update_guest_eip(regs, inst_len);
+    else
+    {
+        VMPORT_DBG_LOG(VMPORT_LOG_GP_UNKNOWN,
+                       "gp: rc=%d e2=%lx ec=%lx ip=%"PRIx64" (%ld) 

ax=%"PRIx64
+ " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64"
si=%"PRIx64

xen/arch/x86/hvm/svm/svm.c +4 -0
+                       " di=%"PRIx64, rc,
+                       (unsigned long)vmcb->exitinfo2,
+                       (unsigned long)regs->error_code,
+                       regs->rip, inst_len, regs->rax, regs->rbx, 

regs->rcx,

xen/arch/x86/hvm/svm/svm.c +5 -0
+                       regs->rdx, regs->rsi, regs->rdi);
+        hvm_inject_hw_exception(TRAP_gp_fault, regs->error_code);
+    }
+}
+
#15 lore raw

Re: [PATCH v3 04/16] hypervisor part of add vmware_port to xl.cfg

In reply to Don Slutz
Quoted 30 lines · Don Slutz

Limited support of VMware's hyper-call.

This is both a more complete support then in currently provided by QEMU and/or KVM and less. The missing part requires QEMU changes and has been left out until the QEMU patches are accepted upstream.

VMware's hyper-call is also known as VMware Backdoor I/O Port.

Note: this support does not depend on vmware_hw being non-zero.

Summary is that VMware treats "IN EAX, DX" (or "OUT DX, EAX"; or "inl %dx, %eax" in AT&T syntax ) to port 0x5658 specially. Note:
since many operations return data in EAX, "OUT DX, EAX" does not work for them on VMware nor with this code.

Also this instruction is allowed to be used from ring 3. To support this the vmexit for GP needs to be enabled. I have not fully tested that nested HVM is doing the right thing for this.

An open source example of using this is:

http://open-vm-tools.sourceforge.net/

Which only uses "IN EAX, DX". Also

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

Lists just "inl (%%dx)" (I assume this is AT&T syntax and is the same as "inl %dx, %eax").

Quoted 8 lines

The support included is enough to allow VMware tools to install in a HVM domU.

For a debug=y build there is a new command line option vmport_debug=. It enabled output to the console of various stages of handling the "IN EAX, DX" instruction.

Patch title "xen: Implement VMWare hypercall (magic port)" or something like that

xen/arch/x86/hvm/svm/emulate.c static unsigned int is_prefix(u8 opc) · line 53

Quoted 10 lines
xen/arch/x86/hvm/svm/emulate.c +1 -1
index 37a1ece..2446eb7 100644
@@ -50,7 +50,7 @@ static unsigned int is_prefix(u8 opc)
     return 0;
 }
 
-static unsigned long svm_rip2pointer(struct vcpu *v)
+unsigned long svm_rip2pointer(struct vcpu *v)

I think we tend to use '_to_' instead of '2'; so this should be svm_rip_to_pointer()

xen/arch/x86/hvm/svm/emulate.c static int fetch(struct vcpu *v, u8 *buf, unsigned long addr, int len) · line 166

Quoted 8 lines
xen/arch/x86/hvm/svm/emulate.c +3 -1
@@ -152,7 +161,9 @@ static int fetch(struct vcpu *v, u8 *buf, unsigned long addr, int len)
 }
 
 int __get_instruction_length_from_list(struct vcpu *v,
-        const enum instruction_index *list, unsigned int list_count)
+                                       const enum instruction_index *list,
+                                       unsigned int list_count,
+                                       bool_t err_rpt)

"err_rpt" reads to me as "error report" -- what's functinally distinct about this is whether you deliver the gp or not, not whether it does a printk. I'd call this "inject_gp" or "gp_on_mismatch" or something.

Quoted 220 lines
xen/arch/x86/hvm/vmware/vmport.c new file +214 -0
new file mode 100644
index 0000000..a6fd95c
@@ -0,0 +1,311 @@
+/*
+ * HVM VMPORT emulation
+ *
+ * Copyright (C) 2012 Verizon Corporation
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License Version 2 (GPLv2)
+ * as published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details. <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/config.h>
+#include <xen/lib.h>
+#include <asm/hvm/hvm.h>
+#include <asm/hvm/support.h>
+#include <asm/hvm/vmport.h>
+
+#include "backdoor_def.h"
+#include "guest_msg_def.h"
+
+#ifndef NDEBUG
+unsigned int opt_vmport_debug __read_mostly;
+integer_param("vmport_debug", opt_vmport_debug);
+#endif
+
+/* More VMware defines */
+
+#define VMWARE_GUI_AUTO_GRAB              0x001
+#define VMWARE_GUI_AUTO_UNGRAB            0x002
+#define VMWARE_GUI_AUTO_SCROLL            0x004
+#define VMWARE_GUI_AUTO_RAISE             0x008
+#define VMWARE_GUI_EXCHANGE_SELECTIONS    0x010
+#define VMWARE_GUI_WARP_CURSOR_ON_UNGRAB  0x020
+#define VMWARE_GUI_FULL_SCREEN            0x040
+
+#define VMWARE_GUI_TO_FULL_SCREEN         0x080
+#define VMWARE_GUI_TO_WINDOW              0x100
+
+#define VMWARE_GUI_AUTO_RAISE_DISABLED    0x200
+
+#define VMWARE_GUI_SYNC_TIME              0x400
+
+/* When set, toolboxes should not show the cursor options page. */
+#define VMWARE_DISABLE_CURSOR_OPTIONS     0x800
+
+inline uint16_t get_low_bits(uint32_t bits)
+{
+    return bits & 0xffff;
+}
+
+void vmport_register(struct domain *d)
+{
+    register_portio_handler(d, BDOOR_PORT, 4, vmport_ioport);
+}
+
+int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val)
+{
+    struct cpu_user_regs *regs = guest_cpu_user_regs();
+    uint32_t cmd = get_low_bits(regs->rcx);
+    uint32_t magic = regs->rax;
+    int rc = X86EMUL_OKAY;
+
+    if ( magic == BDOOR_MAGIC )
+    {
+        uint64_t saved_rax = regs->rax;
+        uint64_t value;
+
+        VMPORT_DBG_LOG(VMPORT_LOG_TRACE,
+                       "VMware trace dir=%d bytes=%u ip=%"PRIx64" cmd=%d ax=%"
+                       PRIx64" bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"
+                       PRIx64" di=%"PRIx64"\n", dir, bytes,
+                       regs->rip, cmd, regs->rax, regs->rbx, regs->rcx,
+                       regs->rdx, regs->rsi, regs->rdi);
+        switch ( cmd )
+        {
+        case BDOOR_CMD_GETMHZ:
+            /* ... */
+            regs->rbx = BDOOR_MAGIC;
+            regs->rax = current->domain->arch.tsc_khz / 1000;
+            break;
+        case BDOOR_CMD_GETVERSION:
+            /* ... */
+            regs->rbx = BDOOR_MAGIC;
+            /* VERSION_MAGIC */
+            regs->rax = 6;
+            /* Claim we are an ESX. VMX_TYPE_SCALABLE_SERVER */
+            regs->rcx = 2;
+            break;
+        case BDOOR_CMD_GETHWVERSION:
+            /* ... */
+            regs->rbx = BDOOR_MAGIC;
+            /* vmware_hw */
+            regs->rax = 0;
+            if ( is_hvm_vcpu(current) )
+            {
+                struct hvm_domain *hd = &current->domain->arch.hvm_domain;
+
+                regs->rax = hd->params[HVM_PARAM_VMWARE_HW];
+            }
+            if ( !regs->rax )
+                regs->rax = 4;  /* Act like version 4 */
+            break;
+        case BDOOR_CMD_GETHZ:
+            value = current->domain->arch.tsc_khz * 1000;
+            /* apic-frequency (bus speed) */
+            regs->rcx = (uint32_t)(1000000000ULL / APIC_BUS_CYCLE_NS);
+            /* High part of tsc-frequency */
+            regs->rbx = (uint32_t)(value >> 32);
+            /* Low part of tsc-frequency */
+            regs->rax = value;
+            break;
+        case BDOOR_CMD_GETTIME:
+            value = get_localtime_us(current->domain);
+            /* hostUsecs */
+            regs->rbx = (uint32_t)(value % 1000000UL);
+            /* hostSecs */
+            regs->rax = value / 1000000ULL;
+            /* maxTimeLag */
+            regs->rcx = 0;
+            break;
+        case BDOOR_CMD_GETTIMEFULL:
+            value = get_localtime_us(current->domain);
+            /* ... */
+            regs->rax = BDOOR_MAGIC;
+            /* hostUsecs */
+            regs->rbx = (uint32_t)(value % 1000000UL);
+            /* High part of hostSecs */
+            regs->rsi = (uint32_t)((value / 1000000ULL) >> 32);
+            /* Low part of hostSecs */
+            regs->rdx = (uint32_t)(value / 1000000ULL);
+            /* maxTimeLag */
+            regs->rcx = 0;
+            break;
+        case BDOOR_CMD_GETGUIOPTIONS:
+            regs->rax = VMWARE_GUI_AUTO_GRAB | VMWARE_GUI_AUTO_UNGRAB |
+                VMWARE_GUI_AUTO_RAISE_DISABLED | VMWARE_GUI_SYNC_TIME |
+                VMWARE_DISABLE_CURSOR_OPTIONS;
+            break;
+        case BDOOR_CMD_SETGUIOPTIONS:
+            regs->rax = 0x0;
+            break;
+        default:
+            VMPORT_DBG_LOG(VMPORT_LOG_ERROR,
+                           "VMware bytes=%d dir=%d cmd=%d",
+                           bytes, dir, cmd);
+            break;
+        }
+        VMPORT_DBG_LOG(VMPORT_LOG_VMWARE_AFTER,
+                       "VMware after ip=%"PRIx64" cmd=%d ax=%"PRIx64" bx=%"
+                       PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64" di=%"
+                       PRIx64"\n",
+                       regs->rip, cmd, regs->rax, regs->rbx, regs->rcx,
+                       regs->rdx, regs->rsi, regs->rdi);
+        if ( dir == IOREQ_READ )
+        {
+            switch ( bytes )
+            {
+            case 1:
+                regs->rax = (saved_rax & 0xffffff00) | (regs->rax & 0xff);
+                break;
+            case 2:
+                regs->rax = (saved_rax & 0xffff0000) | get_low_bits(regs->rax);
+                break;
+            case 4:
+                regs->rax = (uint32_t)regs->rax;
+                break;
+            }
+            *val = regs->rax;
+        }
+        else
+            regs->rax = saved_rax;
+    }
+    else
+    {
+        rc = X86EMUL_UNHANDLEABLE;
+        VMPORT_DBG_LOG(VMPORT_LOG_ERROR,
+                       "Not VMware %x vs %x; ip=%"PRIx64" ax=%"PRIx64
+                       " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64
+                       " di=%"PRIx64"",
+                       magic, BDOOR_MAGIC, regs->rip, regs->rax, regs->rbx,
+                       regs->rcx, regs->rdx, regs->rsi, regs->rdi);
+    }
+
+    return rc;
+}
+
+int vmport_gp_check(struct cpu_user_regs *regs, struct vcpu *v,
+                    unsigned long inst_len, unsigned long inst_addr,
+                    unsigned long ei)
+{
+    if ( !v->domain->arch.hvm_domain.params[HVM_PARAM_VMWARE_PORT] )
+        return 10;
+
+    if ( inst_len && inst_len <= 2 && get_low_bits(regs->rdx) == BDOOR_PORT &&
+         ei == 0 && regs->error_code == 0 &&
+         (uint32_t)regs->rax == BDOOR_MAGIC )
+    {
+        int i = 0;
+        uint32_t val;
+        uint32_t byte_cnt = 4;
+        unsigned char bytes[2];
+        unsigned int fetch_len;
+        int frc;
+        int rc;
+
+        /*
+         * Fetch up to the next page break; we'll fetch from the
+         * next page later if we have to.
+         */
+        fetch_len = min_t(unsigned int, inst_len,

xen/arch/x86/hvm/vmware/vmport.c line 224

Quoted 10 lines
xen/arch/x86/hvm/vmware/vmport.c new file +10 -0
+                          PAGE_SIZE - (inst_addr  & ~PAGE_MASK));
+        frc = hvm_fetch_from_guest_virt_nofault(bytes, inst_addr, fetch_len,
+                                                PFEC_page_present);
+        if ( frc != HVMCOPY_okay )
+        {
+            gdprintk(XENLOG_WARNING,
+                     "Bad instruction fetch at %#lx (frc=%d il=%lu fl=%u)\n",
+                     (unsigned long) inst_addr, frc, inst_len, fetch_len);
+            return 11;
+        }

And what happens if the instruction happens to span a page boundary, and the second half is paged out? Won't this (unexpectedly) cause a #GP, instead of a #PF?

xen/arch/x86/hvm/vmware/vmport.c static void vmx_idtv_reinject(unsigned long idtv_info) · line 2571

Quoted 6 lines
xen/arch/x86/hvm/vmware/vmport.c new file +2 -0
@@ -2565,6 +2567,50 @@ static void vmx_idtv_reinject(unsigned long idtv_info)
     }
 }
 
+static unsigned long vmx_rip2pointer(struct cpu_user_regs *regs,
+                                     struct vcpu *v)

vmx_rip_to_pointer(), please.

xen/include/public/hvm/params.h line 156

Quoted 9 lines
xen/include/public/hvm/params.h +1 -0
index dee6d68..77ff539 100644
@@ -153,7 +153,8 @@
 
 /* Params for VMware */
 #define HVM_PARAM_VMWARE_HW                 35
+#define HVM_PARAM_VMWARE_PORT               36

So why is the CPUID control different than having the port available? Are we expecting a guest to have one without the other?

If so, and the first one really only enables the CPUID leaf, then it should be called "VMWARE_CPUID" or something.

-George

author
#16 lore raw

PATCH v3 5/16 tools part of add vmware_port to xl.cfg

In reply to Don Slutz

If non-zero then
enable a limited support of VMware's hyper-call.

VMware's hyper-call is also known as VMware Backdoor I/O Port.

---
 docs/man/xl.cfg.pod.5           |  7 +++++++
 tools/libxc/xc_domain_restore.c | 11 +++++++++++
 tools/libxc/xc_domain_save.c    | 11 +++++++++++
 tools/libxc/xg_save_restore.h   |  1 +
 tools/libxl/libxl_create.c      |  5 ++++-
 tools/libxl/libxl_dom.c         |  2 ++
 tools/libxl/libxl_types.idl     |  1 +
 tools/libxl/xl_cmdimpl.c        |  2 ++
 8 files changed, 39 insertions(+), 1 deletion(-)
docs/man/xl.cfg.pod.5 +7 -0
index 7f7319a..c083af8 100644
@@ -1153,6 +1153,13 @@ Turns on or off the exposure of VMware cpuid.  The number is the
 VMware's hardware version number, where 0 is off.  If on it also
 forces the use of VMware's VGA in QEMU.
 
+=item B<vmware_port=BOOLEAN>
+
+Turns on or off the exposure of VMware port.  This is known as
+vmport in QEMU.  Also called VMware Backdoor I/O Port.  Not all
+defined VMware backdoor commands are implemented.  A lot of the
+ones that Linux uses are defined.
+
 =back
 
 =head3 Emulated VGA Graphics Device
tools/libxc/xc_domain_restore.c +11 -0
index bc5cd57..0f35186 100644
@@ -744,6 +744,7 @@ typedef struct {
     uint64_t ioreq_server_pfn;
     uint64_t nr_ioreq_server_pages;
     uint64_t vmware_hw;
+    uint64_t vmware_port;
 
     struct toolstack_data_t tdata;
 } pagebuf_t;
@@ -938,6 +939,16 @@ static int pagebuf_get_one(xc_interface *xch, struct restore_ctx *ctx,
         }
         return pagebuf_get_one(xch, ctx, buf, fd, dom);
 
+    case XC_SAVE_ID_HVM_VMWARE_PORT:
+        /* Skip padding 4 bytes then read the vmware port flag. */
+        if ( RDEXACT(fd, &buf->vmware_port, sizeof(uint32_t)) ||
+             RDEXACT(fd, &buf->vmware_port, sizeof(uint64_t)) )
+        {
+            PERROR("error read the vmware_port flag");
+            return -1;
+        }
+        return pagebuf_get_one(xch, ctx, buf, fd, dom);
+
     case XC_SAVE_ID_TOOLSTACK:
         {
             if ( RDEXACT(fd, &buf->tdata.len, sizeof(buf->tdata.len)) )
tools/libxc/xc_domain_save.c +11 -0
index 76dc307..d53bc38 100644
@@ -1761,6 +1761,17 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
             PERROR("Error when writing the vmware_hw value");
             goto out;
         }
+
+        chunk.id = XC_SAVE_ID_HVM_VMWARE_PORT;
+        chunk.data = 0;
+        xc_hvm_param_get(xch, dom, HVM_PARAM_VMWARE_PORT, &chunk.data);
+
+        if ( (chunk.data != 0) &&
+             wrexact(io_fd, &chunk, sizeof(chunk)) )
+        {
+            PERROR("Error when writing the vmware_port flag");
+            goto out;
+        }
     }
 
     if ( callbacks != NULL && callbacks->toolstack_save != NULL )
tools/libxc/xg_save_restore.h +1 -0
index d185ba9..097e06b 100644
@@ -264,6 +264,7 @@
 #define XC_SAVE_ID_HVM_NR_IOREQ_SERVER_PAGES -20
 /* VMware data */
 #define XC_SAVE_ID_HVM_VMWARE_HW      -21
+#define XC_SAVE_ID_HVM_VMWARE_PORT    -22
 
 /*
 ** We process save/restore/migrate in batches of pages; the below
tools/libxl/libxl_create.c +4 -1
index 54842ee..ca0effc 100644
@@ -295,6 +295,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
         libxl_defbool_setdefault(&b_info->u.hvm.viridian,           false);
         libxl_defbool_setdefault(&b_info->u.hvm.hpet,               true);
         libxl_defbool_setdefault(&b_info->u.hvm.vpt_align,          true);
+        libxl_defbool_setdefault(&b_info->u.hvm.vmware_port,        false);
         libxl_defbool_setdefault(&b_info->u.hvm.nested_hvm,         false);
         libxl_defbool_setdefault(&b_info->u.hvm.usb,                false);
         libxl_defbool_setdefault(&b_info->u.hvm.xen_platform_pci,   true);
@@ -428,7 +429,7 @@ int libxl__domain_build(libxl__gc *gc,
         vments[4] = "start_time";
         vments[5] = libxl__sprintf(gc, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
 
-        localents = libxl__calloc(gc, 9, sizeof(char *));
+        localents = libxl__calloc(gc, 11, sizeof(char *));
         localents[0] = "platform/acpi";
         localents[1] = libxl_defbool_val(info->u.hvm.acpi) ? "1" : "0";
         localents[2] = "platform/acpi_s3";
@@ -437,6 +438,8 @@ int libxl__domain_build(libxl__gc *gc,
         localents[5] = libxl_defbool_val(info->u.hvm.acpi_s4) ? "1" : "0";
         localents[6] = "platform/vmware_hw";
         localents[7] = libxl__sprintf(gc, "%"PRId64, info->u.hvm.vmware_hw);
+        localents[8] = "platform/vmware_port";
+        localents[9] = libxl_defbool_val(info->u.hvm.vmware_port) ? "1" : "0";
 
         break;
     case LIBXL_DOMAIN_TYPE_PV:
tools/libxl/libxl_dom.c +2 -0
index 63ae4c5..5d9796d 100644
@@ -221,6 +221,8 @@ static void hvm_set_conf_params(xc_interface *handle, uint32_t domid,
                     libxl_defbool_val(info->u.hvm.hpet));
     xc_set_hvm_param(handle, domid, HVM_PARAM_VMWARE_HW,
                      info->u.hvm.vmware_hw);
+    xc_set_hvm_param(handle, domid, HVM_PARAM_VMWARE_PORT,
+                     libxl_defbool_val(info->u.hvm.vmware_port));
 #endif
     xc_hvm_param_set(handle, domid, HVM_PARAM_TIMER_MODE, timer_mode(info));
     xc_hvm_param_set(handle, domid, HVM_PARAM_VPT_ALIGN,
tools/libxl/libxl_types.idl +1 -0
index d0bd657..278309d 100644
@@ -376,6 +376,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                        ("hpet",             libxl_defbool),
                                        ("vpt_align",        libxl_defbool),
                                        ("vmware_hw",        UInt(64, init_val = 0)),
+                                       ("vmware_port",      libxl_defbool),
                                        ("timer_mode",       libxl_timer_mode),
                                        ("nested_hvm",       libxl_defbool),
                                        ("smbios_firmware",  string),
tools/libxl/xl_cmdimpl.c +2 -0
index c30341a..90efc02 100644
@@ -1035,6 +1035,8 @@ static void parse_config_data(const char *config_source,
         xlu_cfg_get_defbool(config, "viridian", &b_info->u.hvm.viridian, 0);
         if (!xlu_cfg_get_long(config, "vmware_hw",  &l, 1))
             b_info->u.hvm.vmware_hw = l;
+        xlu_cfg_get_defbool(config, "vmware_port", &b_info->u.hvm.vmware_port,
+                            0);
         xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
         xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);
 
Signature · 1 line
1.8.4
#17 lore raw

Re: [PATCH v3 05/16] tools part of add vmware_port to xl.cfg

Quoted 6 lines · Don Slutz

If non-zero then
enable a limited support of VMware's hyper-call.

VMware's hyper-call is also known as VMware Backdoor I/O Port.

Overall this looks fine, but is there any reason not to merge this with 03/16?

#18 lore raw

Re: [PATCH v3 05/16] tools part of add vmware_port to xl.cfg

Quoted 8 lines · George Dunlap
Quoted 6 lines · Don Slutz

If non-zero then
enable a limited support of VMware's hyper-call.

VMware's hyper-call is also known as VMware Backdoor I/O Port.

Overall this looks fine, but is there any reason not to merge this with 03/16?

The reason I have is that v3 03/16 only contains new files. 2 from VMware and 1 to allow use of the VMware files. I added xen/arch/x86/hvm/vmware/includeCheck.h at the request of Konrad Wilk.

This patch has many style issues and white space issues. So I want it as a separate patch so as to be clear on what files do not meet the coding style.
And why and where they came from.

Hope this helps.
-Don Slutz

author
#19 lore raw

PATCH v3 6/16 hypervisor part of convert vmware_port to xentrace usage

In reply to Don Slutz

Reduce the VMPORT_DBG_LOG calls.

---
 xen/arch/x86/hvm/svm/svm.c       | 21 +++++++++------
 xen/arch/x86/hvm/vmware/vmport.c | 57 ++++++++++++++++++++++------------------
 xen/arch/x86/hvm/vmx/vmx.c       | 20 ++++++++------
 xen/include/asm-x86/hvm/trace.h  | 38 +++++++++++++++++++++++++++
 xen/include/asm-x86/hvm/vmport.h |  7 -----
 xen/include/public/trace.h       | 12 +++++++++
 6 files changed, 107 insertions(+), 48 deletions(-)
xen/arch/x86/hvm/svm/svm.c +13 -8
index 12079be..4acbbee 100644
@@ -2081,19 +2081,24 @@ static void svm_vmexit_gp_intercept(struct cpu_user_regs *regs,
     inst_len = __get_instruction_length_from_list(
         v, list, ARRAY_SIZE(list), 0);
 
+    if ( hvm_long_mode_enabled(v) )
+        HVMTRACE_LONG_C3D(TRAP_GP, inst_len, regs->error_code,
+                          TRC_PAR_LONG(vmcb->exitinfo2));
+    else
+        HVMTRACE_C3D(TRAP_GP, inst_len, regs->error_code, vmcb->exitinfo2);
+
     rc = vmport_gp_check(regs, v, inst_len, inst_addr, vmcb->exitinfo2);
     if ( !rc )
         __update_guest_eip(regs, inst_len);
     else
     {
-        VMPORT_DBG_LOG(VMPORT_LOG_GP_UNKNOWN,
-                       "gp: rc=%d e2=%lx ec=%lx ip=%"PRIx64" (%ld) ax=%"PRIx64
-                       " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64
-                       " di=%"PRIx64, rc,
-                       (unsigned long)vmcb->exitinfo2,
-                       (unsigned long)regs->error_code,
-                       regs->rip, inst_len, regs->rax, regs->rbx, regs->rcx,
-                       regs->rdx, regs->rsi, regs->rdi);
+        if ( hvm_long_mode_enabled(v) )
+            HVMTRACE_LONG_C5D(TRAP_GP_UNKNOWN, rc, regs->rax, regs->rbx, regs->rcx,
+                              TRC_PAR_LONG(inst_addr));
+        else
+            HVMTRACE_C5D(TRAP_GP_UNKNOWN, rc, regs->rax, regs->rbx, regs->rcx,
+                         inst_addr);
+
         hvm_inject_hw_exception(TRAP_gp_fault, regs->error_code);
     }
 }
xen/arch/x86/hvm/vmware/vmport.c +32 -25

114 lines not on this page · raw message

xen/arch/x86/hvm/vmx/vmx.c +12 -8
index eaa6df2..9d9ee9d 100644
@@ -2594,19 +2594,23 @@ static void vmx_vmexit_gp_intercept(struct cpu_user_regs *regs,
     __vmread(VM_EXIT_INTR_ERROR_CODE, &ecode);
     regs->error_code = ecode;
 
+    if ( hvm_long_mode_enabled(v) )
+        HVMTRACE_LONG_C3D(TRAP_GP, inst_len, ecode,
+                          TRC_PAR_LONG(exit_qualification));
+    else
+        HVMTRACE_C3D(TRAP_GP, inst_len, ecode, exit_qualification);
+
     rc = vmport_gp_check(regs, v, inst_len, inst_addr, exit_qualification);
     if ( !rc )
         update_guest_eip();
     else
     {
-        VMPORT_DBG_LOG(VMPORT_LOG_GP_UNKNOWN,
-                       "gp: rc=%d e2=%lx ec=%lx ip=%"PRIx64" (%ld) ax=%"PRIx64
-                       " bx=%"PRIx64" cx=%"PRIx64" dx=%"PRIx64" si=%"PRIx64
-                       " di=%"PRIx64, rc,
-                       (unsigned long)exit_qualification,
-                       (unsigned long)regs->error_code,
-                       regs->rip, inst_len, regs->rax, regs->rbx, regs->rcx,
-                       regs->rdx, regs->rsi, regs->rdi);
+        if ( hvm_long_mode_enabled(v) )
+            HVMTRACE_LONG_C5D(TRAP_GP_UNKNOWN, rc, regs->rax, regs->rbx, regs->rcx,
+                              TRC_PAR_LONG(inst_addr));
+        else
+            HVMTRACE_C5D(TRAP_GP_UNKNOWN, rc, regs->rax, regs->rbx, regs->rcx,
+                         inst_addr);
         hvm_inject_hw_exception(TRAP_gp_fault, regs->error_code);
     }
 }
xen/include/asm-x86/hvm/trace.h +38 -0
index de802a6..86c0548 100644
@@ -52,8 +52,20 @@
 #define DO_TRC_HVM_LMSW64      DEFAULT_HVM_MISC
 #define DO_TRC_HVM_REALMODE_EMULATE DEFAULT_HVM_MISC 
 #define DO_TRC_HVM_TRAP             DEFAULT_HVM_MISC
+#define DO_TRC_HVM_TRAP64           DEFAULT_HVM_MISC
 #define DO_TRC_HVM_TRAP_DEBUG       DEFAULT_HVM_MISC
 #define DO_TRC_HVM_VLAPIC           DEFAULT_HVM_MISC
+#define DO_TRC_HVM_TRAP_GP          DEFAULT_HVM_MISC
+#define DO_TRC_HVM_TRAP_GP64        DEFAULT_HVM_MISC
+#define DO_TRC_HVM_TRAP_GP_UNKNOWN  DEFAULT_HVM_MISC
+#define DO_TRC_HVM_TRAP_GP_UNKNOWN64 DEFAULT_HVM_MISC
+#define DO_TRC_HVM_VMPORT_READ_BEFORE DEFAULT_HVM_IO
+#define DO_TRC_HVM_VMPORT_WRITE_AFTER_BEFORE DEFAULT_HVM_IO
+#define DO_TRC_HVM_VMPORT_READ_AFTER DEFAULT_HVM_IO
+#define DO_TRC_HVM_VMPORT_WRITE_AFTER DEFAULT_HVM_IO
+#define DO_TRC_HVM_VMPORT_BAD         DEFAULT_HVM_IO
+#define DO_TRC_HVM_VMPORT_BAD64       DEFAULT_HVM_IO
+#define DO_TRC_HVM_VMPORT_UNKNOWN     DEFAULT_HVM_IO
 
 
 #define TRC_PAR_LONG(par) ((par)&0xFFFFFFFF),((par)>>32)
@@ -98,6 +110,21 @@
 #define HVMTRACE_0D(evt)                            \
     HVMTRACE_ND(evt, 0, 0, 0,  0,  0,  0,  0,  0,  0)
 
+#define HVMTRACE_C6D(evt, d1, d2, d3, d4, d5, d6)    \
+    HVMTRACE_ND(evt, 0, 1, 6, d1, d2, d3, d4, d5, d6)
+#define HVMTRACE_C5D(evt, d1, d2, d3, d4, d5)        \
+    HVMTRACE_ND(evt, 0, 1, 5, d1, d2, d3, d4, d5,  0)
+#define HVMTRACE_C4D(evt, d1, d2, d3, d4)            \
+    HVMTRACE_ND(evt, 0, 1, 4, d1, d2, d3, d4,  0,  0)
+#define HVMTRACE_C3D(evt, d1, d2, d3)                \
+    HVMTRACE_ND(evt, 0, 1, 3, d1, d2, d3,  0,  0,  0)
+#define HVMTRACE_C2D(evt, d1, d2)                    \
+    HVMTRACE_ND(evt, 0, 1, 2, d1, d2,  0,  0,  0,  0)
+#define HVMTRACE_C1D(evt, d1)                        \
+    HVMTRACE_ND(evt, 0, 1, 1, d1,  0,  0,  0,  0,  0)
+#define HVMTRACE_C0D(evt)                            \
+    HVMTRACE_ND(evt, 0, 1, 0,  0,  0,  0,  0,  0,  0)
+
 #define HVMTRACE_LONG_1D(evt, d1)                  \
                    HVMTRACE_2D(evt ## 64, (d1) & 0xFFFFFFFF, (d1) >> 32)
 #define HVMTRACE_LONG_2D(evt, d1, d2, ...)              \
@@ -107,6 +134,17 @@
 #define HVMTRACE_LONG_4D(evt, d1, d2, d3, d4, ...)  \
                    HVMTRACE_5D(evt ## 64, d1, d2, d3, d4)
 
+#define HVMTRACE_LONG_C1D(evt, d1)                  \
+                   HVMTRACE_C2D(evt ## 64, (d1) & 0xFFFFFFFF, (d1) >> 32)
+#define HVMTRACE_LONG_C2D(evt, d1, d2, ...)              \
+                   HVMTRACE_C3D(evt ## 64, d1, d2)
+#define HVMTRACE_LONG_C3D(evt, d1, d2, d3, ...)      \
+                   HVMTRACE_C4D(evt ## 64, d1, d2, d3)
+#define HVMTRACE_LONG_C4D(evt, d1, d2, d3, d4, ...)  \
+                   HVMTRACE_C5D(evt ## 64, d1, d2, d3, d4)
+#define HVMTRACE_LONG_C5D(evt, d1, d2, d3, d4, d5, ...) \
+                   HVMTRACE_C6D(evt ## 64, d1, d2, d3, d4, d5)
+
 #endif /* __ASM_X86_HVM_TRACE_H__ */
 
 /*
xen/include/asm-x86/hvm/vmport.h +0 -7
index 9d72b37..4dec094 100644
@@ -24,13 +24,6 @@
 #define VMPORT_LOG_VGP_UNKNOWN     (1 << 2)
 #define VMPORT_LOG_REALMODE_GP     (1 << 3)
 
-#define VMPORT_LOG_GP_UNKNOWN      (1 << 8)
-#define VMPORT_LOG_GP_NOT_VMWARE   (1 << 9)
-
-#define VMPORT_LOG_TRACE           (1 << 16)
-#define VMPORT_LOG_ERROR           (1 << 17)
-#define VMPORT_LOG_VMWARE_AFTER    (1 << 18)
-
 extern unsigned int opt_vmport_debug;
 #define VMPORT_DBG_LOG(level, _f, _a...)                                \
     do {                                                                \
xen/include/public/trace.h +12 -0
index cfcf4aa..ae3613c 100644
@@ -224,11 +224,23 @@
 #define TRC_HVM_NPF             (TRC_HVM_HANDLER + 0x21)
 #define TRC_HVM_REALMODE_EMULATE (TRC_HVM_HANDLER + 0x22)
 #define TRC_HVM_TRAP             (TRC_HVM_HANDLER + 0x23)
+#define TRC_HVM_TRAP64           (TRC_HVM_HANDLER + TRC_64_FLAG + 0x23)
 #define TRC_HVM_TRAP_DEBUG       (TRC_HVM_HANDLER + 0x24)
 #define TRC_HVM_VLAPIC           (TRC_HVM_HANDLER + 0x25)
+#define TRC_HVM_TRAP_GP          (TRC_HVM_HANDLER + 0x26)
+#define TRC_HVM_TRAP_GP64        (TRC_HVM_HANDLER + TRC_64_FLAG + 0x26)
+#define TRC_HVM_TRAP_GP_UNKNOWN  (TRC_HVM_HANDLER + 0x27)
+#define TRC_HVM_TRAP_GP_UNKNOWN64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x27)
+#define TRC_HVM_VMPORT_READ_BEFORE (TRC_HVM_HANDLER + 0x28)
+#define TRC_HVM_VMPORT_READ_AFTER (TRC_HVM_HANDLER + 0x29)
+#define TRC_HVM_VMPORT_BAD       (TRC_HVM_HANDLER + 0x2a)
+#define TRC_HVM_VMPORT_BAD64     (TRC_HVM_HANDLER + TRC_64_FLAG + 0x2a)
+#define TRC_HVM_VMPORT_UNKNOWN   (TRC_HVM_HANDLER + 0x2b)
 
 #define TRC_HVM_IOPORT_WRITE    (TRC_HVM_HANDLER + 0x216)
 #define TRC_HVM_IOMEM_WRITE     (TRC_HVM_HANDLER + 0x217)
+#define TRC_HVM_VMPORT_WRITE_AFTER_BEFORE (TRC_HVM_HANDLER + 0x228)
+#define TRC_HVM_VMPORT_WRITE_AFTER (TRC_HVM_HANDLER + 0x229)
 
 /* Trace events for emulated devices */
 #define TRC_HVM_EMUL_HPET_START_TIMER  (TRC_HVM_EMUL + 0x1)
Signature · 1 line
1.8.4
author
#20 lore raw

PATCH v3 7/16 tools part of convert vmware_port to xentrace usage

In reply to Don Slutz

Also added missing TRAP_DEBUG & VLAPIC.

---
 tools/xentrace/formats | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/xentrace/formats +13 -0
index da658bf..201a7a8 100644
@@ -79,6 +79,19 @@
 0x00082020  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  INTR_WINDOW [ value = 0x%(1)08x ]
 0x00082021  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  NPF         [ gpa = 0x%(2)08x%(1)08x mfn = 0x%(4)08x%(3)08x qual = 0x%(5)04x p2mt = 0x%(6)04x ]
 0x00082023  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  TRAP        [ vector = 0x%(1)02x ]
+0x00082024  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  TRAP_DEBUG  [ exit_qualification = 0x%(1)08x ]
+0x00082025  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VLAPIC
+0x00082026  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  TRAP_GP     [ inst_len = %(1)d exitinfo1 = %(2)d exitinfo2 = 0x%(3)08x ]
+0x00082126  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  TRAP_GP     [ inst_len = %(1)d exitinfo1 = %(2)d exitinfo2 = 0x%(4)08x%(3)08x ]
+0x00082027  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  TRAP_GP_UNKNOWN [ rc = %(1)d eax = 0x%(2)08x ebx = 0x%(3)08x ecx = 0x%(4)08x inst_addr = 0x%(5)08x ]
+0x00082127  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  TRAP_GP_UNKNOWN [ rc = %(1)d eax = 0x%(2)08x ebx = 0x%(3)08x ecx = 0x%(4)08x inst_addr = 0x%(6)08x%(5)08x ]
+0x00082028  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMPORT_READ_BEFORE  [ eax = 0x%(1)08x ebx = 0x%(2)08x ecx = 0x%(3)08x edx = 0x%(4)08x esi = 0x%(5)08x edi = 0x%(6)08x ]
+0x00082228  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMPORT_WRITE_BEFORE [ eax = 0x%(1)08x ebx = 0x%(2)08x ecx = 0x%(3)08x edx = 0x%(4)08x esi = 0x%(5)08x edi = 0x%(6)08x ]
+0x00082029  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMPORT_READ_AFTER  [ eax = 0x%(1)08x ebx = 0x%(2)08x ecx = 0x%(3)08x edx = 0x%(4)08x esi = 0x%(5)08x edi = 0x%(6)08x ]
+0x00082229  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMPORT_WRITE_AFTER [ eax = 0x%(1)08x ebx = 0x%(2)08x ecx = 0x%(3)08x edx = 0x%(4)08x esi = 0x%(5)08x edi = 0x%(6)08x ]
+0x0008202a  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMPORT_BAD [ dir = %(1)d bytes = 0x%(2)d eax = 0x%(3)08x eip = 0x%(4)08x ]
+0x0008212a  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMPORT_BAD [ dir = %(1)d bytes = %(2)d eax = 0x%(3)08x rip = 0x%(5)08x%(4)08x ]
+0x0008202b  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  VMPORT_UNKNOWN [ bytes << 8 + dir = 0x%(1)03x cmd = 0x%(2)x cmd = %(2)d ebx = 0x%(3)08x ecx = 0x%(4)08x esi = 0x%(5)08x edi = 0x%(6)08x ]
 
 0x0010f001  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  page_grant_map      [ domid = %(1)d ]
 0x0010f002  CPU%(cpu)d  %(tsc)d (+%(reltsc)8d)  page_grant_unmap    [ domid = %(1)d ]
Signature · 1 line
1.8.4
author
#21 lore raw

PATCH v3 8/16 hypervisor part of add limited support of VMware's hyper-call rpc

In reply to Don Slutz

The support included is enough to allow VMware tools to install in a HVM domU and provide guestinfo support. guestinfo support is provide by what is known as VMware RPC support. This guestinfo support is provided via libxc. libxl support has not be written.

Note: VMware RPC support is only available on HVM domU.

This interface is an extension of __HYPERVISOR_HVM_op. It was picked because xc_get_hvm_param() also uses it and VMware guest info is a lot like a hvm param.

The HVMOP_get_vmport_guest_info is used by two libxc functions, xc_get_vmport_guest_info and xc_fetch_vmport_guest_info. xc_fetch_vmport_guest_info is designed to be used to fetch all currently set guestinfo values.

To save on hypervisor heap memory, the guestinfo support in done in two sizes, normal and jumbo. Normal is used to handle up to 128 byte values and jumbo is used to handle up to 4096 byte values.

Since all this is work is done when the guest is doing a single instruction; it was designed to not use the hypervisor heap to allocate the memory at this time. Instead a few are allocated at the create domain time and during the xen's hyper-call to get or set them. This was picked in that if a tool stack is using the VMware guest info support, it should be using either of both of the get and set. And so in this case the guest should only see an out of memory error when the compile max amount of hypervisor heap memory is in use.

Doing it this way does lead to a lot of pointer use and many sub structures.

If the domU is running VMware tools, then the "build version" of the tools is also available via xc_get_HVM_param(). This also enables the use of new triggers that will use the VMware hyper-call to do some limited control of the domU. The most useful are poweroff and reboot. Since a guest process needs to be running for these to work, a tool stack should check that the build version is non zero before assuming these will work.

The 2 hvm param's HVM_PARAM_VMPORT_BUILD_NUMBER_TIME and HVM_PARAM_VMPORT_BUILD_NUMBER_VALUE are how "build version" is accessed. These 2 params are only allowed to be set to zero. The HVM_PARAM_VMPORT_BUILD_NUMBER_TIME can be used to track the last time the VMware tools in the guest responded. One such use would be the health of the tools in the guest. The hvm param HVM_PARAM_VMPORT_RESET_TIME controls how often to request them in seconds minus 1. The minus 1 is to handle to 0 case. I.E. the fastest that can be selected is every second. The default is 4 times a minute.

The VMware RPC support includes the notion of channels that are opened, active and closed. All RPC messages sent via a channel starts with normal ASCII text. The message some times does include binary data.

Currently there are 2 protocols defined for VMware RPC. They determine the direction for data flow, domU to tool stack or tool stack to domU.

There is no provided interrupt for VMware RPC.

For a debug=y build there is a new command line option vmport_debug=. It enabled output to the console of various stages of handling the "IN EAX, DX" instruction. Most uses are the summary ones that show complete RPC actions.

---
 xen/arch/x86/hvm/hvm.c                       |   42 +
 xen/arch/x86/hvm/vmware/Makefile             |    1 +
 xen/arch/x86/hvm/vmware/vmport.c             |    8 +-
 xen/arch/x86/hvm/vmware/vmport_rpc.c         | 1281 ++++++++++++++++++++++++++
 xen/include/asm-x86/hvm/domain.h             |    4 +
 xen/include/asm-x86/hvm/vmport.h             |   16 +
 xen/include/public/arch-x86/hvm/vmporttype.h |  118 +++
 xen/include/public/hvm/hvm_op.h              |   18 +
 xen/include/public/hvm/params.h              |    5 +-
 9 files changed, 1491 insertions(+), 2 deletions(-)
 create mode 100644 xen/arch/x86/hvm/vmware/vmport_rpc.c
 create mode 100644 xen/include/public/arch-x86/hvm/vmporttype.h
xen/arch/x86/hvm/hvm.c +42 -0
index 67ad37f..1bd5ae9 100644
@@ -1499,6 +1499,10 @@ int hvm_domain_initialise(struct domain *d)
         goto fail1;
     d->arch.hvm_domain.io_handler->num_slot = 0;
 
+    rc = vmport_rpc_init(d);
+    if ( rc != 0 )
+        goto fail1;
+
     if ( is_pvh_domain(d) )
     {
         register_portio_handler(d, 0, 0x10003, handle_pvh_io);
@@ -1534,6 +1538,7 @@ int hvm_domain_initialise(struct domain *d)
     stdvga_deinit(d);
     vioapic_deinit(d);
  fail1:
+    vmport_rpc_deinit(d);
     xfree(d->arch.hvm_domain.io_handler);
     xfree(d->arch.hvm_domain.params);
  fail0:
@@ -6155,6 +6160,43 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
+    case HVMOP_get_vmport_guest_info:
+    case HVMOP_set_vmport_guest_info:
+    {
+        struct xen_hvm_vmport_guest_info a;
+        struct domain *d;
+
+        if ( copy_from_guest(&a, arg, 1) )
+            return -EFAULT;
+
+        rc = vmport_rpc_hvmop_precheck(op, &a);
+        if ( rc )
+            return rc;
+
+        d = rcu_lock_domain_by_any_id(a.domid);
+        if ( d == NULL )
+            return rc;
+
+        rc = -EINVAL;
+        if ( !is_hvm_domain(d) )
+            goto param_fail9;
+
+        rc = xsm_hvm_param(XSM_TARGET, d, op);
+        if ( rc )
+            goto param_fail9;
+
+        rc = vmport_rpc_hvmop_do(d, op, &a);
+        if ( rc )
+            goto param_fail9;
+
+        if ( op == HVMOP_get_vmport_guest_info )
+            rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
+
+    param_fail9:
+        rcu_unlock_domain(d);
+        break;
+    }
+
     default:
     {
         gdprintk(XENLOG_DEBUG, "Bad HVM op %ld.\n", op);
xen/arch/x86/hvm/vmware/Makefile +1 -0
index cd8815b..4a14124 100644
@@ -1,2 +1,3 @@
 obj-y += cpuid.o
 obj-y += vmport.o
+obj-y += vmport_rpc.o
xen/arch/x86/hvm/vmware/vmport.c +7 -1
index 0ee2db3..5769a81 100644
@@ -139,6 +139,13 @@ int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val)
             /* maxTimeLag */
             regs->rcx = 0;
             break;
+        case BDOOR_CMD_MESSAGE:
+            if ( !is_pv_vcpu(current) )
+            {
+                /* Only supported for non pv domains */
+                vmport_rpc(&current->domain->arch.hvm_domain, regs);
+            }
+            break;
         case BDOOR_CMD_GETGUIOPTIONS:
             regs->rax = VMWARE_GUI_AUTO_GRAB | VMWARE_GUI_AUTO_UNGRAB |
                 VMWARE_GUI_AUTO_RAISE_DISABLED | VMWARE_GUI_SYNC_TIME |
@@ -306,7 +313,6 @@ int vmport_gp_check(struct cpu_user_regs *regs, struct vcpu *v,
     return 14;
 }
 
-
 /*
  * Local variables:
  * mode: C
xen/arch/x86/hvm/vmware/vmport_rpc.c new file +1281 -0

1,281 lines not on this page · raw message

xen/include/asm-x86/hvm/domain.h +4 -0
index 291a2e0..a571078 100644
@@ -107,6 +107,10 @@ struct hvm_domain {
     /* emulated irq to pirq */
     struct radix_tree_root emuirq_pirq;
 
+    /* VMware special port RPC */
+    spinlock_t             vmport_lock;
+    struct vmport_state   *vmport_data;
+
     uint64_t              *params;
 
     /* Memory ranges with pinned cache attributes. */
xen/include/asm-x86/hvm/vmport.h +16 -0
index 4dec094..e2864ab 100644
@@ -24,6 +24,15 @@
 #define VMPORT_LOG_VGP_UNKNOWN     (1 << 2)
 #define VMPORT_LOG_REALMODE_GP     (1 << 3)
 
+#define VMPORT_LOG_RECV            (1 << 4)
+#define VMPORT_LOG_SEND            (1 << 5)
+#define VMPORT_LOG_SKIP_SEND       (1 << 6)
+#define VMPORT_LOG_ERROR           (1 << 7)
+
+#define VMPORT_LOG_SWEEP           (1 << 8)
+#define VMPORT_LOG_PING            (1 << 9)
+
+
 extern unsigned int opt_vmport_debug;
 #define VMPORT_DBG_LOG(level, _f, _a...)                                \
     do {                                                                \
@@ -41,6 +50,13 @@ int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val);
 int vmport_gp_check(struct cpu_user_regs *regs, struct vcpu *v,
                     unsigned long inst_len, unsigned long inst_addr,
                     unsigned long ei);
+int vmport_rpc_init(struct domain *d);
+void vmport_rpc_deinit(struct domain *d);
+void vmport_rpc(struct hvm_domain *hd, struct cpu_user_regs *ur);
+int vmport_rpc_hvmop_precheck(unsigned long op,
+                              struct xen_hvm_vmport_guest_info *a);
+int vmport_rpc_hvmop_do(struct domain *d, unsigned long op,
+                        struct xen_hvm_vmport_guest_info *a);
 
 #endif /* ASM_X86_HVM_VMPORT_H__ */
 
xen/include/public/arch-x86/hvm/vmporttype.h new file +118 -0

118 lines not on this page · raw message

xen/include/public/hvm/hvm_op.h +18 -0
index eeb0a60..8e1e072 100644
@@ -369,6 +369,24 @@ DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_ioreq_server_state_t);
 
 #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
 
+/* Get/set vmport subcommands */
+#define HVMOP_get_vmport_guest_info 23
+#define HVMOP_set_vmport_guest_info 24
+#define VMPORT_GUEST_INFO_KEY_MAX   40
+#define VMPORT_GUEST_INFO_VAL_MAX   4096
+struct xen_hvm_vmport_guest_info {
+    /* Domain to be accessed */
+    domid_t   domid;
+    /* key length */
+    uint16_t   key_length;
+    /* value length */
+    uint16_t   value_length;
+    /* key and value data */
+    char      data[VMPORT_GUEST_INFO_KEY_MAX + VMPORT_GUEST_INFO_VAL_MAX];
+};
+typedef struct xen_hvm_vmport_guest_info xen_hvm_vmport_guest_info_t;
+DEFINE_XEN_GUEST_HANDLE(xen_hvm_vmport_guest_info_t);
+
 #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
 
 /*
xen/include/public/hvm/params.h +4 -1
index 77ff539..a9afc51 100644
@@ -154,7 +154,10 @@
 /* Params for VMware */
 #define HVM_PARAM_VMWARE_HW                 35
 #define HVM_PARAM_VMWARE_PORT               36
+#define HVM_PARAM_VMPORT_BUILD_NUMBER_TIME  37
+#define HVM_PARAM_VMPORT_BUILD_NUMBER_VALUE 38
+#define HVM_PARAM_VMPORT_RESET_TIME         39
 
-#define HVM_NR_PARAMS          37
+#define HVM_NR_PARAMS          40
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
Signature · 1 line
1.8.4
author
#22 lore raw

PATCH v3 9/16 tools part of add limited support of VMware's hyper-call rpc

In reply to Don Slutz

This guestinfo support is provided via libxc. libxl support has
not be written.

Note: VMware RPC support is only available on HVM domU.

This interface is an extension of __HYPERVISOR_HVM_op. It was picked because xc_get_hvm_param() also uses it and VMware guest info is a lot like a hvm param.

The HVMOP_get_vmport_guest_info is used by two libxc functions, xc_get_vmport_guest_info and xc_fetch_vmport_guest_info. xc_fetch_vmport_guest_info is designed to be used to fetch all currently set guestinfo values.

---
 tools/libxc/xc_domain.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxc/xenctrl.h   |  24 ++++++++++
 2 files changed, 139 insertions(+)
tools/libxc/xc_domain.c +115 -0
index 1a6f90a..9d2453d 100644
@@ -1577,6 +1577,121 @@ int xc_hvm_set_ioreq_server_state(xc_interface *xch,
     return rc;
 }
 
+int xc_set_vmport_guest_info(xc_interface *handle,
+                             domid_t dom,
+                             unsigned int key_len,
+                             char *key,
+                             unsigned int val_len,
+                             char *val)
+{
+    DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BUFFER(xen_hvm_vmport_guest_info_t, arg);
+    int rc;
+
+    if ( (key_len < 1) ||
+        (key_len > VMPORT_GUEST_INFO_KEY_MAX) ||
+        (val_len > VMPORT_GUEST_INFO_VAL_MAX) )
+        return -1;
+
+    arg = xc_hypercall_buffer_alloc(handle, arg, sizeof(*arg));
+    if ( arg == NULL )
+        return -1;
+
+    hypercall.op     = __HYPERVISOR_hvm_op;
+    hypercall.arg[0] = HVMOP_set_vmport_guest_info;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+    arg->domid = dom;
+    arg->key_length = key_len;
+    arg->value_length = val_len;
+    memcpy(arg->data, key, key_len);
+    memcpy(&arg->data[key_len], val, val_len);
+    rc = do_xen_hypercall(handle, &hypercall);
+    xc_hypercall_buffer_free(handle, arg);
+    return rc;
+}
+
+int xc_get_vmport_guest_info(xc_interface *handle,
+                             domid_t dom,
+                             unsigned int key_len,
+                             char *key,
+                             unsigned int val_max,
+                             unsigned int *val_len,
+                             char *val)
+{
+    DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BUFFER(xen_hvm_vmport_guest_info_t, arg);
+    int rc;
+
+    if ( (key_len < 1) ||
+        (key_len > VMPORT_GUEST_INFO_KEY_MAX) )
+        return -1;
+
+    arg = xc_hypercall_buffer_alloc(handle, arg, sizeof(*arg));
+
+    hypercall.op     = __HYPERVISOR_hvm_op;
+    hypercall.arg[0] = HVMOP_get_vmport_guest_info;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+    arg->domid = dom;
+    arg->key_length = key_len;
+    arg->value_length = 0;
+    *val_len = 0;
+    memcpy(arg->data, key, key_len);
+    rc = do_xen_hypercall(handle, &hypercall);
+    if ( rc == 0 )
+    {
+        *val_len = arg->value_length;
+        if ( arg->value_length > val_max )
+            arg->value_length = val_max;
+        memcpy(val, &arg->data[key_len], arg->value_length);
+    }
+    xc_hypercall_buffer_free(handle, arg);
+    return rc;
+}
+
+int xc_fetch_vmport_guest_info(xc_interface *handle,
+                               domid_t dom,
+                               unsigned int idx,
+                               unsigned int key_max,
+                               unsigned int *key_len,
+                               char *key,
+                               unsigned int val_max,
+                               unsigned int *val_len,
+                               char *val)
+{
+    DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BUFFER(xen_hvm_vmport_guest_info_t, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(handle, arg, sizeof(*arg));
+
+    hypercall.op     = __HYPERVISOR_hvm_op;
+    hypercall.arg[0] = HVMOP_get_vmport_guest_info;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+    arg->domid = dom;
+    arg->key_length = 0;
+    arg->value_length = idx;
+    *key_len = 0;
+    *val_len = 0;
+    rc = do_xen_hypercall(handle, &hypercall);
+    if ( rc == 0 )
+    {
+        uint16_t val_off = arg->key_length;
+
+        *key_len = arg->key_length;
+        if ( arg->key_length > key_max )
+            arg->key_length = key_max;
+        memcpy(key, arg->data, arg->key_length);
+        *val_len = arg->value_length;
+        if ( arg->value_length > val_max )
+            arg->value_length = val_max;
+        memcpy(val,
+               &arg->data[val_off],
+               arg->value_length);
+    }
+    xc_hypercall_buffer_free(handle, arg);
+    return rc;
+}
+
 int xc_domain_setdebugging(xc_interface *xch,
                            uint32_t domid,
                            unsigned int enable)
tools/libxc/xenctrl.h +24 -0
index 1c8aa42..bd494f2 100644
@@ -2019,6 +2019,30 @@ int xc_hvm_destroy_ioreq_server(xc_interface *xch,
                                 domid_t domid,
                                 ioservid_t id);
 
+int xc_set_vmport_guest_info(xc_interface *handle,
+                             domid_t dom,
+                             unsigned int key_len,
+                             char *key,
+                             unsigned int val_len,
+                             char *val);
+int xc_get_vmport_guest_info(xc_interface *handle,
+                             domid_t dom,
+                             unsigned int key_len,
+                             char *key,
+                             unsigned int val_max,
+                             unsigned int *val_len,
+                             char *val);
+int xc_fetch_vmport_guest_info(xc_interface *handle,
+                               domid_t dom,
+                               unsigned int idx,
+                               unsigned int key_max,
+                               unsigned int *key_len,
+                               char *key,
+                               unsigned int val_max,
+                               unsigned int *val_len,
+                               char *val);
+
+
 /* HVM guest pass-through */
 int xc_assign_device(xc_interface *xch,
                      uint32_t domid,
Signature · 1 line
1.8.4
author
#23 lore raw

PATCH v3 10/16 Add VMware tool's triggers

In reply to Don Slutz

These are not the same as the PV control interface; they are more like the ACPI power event.

For anything to happen when they are used, the domU must be running a VMware tools daemon that is polling for triggers.

If the domU is running VMware tools, then the "build version" of the tools is also available via xc_get_HVM_param(). This also enables the use of new triggers that will use the VMware hyper-call to do some limited control of the domU. The most useful are poweroff and reboot. Since a guest process needs to be running for these to work, a tool stack should check that the build version is non zero before assuming these will work.

The 2 hvm param's HVM_PARAM_VMPORT_BUILD_NUMBER_TIME and HVM_PARAM_VMPORT_BUILD_NUMBER_VALUE are how "build version" is accessed. These 2 params are only allowed to be set to zero. The HVM_PARAM_VMPORT_BUILD_NUMBER_TIME can be used to track the last time the VMware tools in the guest responded. One such use would be the health of the tools in the guest. The hvm param HVM_PARAM_VMPORT_RESET_TIME controls how often to request them in seconds minus 1. The minus 1 is to handle to 0 case. I.E. the fastest that can be selected is every second. The default is 4 times a minute.

XEN_DOMCTL_SENDTRIGGER_VTPING is the same as what is done using HVM_PARAM_VMPORT_RESET_TIME. This trigger allows the tool stack to request a sooner update of HVM_PARAM_VMPORT_BUILD_NUMBER_TIME and HVM_PARAM_VMPORT_BUILD_NUMBER_VALUE.

---
 xen/arch/x86/domctl.c            | 34 ++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/hvm/vmport.h |  1 +
 xen/include/public/domctl.h      |  3 +++
 3 files changed, 38 insertions(+)
xen/arch/x86/domctl.c +34 -0
index 7a5de43..50596a6 100644
@@ -23,6 +23,7 @@
 #include <xen/paging.h>
 #include <asm/irq.h>
 #include <asm/hvm/hvm.h>
+#include <asm/hvm/vmport.h>
 #include <asm/hvm/support.h>
 #include <asm/hvm/cacheattr.h>
 #include <asm/processor.h>
@@ -579,6 +580,39 @@ long arch_do_domctl(
         }
         break;
 
+        case XEN_DOMCTL_SENDTRIGGER_VTPOWER:
+        {
+            ret = -EINVAL;
+            if ( is_hvm_domain(d) )
+            {
+                ret = 0;
+                vmport_ctrl_send(&d->arch.hvm_domain, "OS_Halt");
+            }
+        }
+        break;
+
+        case XEN_DOMCTL_SENDTRIGGER_VTREBOOT:
+        {
+            ret = -EINVAL;
+            if ( is_hvm_domain(d) )
+            {
+                ret = 0;
+                vmport_ctrl_send(&d->arch.hvm_domain, "OS_Reboot");
+            }
+        }
+        break;
+
+        case XEN_DOMCTL_SENDTRIGGER_VTPING:
+        {
+            ret = -EINVAL;
+            if ( is_hvm_domain(d) )
+            {
+                ret = 0;
+                vmport_ctrl_send(&d->arch.hvm_domain, "ping");
+            }
+        }
+        break;
+
         default:
             ret = -ENOSYS;
         }
xen/include/asm-x86/hvm/vmport.h +1 -0
index e2864ab..8503307 100644
@@ -57,6 +57,7 @@ int vmport_rpc_hvmop_precheck(unsigned long op,
                               struct xen_hvm_vmport_guest_info *a);
 int vmport_rpc_hvmop_do(struct domain *d, unsigned long op,
                         struct xen_hvm_vmport_guest_info *a);
+void vmport_ctrl_send(struct hvm_domain *hd, char *msg);
 
 #endif /* ASM_X86_HVM_VMPORT_H__ */
 
xen/include/public/domctl.h +3 -0
index 69a8b44..2508ffa 100644
@@ -459,6 +459,9 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_address_size_t);
 #define XEN_DOMCTL_SENDTRIGGER_INIT   2
 #define XEN_DOMCTL_SENDTRIGGER_POWER  3
 #define XEN_DOMCTL_SENDTRIGGER_SLEEP  4
+#define XEN_DOMCTL_SENDTRIGGER_VTPOWER  5
+#define XEN_DOMCTL_SENDTRIGGER_VTREBOOT 6
+#define XEN_DOMCTL_SENDTRIGGER_VTPING   7
 struct xen_domctl_sendtrigger {
     uint32_t  trigger;  /* IN */
     uint32_t  vcpu;     /* IN */
Signature · 1 line
1.8.4
author
#24 lore raw

PATCH v3 11/16 Add live migration of VMware's hyper-call RPC

In reply to Don Slutz

The VMware's hyper-call state is included in live migration and save/restore. Because the max size of the VMware guestinfo is large, then data is compressed and expanded in the vmport_save_domain_ctxt and vmport_load_domain_ctxt.

---
 xen/arch/x86/hvm/vmware/vmport_rpc.c   | 302 ++++++++++++++++++++++++++++++++-
 xen/include/public/arch-x86/hvm/save.h |  39 ++++-
 2 files changed, 339 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/vmware/vmport_rpc.c +301 -1
index 695e58f..e25ed09 100644
@@ -39,7 +39,8 @@
 #include <asm/hvm/vmport.h>
 #include <asm/hvm/trace.h>
 
-#include "public/arch-x86/hvm/vmporttype.h"
+#include <public/hvm/save.h>
+#include <public/arch-x86/hvm/save.h>
 
 #include "backdoor_def.h"
 #include "guest_msg_def.h"
@@ -1270,6 +1271,305 @@ void vmport_rpc_deinit(struct domain *d)
     xfree(vs);
 }
 
+/* save and restore functions */
+
+static int vmport_save_domain_ctxt(struct domain *d, hvm_domain_context_t *h)
+{
+    struct hvm_vmport_context *ctxt;
+    struct hvm_save_descriptor *desc;
+    struct hvm_domain *hd = &d->arch.hvm_domain;
+    struct vmport_state *vs = hd->vmport_data;
+    char *p;
+    unsigned int guestinfo_size = 0;
+    unsigned int used_guestinfo = 0;
+    unsigned int used_guestinfo_jumbo = 0;
+    unsigned int chans_size;
+    unsigned int i;
+
+    /* Customized handling for entry since our entry is of variable length */
+    desc = (struct hvm_save_descriptor *)&h->data[h->cur];
+    if ( _hvm_init_entry(h, HVM_SAVE_CODE(VMPORT), 0,
+                         HVM_SAVE_LENGTH(VMPORT)) )
+        return 1;
+    ctxt = (struct hvm_vmport_context *)&h->data[h->cur];
+
+    spin_lock(&hd->vmport_lock);
+
+    ctxt->version = VMPORT_SAVE_VERSION;
+    ctxt->ping_time = vs->ping_time;
+    ctxt->open_cookie = vs->open_cookie;
+    ctxt->used_guestinfo = vs->used_guestinfo;
+    ctxt->used_guestinfo_jumbo = vs->used_guestinfo_jumbo;
+
+    p = ctxt->u.packed.packed_data;
+
+    for ( i = 0; i < VMPORT_MAX_CHANS; i++ )
+    {
+        unsigned int j;
+        unsigned int buf_max;
+
+        ctxt->u.packed.chan_ctl[i].chan = vs->chans[i].ctl;
+        buf_max = vs->chans[i].ctl.send_len;
+        if ( buf_max > VMPORT_MAX_SEND_BUF * 4 )
+            buf_max = VMPORT_MAX_SEND_BUF * 4;
+        memcpy(p, vs->chans[i].send_buf, buf_max);
+        p += buf_max;
+        for ( j = 0; j < VMPORT_MAX_BKTS; j++ )
+        {
+            ctxt->u.packed.chan_ctl[i].recv[j] = vs->chans[i].recv_bkt[j].ctl;
+            buf_max = vs->chans[i].recv_bkt[j].ctl.recv_len;
+            if ( buf_max > VMPORT_MAX_RECV_BUF * 4 )
+                buf_max = VMPORT_MAX_RECV_BUF * 4;
+            memcpy(p, vs->chans[i].recv_bkt[j].recv_buf, buf_max);
+            p += buf_max;
+        }
+        ctxt->u.packed.chan_ctl[i].jumbo = vs->chans[i].jumbo_recv_bkt.ctl;
+        buf_max = vs->chans[i].jumbo_recv_bkt.ctl.recv_len;
+        if ( buf_max > VMPORT_MAX_RECV_JUMBO_BUF * 4 )
+            buf_max = VMPORT_MAX_RECV_JUMBO_BUF * 4;
+        memcpy(p, vs->chans[i].jumbo_recv_bkt.recv_buf, buf_max);
+        p += buf_max;
+    }
+
+    chans_size = p - ctxt->u.packed.packed_data;
+
+    for ( i = 0; i < ctxt->used_guestinfo; i++ )
+    {
+        vmport_guestinfo_t *vg = vs->guestinfo[i];
+
+        if ( vg && vg->key_len )
+        {
+            guestinfo_size += sizeof(vg->key_len) + sizeof(vg->val_len) +
+                vg->key_len + vg->val_len;
+            used_guestinfo++;
+            ASSERT(sizeof(vg->key_len) == 1);
+            *p++ = (char) vg->key_len;
+            ASSERT(sizeof(vg->val_len) == 1);
+            *p++ = (char) vg->val_len;
+            if ( vg->key_len )
+            {
+                memcpy(p, vg->key_data, vg->key_len);
+                p += vg->key_len;
+                if ( vg->val_len )
+                {
+                    memcpy(p, vg->val_data, vg->val_len);
+                    p += vg->val_len;
+                }
+            }
+        }
+    }
+    ctxt->used_guestinfo = used_guestinfo;
+
+    for ( i = 0; i < ctxt->used_guestinfo_jumbo; i++ )
+    {
+        vmport_guestinfo_jumbo_t *vgj =
+            vs->guestinfo_jumbo[i];
+        if ( vgj && vgj->key_len )
+        {
+            guestinfo_size += sizeof(vgj->key_len) + sizeof(vgj->val_len) +
+                vgj->key_len + vgj->val_len;
+            used_guestinfo_jumbo++;
+            ASSERT(sizeof(vgj->key_len) == 1);
+            *p++ = (char) vgj->key_len;
+            memcpy(p, &vgj->val_len, sizeof(vgj->val_len));
+            p += sizeof(vgj->val_len);
+            if ( vgj->key_len )
+            {
+                memcpy(p, vgj->key_data, vgj->key_len);
+                p += vgj->key_len;
+                if ( vgj->val_len )
+                {
+                    memcpy(p, vgj->val_data, vgj->val_len);
+                    p += vgj->val_len;
+                }
+            }
+        }
+    }
+    ctxt->used_guestinfo_jumbo = used_guestinfo_jumbo;
+
+    ctxt->used_guestsize = guestinfo_size;
+
+    spin_unlock(&hd->vmport_lock);
+
+#ifndef NDEBUG
+    gdprintk(XENLOG_WARNING, "chans_size=%d guestinfo_size=%d, used=%ld\n",
+             chans_size, guestinfo_size,
+             p - ctxt->u.packed.packed_data);
+#endif
+    ASSERT(p - ctxt->u.packed.packed_data == chans_size + guestinfo_size);
+    ASSERT(desc->length >= p - (char *)ctxt);
+    desc->length = p - (char *)ctxt; /* Fixup length to be right */
+    h->cur += desc->length; /* Do _hvm_write_entry */
+    ASSERT(guestinfo_size < desc->length);
+
+    return 0;
+}
+
+static int vmport_load_domain_ctxt(struct domain *d, hvm_domain_context_t *h)
+{
+    struct hvm_vmport_context *ctxt;
+    struct hvm_save_descriptor *desc;
+    struct hvm_domain *hd = &d->arch.hvm_domain;
+    struct vmport_state *vs = hd->vmport_data;
+    unsigned int i;
+    uint8_t key_len;
+    uint16_t val_len;
+    char *p;
+    vmport_guestinfo_t *vg;
+    vmport_guestinfo_jumbo_t *vgj;
+    unsigned int loop_cnt;
+    unsigned int guestinfo_size;
+    unsigned int used_guestinfo;
+    unsigned int used_guestinfo_jumbo;
+
+    if ( !vs )
+        return -ENOMEM;
+
+    /* Customized checking for entry since our entry is of variable length */
+    desc = (struct hvm_save_descriptor *)&h->data[h->cur];
+    if ( sizeof(*desc) > h->size - h->cur )
+    {
+        printk(XENLOG_G_WARNING
+               "HVM%d restore: not enough data left to read descriptor"
+               "for type %lu\n", d->domain_id,
+               HVM_SAVE_CODE(VMPORT));
+        return -1;
+    }
+    if ( desc->length + sizeof(*desc) > h->size - h->cur )
+    {
+        printk(XENLOG_G_WARNING
+               "HVM%d restore: not enough data left to read %u bytes "
+               "for type %lu\n", d->domain_id, desc->length,
+               HVM_SAVE_CODE(VMPORT));
+        return -1;
+    }
+    if ( HVM_SAVE_CODE(VMPORT) != desc->typecode ||
+         (desc->length > HVM_SAVE_LENGTH(VMPORT)) )
+    {
+        printk(XENLOG_G_WARNING
+               "HVM%d restore mismatch: expected type %lu with max length %lu, "
+               "saw type %u length %u\n", d->domain_id, HVM_SAVE_CODE(VMPORT),
+               HVM_SAVE_LENGTH(VMPORT),
+               desc->typecode, desc->length);
+        return -1;
+    }
+    h->cur += sizeof(*desc);
+    /* Checking finished */
+
+    ctxt = (struct hvm_vmport_context *)&h->data[h->cur];
+    h->cur += desc->length;
+
+    if ( ctxt->version != VMPORT_SAVE_VERSION )
+        return -EINVAL;
+
+    spin_lock(&hd->vmport_lock);
+
+    vs->ping_time = ctxt->ping_time;
+    vs->open_cookie = ctxt->open_cookie;
+    vs->used_guestinfo = ctxt->used_guestinfo;
+    vs->used_guestinfo_jumbo = ctxt->used_guestinfo_jumbo;
+    guestinfo_size = ctxt->used_guestsize;
+    used_guestinfo = ctxt->used_guestinfo;
+    used_guestinfo_jumbo = ctxt->used_guestinfo_jumbo;
+
+    p = ctxt->u.packed.packed_data;
+
+    for ( i = 0; i < VMPORT_MAX_CHANS; i++ )
+    {
+        unsigned int j;
+
+        vs->chans[i].ctl = ctxt->u.packed.chan_ctl[i].chan;
+        memcpy(vs->chans[i].send_buf, p, vs->chans[i].ctl.send_len);
+        p += vs->chans[i].ctl.send_len;
+        for ( j = 0; j < VMPORT_MAX_BKTS; j++ )
+        {
+            vs->chans[i].recv_bkt[j].ctl = ctxt->u.packed.chan_ctl[i].recv[j];
+            memcpy(vs->chans[i].recv_bkt[j].recv_buf, p,
+                   vs->chans[i].recv_bkt[j].ctl.recv_len);
+            p += vs->chans[i].recv_bkt[j].ctl.recv_len;
+        }
+        vs->chans[i].jumbo_recv_bkt.ctl = ctxt->u.packed.chan_ctl[i].jumbo;
+        memcpy(vs->chans[i].jumbo_recv_bkt.recv_buf, p,
+               vs->chans[i].jumbo_recv_bkt.ctl.recv_len);
+        p += vs->chans[i].jumbo_recv_bkt.ctl.recv_len;
+    }
+
+
+    /* keep at least 10 total and 5 empty entries */
+    loop_cnt = (vs->used_guestinfo + 5) > 10 ?
+        (vs->used_guestinfo + 5) : 10;
+    for ( i = 0; i < loop_cnt; i++ )
+    {
+        if ( !vs->guestinfo[i] )
+        {
+            vs->guestinfo[i] = xzalloc(vmport_guestinfo_t);
+        }
+        if ( i < vs->used_guestinfo
+             && guestinfo_size > 0 )
+        {
+            key_len = (uint8_t)*p++;
+            val_len = (uint8_t)*p++;
+            guestinfo_size -= 2;
+            if ( guestinfo_size >= key_len + val_len )
+            {
+                vg = vs->guestinfo[i];
+                if ( key_len )
+                {
+                    vg->key_len = key_len;
+                    vg->val_len = val_len;
+                    memcpy(vg->key_data, p, key_len);
+                    p += key_len;
+                    memcpy(vg->val_data, p, val_len);
+                    p += val_len;
+                    guestinfo_size -= key_len + val_len;
+                }
+            }
+        }
+    }
+    vs->used_guestinfo = loop_cnt;
+
+    /* keep at least 2 total and 1 empty entries */
+    loop_cnt = (vs->used_guestinfo_jumbo + 1) > 2 ?
+        (vs->used_guestinfo_jumbo + 1) : 2;
+    for ( i = 0; i < loop_cnt; i++ )
+    {
+        if ( !vs->guestinfo_jumbo[i] )
+        {
+            vs->guestinfo_jumbo[i] = xzalloc(vmport_guestinfo_jumbo_t);
+        }
+        if ( i < vs->used_guestinfo_jumbo
+             && guestinfo_size > 0 )
+        {
+            key_len = (uint8_t)*p++;
+            memcpy(&val_len, p, 2);
+            p += 2;
+            guestinfo_size -= 3;
+            if ( guestinfo_size >= key_len + val_len )
+            {
+                vgj = vs->guestinfo_jumbo[i];
+                if ( key_len )
+                {
+                    vgj->key_len = key_len;
+                    vgj->val_len = val_len;
+                    memcpy(vgj->key_data, p, key_len);
+                    p += key_len;
+                    memcpy(vgj->val_data, p, val_len);
+                    p += val_len;
+                    guestinfo_size -= key_len + val_len;
+                }
+            }
+        }
+    }
+    vs->used_guestinfo_jumbo = loop_cnt;
+
+    spin_unlock(&hd->vmport_lock);
+
+    return 0;
+}
+
+HVM_REGISTER_SAVE_RESTORE(VMPORT, vmport_save_domain_ctxt,
+                          vmport_load_domain_ctxt, 1, HVMSR_PER_DOM);
+
 /*
  * Local variables:
  * mode: C
xen/include/public/arch-x86/hvm/save.h +38 -1
index 16d85a3..7cdcb8f 100644
@@ -26,6 +26,8 @@
 #ifndef __XEN_PUBLIC_HVM_SAVE_X86_H__
 #define __XEN_PUBLIC_HVM_SAVE_X86_H__
 
+#include "vmporttype.h"
+
 /* 
  * Save/restore header: general info about the save file. 
  */
@@ -610,9 +612,44 @@ struct hvm_msr {
 
 #define CPU_MSR_CODE  20
 
+/*
+ * VMware context.
+ */
+struct hvm_vmport_context {
+    uint32_t version;
+    uint32_t used_guestsize;
+    uint64_t ping_time;
+    uint32_t open_cookie;
+    uint32_t used_guestinfo;
+    uint32_t used_guestinfo_jumbo;
+    union {
+        struct {
+            vmport_channel_t chans[VMPORT_MAX_CHANS];
+            vmport_guestinfo_t guestinfo[VMPORT_MAX_NUM_KEY];
+            vmport_guestinfo_jumbo_t guestinfo_jumbo[VMPORT_MAX_NUM_JUMBO_KEY];
+        } full;
+        struct {
+            struct {
+                vmport_channel_control_t chan;
+                vmport_bucket_control_t recv[VMPORT_MAX_BKTS];
+                vmport_bucket_control_t jumbo;
+            } chan_ctl[VMPORT_MAX_CHANS];
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+            char packed_data[];
+#elif defined(__GNUC__)
+            char packed_data[0];
+#else
+            char packed_data[1 /* Variable length */];
+#endif
+        } packed;
+    } u;
+};
+
+DECLARE_HVM_SAVE_TYPE(VMPORT, 21, struct hvm_vmport_context);
+
 /* 
  * Largest type-code in use
  */
-#define HVM_SAVE_CODE_MAX 20
+#define HVM_SAVE_CODE_MAX 21
 
 #endif /* __XEN_PUBLIC_HVM_SAVE_X86_H__ */
Signature · 1 line
1.8.4
author
#25 lore raw

PATCH v3 12/16 Add dump of HVM_SAVE_CODE(VMPORT) to xen-hvmctx.

In reply to Don Slutz

It also does some validation of the compressed data. Currently expects that all guest info are printable strings.

---
 tools/misc/xen-hvmctx.c | 229 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 229 insertions(+)
tools/misc/xen-hvmctx.c +229 -0
index 5a69245..d076091 100644
@@ -399,6 +399,225 @@ static void dump_tsc_adjust(void)
     printf("    TSC_ADJUST: tsc_adjust %" PRIx64 "\n", p.tsc_adjust);
 }
 
+static void dump_vmport(int vmport_size)
+{
+    int i;
+    HVM_SAVE_TYPE(VMPORT) *vp;
+    int64_t vmport_guestsize;
+    uint32_t vmport_used_guestinfo;
+    uint32_t vmport_used_guestinfo_jumbo;
+    uint8_t pb[vmport_size];
+    char *p;
+    int chans_size;
+
+    READ(pb);
+    vp = (void *)&pb;
+
+    p = vp->u.packed.packed_data;
+
+    vmport_guestsize = vp->used_guestsize;
+    chans_size = vmport_size - vmport_guestsize - (p - (char *)pb);
+    if ( chans_size < 0 )
+    {
+        fprintf(stderr, "*** VMPORT: bogus chans_size=%d should be >= 0\n"
+                "   vmport_size=%d vmport_guestsize=%d fixed_size=%ld\n",
+                chans_size, vmport_size, (int)vmport_guestsize,
+                p - (char *)pb);
+        chans_size = 0;
+    }
+
+    printf("    VMPORT: ping_time %" PRIu64 "\n", vp->ping_time);
+    printf("    VMPORT: open_cookie %" PRIx32 "\n", vp->open_cookie);
+    for ( i = 0; i < VMPORT_MAX_CHANS; i++ )
+    {
+        int j;
+        vmport_channel_control_t *vc = &vp->u.packed.chan_ctl[i].chan;
+        vmport_bucket_control_t *jb =  &vp->u.packed.chan_ctl[i].jumbo;
+
+        printf("    VMPORT: chan[%d] chan_id %d\n", i, vc->chan_id);
+        printf("    VMPORT: chan[%d] active_time %" PRIx64 "\n",
+               i, vc->active_time);
+        printf("    VMPORT: chan[%d] proto_num %" PRIx32 "\n",
+               i, vc->proto_num);
+        printf("    VMPORT: chan[%d] recv_read %d\n", i, vc->recv_read);
+        printf("    VMPORT: chan[%d] recv_write %d\n", i, vc->recv_write);
+        printf("    VMPORT: chan[%d] jumbo %d\n", i, vc->jumbo);
+        printf("    VMPORT: chan[%d] send_len %d\n", i, vc->send_len);
+        if ( vc->send_len > VMPORT_MAX_SEND_BUF * 4 )
+        {
+            printf("--- VMPORT: trucated send_len=%d > %d\n",
+                   vc->send_len, VMPORT_MAX_SEND_BUF * 4);
+            vc->send_len = VMPORT_MAX_SEND_BUF * 4;
+        }
+        if ( vc->send_len > chans_size )
+        {
+            fprintf(stderr, "*** VMPORT: bogus send_len=%d > %d\n",
+                    vc->send_len, chans_size);
+            if ( chans_size >= 0 )
+                vc->send_len = chans_size;
+            else
+                vc->send_len = 0;
+        }
+        p += vc->send_len;
+        chans_size -= vc->send_len;
+        for ( j = 0; j < VMPORT_MAX_BKTS; j++ )
+        {
+            vmport_bucket_control_t *b = &vp->u.packed.chan_ctl[i].recv[j];
+
+            printf("    VMPORT: chan[%d] bucket[%d] recv_len %d\n",
+                   i, j, b->recv_len);
+            if ( b->recv_len > VMPORT_MAX_RECV_BUF * 4 )
+            {
+                printf("--- VMPORT: trucated recv_len=%d > %d\n",
+                       b->recv_len, VMPORT_MAX_RECV_BUF * 4);
+                b->recv_len = VMPORT_MAX_RECV_BUF * 4;
+            }
+            if ( b->recv_len > chans_size )
+            {
+                fprintf(stderr, "*** VMPORT: bogus recv_len=%d > %d\n",
+                        b->recv_len, chans_size);
+                if ( chans_size >= 0 )
+                    b->recv_len = chans_size;
+                else
+                    b->recv_len = 0;
+            }
+            p += b->recv_len;
+            chans_size -= b->recv_len;
+        }
+        printf("    VMPORT: chan[%d] jumbo_bkt recv_len %d\n", i, jb->recv_len);
+        if ( jb->recv_len > VMPORT_MAX_RECV_JUMBO_BUF * 4 )
+        {
+            printf("--- VMPORT: trucated recv_len=%d > %d\n",
+                   jb->recv_len, VMPORT_MAX_RECV_JUMBO_BUF * 4);
+            jb->recv_len = VMPORT_MAX_RECV_JUMBO_BUF * 4;
+        }
+        if ( jb->recv_len > chans_size )
+        {
+            fprintf(stderr, "*** VMPORT: bogus recv_len=%d > %d\n",
+                    jb->recv_len, chans_size);
+            if ( chans_size >= 0 )
+                jb->recv_len = chans_size;
+            else
+                jb->recv_len = 0;
+        }
+        p += jb->recv_len;
+        chans_size -= jb->recv_len;
+    }
+
+    if ( chans_size != 0 )
+        fprintf(stderr, "*** VMPORT: bogus chans_size=%d should be 0\n",
+                chans_size);
+
+    vmport_used_guestinfo = vp->used_guestinfo;
+    vmport_used_guestinfo_jumbo = vp->used_guestinfo_jumbo;
+
+    if ( vmport_used_guestinfo == 0 )
+        printf("    VMPORT: no small data\n");
+    for ( i = 0; i < vmport_used_guestinfo; i++ )
+    {
+        if ( vmport_guestsize > 0 )
+        {
+            uint8_t key_len = (uint8_t)(*p++);
+            uint8_t val_len = (uint8_t)(*p++);
+            if ( key_len )
+            {
+                char key[VMPORT_MAX_KEY_LEN + 1];
+                char val[VMPORT_MAX_VAL_LEN + 1];
+
+                if ( key_len > VMPORT_MAX_KEY_LEN )
+                {
+                    fprintf(stderr,
+                            "*** VMPORT: bogus key_len=%d > %d for guestinfo[%d]\n",
+                            key_len, VMPORT_MAX_KEY_LEN, i);
+                    key_len = VMPORT_MAX_KEY_LEN;
+                }
+                memcpy(key, p, key_len);
+                p += key_len;
+                key[key_len] = '\0';
+                if ( val_len > VMPORT_MAX_VAL_LEN )
+                {
+                    fprintf(stderr,
+                            "*** VMPORT: bogus val_len=%d > %d for guestinfo[%d]\n",
+                            val_len, VMPORT_MAX_VAL_LEN, i);
+                    val_len = VMPORT_MAX_VAL_LEN;
+                }
+                memcpy(val, p, val_len);
+                p += val_len;
+                val[val_len] = '\0';
+                vmport_guestsize -= 2 + key_len + val_len;
+                printf("    VMPORT: guestinfo[%d](%s) = \"%s\"\n",
+                       i, key, val);
+            }
+            else
+            {
+                fprintf(stderr,
+                        "*** VMPORT: bogus len for guestinfo[%d]\n",
+                        i);
+                vmport_guestsize -= 2;
+            }
+            if ( vmport_guestsize < 0 )
+                printf("    VMPORT: data length skew at guestinfo[%d]\n"
+                       "         remaining datasize=%ld\n",
+                       i, vmport_guestsize);
+        }
+    }
+
+    if ( vmport_guestsize == 0 )
+        printf("    VMPORT: no jumbo data\n");
+    for ( i = 0; i < vmport_used_guestinfo_jumbo; i++ )
+    {
+        if ( vmport_guestsize > 0 )
+        {
+            uint8_t key_len = (uint8_t)(*p++);
+            uint16_t val_len;
+
+            memcpy(&val_len, p, 2);
+            p += 2;
+            if ( key_len )
+            {
+                char key[VMPORT_MAX_KEY_LEN + 1];
+                char val[VMPORT_MAX_VAL_JUMBO_LEN + 1];
+
+                if ( key_len > VMPORT_MAX_KEY_LEN )
+                {
+                    fprintf(stderr,
+                            "*** VMPORT: bogus key_len=%d > %d for guestinfo[%d]\n",
+                            key_len, VMPORT_MAX_KEY_LEN, i);
+                    key_len = VMPORT_MAX_KEY_LEN;
+                }
+                memcpy(key, p, key_len);
+                p += key_len;
+                key[key_len] = '\0';
+                if ( val_len > VMPORT_MAX_VAL_JUMBO_LEN )
+                {
+                    fprintf(stderr,
+                            "*** VMPORT: bogus val_len=%d > %d for guestinfo[%d]\n",
+                            val_len, VMPORT_MAX_VAL_JUMBO_LEN, i);
+                    val_len = VMPORT_MAX_VAL_JUMBO_LEN;
+                }
+                memcpy(val, p, val_len);
+                p += val_len;
+                val[val_len] = '\0';
+                vmport_guestsize -= 2 + key_len + val_len;
+                printf("    VMPORT: guestinfo_jumbo[%d](%s) = \"%s\"\n",
+                       i, key, val);
+            }
+            else
+            {
+                printf("    VMPORT: bogus len for guestinfo_jumbo[%d]\n", i);
+                vmport_guestsize -= 2;
+            }
+            if ( vmport_guestsize < 0 )
+                printf("    VMPORT: data length skew at guestinfo_jumbo[%d]\n"
+                       "         remaining datasize=%ld\n", i,
+                       vmport_guestsize);
+        }
+    }
+
+    if ( !vmport_guestsize )
+        printf("    VMPORT: %ld bytes leftover data\n", vmport_guestsize);
+}
+
 int main(int argc, char **argv)
 {
     int entry, domid;
@@ -467,6 +686,7 @@ int main(int argc, char **argv)
         case HVM_SAVE_CODE(VIRIDIAN_VCPU): dump_viridian_vcpu(); break;
         case HVM_SAVE_CODE(VMCE_VCPU): dump_vmce_vcpu(); break;
         case HVM_SAVE_CODE(TSC_ADJUST): dump_tsc_adjust(); break;
+        case HVM_SAVE_CODE(VMPORT): dump_vmport(desc.length); break;
         case HVM_SAVE_CODE(END): break;
         default:
             printf(" ** Don't understand type %u: skipping\n",
@@ -477,3 +697,12 @@ int main(int argc, char **argv)
 
     return 0;
 } 
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
1.8.4
author
#26 lore raw

PATCH v3 13/16 Add xen-hvm-param

In reply to Don Slutz

A tool to get and set hvm param.

---
 .gitignore                 |   1 +
 tools/misc/Makefile        |   7 +-
 tools/misc/xen-hvm-param.c | 166 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+), 2 deletions(-)
 create mode 100644 tools/misc/xen-hvm-param.c
.gitignore +1 -0
index 47e3c61..0f98619 100644
@@ -180,6 +180,7 @@ tools/misc/xen-tmem-list-parse
 tools/misc/xenperf
 tools/misc/xenpm
 tools/misc/xen-hvmctx
+tools/misc/xen-hvm-param
 tools/misc/gtraceview
 tools/misc/gtracestat
 tools/misc/xenlockprof
tools/misc/Makefile +5 -2
index 69b1817..b8d4579 100644
@@ -10,7 +10,7 @@ CFLAGS += $(CFLAGS_libxenstore)
 HDRS     = $(wildcard *.h)
 
 TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xencov
-TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvmcrash xen-lowmemd xen-mfndump
+TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-hvmcrash xen-lowmemd xen-mfndump
 TARGETS-$(CONFIG_MIGRATE) += xen-hptool
 TARGETS := $(TARGETS-y)
 
@@ -22,7 +22,7 @@ INSTALL_BIN := $(INSTALL_BIN-y)
 
 INSTALL_SBIN-y := xen-bugtool xen-python-path xenperf xenpm xen-tmem-list-parse gtraceview \
 	gtracestat xenlockprof xenwatchdogd xen-ringwatch xencov
-INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvmcrash xen-lowmemd xen-mfndump
+INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-hvmcrash xen-lowmemd xen-mfndump
 INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool
 INSTALL_SBIN := $(INSTALL_SBIN-y)
 
@@ -57,6 +57,9 @@ clean:
 xen-hvmctx: xen-hvmctx.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
+xen-hvm-param: xen-hvm-param.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
+
 xen-hvmcrash: xen-hvmcrash.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
tools/misc/xen-hvm-param.c new file +166 -0

166 lines not on this page · raw message

Signature · 1 line
1.8.4
author
#27 lore raw

PATCH v3 14/16 Add xen-vmware-guestinfo

In reply to Don Slutz

A tool to get and set VMware guestinfo

---
 .gitignore                        |  1 +
 tools/misc/Makefile               |  7 ++-
 tools/misc/xen-vmware-guestinfo.c | 97 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 tools/misc/xen-vmware-guestinfo.c
.gitignore +1 -0
index 0f98619..ad86210 100644
@@ -181,6 +181,7 @@ tools/misc/xenperf
 tools/misc/xenpm
 tools/misc/xen-hvmctx
 tools/misc/xen-hvm-param
+tools/misc/xen-vmware-guestinfo
 tools/misc/gtraceview
 tools/misc/gtracestat
 tools/misc/xenlockprof
tools/misc/Makefile +5 -2
index b8d4579..f2ffe1a 100644
@@ -10,7 +10,7 @@ CFLAGS += $(CFLAGS_libxenstore)
 HDRS     = $(wildcard *.h)
 
 TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xencov
-TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-hvmcrash xen-lowmemd xen-mfndump
+TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
 TARGETS-$(CONFIG_MIGRATE) += xen-hptool
 TARGETS := $(TARGETS-y)
 
@@ -22,7 +22,7 @@ INSTALL_BIN := $(INSTALL_BIN-y)
 
 INSTALL_SBIN-y := xen-bugtool xen-python-path xenperf xenpm xen-tmem-list-parse gtraceview \
 	gtracestat xenlockprof xenwatchdogd xen-ringwatch xencov
-INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-hvmcrash xen-lowmemd xen-mfndump
+INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
 INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool
 INSTALL_SBIN := $(INSTALL_SBIN-y)
 
@@ -60,6 +60,9 @@ xen-hvmctx: xen-hvmctx.o
 xen-hvm-param: xen-hvm-param.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
+xen-vmware-guestinfo: xen-vmware-guestinfo.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
+
 xen-hvmcrash: xen-hvmcrash.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
tools/misc/xen-vmware-guestinfo.c new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
1.8.4
author
#28 lore raw

PATCH v3 15/16 Add xen-list-vmware-guestinfo

In reply to Don Slutz

A tool to list currently set VMware guestinfo

---
 .gitignore                             |  1 +
 tools/misc/Makefile                    |  7 ++-
 tools/misc/xen-list-vmware-guestinfo.c | 88 ++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 2 deletions(-)
 create mode 100644 tools/misc/xen-list-vmware-guestinfo.c
.gitignore +1 -0
index ad86210..a2c546e 100644
@@ -182,6 +182,7 @@ tools/misc/xenpm
 tools/misc/xen-hvmctx
 tools/misc/xen-hvm-param
 tools/misc/xen-vmware-guestinfo
+tools/misc/xen-list-vmware-guestinfo
 tools/misc/gtraceview
 tools/misc/gtracestat
 tools/misc/xenlockprof
tools/misc/Makefile +5 -2
index f2ffe1a..3e7d216 100644
@@ -10,7 +10,7 @@ CFLAGS += $(CFLAGS_libxenstore)
 HDRS     = $(wildcard *.h)
 
 TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xencov
-TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
+TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-list-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
 TARGETS-$(CONFIG_MIGRATE) += xen-hptool
 TARGETS := $(TARGETS-y)
 
@@ -22,7 +22,7 @@ INSTALL_BIN := $(INSTALL_BIN-y)
 
 INSTALL_SBIN-y := xen-bugtool xen-python-path xenperf xenpm xen-tmem-list-parse gtraceview \
 	gtracestat xenlockprof xenwatchdogd xen-ringwatch xencov
-INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
+INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-list-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
 INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool
 INSTALL_SBIN := $(INSTALL_SBIN-y)
 
@@ -63,6 +63,9 @@ xen-hvm-param: xen-hvm-param.o
 xen-vmware-guestinfo: xen-vmware-guestinfo.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
+xen-list-vmware-guestinfo: xen-list-vmware-guestinfo.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
+
 xen-hvmcrash: xen-hvmcrash.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
tools/misc/xen-list-vmware-guestinfo.c new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
1.8.4
author
#29 lore raw

PATCH v3 16/16 Add xen-hvm-send-trigger

In reply to Don Slutz

A tool to send a trigger to a domU via xc_domain_send_trigger

---
 .gitignore                        |   1 +
 tools/misc/Makefile               |   7 ++-
 tools/misc/xen-hvm-send-trigger.c | 103 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+), 2 deletions(-)
 create mode 100644 tools/misc/xen-hvm-send-trigger.c
.gitignore +1 -0
index a2c546e..5a50a40 100644
@@ -183,6 +183,7 @@ tools/misc/xen-hvmctx
 tools/misc/xen-hvm-param
 tools/misc/xen-vmware-guestinfo
 tools/misc/xen-list-vmware-guestinfo
+tools/misc/xen-hvm-send-trigger
 tools/misc/gtraceview
 tools/misc/gtracestat
 tools/misc/xenlockprof
tools/misc/Makefile +5 -2
index 3e7d216..9c5e988 100644
@@ -10,7 +10,7 @@ CFLAGS += $(CFLAGS_libxenstore)
 HDRS     = $(wildcard *.h)
 
 TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xencov
-TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-list-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
+TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-list-vmware-guestinfo xen-hvm-send-trigger xen-hvmcrash xen-lowmemd xen-mfndump
 TARGETS-$(CONFIG_MIGRATE) += xen-hptool
 TARGETS := $(TARGETS-y)
 
@@ -22,7 +22,7 @@ INSTALL_BIN := $(INSTALL_BIN-y)
 
 INSTALL_SBIN-y := xen-bugtool xen-python-path xenperf xenpm xen-tmem-list-parse gtraceview \
 	gtracestat xenlockprof xenwatchdogd xen-ringwatch xencov
-INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-list-vmware-guestinfo xen-hvmcrash xen-lowmemd xen-mfndump
+INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-vmware-guestinfo xen-list-vmware-guestinfo xen-hvm-send-trigger xen-hvmcrash xen-lowmemd xen-mfndump
 INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool
 INSTALL_SBIN := $(INSTALL_SBIN-y)
 
@@ -66,6 +66,9 @@ xen-vmware-guestinfo: xen-vmware-guestinfo.o
 xen-list-vmware-guestinfo: xen-list-vmware-guestinfo.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
+xen-hvm-send-trigger: xen-hvm-send-trigger.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
+
 xen-hvmcrash: xen-hvmcrash.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
tools/misc/xen-hvm-send-trigger.c new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
1.8.4
#30 lore raw
In reply to Don Slutz
Quoted 1 line · Don Slutz

Changes v2 to v3:

Oops, looks like we had a race condition while I was reviewing v2 just now.

Quoted 2 lines

Add optional unit test tools.
Re-worked split of changes.

Given this set of changes I suppose it is likely that most of the comments are still valid, but feel free to ignore those which don't make sense any more.

Ian.

author
#31 lore raw
Quoted 10 lines · Ian Campbell
Quoted 1 line · Don Slutz

Changes v2 to v3:

Oops, looks like we had a race condition while I was reviewing v2 just now.

Quoted 2 lines

Add optional unit test tools.
Re-worked split of changes.

Given this set of changes I suppose it is likely that most of the comments are still valid, but feel free to ignore those which don't make sense any more.

I expect most apply. Will try and merge both sets.

-Don Slutz

Quoted 7 lines

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel