mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* RTC fixes (Artem) * icount fixes (Artem) * rr fixes (Pavel, myself) * hotplug cleanup (Igor) * SCSI fixes (myself) * 4.20-rc1 KVM header update (myself) * coalesced PIO support (Peng Hao) * HVF fixes (Roman B.) * Hyper-V refactoring (Roman K.) * Support for Hyper-V IPI (Vitaly) # gpg: Signature made Fri 19 Oct 2018 12:47:58 BST # gpg: using RSA key BFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # 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: (47 commits) replay: pass raw icount value to replay_save_clock target/i386: kvm: just return after migrate_add_blocker failed hyperv_testdev: add SynIC message and event testmodes hyperv: process POST_MESSAGE hypercall hyperv: add support for KVM_HYPERV_EVENTFD hyperv: process SIGNAL_EVENT hypercall hyperv: add synic event flag signaling hyperv: add synic message delivery hyperv: make overlay pages for SynIC hyperv: only add SynIC in compatible configurations hyperv: qom-ify SynIC hyperv:synic: split capability testing and setting i386: add hyperv-stub for CONFIG_HYPERV=n default-configs: collect CONFIG_HYPERV* in hyperv.mak hyperv: factor out arch-independent API into hw/hyperv hyperv: make hyperv_vp_index inline hyperv: split hyperv-proto.h into x86 and arch-independent parts hyperv: rename kvm_hv_sint_route_set_sint hyperv: make HvSintRoute reference-counted hyperv: address HvSintRoute by X86CPU pointer ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
+53
-3
@@ -79,6 +79,7 @@ struct KVMState
|
||||
int fd;
|
||||
int vmfd;
|
||||
int coalesced_mmio;
|
||||
int coalesced_pio;
|
||||
struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
|
||||
bool coalesced_flush_in_progress;
|
||||
int vcpu_events;
|
||||
@@ -560,6 +561,45 @@ static void kvm_uncoalesce_mmio_region(MemoryListener *listener,
|
||||
}
|
||||
}
|
||||
|
||||
static void kvm_coalesce_pio_add(MemoryListener *listener,
|
||||
MemoryRegionSection *section,
|
||||
hwaddr start, hwaddr size)
|
||||
{
|
||||
KVMState *s = kvm_state;
|
||||
|
||||
if (s->coalesced_pio) {
|
||||
struct kvm_coalesced_mmio_zone zone;
|
||||
|
||||
zone.addr = start;
|
||||
zone.size = size;
|
||||
zone.pio = 1;
|
||||
|
||||
(void)kvm_vm_ioctl(s, KVM_REGISTER_COALESCED_MMIO, &zone);
|
||||
}
|
||||
}
|
||||
|
||||
static void kvm_coalesce_pio_del(MemoryListener *listener,
|
||||
MemoryRegionSection *section,
|
||||
hwaddr start, hwaddr size)
|
||||
{
|
||||
KVMState *s = kvm_state;
|
||||
|
||||
if (s->coalesced_pio) {
|
||||
struct kvm_coalesced_mmio_zone zone;
|
||||
|
||||
zone.addr = start;
|
||||
zone.size = size;
|
||||
zone.pio = 1;
|
||||
|
||||
(void)kvm_vm_ioctl(s, KVM_UNREGISTER_COALESCED_MMIO, &zone);
|
||||
}
|
||||
}
|
||||
|
||||
static MemoryListener kvm_coalesced_pio_listener = {
|
||||
.coalesced_io_add = kvm_coalesce_pio_add,
|
||||
.coalesced_io_del = kvm_coalesce_pio_del,
|
||||
};
|
||||
|
||||
int kvm_check_extension(KVMState *s, unsigned int extension)
|
||||
{
|
||||
int ret;
|
||||
@@ -1616,6 +1656,8 @@ static int kvm_init(MachineState *ms)
|
||||
}
|
||||
|
||||
s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
|
||||
s->coalesced_pio = s->coalesced_mmio &&
|
||||
kvm_check_extension(s, KVM_CAP_COALESCED_PIO);
|
||||
|
||||
#ifdef KVM_CAP_VCPU_EVENTS
|
||||
s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
|
||||
@@ -1686,13 +1728,15 @@ static int kvm_init(MachineState *ms)
|
||||
s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add;
|
||||
s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del;
|
||||
}
|
||||
s->memory_listener.listener.coalesced_mmio_add = kvm_coalesce_mmio_region;
|
||||
s->memory_listener.listener.coalesced_mmio_del = kvm_uncoalesce_mmio_region;
|
||||
s->memory_listener.listener.coalesced_io_add = kvm_coalesce_mmio_region;
|
||||
s->memory_listener.listener.coalesced_io_del = kvm_uncoalesce_mmio_region;
|
||||
|
||||
kvm_memory_listener_register(s, &s->memory_listener,
|
||||
&address_space_memory, 0);
|
||||
memory_listener_register(&kvm_io_listener,
|
||||
&address_space_io);
|
||||
memory_listener_register(&kvm_coalesced_pio_listener,
|
||||
&address_space_io);
|
||||
|
||||
s->many_ioeventfds = kvm_check_many_ioeventfds();
|
||||
|
||||
@@ -1778,7 +1822,13 @@ void kvm_flush_coalesced_mmio_buffer(void)
|
||||
|
||||
ent = &ring->coalesced_mmio[ring->first];
|
||||
|
||||
cpu_physical_memory_write(ent->phys_addr, ent->data, ent->len);
|
||||
if (ent->pio == 1) {
|
||||
address_space_rw(&address_space_io, ent->phys_addr,
|
||||
MEMTXATTRS_UNSPECIFIED, ent->data,
|
||||
ent->len, true);
|
||||
} else {
|
||||
cpu_physical_memory_write(ent->phys_addr, ent->data, ent->len);
|
||||
}
|
||||
smp_wmb();
|
||||
ring->first = (ring->first + 1) % KVM_COALESCED_MMIO_MAX;
|
||||
}
|
||||
|
||||
@@ -509,8 +509,8 @@ static void icount_warp_rt(void)
|
||||
seqlock_write_lock(&timers_state.vm_clock_seqlock,
|
||||
&timers_state.vm_clock_lock);
|
||||
if (runstate_is_running()) {
|
||||
int64_t clock = REPLAY_CLOCK(REPLAY_CLOCK_VIRTUAL_RT,
|
||||
cpu_get_clock_locked());
|
||||
int64_t clock = REPLAY_CLOCK_LOCKED(REPLAY_CLOCK_VIRTUAL_RT,
|
||||
cpu_get_clock_locked());
|
||||
int64_t warp_delta;
|
||||
|
||||
warp_delta = clock - timers_state.vm_clock_warp_start;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
CONFIG_HYPERV=$(CONFIG_KVM)
|
||||
CONFIG_HYPERV_TESTDEV=y
|
||||
@@ -3,6 +3,7 @@
|
||||
include pci.mak
|
||||
include sound.mak
|
||||
include usb.mak
|
||||
include hyperv.mak
|
||||
CONFIG_QXL=$(CONFIG_SPICE)
|
||||
CONFIG_VGA_ISA=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
@@ -58,7 +59,6 @@ CONFIG_XIO3130=y
|
||||
CONFIG_IOH3420=y
|
||||
CONFIG_I82801B11=y
|
||||
CONFIG_SMBIOS=y
|
||||
CONFIG_HYPERV_TESTDEV=$(CONFIG_KVM)
|
||||
CONFIG_PXB=y
|
||||
CONFIG_ACPI_VMGENID=y
|
||||
CONFIG_FW_CFG_DMA=y
|
||||
|
||||
@@ -9,6 +9,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += cpu/
|
||||
devices-dirs-$(CONFIG_SOFTMMU) += display/
|
||||
devices-dirs-$(CONFIG_SOFTMMU) += dma/
|
||||
devices-dirs-$(CONFIG_SOFTMMU) += gpio/
|
||||
devices-dirs-$(CONFIG_HYPERV) += hyperv/
|
||||
devices-dirs-$(CONFIG_SOFTMMU) += i2c/
|
||||
devices-dirs-$(CONFIG_SOFTMMU) += ide/
|
||||
devices-dirs-$(CONFIG_SOFTMMU) += input/
|
||||
|
||||
+8
-2
@@ -585,10 +585,13 @@ static uint64_t es1370_read(void *opaque, hwaddr addr, unsigned size)
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ES1370_REG_ADC_FRAMECNT:
|
||||
d += 2;
|
||||
goto framecnt;
|
||||
case ES1370_REG_DAC1_FRAMECNT:
|
||||
case ES1370_REG_DAC2_FRAMECNT:
|
||||
case ES1370_REG_ADC_FRAMECNT:
|
||||
d += (addr - ES1370_REG_DAC1_FRAMECNT) >> 3;
|
||||
framecnt:
|
||||
val = d->frame_cnt;
|
||||
#ifdef DEBUG_ES1370
|
||||
{
|
||||
@@ -602,10 +605,13 @@ static uint64_t es1370_read(void *opaque, hwaddr addr, unsigned size)
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ES1370_REG_ADC_FRAMEADR:
|
||||
d += 2;
|
||||
goto frameadr;
|
||||
case ES1370_REG_DAC1_FRAMEADR:
|
||||
case ES1370_REG_DAC2_FRAMEADR:
|
||||
case ES1370_REG_ADC_FRAMEADR:
|
||||
d += (addr - ES1370_REG_DAC1_FRAMEADR) >> 3;
|
||||
frameadr:
|
||||
val = d->frame_addr;
|
||||
break;
|
||||
|
||||
|
||||
@@ -35,16 +35,6 @@ void hotplug_handler_plug(HotplugHandler *plug_handler,
|
||||
}
|
||||
}
|
||||
|
||||
void hotplug_handler_post_plug(HotplugHandler *plug_handler,
|
||||
DeviceState *plugged_dev)
|
||||
{
|
||||
HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
|
||||
|
||||
if (hdc->post_plug) {
|
||||
hdc->post_plug(plug_handler, plugged_dev);
|
||||
}
|
||||
}
|
||||
|
||||
void hotplug_handler_unplug_request(HotplugHandler *plug_handler,
|
||||
DeviceState *plugged_dev,
|
||||
Error **errp)
|
||||
|
||||
+6
-10
@@ -832,14 +832,6 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
|
||||
|
||||
DEVICE_LISTENER_CALL(realize, Forward, dev);
|
||||
|
||||
if (hotplug_ctrl) {
|
||||
hotplug_handler_plug(hotplug_ctrl, dev, &local_err);
|
||||
}
|
||||
|
||||
if (local_err != NULL) {
|
||||
goto post_realize_fail;
|
||||
}
|
||||
|
||||
/*
|
||||
* always free/re-initialize here since the value cannot be cleaned up
|
||||
* in device_unrealize due to its usage later on in the unplug path
|
||||
@@ -869,8 +861,12 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
|
||||
dev->pending_deleted_event = false;
|
||||
|
||||
if (hotplug_ctrl) {
|
||||
hotplug_handler_post_plug(hotplug_ctrl, dev);
|
||||
}
|
||||
hotplug_handler_plug(hotplug_ctrl, dev, &local_err);
|
||||
if (local_err != NULL) {
|
||||
goto child_realize_fail;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (!value && dev->realized) {
|
||||
Error **local_errp = NULL;
|
||||
QLIST_FOREACH(bus, &dev->child_bus, sibling) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
obj-y += hyperv.o
|
||||
obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,327 @@
|
||||
/*
|
||||
* QEMU KVM Hyper-V test device to support Hyper-V kvm-unit-tests
|
||||
*
|
||||
* Copyright (C) 2015 Andrey Smetanin <asmetanin@virtuozzo.com>
|
||||
*
|
||||
* Authors:
|
||||
* Andrey Smetanin <asmetanin@virtuozzo.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/queue.h"
|
||||
#include "hw/qdev.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/hyperv/hyperv.h"
|
||||
|
||||
typedef struct TestSintRoute {
|
||||
QLIST_ENTRY(TestSintRoute) le;
|
||||
uint8_t vp_index;
|
||||
uint8_t sint;
|
||||
HvSintRoute *sint_route;
|
||||
} TestSintRoute;
|
||||
|
||||
typedef struct TestMsgConn {
|
||||
QLIST_ENTRY(TestMsgConn) le;
|
||||
uint8_t conn_id;
|
||||
HvSintRoute *sint_route;
|
||||
struct hyperv_message msg;
|
||||
} TestMsgConn;
|
||||
|
||||
typedef struct TestEvtConn {
|
||||
QLIST_ENTRY(TestEvtConn) le;
|
||||
uint8_t conn_id;
|
||||
HvSintRoute *sint_route;
|
||||
EventNotifier notifier;
|
||||
} TestEvtConn;
|
||||
|
||||
struct HypervTestDev {
|
||||
ISADevice parent_obj;
|
||||
MemoryRegion sint_control;
|
||||
QLIST_HEAD(, TestSintRoute) sint_routes;
|
||||
QLIST_HEAD(, TestMsgConn) msg_conns;
|
||||
QLIST_HEAD(, TestEvtConn) evt_conns;
|
||||
};
|
||||
typedef struct HypervTestDev HypervTestDev;
|
||||
|
||||
#define TYPE_HYPERV_TEST_DEV "hyperv-testdev"
|
||||
#define HYPERV_TEST_DEV(obj) \
|
||||
OBJECT_CHECK(HypervTestDev, (obj), TYPE_HYPERV_TEST_DEV)
|
||||
|
||||
enum {
|
||||
HV_TEST_DEV_SINT_ROUTE_CREATE = 1,
|
||||
HV_TEST_DEV_SINT_ROUTE_DESTROY,
|
||||
HV_TEST_DEV_SINT_ROUTE_SET_SINT,
|
||||
HV_TEST_DEV_MSG_CONN_CREATE,
|
||||
HV_TEST_DEV_MSG_CONN_DESTROY,
|
||||
HV_TEST_DEV_EVT_CONN_CREATE,
|
||||
HV_TEST_DEV_EVT_CONN_DESTROY,
|
||||
};
|
||||
|
||||
static void sint_route_create(HypervTestDev *dev,
|
||||
uint8_t vp_index, uint8_t sint)
|
||||
{
|
||||
TestSintRoute *sint_route;
|
||||
|
||||
sint_route = g_new0(TestSintRoute, 1);
|
||||
assert(sint_route);
|
||||
|
||||
sint_route->vp_index = vp_index;
|
||||
sint_route->sint = sint;
|
||||
|
||||
sint_route->sint_route = hyperv_sint_route_new(vp_index, sint, NULL, NULL);
|
||||
assert(sint_route->sint_route);
|
||||
|
||||
QLIST_INSERT_HEAD(&dev->sint_routes, sint_route, le);
|
||||
}
|
||||
|
||||
static TestSintRoute *sint_route_find(HypervTestDev *dev,
|
||||
uint8_t vp_index, uint8_t sint)
|
||||
{
|
||||
TestSintRoute *sint_route;
|
||||
|
||||
QLIST_FOREACH(sint_route, &dev->sint_routes, le) {
|
||||
if (sint_route->vp_index == vp_index && sint_route->sint == sint) {
|
||||
return sint_route;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void sint_route_destroy(HypervTestDev *dev,
|
||||
uint8_t vp_index, uint8_t sint)
|
||||
{
|
||||
TestSintRoute *sint_route;
|
||||
|
||||
sint_route = sint_route_find(dev, vp_index, sint);
|
||||
QLIST_REMOVE(sint_route, le);
|
||||
hyperv_sint_route_unref(sint_route->sint_route);
|
||||
g_free(sint_route);
|
||||
}
|
||||
|
||||
static void sint_route_set_sint(HypervTestDev *dev,
|
||||
uint8_t vp_index, uint8_t sint)
|
||||
{
|
||||
TestSintRoute *sint_route;
|
||||
|
||||
sint_route = sint_route_find(dev, vp_index, sint);
|
||||
|
||||
hyperv_sint_route_set_sint(sint_route->sint_route);
|
||||
}
|
||||
|
||||
static void msg_retry(void *opaque)
|
||||
{
|
||||
TestMsgConn *conn = opaque;
|
||||
assert(!hyperv_post_msg(conn->sint_route, &conn->msg));
|
||||
}
|
||||
|
||||
static void msg_cb(void *data, int status)
|
||||
{
|
||||
TestMsgConn *conn = data;
|
||||
|
||||
if (!status) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(status == -EAGAIN);
|
||||
|
||||
aio_bh_schedule_oneshot(qemu_get_aio_context(), msg_retry, conn);
|
||||
}
|
||||
|
||||
static uint16_t msg_handler(const struct hyperv_post_message_input *msg,
|
||||
void *data)
|
||||
{
|
||||
int ret;
|
||||
TestMsgConn *conn = data;
|
||||
|
||||
/* post the same message we've got */
|
||||
conn->msg.header.message_type = msg->message_type;
|
||||
assert(msg->payload_size < sizeof(conn->msg.payload));
|
||||
conn->msg.header.payload_size = msg->payload_size;
|
||||
memcpy(&conn->msg.payload, msg->payload, msg->payload_size);
|
||||
|
||||
ret = hyperv_post_msg(conn->sint_route, &conn->msg);
|
||||
|
||||
switch (ret) {
|
||||
case 0:
|
||||
return HV_STATUS_SUCCESS;
|
||||
case -EAGAIN:
|
||||
return HV_STATUS_INSUFFICIENT_BUFFERS;
|
||||
default:
|
||||
return HV_STATUS_INVALID_HYPERCALL_INPUT;
|
||||
}
|
||||
}
|
||||
|
||||
static void msg_conn_create(HypervTestDev *dev, uint8_t vp_index,
|
||||
uint8_t sint, uint8_t conn_id)
|
||||
{
|
||||
TestMsgConn *conn;
|
||||
|
||||
conn = g_new0(TestMsgConn, 1);
|
||||
assert(conn);
|
||||
|
||||
conn->conn_id = conn_id;
|
||||
|
||||
conn->sint_route = hyperv_sint_route_new(vp_index, sint, msg_cb, conn);
|
||||
assert(conn->sint_route);
|
||||
|
||||
assert(!hyperv_set_msg_handler(conn->conn_id, msg_handler, conn));
|
||||
|
||||
QLIST_INSERT_HEAD(&dev->msg_conns, conn, le);
|
||||
}
|
||||
|
||||
static void msg_conn_destroy(HypervTestDev *dev, uint8_t conn_id)
|
||||
{
|
||||
TestMsgConn *conn;
|
||||
|
||||
QLIST_FOREACH(conn, &dev->msg_conns, le) {
|
||||
if (conn->conn_id == conn_id) {
|
||||
QLIST_REMOVE(conn, le);
|
||||
hyperv_set_msg_handler(conn->conn_id, NULL, NULL);
|
||||
hyperv_sint_route_unref(conn->sint_route);
|
||||
g_free(conn);
|
||||
return;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
static void evt_conn_handler(EventNotifier *notifier)
|
||||
{
|
||||
TestEvtConn *conn = container_of(notifier, TestEvtConn, notifier);
|
||||
|
||||
event_notifier_test_and_clear(notifier);
|
||||
|
||||
/* signal the same event flag we've got */
|
||||
assert(!hyperv_set_event_flag(conn->sint_route, conn->conn_id));
|
||||
}
|
||||
|
||||
static void evt_conn_create(HypervTestDev *dev, uint8_t vp_index,
|
||||
uint8_t sint, uint8_t conn_id)
|
||||
{
|
||||
TestEvtConn *conn;
|
||||
|
||||
conn = g_new0(TestEvtConn, 1);
|
||||
assert(conn);
|
||||
|
||||
conn->conn_id = conn_id;
|
||||
|
||||
conn->sint_route = hyperv_sint_route_new(vp_index, sint, NULL, NULL);
|
||||
assert(conn->sint_route);
|
||||
|
||||
assert(!event_notifier_init(&conn->notifier, false));
|
||||
|
||||
event_notifier_set_handler(&conn->notifier, evt_conn_handler);
|
||||
|
||||
assert(!hyperv_set_event_flag_handler(conn_id, &conn->notifier));
|
||||
|
||||
QLIST_INSERT_HEAD(&dev->evt_conns, conn, le);
|
||||
}
|
||||
|
||||
static void evt_conn_destroy(HypervTestDev *dev, uint8_t conn_id)
|
||||
{
|
||||
TestEvtConn *conn;
|
||||
|
||||
QLIST_FOREACH(conn, &dev->evt_conns, le) {
|
||||
if (conn->conn_id == conn_id) {
|
||||
QLIST_REMOVE(conn, le);
|
||||
hyperv_set_event_flag_handler(conn->conn_id, NULL);
|
||||
event_notifier_set_handler(&conn->notifier, NULL);
|
||||
event_notifier_cleanup(&conn->notifier);
|
||||
hyperv_sint_route_unref(conn->sint_route);
|
||||
g_free(conn);
|
||||
return;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
static uint64_t hv_test_dev_read(void *opaque, hwaddr addr, unsigned size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hv_test_dev_write(void *opaque, hwaddr addr, uint64_t data,
|
||||
uint32_t len)
|
||||
{
|
||||
HypervTestDev *dev = HYPERV_TEST_DEV(opaque);
|
||||
uint8_t sint = data & 0xFF;
|
||||
uint8_t vp_index = (data >> 8ULL) & 0xFF;
|
||||
uint8_t ctl = (data >> 16ULL) & 0xFF;
|
||||
uint8_t conn_id = (data >> 24ULL) & 0xFF;
|
||||
|
||||
switch (ctl) {
|
||||
case HV_TEST_DEV_SINT_ROUTE_CREATE:
|
||||
sint_route_create(dev, vp_index, sint);
|
||||
break;
|
||||
case HV_TEST_DEV_SINT_ROUTE_DESTROY:
|
||||
sint_route_destroy(dev, vp_index, sint);
|
||||
break;
|
||||
case HV_TEST_DEV_SINT_ROUTE_SET_SINT:
|
||||
sint_route_set_sint(dev, vp_index, sint);
|
||||
break;
|
||||
case HV_TEST_DEV_MSG_CONN_CREATE:
|
||||
msg_conn_create(dev, vp_index, sint, conn_id);
|
||||
break;
|
||||
case HV_TEST_DEV_MSG_CONN_DESTROY:
|
||||
msg_conn_destroy(dev, conn_id);
|
||||
break;
|
||||
case HV_TEST_DEV_EVT_CONN_CREATE:
|
||||
evt_conn_create(dev, vp_index, sint, conn_id);
|
||||
break;
|
||||
case HV_TEST_DEV_EVT_CONN_DESTROY:
|
||||
evt_conn_destroy(dev, conn_id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const MemoryRegionOps synic_test_sint_ops = {
|
||||
.read = hv_test_dev_read,
|
||||
.write = hv_test_dev_write,
|
||||
.valid.min_access_size = 4,
|
||||
.valid.max_access_size = 4,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
static void hv_test_dev_realizefn(DeviceState *d, Error **errp)
|
||||
{
|
||||
ISADevice *isa = ISA_DEVICE(d);
|
||||
HypervTestDev *dev = HYPERV_TEST_DEV(d);
|
||||
MemoryRegion *io = isa_address_space_io(isa);
|
||||
|
||||
QLIST_INIT(&dev->sint_routes);
|
||||
QLIST_INIT(&dev->msg_conns);
|
||||
QLIST_INIT(&dev->evt_conns);
|
||||
memory_region_init_io(&dev->sint_control, OBJECT(dev),
|
||||
&synic_test_sint_ops, dev,
|
||||
"hyperv-testdev-ctl", 4);
|
||||
memory_region_add_subregion(io, 0x3000, &dev->sint_control);
|
||||
}
|
||||
|
||||
static void hv_test_dev_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
||||
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||
dc->realize = hv_test_dev_realizefn;
|
||||
}
|
||||
|
||||
static const TypeInfo hv_test_dev_info = {
|
||||
.name = TYPE_HYPERV_TEST_DEV,
|
||||
.parent = TYPE_ISA_DEVICE,
|
||||
.instance_size = sizeof(HypervTestDev),
|
||||
.class_init = hv_test_dev_class_init,
|
||||
};
|
||||
|
||||
static void hv_test_dev_register_types(void)
|
||||
{
|
||||
type_register_static(&hv_test_dev_info);
|
||||
}
|
||||
type_init(hv_test_dev_register_types);
|
||||
@@ -71,7 +71,6 @@ obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
|
||||
obj-$(CONFIG_IOTKIT_SYSINFO) += iotkit-sysinfo.o
|
||||
|
||||
obj-$(CONFIG_PVPANIC) += pvpanic.o
|
||||
obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
|
||||
obj-$(CONFIG_AUX) += auxbus.o
|
||||
obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
|
||||
obj-$(CONFIG_MSF2) += msf2-sysreg.o
|
||||
|
||||
+2
-2
@@ -342,7 +342,7 @@ static void *edu_fact_thread(void *opaque)
|
||||
|
||||
static void pci_edu_realize(PCIDevice *pdev, Error **errp)
|
||||
{
|
||||
EduState *edu = DO_UPCAST(EduState, pdev, pdev);
|
||||
EduState *edu = EDU(pdev);
|
||||
uint8_t *pci_conf = pdev->config;
|
||||
|
||||
pci_config_set_interrupt_pin(pci_conf, 1);
|
||||
@@ -365,7 +365,7 @@ static void pci_edu_realize(PCIDevice *pdev, Error **errp)
|
||||
|
||||
static void pci_edu_uninit(PCIDevice *pdev)
|
||||
{
|
||||
EduState *edu = DO_UPCAST(EduState, pdev, pdev);
|
||||
EduState *edu = EDU(pdev);
|
||||
|
||||
qemu_mutex_lock(&edu->thr_mutex);
|
||||
edu->stopping = true;
|
||||
|
||||
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* QEMU KVM Hyper-V test device to support Hyper-V kvm-unit-tests
|
||||
*
|
||||
* Copyright (C) 2015 Andrey Smetanin <asmetanin@virtuozzo.com>
|
||||
*
|
||||
* Authors:
|
||||
* Andrey Smetanin <asmetanin@virtuozzo.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include <linux/kvm.h>
|
||||
#include "hw/hw.h"
|
||||
#include "hw/qdev.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "sysemu/kvm.h"
|
||||
#include "target/i386/hyperv.h"
|
||||
#include "kvm_i386.h"
|
||||
|
||||
#define HV_TEST_DEV_MAX_SINT_ROUTES 64
|
||||
|
||||
struct HypervTestDev {
|
||||
ISADevice parent_obj;
|
||||
MemoryRegion sint_control;
|
||||
HvSintRoute *sint_route[HV_TEST_DEV_MAX_SINT_ROUTES];
|
||||
};
|
||||
typedef struct HypervTestDev HypervTestDev;
|
||||
|
||||
#define TYPE_HYPERV_TEST_DEV "hyperv-testdev"
|
||||
#define HYPERV_TEST_DEV(obj) \
|
||||
OBJECT_CHECK(HypervTestDev, (obj), TYPE_HYPERV_TEST_DEV)
|
||||
|
||||
enum {
|
||||
HV_TEST_DEV_SINT_ROUTE_CREATE = 1,
|
||||
HV_TEST_DEV_SINT_ROUTE_DESTROY,
|
||||
HV_TEST_DEV_SINT_ROUTE_SET_SINT
|
||||
};
|
||||
|
||||
static int alloc_sint_route_index(HypervTestDev *dev)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dev->sint_route); i++) {
|
||||
if (dev->sint_route[i] == NULL) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void free_sint_route_index(HypervTestDev *dev, int i)
|
||||
{
|
||||
assert(i >= 0 && i < ARRAY_SIZE(dev->sint_route));
|
||||
dev->sint_route[i] = NULL;
|
||||
}
|
||||
|
||||
static int find_sint_route_index(HypervTestDev *dev, uint32_t vp_index,
|
||||
uint32_t sint)
|
||||
{
|
||||
HvSintRoute *sint_route;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(dev->sint_route); i++) {
|
||||
sint_route = dev->sint_route[i];
|
||||
if (sint_route && sint_route->vp_index == vp_index &&
|
||||
sint_route->sint == sint) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void hv_synic_test_dev_control(HypervTestDev *dev, uint32_t ctl,
|
||||
uint32_t vp_index, uint32_t sint)
|
||||
{
|
||||
int i;
|
||||
HvSintRoute *sint_route;
|
||||
|
||||
switch (ctl) {
|
||||
case HV_TEST_DEV_SINT_ROUTE_CREATE:
|
||||
i = alloc_sint_route_index(dev);
|
||||
assert(i >= 0);
|
||||
sint_route = kvm_hv_sint_route_create(vp_index, sint, NULL);
|
||||
assert(sint_route);
|
||||
dev->sint_route[i] = sint_route;
|
||||
break;
|
||||
case HV_TEST_DEV_SINT_ROUTE_DESTROY:
|
||||
i = find_sint_route_index(dev, vp_index, sint);
|
||||
assert(i >= 0);
|
||||
sint_route = dev->sint_route[i];
|
||||
kvm_hv_sint_route_destroy(sint_route);
|
||||
free_sint_route_index(dev, i);
|
||||
break;
|
||||
case HV_TEST_DEV_SINT_ROUTE_SET_SINT:
|
||||
i = find_sint_route_index(dev, vp_index, sint);
|
||||
assert(i >= 0);
|
||||
sint_route = dev->sint_route[i];
|
||||
kvm_hv_sint_route_set_sint(sint_route);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t hv_test_dev_read(void *opaque, hwaddr addr, unsigned size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hv_test_dev_write(void *opaque, hwaddr addr, uint64_t data,
|
||||
uint32_t len)
|
||||
{
|
||||
HypervTestDev *dev = HYPERV_TEST_DEV(opaque);
|
||||
uint8_t ctl;
|
||||
|
||||
ctl = (data >> 16ULL) & 0xFF;
|
||||
switch (ctl) {
|
||||
case HV_TEST_DEV_SINT_ROUTE_CREATE:
|
||||
case HV_TEST_DEV_SINT_ROUTE_DESTROY:
|
||||
case HV_TEST_DEV_SINT_ROUTE_SET_SINT: {
|
||||
uint8_t sint = data & 0xFF;
|
||||
uint8_t vp_index = (data >> 8ULL) & 0xFF;
|
||||
hv_synic_test_dev_control(dev, ctl, vp_index, sint);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const MemoryRegionOps synic_test_sint_ops = {
|
||||
.read = hv_test_dev_read,
|
||||
.write = hv_test_dev_write,
|
||||
.valid.min_access_size = 4,
|
||||
.valid.max_access_size = 4,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
static void hv_test_dev_realizefn(DeviceState *d, Error **errp)
|
||||
{
|
||||
ISADevice *isa = ISA_DEVICE(d);
|
||||
HypervTestDev *dev = HYPERV_TEST_DEV(d);
|
||||
MemoryRegion *io = isa_address_space_io(isa);
|
||||
|
||||
memset(dev->sint_route, 0, sizeof(dev->sint_route));
|
||||
memory_region_init_io(&dev->sint_control, OBJECT(dev),
|
||||
&synic_test_sint_ops, dev,
|
||||
"hyperv-testdev-ctl", 4);
|
||||
memory_region_add_subregion(io, 0x3000, &dev->sint_control);
|
||||
}
|
||||
|
||||
static void hv_test_dev_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
||||
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||
dc->realize = hv_test_dev_realizefn;
|
||||
}
|
||||
|
||||
static const TypeInfo hv_test_dev_info = {
|
||||
.name = TYPE_HYPERV_TEST_DEV,
|
||||
.parent = TYPE_ISA_DEVICE,
|
||||
.instance_size = sizeof(HypervTestDev),
|
||||
.class_init = hv_test_dev_class_init,
|
||||
};
|
||||
|
||||
static void hv_test_dev_register_types(void)
|
||||
{
|
||||
type_register_static(&hv_test_dev_info);
|
||||
}
|
||||
type_init(hv_test_dev_register_types);
|
||||
@@ -327,6 +327,10 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)
|
||||
|
||||
sysbus_add_io(sbd, 0xcfc, &s->data_mem);
|
||||
sysbus_init_ioports(sbd, 0xcfc, 4);
|
||||
|
||||
/* register i440fx 0xcf8 port as coalesced pio */
|
||||
memory_region_set_flush_coalesced(&s->data_mem);
|
||||
memory_region_add_coalescing(&s->conf_mem, 0, 4);
|
||||
}
|
||||
|
||||
static void i440fx_realize(PCIDevice *dev, Error **errp)
|
||||
|
||||
@@ -51,6 +51,10 @@ static void q35_host_realize(DeviceState *dev, Error **errp)
|
||||
sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem);
|
||||
sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, 4);
|
||||
|
||||
/* register q35 0xcf8 port as coalesced pio */
|
||||
memory_region_set_flush_coalesced(&pci->data_mem);
|
||||
memory_region_add_coalescing(&pci->conf_mem, 0, 4);
|
||||
|
||||
pci->bus = pci_root_bus_new(DEVICE(s), "pcie.0",
|
||||
s->mch.pci_address_space,
|
||||
s->mch.address_space_io,
|
||||
|
||||
+17
-14
@@ -441,9 +441,18 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed)
|
||||
}
|
||||
switch (error) {
|
||||
case 0:
|
||||
/* The command has run, no need to fake sense. */
|
||||
/* A passthrough command has run and has produced sense data; check
|
||||
* whether the error has to be handled by the guest or should rather
|
||||
* pause the host.
|
||||
*/
|
||||
assert(r->status && *r->status);
|
||||
scsi_req_complete(&r->req, *r->status);
|
||||
error = scsi_sense_buf_to_errno(r->req.sense, sizeof(r->req.sense));
|
||||
if (error == ECANCELED || error == EAGAIN || error == ENOTCONN ||
|
||||
error == 0) {
|
||||
/* These errors are handled by guest. */
|
||||
scsi_req_complete(&r->req, *r->status);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case ENOMEDIUM:
|
||||
scsi_check_condition(r, SENSE_CODE(NO_MEDIUM));
|
||||
@@ -462,23 +471,17 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
assert(r->status && *r->status);
|
||||
error = scsi_sense_buf_to_errno(r->req.sense, sizeof(r->req.sense));
|
||||
|
||||
if (error == ECANCELED || error == EAGAIN || error == ENOTCONN ||
|
||||
error == 0) {
|
||||
/* These errors are handled by guest. */
|
||||
scsi_req_complete(&r->req, *r->status);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
blk_error_action(s->qdev.conf.blk, action, is_read, error);
|
||||
if (action == BLOCK_ERROR_ACTION_IGNORE) {
|
||||
scsi_req_complete(&r->req, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == BLOCK_ERROR_ACTION_STOP) {
|
||||
scsi_req_retry(&r->req);
|
||||
}
|
||||
return action != BLOCK_ERROR_ACTION_IGNORE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void scsi_write_complete_noio(SCSIDiskReq *r, int ret)
|
||||
|
||||
+1
-10
@@ -797,16 +797,8 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||||
virtio_scsi_acquire(s);
|
||||
blk_set_aio_context(sd->conf.blk, s->ctx);
|
||||
virtio_scsi_release(s);
|
||||
}
|
||||
}
|
||||
|
||||
/* Announce the new device after it has been plugged */
|
||||
static void virtio_scsi_post_hotplug(HotplugHandler *hotplug_dev,
|
||||
DeviceState *dev)
|
||||
{
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(hotplug_dev);
|
||||
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
||||
SCSIDevice *sd = SCSI_DEVICE(dev);
|
||||
}
|
||||
|
||||
if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
|
||||
virtio_scsi_acquire(s);
|
||||
@@ -976,7 +968,6 @@ static void virtio_scsi_class_init(ObjectClass *klass, void *data)
|
||||
vdc->start_ioeventfd = virtio_scsi_dataplane_start;
|
||||
vdc->stop_ioeventfd = virtio_scsi_dataplane_stop;
|
||||
hc->plug = virtio_scsi_hotplug;
|
||||
hc->post_plug = virtio_scsi_post_hotplug;
|
||||
hc->unplug = virtio_scsi_hotunplug;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "qapi/qapi-commands-misc.h"
|
||||
#include "qapi/qapi-events-misc.h"
|
||||
#include "qapi/visitor.h"
|
||||
#include "exec/address-spaces.h"
|
||||
|
||||
#ifdef TARGET_I386
|
||||
#include "hw/i386/apic.h"
|
||||
@@ -70,6 +71,7 @@ typedef struct RTCState {
|
||||
ISADevice parent_obj;
|
||||
|
||||
MemoryRegion io;
|
||||
MemoryRegion coalesced_io;
|
||||
uint8_t cmos_data[128];
|
||||
uint8_t cmos_index;
|
||||
int32_t base_year;
|
||||
@@ -990,6 +992,13 @@ static void rtc_realizefn(DeviceState *dev, Error **errp)
|
||||
memory_region_init_io(&s->io, OBJECT(s), &cmos_ops, s, "rtc", 2);
|
||||
isa_register_ioport(isadev, &s->io, base);
|
||||
|
||||
/* register rtc 0x70 port for coalesced_pio */
|
||||
memory_region_set_flush_coalesced(&s->io);
|
||||
memory_region_init_io(&s->coalesced_io, OBJECT(s), &cmos_ops,
|
||||
s, "rtc-index", 1);
|
||||
memory_region_add_subregion(&s->io, 0, &s->coalesced_io);
|
||||
memory_region_add_coalescing(&s->coalesced_io, 0, 1);
|
||||
|
||||
qdev_set_legacy_instance_id(dev, base, 3);
|
||||
qemu_register_reset(rtc_reset, s);
|
||||
|
||||
|
||||
+52
-7
@@ -387,6 +387,32 @@ struct LinuxAioState *aio_setup_linux_aio(AioContext *ctx, Error **errp);
|
||||
/* Return the LinuxAioState bound to this AioContext */
|
||||
struct LinuxAioState *aio_get_linux_aio(AioContext *ctx);
|
||||
|
||||
/**
|
||||
* aio_timer_new_with_attrs:
|
||||
* @ctx: the aio context
|
||||
* @type: the clock type
|
||||
* @scale: the scale
|
||||
* @attributes: 0, or one to multiple OR'ed QEMU_TIMER_ATTR_<id> values
|
||||
* to assign
|
||||
* @cb: the callback to call on timer expiry
|
||||
* @opaque: the opaque pointer to pass to the callback
|
||||
*
|
||||
* Allocate a new timer (with attributes) attached to the context @ctx.
|
||||
* The function is responsible for memory allocation.
|
||||
*
|
||||
* The preferred interface is aio_timer_init or aio_timer_init_with_attrs.
|
||||
* Use that unless you really need dynamic memory allocation.
|
||||
*
|
||||
* Returns: a pointer to the new timer
|
||||
*/
|
||||
static inline QEMUTimer *aio_timer_new_with_attrs(AioContext *ctx,
|
||||
QEMUClockType type,
|
||||
int scale, int attributes,
|
||||
QEMUTimerCB *cb, void *opaque)
|
||||
{
|
||||
return timer_new_full(&ctx->tlg, type, scale, attributes, cb, opaque);
|
||||
}
|
||||
|
||||
/**
|
||||
* aio_timer_new:
|
||||
* @ctx: the aio context
|
||||
@@ -396,10 +422,7 @@ struct LinuxAioState *aio_get_linux_aio(AioContext *ctx);
|
||||
* @opaque: the opaque pointer to pass to the callback
|
||||
*
|
||||
* Allocate a new timer attached to the context @ctx.
|
||||
* The function is responsible for memory allocation.
|
||||
*
|
||||
* The preferred interface is aio_timer_init. Use that
|
||||
* unless you really need dynamic memory allocation.
|
||||
* See aio_timer_new_with_attrs for details.
|
||||
*
|
||||
* Returns: a pointer to the new timer
|
||||
*/
|
||||
@@ -407,7 +430,29 @@ static inline QEMUTimer *aio_timer_new(AioContext *ctx, QEMUClockType type,
|
||||
int scale,
|
||||
QEMUTimerCB *cb, void *opaque)
|
||||
{
|
||||
return timer_new_tl(ctx->tlg.tl[type], scale, cb, opaque);
|
||||
return timer_new_full(&ctx->tlg, type, scale, 0, cb, opaque);
|
||||
}
|
||||
|
||||
/**
|
||||
* aio_timer_init_with_attrs:
|
||||
* @ctx: the aio context
|
||||
* @ts: the timer
|
||||
* @type: the clock type
|
||||
* @scale: the scale
|
||||
* @attributes: 0, or one to multiple OR'ed QEMU_TIMER_ATTR_<id> values
|
||||
* to assign
|
||||
* @cb: the callback to call on timer expiry
|
||||
* @opaque: the opaque pointer to pass to the callback
|
||||
*
|
||||
* Initialise a new timer (with attributes) attached to the context @ctx.
|
||||
* The caller is responsible for memory allocation.
|
||||
*/
|
||||
static inline void aio_timer_init_with_attrs(AioContext *ctx,
|
||||
QEMUTimer *ts, QEMUClockType type,
|
||||
int scale, int attributes,
|
||||
QEMUTimerCB *cb, void *opaque)
|
||||
{
|
||||
timer_init_full(ts, &ctx->tlg, type, scale, attributes, cb, opaque);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -420,14 +465,14 @@ static inline QEMUTimer *aio_timer_new(AioContext *ctx, QEMUClockType type,
|
||||
* @opaque: the opaque pointer to pass to the callback
|
||||
*
|
||||
* Initialise a new timer attached to the context @ctx.
|
||||
* The caller is responsible for memory allocation.
|
||||
* See aio_timer_init_with_attrs for details.
|
||||
*/
|
||||
static inline void aio_timer_init(AioContext *ctx,
|
||||
QEMUTimer *ts, QEMUClockType type,
|
||||
int scale,
|
||||
QEMUTimerCB *cb, void *opaque)
|
||||
{
|
||||
timer_init_tl(ts, ctx->tlg.tl[type], scale, cb, opaque);
|
||||
timer_init_full(ts, &ctx->tlg, type, scale, 0, cb, opaque);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user