ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * QEMU VMPort emulation |
| 3 | * |
Stefan Weil | bcc4e41 | 2011-12-02 10:30:41 +0100 | [diff] [blame] | 4 | * Copyright (C) 2007 Hervé Poussineau |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | * THE SOFTWARE. |
| 23 | */ |
Liran Alon | 2928225 | 2020-03-12 18:54:16 +0200 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Guest code that interacts with this virtual device can be found |
| 27 | * in VMware open-vm-tools open-source project: |
| 28 | * https://github.com/vmware/open-vm-tools |
| 29 | */ |
| 30 | |
Peter Maydell | 0d1c978 | 2016-01-26 18:17:17 +0000 | [diff] [blame] | 31 | #include "qemu/osdep.h" |
Paolo Bonzini | 0d09e41 | 2013-02-05 17:06:20 +0100 | [diff] [blame] | 32 | #include "hw/isa/isa.h" |
Liran Alon | d8f23d6 | 2020-03-12 18:54:22 +0200 | [diff] [blame] | 33 | #include "hw/i386/vmport.h" |
Liran Alon | c9ab24c | 2020-03-12 18:54:17 +0200 | [diff] [blame] | 34 | #include "hw/qdev-properties.h" |
Paolo Bonzini | 86378b2 | 2020-10-28 06:22:23 -0400 | [diff] [blame] | 35 | #include "hw/boards.h" |
Liran Alon | aaacf1c | 2020-03-12 18:54:24 +0200 | [diff] [blame] | 36 | #include "sysemu/sysemu.h" |
Vincent Palatin | b394662 | 2017-01-10 11:59:55 +0100 | [diff] [blame] | 37 | #include "sysemu/hw_accel.h" |
Philippe Mathieu-Daudé | c781a2c | 2020-05-18 12:31:13 +0200 | [diff] [blame] | 38 | #include "sysemu/qtest.h" |
Laurent Vivier | 43ab9a5 | 2017-12-21 22:11:03 +0100 | [diff] [blame] | 39 | #include "qemu/log.h" |
Philippe Mathieu-Daudé | 7299e1a | 2017-12-15 00:43:55 -0300 | [diff] [blame] | 40 | #include "trace.h" |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 41 | #include "qom/object.h" |
aliguori | 61ada15 | 2008-08-19 19:13:06 +0000 | [diff] [blame] | 42 | |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 43 | #define VMPORT_MAGIC 0x564D5868 |
| 44 | |
Liran Alon | b889212 | 2020-03-12 18:54:18 +0200 | [diff] [blame] | 45 | /* Compatibility flags for migration */ |
Liran Alon | 0342ee7 | 2020-03-12 18:54:19 +0200 | [diff] [blame] | 46 | #define VMPORT_COMPAT_READ_SET_EAX_BIT 0 |
| 47 | #define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT 1 |
Liran Alon | f8bdc55 | 2020-03-12 18:54:21 +0200 | [diff] [blame] | 48 | #define VMPORT_COMPAT_REPORT_VMX_TYPE_BIT 2 |
Liran Alon | aaacf1c | 2020-03-12 18:54:24 +0200 | [diff] [blame] | 49 | #define VMPORT_COMPAT_CMDS_V2_BIT 3 |
Liran Alon | 0342ee7 | 2020-03-12 18:54:19 +0200 | [diff] [blame] | 50 | #define VMPORT_COMPAT_READ_SET_EAX \ |
Liran Alon | b889212 | 2020-03-12 18:54:18 +0200 | [diff] [blame] | 51 | (1 << VMPORT_COMPAT_READ_SET_EAX_BIT) |
Liran Alon | 0342ee7 | 2020-03-12 18:54:19 +0200 | [diff] [blame] | 52 | #define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD \ |
| 53 | (1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT) |
Liran Alon | f8bdc55 | 2020-03-12 18:54:21 +0200 | [diff] [blame] | 54 | #define VMPORT_COMPAT_REPORT_VMX_TYPE \ |
| 55 | (1 << VMPORT_COMPAT_REPORT_VMX_TYPE_BIT) |
Liran Alon | aaacf1c | 2020-03-12 18:54:24 +0200 | [diff] [blame] | 56 | #define VMPORT_COMPAT_CMDS_V2 \ |
| 57 | (1 << VMPORT_COMPAT_CMDS_V2_BIT) |
Liran Alon | b889212 | 2020-03-12 18:54:18 +0200 | [diff] [blame] | 58 | |
Liran Alon | acacd35 | 2020-03-12 18:54:27 +0200 | [diff] [blame] | 59 | /* vCPU features reported by CMD_GET_VCPU_INFO */ |
| 60 | #define VCPU_INFO_SLC64_BIT 0 |
| 61 | #define VCPU_INFO_SYNC_VTSCS_BIT 1 |
| 62 | #define VCPU_INFO_HV_REPLAY_OK_BIT 2 |
| 63 | #define VCPU_INFO_LEGACY_X2APIC_BIT 3 |
| 64 | #define VCPU_INFO_RESERVED_BIT 31 |
| 65 | |
Eduardo Habkost | 8063396 | 2020-09-16 14:25:19 -0400 | [diff] [blame] | 66 | OBJECT_DECLARE_SIMPLE_TYPE(VMPortState, VMPORT) |
Andreas Färber | f02317a | 2013-04-27 22:18:54 +0200 | [diff] [blame] | 67 | |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 68 | struct VMPortState { |
Andreas Färber | f02317a | 2013-04-27 22:18:54 +0200 | [diff] [blame] | 69 | ISADevice parent_obj; |
| 70 | |
Richard Henderson | f75317b | 2011-08-16 08:38:14 -0700 | [diff] [blame] | 71 | MemoryRegion io; |
Jan Kiszka | d67f679 | 2013-06-22 08:07:06 +0200 | [diff] [blame] | 72 | VMPortReadFunc *func[VMPORT_ENTRIES]; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 73 | void *opaque[VMPORT_ENTRIES]; |
Liran Alon | b889212 | 2020-03-12 18:54:18 +0200 | [diff] [blame] | 74 | |
Liran Alon | 2fd2f79 | 2020-03-12 18:54:20 +0200 | [diff] [blame] | 75 | uint32_t vmware_vmx_version; |
Liran Alon | f8bdc55 | 2020-03-12 18:54:21 +0200 | [diff] [blame] | 76 | uint8_t vmware_vmx_type; |
Liran Alon | 2fd2f79 | 2020-03-12 18:54:20 +0200 | [diff] [blame] | 77 | |
Liran Alon | b889212 | 2020-03-12 18:54:18 +0200 | [diff] [blame] | 78 | uint32_t compat_flags; |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 79 | }; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 80 | |
Marcelo Tosatti | e14da0a | 2011-02-17 01:27:19 -0200 | [diff] [blame] | 81 | static VMPortState *port_state; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 82 | |
Liran Alon | dcd938f | 2020-03-12 18:54:23 +0200 | [diff] [blame] | 83 | void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *opaque) |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 84 | { |
Liran Alon | dcd938f | 2020-03-12 18:54:23 +0200 | [diff] [blame] | 85 | assert(command < VMPORT_ENTRIES); |
Liran Alon | 23accdf | 2020-03-12 18:54:31 +0200 | [diff] [blame] | 86 | assert(port_state); |
| 87 | |
Philippe Mathieu-Daudé | 7299e1a | 2017-12-15 00:43:55 -0300 | [diff] [blame] | 88 | trace_vmport_register(command, func, opaque); |
Marcelo Tosatti | e14da0a | 2011-02-17 01:27:19 -0200 | [diff] [blame] | 89 | port_state->func[command] = func; |
| 90 | port_state->opaque[command] = opaque; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Alexander Graf | 360d613 | 2012-10-08 13:44:24 +0200 | [diff] [blame] | 93 | static uint64_t vmport_ioport_read(void *opaque, hwaddr addr, |
| 94 | unsigned size) |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 95 | { |
| 96 | VMPortState *s = opaque; |
Andreas Färber | 4917cf4 | 2013-05-27 05:17:50 +0200 | [diff] [blame] | 97 | CPUState *cs = current_cpu; |
| 98 | X86CPU *cpu = X86_CPU(cs); |
Philippe Mathieu-Daudé | c781a2c | 2020-05-18 12:31:13 +0200 | [diff] [blame] | 99 | CPUX86State *env; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 100 | unsigned char command; |
ths | 6dab28d | 2007-10-09 03:19:01 +0000 | [diff] [blame] | 101 | uint32_t eax; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 102 | |
Philippe Mathieu-Daudé | c781a2c | 2020-05-18 12:31:13 +0200 | [diff] [blame] | 103 | if (qtest_enabled()) { |
| 104 | return -1; |
| 105 | } |
| 106 | env = &cpu->env; |
Andreas Färber | 4917cf4 | 2013-05-27 05:17:50 +0200 | [diff] [blame] | 107 | cpu_synchronize_state(cs); |
Jan Kiszka | 03c63b9 | 2010-02-03 21:16:41 +0100 | [diff] [blame] | 108 | |
aurel32 | 26fb5e4 | 2008-04-07 19:47:25 +0000 | [diff] [blame] | 109 | eax = env->regs[R_EAX]; |
Philippe Mathieu-Daudé | 323d7d1 | 2017-10-17 13:44:24 -0300 | [diff] [blame] | 110 | if (eax != VMPORT_MAGIC) { |
Liran Alon | 0342ee7 | 2020-03-12 18:54:19 +0200 | [diff] [blame] | 111 | goto err; |
Philippe Mathieu-Daudé | 323d7d1 | 2017-10-17 13:44:24 -0300 | [diff] [blame] | 112 | } |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 113 | |
aurel32 | 26fb5e4 | 2008-04-07 19:47:25 +0000 | [diff] [blame] | 114 | command = env->regs[R_ECX]; |
Philippe Mathieu-Daudé | 7299e1a | 2017-12-15 00:43:55 -0300 | [diff] [blame] | 115 | trace_vmport_command(command); |
| 116 | if (command >= VMPORT_ENTRIES || !s->func[command]) { |
| 117 | qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command); |
Liran Alon | 0342ee7 | 2020-03-12 18:54:19 +0200 | [diff] [blame] | 118 | goto err; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 119 | } |
| 120 | |
Liran Alon | b889212 | 2020-03-12 18:54:18 +0200 | [diff] [blame] | 121 | eax = s->func[command](s->opaque[command], addr); |
Liran Alon | 0342ee7 | 2020-03-12 18:54:19 +0200 | [diff] [blame] | 122 | goto out; |
| 123 | |
| 124 | err: |
| 125 | if (s->compat_flags & VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD) { |
| 126 | eax = UINT32_MAX; |
| 127 | } |
Liran Alon | b889212 | 2020-03-12 18:54:18 +0200 | [diff] [blame] | 128 | |
| 129 | out: |
| 130 | /* |
| 131 | * The call above to cpu_synchronize_state() gets vCPU registers values |
| 132 | * to QEMU but also cause QEMU to write QEMU vCPU registers values to |
| 133 | * vCPU implementation (e.g. Accelerator such as KVM) just before |
| 134 | * resuming guest. |
| 135 | * |
| 136 | * Therefore, in order to make IOPort return value propagate to |
| 137 | * guest EAX, we need to explicitly update QEMU EAX register value. |
| 138 | */ |
| 139 | if (s->compat_flags & VMPORT_COMPAT_READ_SET_EAX) { |
| 140 | cpu->env.regs[R_EAX] = eax; |
| 141 | } |
| 142 | |
| 143 | return eax; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Alexander Graf | 360d613 | 2012-10-08 13:44:24 +0200 | [diff] [blame] | 146 | static void vmport_ioport_write(void *opaque, hwaddr addr, |
| 147 | uint64_t val, unsigned size) |
aliguori | e9396bd | 2008-07-28 18:58:02 +0000 | [diff] [blame] | 148 | { |
Andreas Färber | 4917cf4 | 2013-05-27 05:17:50 +0200 | [diff] [blame] | 149 | X86CPU *cpu = X86_CPU(current_cpu); |
aliguori | e9396bd | 2008-07-28 18:58:02 +0000 | [diff] [blame] | 150 | |
Philippe Mathieu-Daudé | c781a2c | 2020-05-18 12:31:13 +0200 | [diff] [blame] | 151 | if (qtest_enabled()) { |
| 152 | return; |
| 153 | } |
Andreas Färber | 4917cf4 | 2013-05-27 05:17:50 +0200 | [diff] [blame] | 154 | cpu->env.regs[R_EAX] = vmport_ioport_read(opaque, addr, 4); |
aliguori | e9396bd | 2008-07-28 18:58:02 +0000 | [diff] [blame] | 155 | } |
| 156 | |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 157 | static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr) |
| 158 | { |
Andreas Färber | 4917cf4 | 2013-05-27 05:17:50 +0200 | [diff] [blame] | 159 | X86CPU *cpu = X86_CPU(current_cpu); |
| 160 | |
Philippe Mathieu-Daudé | c781a2c | 2020-05-18 12:31:13 +0200 | [diff] [blame] | 161 | if (qtest_enabled()) { |
| 162 | return -1; |
| 163 | } |
Andreas Färber | 4917cf4 | 2013-05-27 05:17:50 +0200 | [diff] [blame] | 164 | cpu->env.regs[R_EBX] = VMPORT_MAGIC; |
Liran Alon | f8bdc55 | 2020-03-12 18:54:21 +0200 | [diff] [blame] | 165 | if (port_state->compat_flags & VMPORT_COMPAT_REPORT_VMX_TYPE) { |
| 166 | cpu->env.regs[R_ECX] = port_state->vmware_vmx_type; |
| 167 | } |
Liran Alon | 2fd2f79 | 2020-03-12 18:54:20 +0200 | [diff] [blame] | 168 | return port_state->vmware_vmx_version; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Liran Alon | aaacf1c | 2020-03-12 18:54:24 +0200 | [diff] [blame] | 171 | static uint32_t vmport_cmd_get_bios_uuid(void *opaque, uint32_t addr) |
| 172 | { |
| 173 | X86CPU *cpu = X86_CPU(current_cpu); |
| 174 | uint32_t *uuid_parts = (uint32_t *)(qemu_uuid.data); |
| 175 | |
| 176 | cpu->env.regs[R_EAX] = le32_to_cpu(uuid_parts[0]); |
| 177 | cpu->env.regs[R_EBX] = le32_to_cpu(uuid_parts[1]); |
| 178 | cpu->env.regs[R_ECX] = le32_to_cpu(uuid_parts[2]); |
| 179 | cpu->env.regs[R_EDX] = le32_to_cpu(uuid_parts[3]); |
| 180 | return cpu->env.regs[R_EAX]; |
| 181 | } |
| 182 | |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 183 | static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) |
| 184 | { |
Andreas Färber | 4917cf4 | 2013-05-27 05:17:50 +0200 | [diff] [blame] | 185 | X86CPU *cpu = X86_CPU(current_cpu); |
| 186 | |
Philippe Mathieu-Daudé | c781a2c | 2020-05-18 12:31:13 +0200 | [diff] [blame] | 187 | if (qtest_enabled()) { |
| 188 | return -1; |
| 189 | } |
Andreas Färber | 4917cf4 | 2013-05-27 05:17:50 +0200 | [diff] [blame] | 190 | cpu->env.regs[R_EBX] = 0x1177; |
Paolo Bonzini | 86378b2 | 2020-10-28 06:22:23 -0400 | [diff] [blame] | 191 | return current_machine->ram_size; |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Liran Alon | d6048bf | 2020-03-12 18:54:30 +0200 | [diff] [blame] | 194 | static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr) |
| 195 | { |
| 196 | X86CPU *cpu = X86_CPU(current_cpu); |
| 197 | |
| 198 | if (cpu->env.tsc_khz && cpu->env.apic_bus_freq) { |
| 199 | uint64_t tsc_freq = (uint64_t)cpu->env.tsc_khz * 1000; |
| 200 | |
| 201 | cpu->env.regs[R_ECX] = cpu->env.apic_bus_freq; |
| 202 | cpu->env.regs[R_EBX] = (uint32_t)(tsc_freq >> 32); |
| 203 | cpu->env.regs[R_EAX] = (uint32_t)tsc_freq; |
| 204 | } else { |
| 205 | /* Signal cmd as not supported */ |
| 206 | cpu->env.regs[R_EBX] = UINT32_MAX; |
| 207 | } |
| 208 | |
| 209 | return cpu->env.regs[R_EAX]; |
| 210 | } |
| 211 | |
Liran Alon | acacd35 | 2020-03-12 18:54:27 +0200 | [diff] [blame] | 212 | static uint32_t vmport_cmd_get_vcpu_info(void *opaque, uint32_t addr) |
| 213 | { |
Liran Alon | 7f9114b | 2020-03-12 18:54:28 +0200 | [diff] [blame] | 214 | X86CPU *cpu = X86_CPU(current_cpu); |
| 215 | uint32_t ret = 0; |
| 216 | |
| 217 | if (cpu->env.features[FEAT_1_ECX] & CPUID_EXT_X2APIC) { |
| 218 | ret |= 1 << VCPU_INFO_LEGACY_X2APIC_BIT; |
| 219 | } |
| 220 | |
| 221 | return ret; |
Liran Alon | acacd35 | 2020-03-12 18:54:27 +0200 | [diff] [blame] | 222 | } |
| 223 | |
Richard Henderson | f75317b | 2011-08-16 08:38:14 -0700 | [diff] [blame] | 224 | static const MemoryRegionOps vmport_ops = { |
Alexander Graf | 360d613 | 2012-10-08 13:44:24 +0200 | [diff] [blame] | 225 | .read = vmport_ioport_read, |
| 226 | .write = vmport_ioport_write, |
| 227 | .impl = { |
| 228 | .min_access_size = 4, |
| 229 | .max_access_size = 4, |
| 230 | }, |
| 231 | .endianness = DEVICE_LITTLE_ENDIAN, |
Richard Henderson | f75317b | 2011-08-16 08:38:14 -0700 | [diff] [blame] | 232 | }; |
| 233 | |
Andreas Färber | db895a1 | 2012-11-25 02:37:14 +0100 | [diff] [blame] | 234 | static void vmport_realizefn(DeviceState *dev, Error **errp) |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 235 | { |
Andreas Färber | db895a1 | 2012-11-25 02:37:14 +0100 | [diff] [blame] | 236 | ISADevice *isadev = ISA_DEVICE(dev); |
Andreas Färber | f02317a | 2013-04-27 22:18:54 +0200 | [diff] [blame] | 237 | VMPortState *s = VMPORT(dev); |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 238 | |
Paolo Bonzini | 3c16154 | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 239 | memory_region_init_io(&s->io, OBJECT(s), &vmport_ops, s, "vmport", 1); |
Andreas Färber | db895a1 | 2012-11-25 02:37:14 +0100 | [diff] [blame] | 240 | isa_register_ioport(isadev, &s->io, 0x5658); |
Richard Henderson | f75317b | 2011-08-16 08:38:14 -0700 | [diff] [blame] | 241 | |
Marcelo Tosatti | e14da0a | 2011-02-17 01:27:19 -0200 | [diff] [blame] | 242 | port_state = s; |
Liran Alon | aaacf1c | 2020-03-12 18:54:24 +0200 | [diff] [blame] | 243 | |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 244 | /* Register some generic port commands */ |
aurel32 | 26fb5e4 | 2008-04-07 19:47:25 +0000 | [diff] [blame] | 245 | vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL); |
| 246 | vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); |
Liran Alon | aaacf1c | 2020-03-12 18:54:24 +0200 | [diff] [blame] | 247 | if (s->compat_flags & VMPORT_COMPAT_CMDS_V2) { |
| 248 | vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, NULL); |
Liran Alon | d6048bf | 2020-03-12 18:54:30 +0200 | [diff] [blame] | 249 | vmport_register(VMPORT_CMD_GETHZ, vmport_cmd_get_hz, NULL); |
Liran Alon | acacd35 | 2020-03-12 18:54:27 +0200 | [diff] [blame] | 250 | vmport_register(VMPORT_CMD_GET_VCPU_INFO, vmport_cmd_get_vcpu_info, |
| 251 | NULL); |
Liran Alon | aaacf1c | 2020-03-12 18:54:24 +0200 | [diff] [blame] | 252 | } |
ths | 0975c30 | 2007-08-26 17:48:12 +0000 | [diff] [blame] | 253 | } |
Blue Swirl | 6872ef6 | 2011-02-05 14:34:41 +0000 | [diff] [blame] | 254 | |
Liran Alon | c9ab24c | 2020-03-12 18:54:17 +0200 | [diff] [blame] | 255 | static Property vmport_properties[] = { |
Liran Alon | b889212 | 2020-03-12 18:54:18 +0200 | [diff] [blame] | 256 | /* Used to enforce compatibility for migration */ |
| 257 | DEFINE_PROP_BIT("x-read-set-eax", VMPortState, compat_flags, |
| 258 | VMPORT_COMPAT_READ_SET_EAX_BIT, true), |
Liran Alon | 0342ee7 | 2020-03-12 18:54:19 +0200 | [diff] [blame] | 259 | DEFINE_PROP_BIT("x-signal-unsupported-cmd", VMPortState, compat_flags, |
| 260 | VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT, true), |
Liran Alon | f8bdc55 | 2020-03-12 18:54:21 +0200 | [diff] [blame] | 261 | DEFINE_PROP_BIT("x-report-vmx-type", VMPortState, compat_flags, |
| 262 | VMPORT_COMPAT_REPORT_VMX_TYPE_BIT, true), |
Liran Alon | aaacf1c | 2020-03-12 18:54:24 +0200 | [diff] [blame] | 263 | DEFINE_PROP_BIT("x-cmds-v2", VMPortState, compat_flags, |
| 264 | VMPORT_COMPAT_CMDS_V2_BIT, true), |
Liran Alon | 2fd2f79 | 2020-03-12 18:54:20 +0200 | [diff] [blame] | 265 | |
| 266 | /* Default value taken from open-vm-tools code VERSION_MAGIC definition */ |
| 267 | DEFINE_PROP_UINT32("vmware-vmx-version", VMPortState, |
| 268 | vmware_vmx_version, 6), |
Liran Alon | f8bdc55 | 2020-03-12 18:54:21 +0200 | [diff] [blame] | 269 | /* |
| 270 | * Value determines which VMware product type host report itself to guest. |
| 271 | * |
| 272 | * Most guests are fine with exposing host as VMware ESX server. |
| 273 | * Some legacy/proprietary guests hard-code a given type. |
| 274 | * |
| 275 | * For a complete list of values, refer to enum VMXType at open-vm-tools |
| 276 | * project (Defined at lib/include/vm_vmx_type.h). |
| 277 | * |
| 278 | * Reasonable options: |
| 279 | * 0 - Unset |
| 280 | * 1 - VMware Express (deprecated) |
| 281 | * 2 - VMware ESX Server |
| 282 | * 3 - VMware Server (Deprecated) |
| 283 | * 4 - VMware Workstation |
| 284 | * 5 - ACE 1.x (Deprecated) |
| 285 | */ |
| 286 | DEFINE_PROP_UINT8("vmware-vmx-type", VMPortState, vmware_vmx_type, 2), |
Liran Alon | 2fd2f79 | 2020-03-12 18:54:20 +0200 | [diff] [blame] | 287 | |
Liran Alon | c9ab24c | 2020-03-12 18:54:17 +0200 | [diff] [blame] | 288 | DEFINE_PROP_END_OF_LIST(), |
| 289 | }; |
| 290 | |
Anthony Liguori | 8f04ee0 | 2011-12-04 11:52:49 -0600 | [diff] [blame] | 291 | static void vmport_class_initfn(ObjectClass *klass, void *data) |
| 292 | { |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 293 | DeviceClass *dc = DEVICE_CLASS(klass); |
Andreas Färber | db895a1 | 2012-11-25 02:37:14 +0100 | [diff] [blame] | 294 | |
| 295 | dc->realize = vmport_realizefn; |
Markus Armbruster | f3b1764 | 2013-11-28 17:27:02 +0100 | [diff] [blame] | 296 | /* Reason: realize sets global port_state */ |
Eduardo Habkost | e90f2a8 | 2017-05-03 17:35:44 -0300 | [diff] [blame] | 297 | dc->user_creatable = false; |
Liran Alon | c9ab24c | 2020-03-12 18:54:17 +0200 | [diff] [blame] | 298 | device_class_set_props(dc, vmport_properties); |
Anthony Liguori | 8f04ee0 | 2011-12-04 11:52:49 -0600 | [diff] [blame] | 299 | } |
| 300 | |
Andreas Färber | 8c43a6f | 2013-01-10 16:19:07 +0100 | [diff] [blame] | 301 | static const TypeInfo vmport_info = { |
Andreas Färber | f02317a | 2013-04-27 22:18:54 +0200 | [diff] [blame] | 302 | .name = TYPE_VMPORT, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 303 | .parent = TYPE_ISA_DEVICE, |
| 304 | .instance_size = sizeof(VMPortState), |
| 305 | .class_init = vmport_class_initfn, |
Blue Swirl | 6872ef6 | 2011-02-05 14:34:41 +0000 | [diff] [blame] | 306 | }; |
| 307 | |
Andreas Färber | 83f7d43 | 2012-02-09 15:20:55 +0100 | [diff] [blame] | 308 | static void vmport_register_types(void) |
Blue Swirl | 6872ef6 | 2011-02-05 14:34:41 +0000 | [diff] [blame] | 309 | { |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 310 | type_register_static(&vmport_info); |
Blue Swirl | 6872ef6 | 2011-02-05 14:34:41 +0000 | [diff] [blame] | 311 | } |
Andreas Färber | 83f7d43 | 2012-02-09 15:20:55 +0100 | [diff] [blame] | 312 | |
| 313 | type_init(vmport_register_types) |