hw/i386/vmport: Set EAX to -1 on failed and unsupported commands
This is used as a signal for VMware Tools to know if a command it attempted to invoke, failed or is unsupported. As a result, VMware Tools will either report failure to user or fallback to another backdoor command in attempt to perform some operation. A few examples: * open-vm-tools TimeSyncReadHost() function fallbacks to CMD_GETTIMEFULL command when CMD_GETTIMEFULL_WITH_LAG fails/unsupported. * open-vm-tools Hostinfo_NestingSupported() function verifies EAX != -1 to check for success. * open-vm-tools Hostinfo_VCPUInfoBackdoor() functions checks if reserved-bit is set to indicate command is unimplemented. Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com> Signed-off-by: Liran Alon <liran.alon@oracle.com> Message-Id: <20200312165431.82118-5-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
b889212973
commit
0342ee761e
|
@ -44,6 +44,7 @@ GlobalProperty hw_compat_4_2[] = {
|
||||||
{ "qxl-vga", "revision", "4" },
|
{ "qxl-vga", "revision", "4" },
|
||||||
{ "fw_cfg", "acpi-mr-restore", "false" },
|
{ "fw_cfg", "acpi-mr-restore", "false" },
|
||||||
{ "vmport", "x-read-set-eax", "off" },
|
{ "vmport", "x-read-set-eax", "off" },
|
||||||
|
{ "vmport", "x-signal-unsupported-cmd", "off" },
|
||||||
};
|
};
|
||||||
const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);
|
const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,12 @@
|
||||||
#define VMPORT_MAGIC 0x564D5868
|
#define VMPORT_MAGIC 0x564D5868
|
||||||
|
|
||||||
/* Compatibility flags for migration */
|
/* Compatibility flags for migration */
|
||||||
#define VMPORT_COMPAT_READ_SET_EAX_BIT 0
|
#define VMPORT_COMPAT_READ_SET_EAX_BIT 0
|
||||||
#define VMPORT_COMPAT_READ_SET_EAX \
|
#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT 1
|
||||||
|
#define VMPORT_COMPAT_READ_SET_EAX \
|
||||||
(1 << VMPORT_COMPAT_READ_SET_EAX_BIT)
|
(1 << VMPORT_COMPAT_READ_SET_EAX_BIT)
|
||||||
|
#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD \
|
||||||
|
(1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT)
|
||||||
|
|
||||||
#define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT)
|
#define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT)
|
||||||
|
|
||||||
|
@ -87,17 +90,23 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr,
|
||||||
|
|
||||||
eax = env->regs[R_EAX];
|
eax = env->regs[R_EAX];
|
||||||
if (eax != VMPORT_MAGIC) {
|
if (eax != VMPORT_MAGIC) {
|
||||||
goto out;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
command = env->regs[R_ECX];
|
command = env->regs[R_ECX];
|
||||||
trace_vmport_command(command);
|
trace_vmport_command(command);
|
||||||
if (command >= VMPORT_ENTRIES || !s->func[command]) {
|
if (command >= VMPORT_ENTRIES || !s->func[command]) {
|
||||||
qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command);
|
qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command);
|
||||||
goto out;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
eax = s->func[command](s->opaque[command], addr);
|
eax = s->func[command](s->opaque[command], addr);
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (s->compat_flags & VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD) {
|
||||||
|
eax = UINT32_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/*
|
/*
|
||||||
|
@ -168,6 +177,8 @@ static Property vmport_properties[] = {
|
||||||
/* Used to enforce compatibility for migration */
|
/* Used to enforce compatibility for migration */
|
||||||
DEFINE_PROP_BIT("x-read-set-eax", VMPortState, compat_flags,
|
DEFINE_PROP_BIT("x-read-set-eax", VMPortState, compat_flags,
|
||||||
VMPORT_COMPAT_READ_SET_EAX_BIT, true),
|
VMPORT_COMPAT_READ_SET_EAX_BIT, true),
|
||||||
|
DEFINE_PROP_BIT("x-signal-unsupported-cmd", VMPortState, compat_flags,
|
||||||
|
VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT, true),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue