qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Don Slutz <dslutz@verizon.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Don Slutz" <dslutz@verizon.com>,
	"Luiz Capitulino" <lcapitulino@redhat.com>,
	"Anthony Liguori" <aliguori@amazon.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH v2 2/7] vmport_rpc: Add the object vmport_rpc
Date: Mon, 16 Mar 2015 19:20:59 -0400	[thread overview]
Message-ID: <1426548064-21182-3-git-send-email-dslutz@verizon.com> (raw)
In-Reply-To: <1426548064-21182-1-git-send-email-dslutz@verizon.com>

This is the 1st part of "Add limited support of VMware's hyper-call
rpc".

This patch uses existing infrastructure used by vmmouse.c (provided
by vmport.c) to handle the VMware backdoor command 30.

One of the better on-line references is:

https://sites.google.com/site/chitchatvmback/backdoor

More in next patch.

Signed-off-by: Don Slutz <dslutz@verizon.com>
---
 hw/i386/pc.c          |   6 +++
 hw/misc/Makefile.objs |   1 +
 hw/misc/vmport_rpc.c  | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)
 create mode 100644 hw/misc/vmport_rpc.c

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index b5b2aad..204f4a9 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1463,8 +1463,14 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
     i8042 = isa_create_simple(isa_bus, "i8042");
     i8042_setup_a20_line(i8042, &a20_line[0]);
     if (!no_vmport) {
+        ISADevice *vmport_rpc;
+
         vmport_init(isa_bus);
         vmmouse = isa_try_create(isa_bus, "vmmouse");
+        vmport_rpc = isa_try_create(isa_bus, "vmport_rpc");
+        if (vmport_rpc) {
+            qdev_init_nofail(DEVICE(vmport_rpc));
+        }
     } else {
         vmmouse = NULL;
     }
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
index 4aa76ff..e04c8ac 100644
--- a/hw/misc/Makefile.objs
+++ b/hw/misc/Makefile.objs
@@ -7,6 +7,7 @@ common-obj-$(CONFIG_ISA_TESTDEV) += pc-testdev.o
 common-obj-$(CONFIG_PCI_TESTDEV) += pci-testdev.o
 
 obj-$(CONFIG_VMPORT) += vmport.o
+obj-$(CONFIG_VMPORT) += vmport_rpc.o
 
 # ARM devices
 common-obj-$(CONFIG_PL310) += arm_l2x0.o
diff --git a/hw/misc/vmport_rpc.c b/hw/misc/vmport_rpc.c
new file mode 100644
index 0000000..b7cd355
--- /dev/null
+++ b/hw/misc/vmport_rpc.c
@@ -0,0 +1,126 @@
+/*
+ * QEMU VMPORT RPC emulation
+ *
+ * Copyright (C) 2015 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/>.
+ */
+
+/*
+ * One of the better on-line references is:
+ *
+ * https://sites.google.com/site/chitchatvmback/backdoor
+ *
+ * Which points you to:
+ *
+ * http://open-vm-tools.sourceforge.net/
+ *
+ * as a place to get more accurate information by studying.
+ */
+
+#include "hw/hw.h"
+#include "hw/i386/pc.h"
+#include "hw/qdev.h"
+#include "trace.h"
+#include "qmp-commands.h"
+#include "qapi/qmp/qerror.h"
+
+/* #define VMPORT_RPC_DEBUG */
+
+#define TYPE_VMPORT_RPC "vmport_rpc"
+#define VMPORT_RPC(obj) OBJECT_CHECK(VMPortRpcState, (obj), TYPE_VMPORT_RPC)
+
+/* VMPORT RPC Command */
+#define VMPORT_RPC_COMMAND  30
+
+/* The vmport_rpc object. */
+typedef struct VMPortRpcState {
+    ISADevice parent_obj;
+
+    /* Properties */
+    uint64_t reset_time;
+    uint64_t build_number_value;
+    uint64_t build_number_time;
+
+    /* Private data */
+} VMPortRpcState;
+
+typedef struct {
+    uint32_t eax;
+    uint32_t ebx;
+    uint32_t ecx;
+    uint32_t edx;
+    uint32_t esi;
+    uint32_t edi;
+} vregs;
+
+static uint32_t vmport_rpc_ioport_read(void *opaque, uint32_t addr)
+{
+    VMPortRpcState *s = opaque;
+    union {
+        uint32_t data[6];
+        vregs regs;
+    } ur;
+
+    vmmouse_get_data(ur.data);
+
+    s->build_number_time++;
+
+    vmmouse_set_data(ur.data);
+    return ur.data[0];
+}
+
+static void vmport_rpc_reset(DeviceState *d)
+{
+    VMPortRpcState *s = VMPORT_RPC(d);
+
+    s->reset_time = 14;
+    s->build_number_value = 0;
+    s->build_number_time = 0;
+}
+
+static void vmport_rpc_realize(DeviceState *dev, Error **errp)
+{
+    VMPortRpcState *s = VMPORT_RPC(dev);
+
+    vmport_register(VMPORT_RPC_COMMAND, vmport_rpc_ioport_read, s);
+}
+
+static Property vmport_rpc_properties[] = {
+    DEFINE_PROP_UINT64("reset-time", VMPortRpcState, reset_time, 14),
+    DEFINE_PROP_UINT64("build-number-value", VMPortRpcState,
+                       build_number_value, 0),
+    DEFINE_PROP_UINT64("build-number-time", VMPortRpcState,
+                       build_number_time, 0),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vmport_rpc_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->realize = vmport_rpc_realize;
+    dc->reset = vmport_rpc_reset;
+    dc->props = vmport_rpc_properties;
+}
+
+static const TypeInfo vmport_rpc_info = {
+    .name          = TYPE_VMPORT_RPC,
+    .parent        = TYPE_ISA_DEVICE,
+    .instance_size = sizeof(VMPortRpcState),
+    .class_init    = vmport_rpc_class_init,
+};
+
+static void vmport_rpc_register_types(void)
+{
+    type_register_static(&vmport_rpc_info);
+}
+
+type_init(vmport_rpc_register_types)
-- 
1.8.4

  parent reply	other threads:[~2015-03-16 23:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 23:20 [Qemu-devel] [PATCH v2 0/7] Add limited support of VMware's hyper-call rpc Don Slutz
2015-03-16 23:20 ` [Qemu-devel] [PATCH v2 1/7] vmport.c: Fix vmport_cmd_ram_size Don Slutz
2015-03-16 23:20 ` Don Slutz [this message]
2015-03-16 23:21 ` [Qemu-devel] [PATCH v2 3/7] vmport_rpc: Add limited support of VMware's hyper-call rpc Don Slutz
2015-03-16 23:21 ` [Qemu-devel] [PATCH v2 4/7] vmport_rpc: Add QMP access to vmport_rpc object Don Slutz
2015-03-16 23:21 ` [Qemu-devel] [PATCH v2 5/7] vmport_rpc: Add migration Don Slutz
2015-03-16 23:21 ` [Qemu-devel] [PATCH v2 6/7] vmport: Add VMware all ring hack Don Slutz
2015-03-16 23:21 ` [Qemu-devel] [PATCH v2 7/7] MAINTAINERS: add VMware port Don Slutz
  -- strict thread matches above, loose matches on Subject: below --
2015-04-27 22:45 [Qemu-devel] [PATCH v2 0/7] Add limited support of VMware's hyper-call rpc Don Slutz
2015-04-27 22:45 ` [Qemu-devel] [PATCH v2 2/7] vmport_rpc: Add the object vmport_rpc Don Slutz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426548064-21182-3-git-send-email-dslutz@verizon.com \
    --to=dslutz@verizon.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).