mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 02:24:58 -06:00
* Miscellaneous fixes and feature enablement (many)
* SEV refactoring (David) * Hyper-V initial support (Jon) * i386 TCG fixes (x87 and SSE, Joseph) * vmport cleanup and improvements (Philippe, Liran) * Use-after-free with vCPU hot-unplug (Nengyuan) * run-coverity-scan improvements (myself) * Record/replay fixes (Pavel) * -machine kernel_irqchip=split improvements for INTx (Peter) * Code cleanups (Philippe) * Crash and security fixes (PJP) * HVF cleanups (Roman) -----BEGIN PGP SIGNATURE----- iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAl7jpdAUHHBib256aW5p QHJlZGhhdC5jb20ACgkQv/vSX3jHroMfjwf/X7+0euuE9dwKFKDDMmIi+4lRWnq7 gSOyE1BYSfDIUXRIukf64konXe0VpiotNYlyEaYnnQjkMdGm5E9iXKF+LgEwXj/t NSGkfj5J3VeWRG4JJp642CSN/aZWO8uzkenld3myCnu6TicuN351tDJchiFwAk9f wsXtgLKd67zE8MLVt8AP0rNTbzMHttPXnPaOXDCuwjMHNvMEKnC93UeOeM0M4H5s 3Dl2HvsNWZ2SzUG9mAbWp0bWWuoIb+Ep9//87HWANvb7Z8jratRws18i6tYt1sPx 8zOnUS87sVnh1CQlXBDd9fEcqBUVgR9pAlqaaYavNhFp5eC31euvpDU8Iw== =F4sU -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging * Miscellaneous fixes and feature enablement (many) * SEV refactoring (David) * Hyper-V initial support (Jon) * i386 TCG fixes (x87 and SSE, Joseph) * vmport cleanup and improvements (Philippe, Liran) * Use-after-free with vCPU hot-unplug (Nengyuan) * run-coverity-scan improvements (myself) * Record/replay fixes (Pavel) * -machine kernel_irqchip=split improvements for INTx (Peter) * Code cleanups (Philippe) * Crash and security fixes (PJP) * HVF cleanups (Roman) # gpg: Signature made Fri 12 Jun 2020 16:57:04 BST # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (116 commits) target/i386: Remove obsolete TODO file stubs: move Xen stubs to accel/ replay: fix replay shutdown for console mode exec/cpu-common: Move MUSB specific typedefs to 'hw/usb/hcd-musb.h' hw/usb: Move device-specific declarations to new 'hcd-musb.h' header exec/memory: Remove unused MemoryRegionMmio type checkpatch: reversed logic with acpi test checks target/i386: sev: Unify SEVState and SevGuestState target/i386: sev: Remove redundant handle field target/i386: sev: Remove redundant policy field target/i386: sev: Remove redundant cbitpos and reduced_phys_bits fields target/i386: sev: Partial cleanup to sev_state global target/i386: sev: Embed SEVState in SevGuestState target/i386: sev: Rename QSevGuestInfo target/i386: sev: Move local structure definitions into .c file target/i386: sev: Remove unused QSevGuestInfoClass xen: fix build without pci passthrough i386: hvf: Drop HVFX86EmulatorState i386: hvf: Move mmio_buf into CPUX86State i386: hvf: Move lazy_flags into CPUX86State ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org> # Conflicts: # hw/i386/acpi-build.c
This commit is contained in:
commit
7d3660e798
126 changed files with 6572 additions and 980 deletions
|
@ -51,6 +51,7 @@
|
|||
#include "hw/mem/nvdimm.h"
|
||||
#include "sysemu/numa.h"
|
||||
#include "sysemu/reset.h"
|
||||
#include "hw/hyperv/vmbus-bridge.h"
|
||||
|
||||
/* Supported chipsets: */
|
||||
#include "hw/southbridge/piix.h"
|
||||
|
@ -1052,9 +1053,47 @@ static Aml *build_mouse_device_aml(void)
|
|||
return dev;
|
||||
}
|
||||
|
||||
static Aml *build_vmbus_device_aml(VMBusBridge *vmbus_bridge)
|
||||
{
|
||||
Aml *dev;
|
||||
Aml *method;
|
||||
Aml *crs;
|
||||
|
||||
dev = aml_device("VMBS");
|
||||
aml_append(dev, aml_name_decl("STA", aml_int(0xF)));
|
||||
aml_append(dev, aml_name_decl("_HID", aml_string("VMBus")));
|
||||
aml_append(dev, aml_name_decl("_UID", aml_int(0x0)));
|
||||
aml_append(dev, aml_name_decl("_DDN", aml_string("VMBUS")));
|
||||
|
||||
method = aml_method("_DIS", 0, AML_NOTSERIALIZED);
|
||||
aml_append(method, aml_store(aml_and(aml_name("STA"), aml_int(0xD), NULL),
|
||||
aml_name("STA")));
|
||||
aml_append(dev, method);
|
||||
|
||||
method = aml_method("_PS0", 0, AML_NOTSERIALIZED);
|
||||
aml_append(method, aml_store(aml_or(aml_name("STA"), aml_int(0xF), NULL),
|
||||
aml_name("STA")));
|
||||
aml_append(dev, method);
|
||||
|
||||
method = aml_method("_STA", 0, AML_NOTSERIALIZED);
|
||||
aml_append(method, aml_return(aml_name("STA")));
|
||||
aml_append(dev, method);
|
||||
|
||||
aml_append(dev, aml_name_decl("_PS3", aml_int(0x0)));
|
||||
|
||||
crs = aml_resource_template();
|
||||
aml_append(crs, aml_irq_no_flags(vmbus_bridge->irq0));
|
||||
/* FIXME: newer HyperV gets by with only one IRQ */
|
||||
aml_append(crs, aml_irq_no_flags(vmbus_bridge->irq1));
|
||||
aml_append(dev, aml_name_decl("_CRS", crs));
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void build_isa_devices_aml(Aml *table)
|
||||
{
|
||||
ISADevice *fdc = pc_find_fdc0();
|
||||
VMBusBridge *vmbus_bridge = vmbus_bridge_find();
|
||||
bool ambiguous;
|
||||
|
||||
Aml *scope = aml_scope("_SB.PCI0.ISA");
|
||||
|
@ -1075,6 +1114,10 @@ static void build_isa_devices_aml(Aml *table)
|
|||
isa_build_aml(ISA_BUS(obj), scope);
|
||||
}
|
||||
|
||||
if (vmbus_bridge) {
|
||||
aml_append(scope, build_vmbus_device_aml(vmbus_bridge));
|
||||
}
|
||||
|
||||
aml_append(table, scope);
|
||||
}
|
||||
|
||||
|
|
|
@ -370,7 +370,7 @@ static void amdvi_completion_wait(AMDVIState *s, uint64_t *cmd)
|
|||
hwaddr addr = cpu_to_le64(extract64(cmd[0], 3, 49)) << 3;
|
||||
uint64_t data = cpu_to_le64(cmd[1]);
|
||||
|
||||
if (extract64(cmd[0], 51, 8)) {
|
||||
if (extract64(cmd[0], 52, 8)) {
|
||||
amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4),
|
||||
s->cmdbuf + s->cmdbuf_head);
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd)
|
|||
uint16_t devid = cpu_to_le16((uint16_t)extract64(cmd[0], 0, 16));
|
||||
|
||||
/* This command should invalidate internal caches of which there isn't */
|
||||
if (extract64(cmd[0], 15, 16) || cmd[1]) {
|
||||
if (extract64(cmd[0], 16, 44) || cmd[1]) {
|
||||
amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4),
|
||||
s->cmdbuf + s->cmdbuf_head);
|
||||
}
|
||||
|
@ -405,9 +405,9 @@ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd)
|
|||
|
||||
static void amdvi_complete_ppr(AMDVIState *s, uint64_t *cmd)
|
||||
{
|
||||
if (extract64(cmd[0], 15, 16) || extract64(cmd[0], 19, 8) ||
|
||||
if (extract64(cmd[0], 16, 16) || extract64(cmd[0], 52, 8) ||
|
||||
extract64(cmd[1], 0, 2) || extract64(cmd[1], 3, 29)
|
||||
|| extract64(cmd[1], 47, 16)) {
|
||||
|| extract64(cmd[1], 48, 16)) {
|
||||
amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4),
|
||||
s->cmdbuf + s->cmdbuf_head);
|
||||
}
|
||||
|
@ -438,8 +438,8 @@ static void amdvi_inval_pages(AMDVIState *s, uint64_t *cmd)
|
|||
{
|
||||
uint16_t domid = cpu_to_le16((uint16_t)extract64(cmd[0], 32, 16));
|
||||
|
||||
if (extract64(cmd[0], 20, 12) || extract64(cmd[0], 16, 12) ||
|
||||
extract64(cmd[0], 3, 10)) {
|
||||
if (extract64(cmd[0], 20, 12) || extract64(cmd[0], 48, 12) ||
|
||||
extract64(cmd[1], 3, 9)) {
|
||||
amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4),
|
||||
s->cmdbuf + s->cmdbuf_head);
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ static void amdvi_inval_pages(AMDVIState *s, uint64_t *cmd)
|
|||
|
||||
static void amdvi_prefetch_pages(AMDVIState *s, uint64_t *cmd)
|
||||
{
|
||||
if (extract64(cmd[0], 16, 8) || extract64(cmd[0], 20, 8) ||
|
||||
if (extract64(cmd[0], 16, 8) || extract64(cmd[0], 52, 8) ||
|
||||
extract64(cmd[1], 1, 1) || extract64(cmd[1], 3, 1) ||
|
||||
extract64(cmd[1], 5, 7)) {
|
||||
amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4),
|
||||
|
@ -463,7 +463,7 @@ static void amdvi_prefetch_pages(AMDVIState *s, uint64_t *cmd)
|
|||
|
||||
static void amdvi_inval_inttable(AMDVIState *s, uint64_t *cmd)
|
||||
{
|
||||
if (extract64(cmd[0], 16, 16) || cmd[1]) {
|
||||
if (extract64(cmd[0], 16, 44) || cmd[1]) {
|
||||
amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4),
|
||||
s->cmdbuf + s->cmdbuf_head);
|
||||
return;
|
||||
|
@ -479,7 +479,8 @@ static void iommu_inval_iotlb(AMDVIState *s, uint64_t *cmd)
|
|||
{
|
||||
|
||||
uint16_t devid = extract64(cmd[0], 0, 16);
|
||||
if (extract64(cmd[1], 1, 1) || extract64(cmd[1], 3, 9)) {
|
||||
if (extract64(cmd[1], 1, 1) || extract64(cmd[1], 3, 1) ||
|
||||
extract64(cmd[1], 6, 6)) {
|
||||
amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4),
|
||||
s->cmdbuf + s->cmdbuf_head);
|
||||
return;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "hw/i386/apic.h"
|
||||
#include "hw/i386/topology.h"
|
||||
#include "hw/i386/fw_cfg.h"
|
||||
#include "hw/i386/vmport.h"
|
||||
#include "sysemu/cpus.h"
|
||||
#include "hw/block/fdc.h"
|
||||
#include "hw/ide.h"
|
||||
|
@ -56,6 +57,7 @@
|
|||
#include "sysemu/tcg.h"
|
||||
#include "sysemu/numa.h"
|
||||
#include "sysemu/kvm.h"
|
||||
#include "sysemu/xen.h"
|
||||
#include "sysemu/qtest.h"
|
||||
#include "sysemu/reset.h"
|
||||
#include "sysemu/runstate.h"
|
||||
|
@ -91,7 +93,6 @@
|
|||
#include "qapi/qmp/qerror.h"
|
||||
#include "config-devices.h"
|
||||
#include "e820_memory_layout.h"
|
||||
#include "vmport.h"
|
||||
#include "fw_cfg.h"
|
||||
#include "trace.h"
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "cpu.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "sysemu/xen.h"
|
||||
#ifdef CONFIG_XEN
|
||||
#include <xen/hvm/hvm_info_table.h>
|
||||
#include "hw/xen/xen_pt.h"
|
||||
|
@ -60,6 +61,7 @@
|
|||
#include "migration/global_state.h"
|
||||
#include "migration/misc.h"
|
||||
#include "sysemu/numa.h"
|
||||
#include "hw/hyperv/vmbus-bridge.h"
|
||||
#include "hw/mem/nvdimm.h"
|
||||
#include "hw/i386/acpi-build.h"
|
||||
|
||||
|
@ -375,7 +377,7 @@ static void pc_init_isa(MachineState *machine)
|
|||
#ifdef CONFIG_XEN
|
||||
static void pc_xen_hvm_init_pci(MachineState *machine)
|
||||
{
|
||||
const char *pci_type = has_igd_gfx_passthru ?
|
||||
const char *pci_type = xen_igd_gfx_pt_enabled() ?
|
||||
TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_DEVICE;
|
||||
|
||||
pc_init1(machine,
|
||||
|
@ -419,6 +421,7 @@ static void pc_i440fx_machine_options(MachineClass *m)
|
|||
m->default_machine_opts = "firmware=bios-256k.bin";
|
||||
m->default_display = "std";
|
||||
machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
|
||||
machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE);
|
||||
}
|
||||
|
||||
static void pc_i440fx_5_1_machine_options(MachineClass *m)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "hw/rtc/mc146818rtc.h"
|
||||
#include "hw/xen/xen.h"
|
||||
#include "sysemu/kvm.h"
|
||||
#include "sysemu/xen.h"
|
||||
#include "hw/kvm/clock.h"
|
||||
#include "hw/pci-host/q35.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
|
@ -53,6 +54,7 @@
|
|||
#include "qapi/error.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "sysemu/numa.h"
|
||||
#include "hw/hyperv/vmbus-bridge.h"
|
||||
#include "hw/mem/nvdimm.h"
|
||||
#include "hw/i386/acpi-build.h"
|
||||
|
||||
|
@ -348,6 +350,7 @@ static void pc_q35_machine_options(MachineClass *m)
|
|||
machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE);
|
||||
machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE);
|
||||
machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
|
||||
machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE);
|
||||
m->max_cpus = 288;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,21 +25,15 @@
|
|||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "ui/console.h"
|
||||
#include "hw/i386/vmport.h"
|
||||
#include "hw/input/i8042.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "vmport.h"
|
||||
#include "cpu.h"
|
||||
|
||||
/* debug only vmmouse */
|
||||
//#define DEBUG_VMMOUSE
|
||||
|
||||
/* VMMouse Commands */
|
||||
#define VMMOUSE_GETVERSION 10
|
||||
#define VMMOUSE_DATA 39
|
||||
#define VMMOUSE_STATUS 40
|
||||
#define VMMOUSE_COMMAND 41
|
||||
|
||||
#define VMMOUSE_READ_ID 0x45414552
|
||||
#define VMMOUSE_DISABLE 0x000000f5
|
||||
#define VMMOUSE_REQUEST_RELATIVE 0x4c455252
|
||||
|
@ -217,10 +211,10 @@ static uint32_t vmmouse_ioport_read(void *opaque, uint32_t addr)
|
|||
command = data[2] & 0xFFFF;
|
||||
|
||||
switch (command) {
|
||||
case VMMOUSE_STATUS:
|
||||
case VMPORT_CMD_VMMOUSE_STATUS:
|
||||
data[0] = vmmouse_get_status(s);
|
||||
break;
|
||||
case VMMOUSE_COMMAND:
|
||||
case VMPORT_CMD_VMMOUSE_COMMAND:
|
||||
switch (data[1]) {
|
||||
case VMMOUSE_DISABLE:
|
||||
vmmouse_disable(s);
|
||||
|
@ -239,7 +233,7 @@ static uint32_t vmmouse_ioport_read(void *opaque, uint32_t addr)
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case VMMOUSE_DATA:
|
||||
case VMPORT_CMD_VMMOUSE_DATA:
|
||||
vmmouse_data(s, data, data[1]);
|
||||
break;
|
||||
default:
|
||||
|
@ -296,9 +290,9 @@ static void vmmouse_realizefn(DeviceState *dev, Error **errp)
|
|||
return;
|
||||
}
|
||||
|
||||
vmport_register(VMMOUSE_STATUS, vmmouse_ioport_read, s);
|
||||
vmport_register(VMMOUSE_COMMAND, vmmouse_ioport_read, s);
|
||||
vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s);
|
||||
vmport_register(VMPORT_CMD_VMMOUSE_STATUS, vmmouse_ioport_read, s);
|
||||
vmport_register(VMPORT_CMD_VMMOUSE_COMMAND, vmmouse_ioport_read, s);
|
||||
vmport_register(VMPORT_CMD_VMMOUSE_DATA, vmmouse_ioport_read, s);
|
||||
}
|
||||
|
||||
static Property vmmouse_properties[] = {
|
||||
|
|
183
hw/i386/vmport.c
183
hw/i386/vmport.c
|
@ -21,20 +21,47 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Guest code that interacts with this virtual device can be found
|
||||
* in VMware open-vm-tools open-source project:
|
||||
* https://github.com/vmware/open-vm-tools
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#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 "sysemu/qtest.h"
|
||||
#include "qemu/log.h"
|
||||
#include "vmport.h"
|
||||
#include "cpu.h"
|
||||
#include "trace.h"
|
||||
|
||||
#define VMPORT_CMD_GETVERSION 0x0a
|
||||
#define VMPORT_CMD_GETRAMSIZE 0x14
|
||||
|
||||
#define VMPORT_ENTRIES 0x2c
|
||||
#define VMPORT_MAGIC 0x564D5868
|
||||
|
||||
/* Compatibility flags for migration */
|
||||
#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)
|
||||
|
||||
/* vCPU features reported by CMD_GET_VCPU_INFO */
|
||||
#define VCPU_INFO_SLC64_BIT 0
|
||||
#define VCPU_INFO_SYNC_VTSCS_BIT 1
|
||||
#define VCPU_INFO_HV_REPLAY_OK_BIT 2
|
||||
#define VCPU_INFO_LEGACY_X2APIC_BIT 3
|
||||
#define VCPU_INFO_RESERVED_BIT 31
|
||||
|
||||
#define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT)
|
||||
|
||||
typedef struct VMPortState {
|
||||
|
@ -43,15 +70,19 @@ typedef struct VMPortState {
|
|||
MemoryRegion io;
|
||||
VMPortReadFunc *func[VMPORT_ENTRIES];
|
||||
void *opaque[VMPORT_ENTRIES];
|
||||
|
||||
uint32_t vmware_vmx_version;
|
||||
uint8_t vmware_vmx_type;
|
||||
|
||||
uint32_t compat_flags;
|
||||
} VMPortState;
|
||||
|
||||
static VMPortState *port_state;
|
||||
|
||||
void vmport_register(unsigned char command, VMPortReadFunc *func, void *opaque)
|
||||
void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *opaque)
|
||||
{
|
||||
if (command >= VMPORT_ENTRIES) {
|
||||
return;
|
||||
}
|
||||
assert(command < VMPORT_ENTRIES);
|
||||
assert(port_state);
|
||||
|
||||
trace_vmport_register(command, func, opaque);
|
||||
port_state->func[command] = func;
|
||||
|
@ -64,25 +95,51 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr,
|
|||
VMPortState *s = opaque;
|
||||
CPUState *cs = current_cpu;
|
||||
X86CPU *cpu = X86_CPU(cs);
|
||||
CPUX86State *env = &cpu->env;
|
||||
CPUX86State *env;
|
||||
unsigned char command;
|
||||
uint32_t eax;
|
||||
|
||||
if (qtest_enabled()) {
|
||||
return -1;
|
||||
}
|
||||
env = &cpu->env;
|
||||
cpu_synchronize_state(cs);
|
||||
|
||||
eax = env->regs[R_EAX];
|
||||
if (eax != VMPORT_MAGIC) {
|
||||
return eax;
|
||||
goto err;
|
||||
}
|
||||
|
||||
command = env->regs[R_ECX];
|
||||
trace_vmport_command(command);
|
||||
if (command >= VMPORT_ENTRIES || !s->func[command]) {
|
||||
qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command);
|
||||
return eax;
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 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:
|
||||
/*
|
||||
* The call above to cpu_synchronize_state() gets vCPU registers values
|
||||
* to QEMU but also cause QEMU to write QEMU vCPU registers values to
|
||||
* vCPU implementation (e.g. Accelerator such as KVM) just before
|
||||
* resuming guest.
|
||||
*
|
||||
* Therefore, in order to make IOPort return value propagate to
|
||||
* guest EAX, we need to explicitly update QEMU EAX register value.
|
||||
*/
|
||||
if (s->compat_flags & VMPORT_COMPAT_READ_SET_EAX) {
|
||||
cpu->env.regs[R_EAX] = eax;
|
||||
}
|
||||
|
||||
return eax;
|
||||
}
|
||||
|
||||
static void vmport_ioport_write(void *opaque, hwaddr addr,
|
||||
|
@ -90,6 +147,9 @@ static void vmport_ioport_write(void *opaque, hwaddr addr,
|
|||
{
|
||||
X86CPU *cpu = X86_CPU(current_cpu);
|
||||
|
||||
if (qtest_enabled()) {
|
||||
return;
|
||||
}
|
||||
cpu->env.regs[R_EAX] = vmport_ioport_read(opaque, addr, 4);
|
||||
}
|
||||
|
||||
|
@ -97,18 +157,69 @@ static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)
|
|||
{
|
||||
X86CPU *cpu = X86_CPU(current_cpu);
|
||||
|
||||
if (qtest_enabled()) {
|
||||
return -1;
|
||||
}
|
||||
cpu->env.regs[R_EBX] = VMPORT_MAGIC;
|
||||
return 6;
|
||||
if (port_state->compat_flags & VMPORT_COMPAT_REPORT_VMX_TYPE) {
|
||||
cpu->env.regs[R_ECX] = port_state->vmware_vmx_type;
|
||||
}
|
||||
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);
|
||||
|
||||
if (qtest_enabled()) {
|
||||
return -1;
|
||||
}
|
||||
cpu->env.regs[R_EBX] = 0x1177;
|
||||
return ram_size;
|
||||
}
|
||||
|
||||
static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr)
|
||||
{
|
||||
X86CPU *cpu = X86_CPU(current_cpu);
|
||||
|
||||
if (cpu->env.tsc_khz && cpu->env.apic_bus_freq) {
|
||||
uint64_t tsc_freq = (uint64_t)cpu->env.tsc_khz * 1000;
|
||||
|
||||
cpu->env.regs[R_ECX] = cpu->env.apic_bus_freq;
|
||||
cpu->env.regs[R_EBX] = (uint32_t)(tsc_freq >> 32);
|
||||
cpu->env.regs[R_EAX] = (uint32_t)tsc_freq;
|
||||
} else {
|
||||
/* Signal cmd as not supported */
|
||||
cpu->env.regs[R_EBX] = UINT32_MAX;
|
||||
}
|
||||
|
||||
return cpu->env.regs[R_EAX];
|
||||
}
|
||||
|
||||
static uint32_t vmport_cmd_get_vcpu_info(void *opaque, uint32_t addr)
|
||||
{
|
||||
X86CPU *cpu = X86_CPU(current_cpu);
|
||||
uint32_t ret = 0;
|
||||
|
||||
if (cpu->env.features[FEAT_1_ECX] & CPUID_EXT_X2APIC) {
|
||||
ret |= 1 << VCPU_INFO_LEGACY_X2APIC_BIT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const MemoryRegionOps vmport_ops = {
|
||||
.read = vmport_ioport_read,
|
||||
.write = vmport_ioport_write,
|
||||
|
@ -128,11 +239,54 @@ 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);
|
||||
vmport_register(VMPORT_CMD_GETHZ, vmport_cmd_get_hz, NULL);
|
||||
vmport_register(VMPORT_CMD_GET_VCPU_INFO, vmport_cmd_get_vcpu_info,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static Property vmport_properties[] = {
|
||||
/* Used to enforce compatibility for migration */
|
||||
DEFINE_PROP_BIT("x-read-set-eax", VMPortState, compat_flags,
|
||||
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_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,
|
||||
vmware_vmx_version, 6),
|
||||
/*
|
||||
* Value determines which VMware product type host report itself to guest.
|
||||
*
|
||||
* Most guests are fine with exposing host as VMware ESX server.
|
||||
* Some legacy/proprietary guests hard-code a given type.
|
||||
*
|
||||
* For a complete list of values, refer to enum VMXType at open-vm-tools
|
||||
* project (Defined at lib/include/vm_vmx_type.h).
|
||||
*
|
||||
* Reasonable options:
|
||||
* 0 - Unset
|
||||
* 1 - VMware Express (deprecated)
|
||||
* 2 - VMware ESX Server
|
||||
* 3 - VMware Server (Deprecated)
|
||||
* 4 - VMware Workstation
|
||||
* 5 - ACE 1.x (Deprecated)
|
||||
*/
|
||||
DEFINE_PROP_UINT8("vmware-vmx-type", VMPortState, vmware_vmx_type, 2),
|
||||
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void vmport_class_initfn(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
@ -140,6 +294,7 @@ static void vmport_class_initfn(ObjectClass *klass, void *data)
|
|||
dc->realize = vmport_realizefn;
|
||||
/* Reason: realize sets global port_state */
|
||||
dc->user_creatable = false;
|
||||
device_class_set_props(dc, vmport_properties);
|
||||
}
|
||||
|
||||
static const TypeInfo vmport_info = {
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* QEMU VMPort emulation
|
||||
*
|
||||
* Copyright (C) 2007 Hervé Poussineau
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef HW_I386_VMPORT_H
|
||||
#define HW_I386_VMPORT_H
|
||||
|
||||
#define TYPE_VMPORT "vmport"
|
||||
|
||||
typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address);
|
||||
|
||||
void vmport_register(unsigned char command, VMPortReadFunc *func, void *opaque);
|
||||
|
||||
#endif
|
|
@ -29,6 +29,7 @@
|
|||
#include "qemu/range.h"
|
||||
#include "sysemu/runstate.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "sysemu/xen.h"
|
||||
#include "sysemu/xen-mapcache.h"
|
||||
#include "trace.h"
|
||||
#include "exec/address-spaces.h"
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "hw/xen/xen-legacy-backend.h"
|
||||
#include "trace.h"
|
||||
#include "exec/address-spaces.h"
|
||||
#include "sysemu/xen.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/module.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue