Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into…
Browse files Browse the repository at this point in the history
… staging

* MTTCG fix for win32
* virtio-scsi assertion failure
* mem-prealloc coverity fix
* x86 migration revert which requires more thought
* x86 instruction limit (avoids >2 page translation blocks)
* nbd dead code cleanup
* small memory.c logic fix

# gpg: Signature made Mon 27 Mar 2017 17:03:04 BST
# gpg:                using RSA key 0xBFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <[email protected]>"
# gpg:                 aka "Paolo Bonzini <[email protected]>"
# 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:
  scsi-generic: Fill in opt_xfer_len in INQUIRY reply if it is zero
  Revert "apic: save apic_delivered flag"
  nbd: drop unused NBDClientSession.is_unix field
  win32: replace custom mutex and condition variable with native primitives
  mem-prealloc: fix sysconf(_SC_NPROCESSORS_ONLN) failure case.
  tcg/i386: Check the size of instruction being translated
  virtio-scsi: Fix acquire/release in dataplane handlers
  virtio-scsi: Make virtio_scsi_acquire/release public
  clear pending status before calling memory commit

Signed-off-by: Peter Maydell <[email protected]>
  • Loading branch information
pm215 committed Mar 27, 2017
2 parents 9366f53 + bed58b4 commit eb06c9e
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 209 deletions.
2 changes: 0 additions & 2 deletions block/nbd-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ typedef struct NBDClientSession {

Coroutine *recv_coroutine[MAX_NBD_REQUESTS];
NBDReply reply;

bool is_unix;
} NBDClientSession;

NBDClientSession *nbd_get_client_session(BlockDriverState *bs);
Expand Down
2 changes: 0 additions & 2 deletions block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, Error **errp)
goto done;
}

s->client.is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;

done:
QDECREF(addr);
qobject_decref(crumpled_addr);
Expand Down
33 changes: 0 additions & 33 deletions hw/intc/apic_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,25 +387,6 @@ static bool apic_common_sipi_needed(void *opaque)
return s->wait_for_sipi != 0;
}

static bool apic_irq_delivered_needed(void *opaque)
{
APICCommonState *s = APIC_COMMON(opaque);
return s->cpu == X86_CPU(first_cpu) && apic_irq_delivered != 0;
}

static void apic_irq_delivered_pre_save(void *opaque)
{
APICCommonState *s = APIC_COMMON(opaque);
s->apic_irq_delivered = apic_irq_delivered;
}

static int apic_irq_delivered_post_load(void *opaque, int version_id)
{
APICCommonState *s = APIC_COMMON(opaque);
apic_irq_delivered = s->apic_irq_delivered;
return 0;
}

static const VMStateDescription vmstate_apic_common_sipi = {
.name = "apic_sipi",
.version_id = 1,
Expand All @@ -418,19 +399,6 @@ static const VMStateDescription vmstate_apic_common_sipi = {
}
};

static const VMStateDescription vmstate_apic_irq_delivered = {
.name = "apic_irq_delivered",
.version_id = 1,
.minimum_version_id = 1,
.needed = apic_irq_delivered_needed,
.pre_save = apic_irq_delivered_pre_save,
.post_load = apic_irq_delivered_post_load,
.fields = (VMStateField[]) {
VMSTATE_INT32(apic_irq_delivered, APICCommonState),
VMSTATE_END_OF_LIST()
}
};

static const VMStateDescription vmstate_apic_common = {
.name = "apic",
.version_id = 3,
Expand Down Expand Up @@ -465,7 +433,6 @@ static const VMStateDescription vmstate_apic_common = {
},
.subsections = (const VMStateDescription*[]) {
&vmstate_apic_common_sipi,
&vmstate_apic_irq_delivered,
NULL
}
};
Expand Down
5 changes: 2 additions & 3 deletions hw/scsi/scsi-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ static void scsi_read_complete(void * opaque, int ret)
assert(max_transfer);
stl_be_p(&r->buf[8], max_transfer);
/* Also take care of the opt xfer len. */
if (ldl_be_p(&r->buf[12]) > max_transfer) {
stl_be_p(&r->buf[12], max_transfer);
}
stl_be_p(&r->buf[12],
MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12])));
}
scsi_req_data(&r->req, len);
scsi_req_unref(&r->req);
Expand Down
20 changes: 16 additions & 4 deletions hw/scsi/virtio-scsi-dataplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,40 @@ void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp)
static bool virtio_scsi_data_plane_handle_cmd(VirtIODevice *vdev,
VirtQueue *vq)
{
VirtIOSCSI *s = (VirtIOSCSI *)vdev;
bool progress;
VirtIOSCSI *s = VIRTIO_SCSI(vdev);

virtio_scsi_acquire(s);
assert(s->ctx && s->dataplane_started);
return virtio_scsi_handle_cmd_vq(s, vq);
progress = virtio_scsi_handle_cmd_vq(s, vq);
virtio_scsi_release(s);
return progress;
}

