qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Liran Alon <liran.alon@oracle.com>,
	Nikita Leshenko <nikita.leshchenko@oracle.com>
Subject: [PULL 033/115] hw/i386/vmport: Add support for CMD_GETBIOSUUID
Date: Thu, 11 Jun 2020 15:43:27 -0400	[thread overview]
Message-ID: <20200611194449.31468-34-pbonzini@redhat.com> (raw)
In-Reply-To: <20200611194449.31468-1-pbonzini@redhat.com>

From: Liran Alon <liran.alon@oracle.com>

This is VMware documented functionallity that some guests rely on.
Returns the BIOS UUID of the current virtual machine.

Note that we also introduce a new compatability flag "x-cmds-v2" to
make sure to expose new VMPort commands only to new machine-types.
This flag will also be used by the following patches that will introduce
additional VMPort commands.

Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Message-Id: <20200312165431.82118-10-liran.alon@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/core/machine.c        |  1 +
 hw/i386/vmport.c         | 22 ++++++++++++++++++++++
 include/hw/i386/vmport.h |  1 +
 3 files changed, 24 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 9a07e9333a..5460e62294 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -46,6 +46,7 @@ GlobalProperty hw_compat_4_2[] = {
     { "vmport", "x-read-set-eax", "off" },
     { "vmport", "x-signal-unsupported-cmd", "off" },
     { "vmport", "x-report-vmx-type", "off" },
+    { "vmport", "x-cmds-v2", "off" },
 };
 const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);
 
diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c
index 359cdef1e0..8006ff91d4 100644
--- a/hw/i386/vmport.c
+++ b/hw/i386/vmport.c
@@ -32,6 +32,7 @@
 #include "hw/isa/isa.h"
 #include "hw/i386/vmport.h"
 #include "hw/qdev-properties.h"
+#include "sysemu/sysemu.h"
 #include "sysemu/hw_accel.h"
 #include "qemu/log.h"
 #include "cpu.h"
@@ -43,12 +44,15 @@
 #define VMPORT_COMPAT_READ_SET_EAX_BIT              0
 #define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT    1
 #define VMPORT_COMPAT_REPORT_VMX_TYPE_BIT           2
+#define VMPORT_COMPAT_CMDS_V2_BIT                   3
 #define VMPORT_COMPAT_READ_SET_EAX              \
     (1 << VMPORT_COMPAT_READ_SET_EAX_BIT)
 #define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD    \
     (1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT)
 #define VMPORT_COMPAT_REPORT_VMX_TYPE           \
     (1 << VMPORT_COMPAT_REPORT_VMX_TYPE_BIT)
+#define VMPORT_COMPAT_CMDS_V2                   \
+    (1 << VMPORT_COMPAT_CMDS_V2_BIT)
 
 #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT)
 
@@ -143,6 +147,18 @@ static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)
     return port_state->vmware_vmx_version;
 }
 
+static uint32_t vmport_cmd_get_bios_uuid(void *opaque, uint32_t addr)
+{
+    X86CPU *cpu = X86_CPU(current_cpu);
+    uint32_t *uuid_parts = (uint32_t *)(qemu_uuid.data);
+
+    cpu->env.regs[R_EAX] = le32_to_cpu(uuid_parts[0]);
+    cpu->env.regs[R_EBX] = le32_to_cpu(uuid_parts[1]);
+    cpu->env.regs[R_ECX] = le32_to_cpu(uuid_parts[2]);
+    cpu->env.regs[R_EDX] = le32_to_cpu(uuid_parts[3]);
+    return cpu->env.regs[R_EAX];
+}
+
 static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
 {
     X86CPU *cpu = X86_CPU(current_cpu);
@@ -170,9 +186,13 @@ static void vmport_realizefn(DeviceState *dev, Error **errp)
     isa_register_ioport(isadev, &s->io, 0x5658);
 
     port_state = s;
+
     /* Register some generic port commands */
     vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL);
     vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL);
