From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3PbE-0000UL-Op for qemu-devel@nongnu.org; Fri, 12 Jun 2015 10:06:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z3Pb9-0002WI-Bd for qemu-devel@nongnu.org; Fri, 12 Jun 2015 10:06:24 -0400 Received: from omzsmtpe04.verizonbusiness.com ([199.249.25.207]:49647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3Pb9-0002UX-3i for qemu-devel@nongnu.org; Fri, 12 Jun 2015 10:06:19 -0400 From: Don Slutz Date: Fri, 12 Jun 2015 10:05:51 -0400 Message-Id: <1434117956-4929-5-git-send-email-dslutz@verizon.com> In-Reply-To: <1434117956-4929-1-git-send-email-dslutz@verizon.com> References: <1434117956-4929-1-git-send-email-dslutz@verizon.com> Subject: [Qemu-devel] [PATCH v7 4/9] vmport_rpc: Add the object vmport_rpc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Markus Armbruster , Don Slutz , Luiz Capitulino , Don Slutz , Anthony Liguori , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson 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 CC: Don Slutz --- 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 3f0d435..48711c6 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1478,8 +1478,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. . + */ + +/* + * 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