static bool virtio_scsi_data_plane_handle_ctrl(VirtIODevice *vdev,
VirtQueue *vq)
{
bool progress;
VirtIOSCSI *s = VIRTIO_SCSI(vdev);

virtio_scsi_acquire(s);
assert(s->ctx && s->dataplane_started);
return virtio_scsi_handle_ctrl_vq(s, vq);
progress = virtio_scsi_handle_ctrl_vq(s, vq);
virtio_scsi_release(s);
return progress;
}

static bool virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,
VirtQueue *vq)
{
bool progress;
VirtIOSCSI *s = VIRTIO_SCSI(vdev);

virtio_scsi_acquire(s);
assert(s->ctx && s->dataplane_started);
return virtio_scsi_handle_event_vq(s, vq);
progress = virtio_scsi_handle_event_vq(s, vq);
virtio_scsi_release(s);
return progress;
}

static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n,
Expand Down
41 changes: 14 additions & 27 deletions hw/scsi/virtio-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,31 +422,15 @@ static void virtio_scsi_handle_ctrl_req(VirtIOSCSI *s, VirtIOSCSIReq *req)
}
}

static inline void virtio_scsi_acquire(VirtIOSCSI *s)
{
if (s->ctx) {
aio_context_acquire(s->ctx);
}
}

static inline void virtio_scsi_release(VirtIOSCSI *s)
{
if (s->ctx) {
aio_context_release(s->ctx);
}
}

bool virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq)
{
VirtIOSCSIReq *req;
bool progress = false;

virtio_scsi_acquire(s);
while ((req = virtio_scsi_pop_req(s, vq))) {
progress = true;
virtio_scsi_handle_ctrl_req(s, req);
}
virtio_scsi_release(s);
return progress;
}

Expand All @@ -460,7 +444,9 @@ static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
return;
}
}
virtio_scsi_acquire(s);
virtio_scsi_handle_ctrl_vq(s, vq);
virtio_scsi_release(s);
}

static void virtio_scsi_complete_cmd_req(VirtIOSCSIReq *req)
Expand Down Expand Up @@ -604,7 +590,6 @@ bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq)

QTAILQ_HEAD(, VirtIOSCSIReq) reqs = QTAILQ_HEAD_INITIALIZER(reqs);

virtio_scsi_acquire(s);
do {
virtio_queue_set_notification(vq, 0);

Expand Down Expand Up @@ -632,7 +617,6 @@ bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq)
QTAILQ_FOREACH_SAFE(req, &reqs, next, next) {
virtio_scsi_handle_cmd_req_submit(s, req);
}
virtio_scsi_release(s);
return progress;
}

Expand All @@ -647,7 +631,9 @@ static void virtio_scsi_handle_cmd(VirtIODevice *vdev, VirtQueue *vq)
return;
}
}
virtio_scsi_acquire(s);
virtio_scsi_handle_cmd_vq(s, vq);
virtio_scsi_release(s);
}

static void virtio_scsi_get_config(VirtIODevice *vdev,
Expand Down Expand Up @@ -723,12 +709,10 @@ void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
return;
}

virtio_scsi_acquire(s);

req = virtio_scsi_pop_req(s, vs->event_vq);
if (!req) {
s->events_dropped = true;
goto out;
return;
}

if (s->events_dropped) {
Expand All @@ -738,7 +722,7 @@ void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,

if (virtio_scsi_parse_req(req, 0, sizeof(VirtIOSCSIEvent))) {
virtio_scsi_bad_req(req);
goto out;
return;
}

evt = &req->resp.event;
Expand All @@ -758,19 +742,14 @@ void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
evt->lun[3] = dev->lun & 0xFF;
}
virtio_scsi_complete_req(req);
out:
virtio_scsi_release(s);
}

bool virtio_scsi_handle_event_vq(VirtIOSCSI *s, VirtQueue *vq)
{
virtio_scsi_acquire(s);
if (s->events_dropped) {
virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0);
virtio_scsi_release(s);
return true;
}
virtio_scsi_release(s);
return false;
}