+    if (s->compat_flags & VMPORT_COMPAT_CMDS_V2) {
+        vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, NULL);
+    }
 }
 
 static Property vmport_properties[] = {
@@ -183,6 +203,8 @@ static Property vmport_properties[] = {
                     VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT, true),
     DEFINE_PROP_BIT("x-report-vmx-type", VMPortState, compat_flags,
                     VMPORT_COMPAT_REPORT_VMX_TYPE_BIT, true),
+    DEFINE_PROP_BIT("x-cmds-v2", VMPortState, compat_flags,
+                    VMPORT_COMPAT_CMDS_V2_BIT, true),
 
     /* Default value taken from open-vm-tools code VERSION_MAGIC definition */
     DEFINE_PROP_UINT32("vmware-vmx-version", VMPortState,
diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h
index bbe2c58bf9..7f566ccc02 100644
--- a/include/hw/i386/vmport.h
+++ b/include/hw/i386/vmport.h
@@ -8,6 +8,7 @@ typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address);
 
 typedef enum {
     VMPORT_CMD_GETVERSION       = 10,
+    VMPORT_CMD_GETBIOSUUID      = 19,
     VMPORT_CMD_GETRAMSIZE       = 20,
     VMPORT_CMD_VMMOUSE_DATA     = 39,
     VMPORT_CMD_VMMOUSE_STATUS   = 40,
-- 
2.26.2




  parent reply	other threads:[~2020-06-11 20:02 UTC|newest]

Thread overview: 126+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11 19:42 [PULL 000/115] Huge miscellaneous pull request for 2020-06-11 Paolo Bonzini
2020-06-11 19:42 ` [PULL 001/115] docker.py/build: support -t and -f arguments Paolo Bonzini
2020-06-11 19:42 ` [PULL 002/115] docker.py/build: support binary files in --extra-files Paolo Bonzini
2020-06-11 19:42 ` [PULL 003/115] run-coverity-scan: get Coverity token and email from special git config section Paolo Bonzini
2020-06-11 19:42 ` [PULL 004/115] run-coverity-scan: use docker.py Paolo Bonzini
2020-06-11 19:42 ` [PULL 005/115] run-coverity-scan: add --no-update-tools option Paolo Bonzini
2020-06-11 19:43 ` [PULL 006/115] run-coverity-scan: use --no-update-tools in docker run Paolo Bonzini
2020-06-11 19:43 ` [PULL 007/115] run-coverity-scan: download tools outside the container Paolo Bonzini
2020-06-11 19:43 ` [PULL 008/115] run-coverity-scan: support --update-tools-only --docker Paolo Bonzini
2020-06-11 19:43 ` [PULL 009/115] vl.c: run preconfig loop before creating default RAM backend Paolo Bonzini
2020-06-11 19:43 ` [PULL 010/115] numa: prevent usage of -M memory-backend and -numa memdev at the same time Paolo Bonzini
2020-06-11 19:43 ` [PULL 011/115] icount: fix shift=auto for record/replay Paolo Bonzini
2020-06-11 19:43 ` [PULL 012/115] qom/object: Fix object_child_foreach_recursive() return value Paolo Bonzini
2020-06-11 19:43 ` [PULL 013/115] target/i386: Fix OUTL debug output Paolo Bonzini
2020-06-11 19:43 ` [PULL 014/115] qom/object: Move Object typedef to 'qemu/typedefs.h' Paolo Bonzini
2020-06-11 19:43 ` [PULL 015/115] io/task: Move 'qom/object.h' header to source Paolo Bonzini
2020-06-11 19:43 ` [PULL 016/115] Makefile: Let the 'help' target list the helper targets Paolo Bonzini
2020-06-11 19:43 ` [PULL 017/115] hyperv: expose API to determine if synic is enabled Paolo Bonzini
2020-06-11 19:43 ` [PULL 018/115] vmbus: add vmbus protocol definitions Paolo Bonzini
2020-06-11 19:43 ` [PULL 019/115] vmbus: vmbus implementation Paolo Bonzini
2020-06-11 19:43 ` [PULL 020/115] i386:pc: whitelist dynamic vmbus-bridge Paolo Bonzini
2020-06-11 19:43 ` [PULL 021/115] i386: Hyper-V VMBus ACPI DSDT entry Paolo Bonzini
2020-06-11 19:43 ` [PULL 022/115] vmbus: add infrastructure to save/load vmbus requests Paolo Bonzini
2020-06-11 19:43 ` [PULL 023/115] target/i386: Fix the CPUID leaf CPUID_Fn80000008 Paolo Bonzini
2020-06-11 19:43 ` [PULL 024/115] target/i386: fix phadd* with identical destination and source register Paolo Bonzini
2020-06-11 19:43 ` [PULL 025/115] hw/i386/vmport: Add reference to VMware open-vm-tools Paolo Bonzini
2020-06-11 19:43 ` [PULL 026/115] hw/i386/vmport: Add device properties Paolo Bonzini
2020-06-11 19:43 ` [PULL 027/115] hw/i386/vmport: Propagate IOPort read to vCPU EAX register Paolo Bonzini
2020-06-23  8:46   ` Laurent Vivier
2020-06-23  9:34     ` Liran Alon
2020-06-23 10:25       ` Paolo Bonzini
2020-06-23 10:26         ` Laurent Vivier
2020-06-11 19:43 ` [PULL 028/115] hw/i386/vmport: Set EAX to -1 on failed and unsupported commands Paolo Bonzini
2020-06-11 19:43 ` [PULL 029/115] hw/i386/vmport: Introduce vmware-vmx-version property Paolo Bonzini
2020-06-11 19:43 ` [PULL 030/115] hw/i386/vmport: Report vmware-vmx-type in CMD_GETVERSION Paolo Bonzini
2020-06-11 19:43 ` [PULL 031/115] hw/i386/vmport: Introduce vmport.h Paolo Bonzini
2020-06-11 19:43 ` [PULL 032/115] hw/i386/vmport: Define enum for all commands Paolo Bonzini
2020-06-11 19:43 ` Paolo Bonzini [this message]
2020-06-11 19:43 ` [PULL 034/115] hw/i386/vmport: Add support for CMD_GET_VCPU_INFO Paolo Bonzini
2020-06-11 19:43 ` [PULL 035/115] hw/i386/vmport: Allow x2apic without IR Paolo Bonzini
2020-06-11 19:43 ` [PULL 036/115] i386/cpu: Store LAPIC bus frequency in CPU structure Paolo Bonzini
2020-06-11 19:43 ` [PULL 037/115] hw/i386/vmport: Add support for CMD_GETHZ Paolo Bonzini
2020-06-11 19:43 ` [PULL 038/115] hw/i386/vmport: Assert vmport initialized before registering commands Paolo Bonzini
2020-06-11 19:43 ` [PULL 039/115] accel: Move Xen accelerator code under accel/xen/ Paolo Bonzini
2020-06-11 19:43 ` [PULL 040/115] qom: remove index from object_resolve_abs_path() Paolo Bonzini
2020-06-11 19:43 ` [PULL 041/115] qom/object: factor out the initialization of hash table of properties Paolo Bonzini
2020-06-11 19:43 ` [PULL 042/115] qom/object: simplify type_initialize_interface() Paolo Bonzini
2020-06-11 19:43 ` [PULL 043/115] qom/object: pass (Object *) to object_initialize_with_type() Paolo Bonzini
2020-06-11 19:43 ` [PULL 044/115] qom/container: remove .instance_size initializer from container_info Paolo Bonzini
2020-06-11 19:43 ` [PULL 045/115] cpus: Fix botched configure_icount() error API violation fix Paolo Bonzini
2020-06-11 19:43 ` [PULL 046/115] hax: Dynamic allocate vcpu state structure Paolo Bonzini
2020-06-11 19:43 ` [PULL 047/115] i386/kvm: fix a use-after-free when vcpu plug/unplug Paolo Bonzini
2020-06-11 19:43 ` [PULL 048/115] megasas: use unsigned type for reply_queue_head and check index Paolo Bonzini
2020-06-11 19:43 ` [PULL 049/115] megasas: avoid NULL pointer dereference Paolo Bonzini
2020-06-11 19:43 ` [PULL 050/115] megasas: use unsigned type for positive numeric fields Paolo Bonzini
2020-06-11 19:43 ` [PULL 051/115] target/i386: implement special cases for fxtract Paolo Bonzini
2020-06-11 19:43 ` [PULL 052/115] target/i386: fix fscale handling of signaling NaN Paolo Bonzini
2020-06-11 19:43 ` [PULL 053/115] target/i386: fix fscale handling of invalid exponent encodings Paolo Bonzini
2020-06-11 19:43 ` [PULL 054/115] target/i386: fix fscale handling of infinite exponents Paolo Bonzini
2020-06-11 19:43 ` [PULL 055/115] target/i386: fix fscale handling of rounding precision Paolo Bonzini
2020-06-11 19:43 ` [PULL 056/115] exec: Let address_space_read/write_cached() propagate MemTxResult Paolo Bonzini
2020-06-11 19:43 ` [PULL 057/115] exec: Propagate cpu_memory_rw_debug() error Paolo Bonzini
2020-06-11 19:43 ` [PULL 058/115] disas: Let disas::read_memory() handler return EIO on error Paolo Bonzini
2020-06-11 19:43 ` [PULL 059/115] hw/elf_ops: Do not ignore write failures when loading ELF Paolo Bonzini
2020-06-11 19:43 ` [PULL 060/115] target/i386: fix floating-point load-constant rounding Paolo Bonzini
2020-06-11 19:43 ` [PULL 061/115] target/i386: fix fxam handling of invalid encodings Paolo Bonzini
2020-06-11 19:43 ` [PULL 062/115] target/i386: fix fbstp handling of negative zero Paolo Bonzini
2020-06-11 19:43 ` [PULL 063/115] target/i386: fix fbstp handling of out-of-range values Paolo Bonzini
2020-06-11 19:43 ` [PULL 064/115] target/i386: fix fisttpl, fisttpll " Paolo Bonzini
2020-06-11 19:43 ` [PULL 065/115] hw/i386/vmport: Allow QTest use without crashing Paolo Bonzini
2020-06-11 19:44 ` [PULL 066/115] x86/cpu: Enable AVX512_VP2INTERSECT cpu feature Paolo Bonzini
2020-06-11 19:44 ` [PULL 067/115] vfio/pci: Use kvm_irqchip_add_irqfd_notifier_gsi() for irqfds Paolo Bonzini
2020-06-11 19:44 ` [PULL 068/115] KVM: Pass EventNotifier into kvm_irqchip_assign_irqfd Paolo Bonzini
2020-06-11 19:44 ` [PULL 069/115] KVM: Kick resamplefd for split kernel irqchip Paolo Bonzini
2020-06-11 19:44 ` [PULL 070/115] chardev/char-socket: Properly make qio connections non blocking Paolo Bonzini
2020-06-11 19:44 ` [PULL 071/115] tests: machine-none-test: Enable MicroBlaze testing Paolo Bonzini
2020-06-11 19:44 ` [PULL 072/115] hw/i386/amd_iommu: Fix the reserved bits definition of IOMMU commands Paolo Bonzini
2020-06-11 19:44 ` [PULL 073/115] replay: implement fair mutex Paolo Bonzini
2020-06-11 19:44 ` [PULL 074/115] i386: Remove unused define's from hax and hvf Paolo Bonzini
2020-06-11 19:44 ` [PULL 075/115] target/i386: define a new MSR based feature word - FEAT_PERF_CAPABILITIES Paolo Bonzini
2020-06-11 19:44 ` [PULL 076/115] util/oslib: Returns the real thread identifier on FreeBSD and NetBSD Paolo Bonzini
2020-06-11 19:44 ` [PULL 077/115] memory: Make 'info mtree' not display disabled regions by default Paolo Bonzini
2020-06-11 19:44 ` [PULL 078/115] qemu/thread: Mark qemu_thread_exit() with 'noreturn' attribute Paolo Bonzini
2020-06-11 19:44 ` [PULL 079/115] configure: Do not ignore malloc value Paolo Bonzini
2020-06-11 19:44 ` [PULL 080/115] exec: set map length to zero when returning NULL Paolo Bonzini
2020-06-11 19:44 ` [PULL 081/115] target/i386: fix IEEE x87 floating-point exception raising Paolo Bonzini
2020-06-11 19:44 ` [PULL 082/115] target/i386: correct fix for pcmpxstrx substring search Paolo Bonzini
2020-06-11 19:44 ` [PULL 083/115] sysemu/accel: Restrict machine methods to system-mode Paolo Bonzini
2020-06-11 19:44 ` [PULL 084/115] sysemu/tcg: Only declare tcg_allowed when TCG is available Paolo Bonzini
2020-06-11 19:44 ` [PULL 085/115] sysemu/hvf: Only declare hvf_allowed when HVF " Paolo Bonzini
2020-06-11 19:44 ` [PULL 086/115] target/ppc: Restrict PPCVirtualHypervisorClass to system-mode Paolo Bonzini
2020-06-11 19:44 ` [PULL 087/115] i386: hvf: Move HVFState definition into hvf Paolo Bonzini
2020-06-11 19:44 ` [PULL 088/115] i386: hvf: Drop useless declarations in sysemu Paolo Bonzini
2020-06-11 19:44 ` [PULL 089/115] i386: hvf: Drop unused variable Paolo Bonzini
2020-06-11 19:44 ` [PULL 090/115] i386: hvf: Use ins_len to advance IP Paolo Bonzini
2020-06-11 19:44 ` [PULL 091/115] i386: hvf: Use IP from CPUX86State Paolo Bonzini
2020-06-11 19:44 ` [PULL 092/115] i386: hvf: Drop fetch_rip from HVFX86EmulatorState Paolo Bonzini
2020-06-11 19:44 ` [PULL 093/115] i386: hvf: Drop rflags " Paolo Bonzini
2020-06-11 19:44 ` [PULL 094/115] i386: hvf: Drop copy of RFLAGS defines Paolo Bonzini
2020-06-11 19:44 ` [PULL 095/115] i386: hvf: Drop regs in HVFX86EmulatorState Paolo Bonzini
2020-06-11 19:44 ` [PULL 096/115] i386: hvf: Move lazy_flags into CPUX86State Paolo Bonzini
2020-06-11 19:44 ` [PULL 097/115] i386: hvf: Move mmio_buf " Paolo Bonzini
2020-06-11 19:44 ` [PULL 098/115] i386: hvf: Drop HVFX86EmulatorState Paolo Bonzini
2020-06-11 19:44 ` [PULL 099/115] xen: fix build without pci passthrough Paolo Bonzini
2020-06-11 19:44 ` [PULL 100/115] target/i386: sev: Remove unused QSevGuestInfoClass Paolo Bonzini
2020-06-11 19:44 ` [PULL 101/115] target/i386: sev: Move local structure definitions into .c file Paolo Bonzini
2020-06-11 19:44 ` [PULL 102/115] target/i386: sev: Rename QSevGuestInfo Paolo Bonzini
2020-06-11 19:44 ` [PULL 103/115] target/i386: sev: Embed SEVState in SevGuestState Paolo Bonzini
2020-06-11 19:44 ` [PULL 104/115] target/i386: sev: Partial cleanup to sev_state global Paolo Bonzini
2020-06-11 19:44 ` [PULL 105/115] target/i386: sev: Remove redundant cbitpos and reduced_phys_bits fields Paolo Bonzini
2020-06-11 19:44 ` [PULL 106/115] target/i386: sev: Remove redundant policy field Paolo Bonzini
2020-06-11 19:44 ` [PULL 107/115] target/i386: sev: Remove redundant handle field Paolo Bonzini
2020-06-11 19:44 ` [PULL 108/115] target/i386: sev: Unify SEVState and SevGuestState Paolo Bonzini
2020-06-11 19:44 ` [PULL 109/115] checkpatch: reversed logic with acpi test checks Paolo Bonzini
2020-06-11 19:44 ` [PULL 110/115] exec/memory: Remove unused MemoryRegionMmio type Paolo Bonzini
2020-06-11 19:44 ` [PULL 111/115] hw/usb: Move device-specific declarations to new 'hcd-musb.h' header Paolo Bonzini
2020-06-11 19:44 ` [PULL 112/115] exec/cpu-common: Move MUSB specific typedefs to 'hw/usb/hcd-musb.h' Paolo Bonzini
2020-06-11 19:44 ` [PULL 113/115] replay: fix replay shutdown for console mode Paolo Bonzini
2020-06-11 19:44 ` [PULL 114/115] stubs: move Xen stubs to accel/ Paolo Bonzini
2020-06-11 19:44 ` [PULL 115/115] target/i386: Remove obsolete TODO file Paolo Bonzini
2020-06-12  2:00 ` [PULL 000/115] Huge miscellaneous pull request for 2020-06-11 no-reply
2020-06-12 13:09 ` Peter Maydell
2020-06-12 13:33   ` Paolo Bonzini
2020-06-12 13:46     ` Roman Bolshakov
2020-06-12 14:53     ` Roman Bolshakov
2020-06-12 15:14       ` Paolo Bonzini

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=20200611194449.31468-34-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=liran.alon@oracle.com \
    --cc=nikita.leshchenko@oracle.com \
    --cc=qemu-devel@nongnu.org \
    /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).