Expand All @@ -784,7 +763,9 @@ static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq)
return;
}
}
virtio_scsi_acquire(s);
virtio_scsi_handle_event_vq(s, vq);
virtio_scsi_release(s);
}

static void virtio_scsi_change(SCSIBus *bus, SCSIDevice *dev, SCSISense sense)
Expand All @@ -794,8 +775,10 @@ static void virtio_scsi_change(SCSIBus *bus, SCSIDevice *dev, SCSISense sense)

if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_CHANGE) &&
dev->type != TYPE_ROM) {
virtio_scsi_acquire(s);
virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_PARAM_CHANGE,
sense.asc | (sense.ascq << 8));
virtio_scsi_release(s);
}
}

Expand All @@ -817,9 +800,11 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
}

if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
virtio_scsi_acquire(s);
virtio_scsi_push_event(s, sd,
VIRTIO_SCSI_T_TRANSPORT_RESET,
VIRTIO_SCSI_EVT_RESET_RESCAN);
virtio_scsi_release(s);
}
}

Expand All @@ -831,9 +816,11 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev,
SCSIDevice *sd = SCSI_DEVICE(dev);

if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
virtio_scsi_acquire(s);
virtio_scsi_push_event(s, sd,
VIRTIO_SCSI_T_TRANSPORT_RESET,
VIRTIO_SCSI_EVT_RESET_REMOVED);
virtio_scsi_release(s);
}

qdev_simple_device_unplug_cb(hotplug_dev, dev, errp);
Expand Down
2 changes: 0 additions & 2 deletions include/hw/i386/apic_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ struct APICCommonState {
DeviceState *vapic;
hwaddr vapic_paddr; /* note: persistence via kvmvapic */
bool legacy_instance_id;

int apic_irq_delivered; /* for saving static variable */
};

typedef struct VAPICState {
Expand Down
14 changes: 14 additions & 0 deletions include/hw/virtio/virtio-scsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ typedef struct VirtIOSCSIReq {
} req;
} VirtIOSCSIReq;

static inline void virtio_scsi_acquire(VirtIOSCSI *s)
{
if (s->ctx) {
aio_context_acquire(s->ctx);
}
}

static inline void virtio_scsi_release(VirtIOSCSI *s)
{
if (s->ctx) {
aio_context_release(s->ctx);
}
}

void virtio_scsi_common_realize(DeviceState *dev, Error **errp,
VirtIOHandleOutput ctrl, VirtIOHandleOutput evt,
VirtIOHandleOutput cmd);
Expand Down
7 changes: 2 additions & 5 deletions include/qemu/thread-win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#include <windows.h>

struct QemuMutex {
CRITICAL_SECTION lock;
LONG owner;
SRWLOCK lock;
};

typedef struct QemuRecMutex QemuRecMutex;
Expand All @@ -19,9 +18,7 @@ int qemu_rec_mutex_trylock(QemuRecMutex *mutex);
void qemu_rec_mutex_unlock(QemuRecMutex *mutex);

struct QemuCond {
LONG waiters, target;
HANDLE sema;
HANDLE continue_event;
CONDITION_VARIABLE var;
};

struct QemuSemaphore {
Expand Down
10 changes: 2 additions & 8 deletions memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,12 +906,6 @@ void memory_region_transaction_begin(void)
++memory_region_transaction_depth;
}

static void memory_region_clear_pending(void)
{
memory_region_update_pending = false;
ioeventfd_update_pending = false;
}

void memory_region_transaction_commit(void)
{
AddressSpace *as;
Expand All @@ -927,14 +921,14 @@ void memory_region_transaction_commit(void)
QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
address_space_update_topology(as);
}

memory_region_update_pending = false;
MEMORY_LISTENER_CALL_GLOBAL(commit, Forward);
} else if (ioeventfd_update_pending) {
QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
address_space_update_ioeventfds(as);
}
ioeventfd_update_pending = false;
}
memory_region_clear_pending();
}
}

Expand Down
7 changes: 7 additions & 0 deletions target/i386/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -4418,6 +4418,13 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
s->vex_l = 0;
s->vex_v = 0;
next_byte:
/* x86 has an upper limit of 15 bytes for an instruction. Since we
* do not want to decode and generate IR for an illegal
* instruction, the following check limits the instruction size to
* 25 bytes: 14 prefix + 1 opc + 6 (modrm+sib+ofs) + 4 imm */
if (s->pc - pc_start > 14) {
goto illegal_op;
}
b = cpu_ldub_code(env, s->pc);
s->pc++;
/* Collect prefixes. */
Expand Down
Loading

0 comments on commit eb06c9e

Please sign in to comment.