Patch Round-up for stable 2.4.1, freeze on 2015-10-29
Subsystems (3)
cover Patch Round-up for stable 2.4.1, freeze on 2015-10-29
Hi everyone,
The following new patches are queued for QEMU stable v2.4.1:
https://github.com/mdroth/qemu/commits/stable-2.4-staging
The release is planned for 2015-11-03:
http://wiki.qemu.org/Planning/2.4
Please respond here or CC [email protected] on any patches you think should be included in the release.
Testing/feedback is greatly appreciated.
Thanks!
----------------------------------------------------------------
Alberto Garcia (1):
gtk: use setlocale() for LC_MESSAGES only
Alexander Graf (1):
PPC: E500: Update u-boot to commit 79c884d7e4
Aníbal Limón (1):
cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
Aurelien Jarno (2):
target-ppc: fix vcipher, vcipherlast, vncipherlast and vpermxor
target-ppc: fix xscmpodp and xscmpudp decoding
Christian Borntraeger (1):
s390x/kvm: Fix vector validity bit in device machine checks
Cornelia Huck (2):
s390x/css: start with cleared cstat/dstat
virtio: avoid leading underscores for helpers
Dr. David Alan Gilbert (1):
Migration: Generate the completed event only when we complete
Fam Zheng (2):
scsi-disk: Fix assertion failure on WRITE SAME
vmxnet3: Drop net_vmxnet3_info.can_receive
Gerd Hoffmann (1):
virtio-input: ignore events until the guest driver is ready
Gonglei (1):
vhost-scsi: fix wrong vhost-scsi firmware path
James Hogan (1):
tcg/mips: Fix clobbering of qemu_ld inputs
Jason Wang (1):
virtio-net: unbreak self announcement and guest offloads after migration
John Snow (2):
ide: fix ATAPI command permissions
ide: unify io_buffer_offset increments
Kevin Wolf (1):
mirror: Fix coroutine reentrance
Mark Cave-Ayland (1):
mac_dbdma: always clear FLUSH bit once DBDMA channel flush is complete
Markus Armbruster (5):
qom: Do not reuse errp after a possible error
qom: Fix invalid error check in property_get_str()
qmp: Fix device-list-properties not to crash for abstract device
qdev: Protect device-list-properties against broken devices Revert "qdev: Use qdev_get_device_class() for -device <type>,help"
Max Reitz (2):
qemu-img: Fix crash in amend invocation
qcow2: Make size_to_clusters() return uint64_t
Michael Roth (1):
spapr_pci: fix device tree props for MSI/MSI-X
Michael S. Tsirkin (1):
scripts/dump-guest-memory.py: fix after RAMBlock change
Peter Crosthwaite (2):
exec-all: Translate TCI return addresses backwards too
misc: zynq_slcr: Fix MMIO writes
Peter Lieven (2):
block/iscsi: validate block size returned from target block/nfs: fix calculation of allocated file size
Peter Maydell (1):
target-arm/arm-semi.c: Fix broken SYS_WRITE0 via gdb
Pierre Morel (1):
virtio dataplane: adapt dataplane for virtio Version 1
Richard Henderson (1):
target-arm: Share all common TCG temporaries
Stefan Weil (1):
slirp: Fix non blocking connect for w32
Tony Krowiak (1):
util/qemu-config: fix missing machine command line options
Vladislav Yasevich (2):
rtl8139: Fix receive buffer overflow check
rtl8139: Do not consume the packet during overflow in standard mode.
Wen Congyang (1):
nbd: release exp->blk after all clients are closed
block/iscsi.c | 4 ++ block/mirror.c | 15 ++++--- block/nfs.c | 2 +- block/qcow2-cluster.c | 28 ++++++++----- block/qcow2-refcount.c | 12 ++++-- block/qcow2.h | 6 +-- cpus.c | 2 +- hw/arm/allwinner-a10.c | 6 +++ hw/arm/digic.c | 6 +++ hw/arm/xlnx-zynqmp.c | 6 +++ hw/block/virtio-blk.c | 7 ++-- hw/char/virtio-serial-bus.c | 2 +- hw/ide/ahci.c | 22 ++++------ hw/ide/core.c | 35 ++++++++-------- hw/ide/internal.h | 1 + hw/input/virtio-input.c | 4 ++ hw/misc/macio/mac_dbdma.c | 12 +++--- hw/misc/zynq_slcr.c | 8 ++-- hw/net/rtl8139.c | 8 ++-- hw/net/vhost_net.c | 2 +- hw/net/virtio-net.c | 65 ++++++++++++++++------------- hw/net/vmxnet3.c | 1 - hw/pci-host/versatile.c | 11 +++++ hw/ppc/spapr_pci.c | 12 +++++- hw/s390x/css.c | 2 + hw/scsi/scsi-disk.c | 4 ++ hw/scsi/vhost-scsi.c | 2 +- hw/scsi/virtio-scsi.c | 8 ++-- hw/virtio/dataplane/vring.c | 79 +++++++++++++++++++++++++++--------- hw/virtio/vhost.c | 4 +- hw/virtio/virtio-balloon.c | 2 +- hw/virtio/virtio.c | 14 +++---- include/exec/exec-all.h | 6 +-- include/hw/qdev-core.h | 13 ++++++ include/hw/virtio/dataplane/vring.h | 4 +- include/hw/virtio/virtio-access.h | 2 +- include/hw/virtio/virtio.h | 11 ++--- migration/migration.c | 8 +++- nbd.c | 21 +++++++--- pc-bios/u-boot.e500 | Bin 330260 -> 347788 bytes qdev-monitor.c | 9 ++-- qemu-img.c | 3 +- qmp.c | 11 +++++ qom/object.c | 53 +++++++++++++++++++----- scripts/dump-guest-memory.py | 2 +- slirp/tcp_input.c | 8 +++- target-alpha/cpu.c | 7 ++++ target-arm/arm-semi.c | 2 +- target-arm/cpu.c | 11 +++++ target-arm/translate-a64.c | 22 ---------- target-arm/translate.c | 10 ++--- target-arm/translate.h | 8 ++++ target-cris/cpu.c | 7 ++++ target-i386/cpu.c | 8 ++++ target-lm32/cpu.c | 7 ++++ target-m68k/cpu.c | 7 ++++ target-microblaze/cpu.c | 6 +++ target-mips/cpu.c | 7 ++++ target-moxie/cpu.c | 7 ++++ target-openrisc/cpu.c | 7 ++++ target-ppc/int_helper.c | 19 ++++++--- target-ppc/kvm.c | 4 ++ target-ppc/translate.c | 11 ++++- target-s390x/cpu.c | 7 ++++ target-s390x/kvm.c | 3 ++ target-sh4/cpu.c | 7 ++++ target-sparc/cpu.c | 7 ++++ target-tricore/cpu.c | 6 +++ target-unicore32/cpu.c | 7 ++++ target-xtensa/cpu.c | 7 ++++ tcg/aarch64/tcg-target.c | 28 +++++++++---- tcg/mips/tcg-target.c | 26 +++++++----- ui/gtk.c | 21 +++++++++- util/qemu-config.c | 8 ++++ 74 files changed, 589 insertions(+), 231 deletions(-)
PATCH 1/40 scsi-disk: Fix assertion failure on WRITE SAME
From: Fam Zheng <[email protected]>
The last portion of an unaligned WRITE SAME command could fail the assertion in bdrv_aligned_pwritev:
assert(!qiov || bytes == qiov->size);
Because we updated data->iov.iov_len right above this if block, but data->qiov still has the old size.
Reinitialize the qiov to make them equal and keep block layer happy.
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/scsi/scsi-disk.c +4 -0
@@ -1683,6 +1683,10 @@ static void scsi_write_same_complete(void *opaque, int ret)if (data->iov.iov_len) {block_acct_start (blk_get_stats (s->qdev.conf.blk), &r->acct, data->iov.iov_len,BLOCK_ACCT_WRITE ); +/* blk_aio_write doesn't like the qiov size being different from +* nb_sectors, make sure they match. +*/ +qemu_iovec_init_external (&data->qiov, &data->iov,1 ); r->req.aiocb =blk_aio_writev (s->qdev.conf.blk, data->sector, &data->qiov, data->iov.iov_len /512 , scsi_write_same_complete, data);
Signature · 1 line
1.9.1
PATCH 2/40 mirror: Fix coroutine reentrance
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
This fixes a regression introduced by commit dcfb3beb ("mirror: Do zero write on target if sectors not allocated"), which was reported to cause aborts with the message "Co-routine re-entered recursively".
The cause for this bug is the following code in mirror_iteration_done():
if (s->common.busy) {
qemu_coroutine_enter(s->common.co, NULL);
}This has always been ugly because - unlike most places that reenter - it doesn't have a specific yield that it pairs with, but is more uncontrolled. What we really mean here is "reenter the coroutine if it's in one of the four explicit yields in mirror.c".
This used to be equivalent with s->common.busy because neither mirror_run() nor mirror_iteration() call any function that could yield. However since commit dcfb3beb this doesn't hold true any more:bdrv_get_block_status_above() can yield.
So what happens is that bdrv_get_block_status_above() wants to take a lock that is already held, so it adds itself to the queue of waiting coroutines and yields. Instead of being woken up by the unlock function, however, it gets woken up by mirror_iteration_done(), which is obviously wrong.
In most cases the code actually happens to cope fairly well with such cases, but in this specific case, the unlock must already have scheduled the coroutine for wakeup when mirror_iteration_done() reentered it. And then the coroutine happened to process the scheduled restarts and tried to reenter itself recursively.
This patch fixes the problem by pairing the reenter in mirror_iteration_done() with specific yields instead of abusing s->common.busy.
Message-id: [email protected]
--- block/mirror.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
block/mirror.c +10 -5
@@ -60,6 +60,7 @@ typedef struct MirrorBlockJob {int sectors_in_flight;int ret;bool unmap; +bool waiting_for_io; } MirrorBlockJob; typedef struct MirrorOp {
@@ -114,11 +115,7 @@ static void mirror_iteration_done(MirrorOp *op, int ret)qemu_iovec_destroy (&op->qiov);g_slice_free (MirrorOp, op); -/* Enter coroutine when it is not sleeping. The coroutine sleeps to -* rate-limit itself. The coroutine will eventually resume since there is -* a sleep timeout so don't wake it early. -*/ -if (s->common.busy) { +if (s->waiting_for_io) {qemu_coroutine_enter (s->common.co,NULL ); } }
@@ -203,7 +200,9 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)/* Wait for I/O to this cluster (from a previous iteration) to be done. */ while (test_bit (next_chunk, s->in_flight_bitmap)) {trace_mirror_yield_in_flight (s, sector_num, s->in_flight); + s->waiting_for_io = true;qemu_coroutine_yield (); + s->waiting_for_io = false; } do {
@@ -239,7 +238,9 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)*/ while (nb_chunks ==0 && s->buf_free_count < added_chunks) {trace_mirror_yield_buf_busy (s, nb_chunks, s->in_flight); + s->waiting_for_io = true;qemu_coroutine_yield (); + s->waiting_for_io = false; }if (s->buf_free_count < nb_chunks + added_chunks) {trace_mirror_break_buf_busy (s, nb_chunks, s->in_flight);
@@ -333,7 +334,9 @@ static void mirror_free_init(MirrorBlockJob *s)static void mirror_drain (MirrorBlockJob *s) {while (s->in_flight >0 ) { + s->waiting_for_io = true;qemu_coroutine_yield (); + s->waiting_for_io = false; } }
@@ -506,7 +509,9 @@ static void coroutine_fn mirror_run(void *opaque)if (s->in_flight ==MAX_IN_FLIGHT || s->buf_free_count ==0 || (cnt ==0 && s->in_flight >0 )) {trace_mirror_yield (s, s->in_flight, s->buf_free_count, cnt); + s->waiting_for_io = true;qemu_coroutine_yield (); + s->waiting_for_io = false;continue ; }else if (cnt !=0 ) { delay_ns =mirror_iteration (s);
Signature · 1 line
1.9.1
PATCH 3/40 target-arm/arm-semi.c: Fix broken SYS_WRITE0 via gdb
In reply to Michael RothFrom: Peter Maydell <[email protected]>
A spurious trailing "\n" in the gdb syscall format string used for SYS_WRITE0 meant that gdb would reject the remote syscall, with the effect that the output from the guest was silently dropped. Remove the newline so that gdb accepts the packet.
--- target-arm/arm-semi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/arm-semi.c +1 -1
@@ -260,7 +260,7 @@ uint32_t do_arm_semihosting(CPUARMState *env)return (uint32_t )-1 ; len =strlen (s);if (use_gdb_syscalls ()) { -gdb_do_syscall (arm_semi_cb,"write,2,%x,%x\n" , args, len); +gdb_do_syscall (arm_semi_cb,"write,2,%x,%x" , args, len); ret = env->regs[0 ]; }else { ret =write (STDERR_FILENO , s, len);
Signature · 1 line
1.9.1
PATCH 4/40 block/iscsi: validate block size returned from target
In reply to Michael RothFrom: Peter Lieven <[email protected]>
It has been reported that at least tgtd returns a block size of 0 for LUN 0. To avoid running into divide by zero later on and protect against other problematic block sizes validate the block size right at connection time.
Message-Id: <[email protected]>
--- block/iscsi.c | 4 ++++ 1 file changed, 4 insertions(+)
block/iscsi.c +4 -0
@@ -1214,6 +1214,10 @@ static void iscsi_readcapacity_sync(IscsiLun *iscsilun, Error **errp)if (task ==NULL || task->status !=SCSI_STATUS_GOOD ) {error_setg (errp,"iSCSI: failed to send readcapacity10 command." ); + }else if (!iscsilun->block_size || + iscsilun->block_size %BDRV_SECTOR_SIZE ) { +error_setg (errp,"iSCSI: the target returned an invalid " +"block size of %d." , iscsilun->block_size); }if (task) {scsi_free_scsi_task (task);
Signature · 1 line
1.9.1
PATCH 5/40 exec-all: Translate TCI return addresses backwards too
In reply to Michael RothFrom: Peter Crosthwaite <[email protected]>
This subtraction of return addresses applies directly to TCI as well as host-TCG. This fixes Linux boots for at least Microblaze, CRIS, ARM and SH4 when using TCI.
[sw: Removed indentation for preprocessor statement] [sw: The patch also fixes Linux boot for x86_64]
--- include/exec/exec-all.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
include/exec/exec-all.h +1 -5
@@ -308,11 +308,7 @@ extern uintptr_t tci_tb_ptr;to indicate the compressed mode; subtracting two works around that. It is also the case that there are no host isas that contain a call insn smaller than 4 bytes, so we don't worry about special-casing this. */ -#if defined(CONFIG_TCG_INTERPRETER ) -# define GETPC_ADJ 0 -#else -# define GETPC_ADJ 2 -#endif +#define GETPC_ADJ 2#define GETPC () (GETRA() - GETPC_ADJ)
Signature · 1 line
1.9.1
PATCH 6/40 block/nfs: fix calculation of allocated file size
In reply to Michael RothFrom: Peter Lieven <[email protected]>
st.st_blocks is always counted in 512 byte units. Do not use st.st_blksize as multiplicator which may be larger.
Message-id: [email protected]
--- block/nfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/nfs.c +1 -1
@@ -475,7 +475,7 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)aio_poll (client->aio_context, true); } -return (task.ret <0 ? task.ret : st.st_blocks * st.st_blksize); +return (task.ret <0 ? task.ret : st.st_blocks *512 ); }static int nfs_file_truncate (BlockDriverState *bs,int64_t offset)
Signature · 1 line
1.9.1
PATCH 7/40 qemu-img: Fix crash in amend invocation
In reply to Michael RothFrom: Max Reitz <[email protected]>
Example:
$ ./qemu-img create -f qcow2 /tmp/t.qcow2 64M
$ ./qemu-img amend -f qcow2 -o backing_file=/tmp/t.qcow2, -o help \
/tmp/t.qcow2This should not crash. This actually is tested by iotest 082, but not caught due to the segmentation fault being silent (which is something that needs to be fixed, too).
--- qemu-img.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
qemu-img.c +2 -1
@@ -2931,7 +2931,7 @@ static int img_amend(int argc, char **argv)if (!is_valid_option_list (optarg)) {error_report ("Invalid option list: %s" , optarg); ret =-1 ; - goto out; + goto out_no_progress; }if (!options) { options =g_strdup (optarg);
@@ -3031,6 +3031,7 @@ static int img_amend(int argc, char **argv) out:qemu_progress_end (); +out_no_progress:blk_unref (blk);qemu_opts_del (opts);qemu_opts_free (create_opts);
Signature · 1 line
1.9.1
PATCH 8/40 mac_dbdma: always clear FLUSH bit once DBDMA channel flush is complete
In reply to Michael RothFrom: Mark Cave-Ayland <[email protected]>
The code to flush the DBDMA channel was effectively duplicated in dbdma_control_write(), except for the fact that the copy executed outside of a RUN bit transition was broken by not clearing the FLUSH bit once the flush was complete.
Newer PPC Linux kernels would timeout waiting for the FLUSH bit to clear again after submitting a FLUSH command. Fix this by always clearing the FLUSH bit once the channel flush is complete and removing the repeated code.
--- hw/misc/macio/mac_dbdma.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
hw/misc/macio/mac_dbdma.c +5 -7
@@ -590,10 +590,11 @@ dbdma_control_write(DBDMA_channel *ch)if ((ch->regs[DBDMA_STATUS ] &RUN ) && !(status &RUN )) {/* RUN is cleared */ status &= ~(ACTIVE |DEAD ); -if ((status &FLUSH ) && ch->flush) { - ch->flush (&ch->io); - status &= ~FLUSH ; - } + } + +if ((status &FLUSH ) && ch->flush) { + ch->flush (&ch->io); + status &= ~FLUSH ; }DBDMA_DPRINTF (" status 0x%08x\n" , status);
@@ -603,9 +604,6 @@ dbdma_control_write(DBDMA_channel *ch)if (status &ACTIVE ) {DBDMA_kick (dbdma_from_ch (ch)); } -if ((status &FLUSH ) && ch->flush) { - ch->flush (&ch->io); - } } static void dbdma_write(void *opaque, hwaddr addr,
Signature · 1 line
1.9.1
PATCH 9/40 vhost-scsi: fix wrong vhost-scsi firmware path
In reply to Michael RothFrom: Gonglei <[email protected]>
vhost-scsi bootindex does't work because Qemu passes wrong fireware path to seabios.
before:
/pci@i0cf8/scsi@7channel@0/vhost-scsi@0,0
after applying the patch:
/pci@i0cf8/scsi@7/channel@0/vhost-scsi@0,0
Message-Id: <[email protected]>
--- hw/scsi/vhost-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/scsi/vhost-scsi.c +1 -1
@@ -291,7 +291,7 @@ static char *vhost_scsi_get_fw_dev_path(FWPathProvider *p, BusState *bus, {VHostSCSI *s =VHOST_SCSI (dev);/* format: channel@channel/vhost-scsi@target,lun */ -return g_strdup_printf ("channel@%x/%s@%x,%x" , s->channel, +return g_strdup_printf ("/channel@%x/%s@%x,%x" , s->channel,qdev_fw_name (dev), s->target, s->lun); }
Signature · 1 line
1.9.1
PATCH 10/40 scripts/dump-guest-memory.py: fix after RAMBlock change
In reply to Michael RothFrom: "Michael S. Tsirkin" <[email protected]>
commit 9b8424d5735278ca382f11adc7c63072b632ab83
"exec: split length -> used_length/max_length"
changed field names in struct RAMBlock
It turns out that scripts/dump-guest-memory.py was poking at this field, update it accordingly.
Message-Id: <[email protected]>
--- scripts/dump-guest-memory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/dump-guest-memory.py +1 -1
@@ -118,7 +118,7 @@ shape and this command should mostly work.""" def qemu_get_ram_block(self, ram_addr): ram_blocks = gdb.parse_and_eval("ram_list.blocks") for block in self.qlist_foreach(ram_blocks, "next"): - if (ram_addr - block["offset"] < block["length"]): + if (ram_addr - block["offset"] < block["used_length"]): return block raise gdb.GdbError("Bad ram offset %x" % ram_addr)
Signature · 1 line
1.9.1
PATCH 11/40 PPC: E500: Update u-boot to commit 79c884d7e4
In reply to Michael RothFrom: Alexander Graf <[email protected]>
The current U-Boot binary in QEMU has a bug where it fails to support dynamic CCSR addressing. Without this support, u-boot can not boot the ppce500 machine anymore. This has been fixed upstream in u-boot commit e834975b.
Update the u-boot blob we carry in QEMU to the latest u-boot upstream, so that we can successfully run u-boot with the ppce500 machine again.
--- pc-bios/u-boot.e500 | Bin 330260 -> 347788 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/u-boot.e500 binary +0 -0
Signature · 1 line
1.9.1
PATCH 12/40 s390x/css: start with cleared cstat/dstat
In reply to Michael RothFrom: Cornelia Huck <[email protected]>
When executing the start function, we should start with a clear state regarding subchannel and device status; it is easy to forget updating one of them after the ccw has been processed.
Note that we don't need to care about resetting the various control
fields: They are cleared by tsch(), and if they were still pending, we wouldn't be able to execute the start function in the first place.
Also note that we don't want to clear cstat/dstat if a suspended subchannel is resumed.
This fixes a bug where we would continue to present channel-program check in cstat even though later ccw requests for the subchannel finished without error (i.e. cstat should be 0).
--- hw/s390x/css.c | 2 ++ 1 file changed, 2 insertions(+)
hw/s390x/css.c +2 -0
@@ -392,6 +392,8 @@ static void sch_handle_start_func(SubchDev *sch, ORB *orb) path =0x80 ;if (!(s->ctrl &SCSW_ACTL_SUSP )) { + s->cstat =0 ; + s->dstat =0 ;/* Look at the orb and try to execute the channel program. */ assert (orb !=NULL );/* resume does not pass an orb */ p->intparm = orb->intparm;
Signature · 1 line
1.9.1
PATCH 13/40 rtl8139: Fix receive buffer overflow check
In reply to Michael RothFrom: Vladislav Yasevich <[email protected]>
rtl8139_do_receive() tries to check for the overflow condition by making sure that packet_size + 8 does not exceed the available buffer space. The issue here is that RxBuffAddr, used to calculate available buffer space, is aligned to a a 4 byte boundry after every update. So it is possible that every packet ends up being slightly padded when written to the receive buffer. This padding is not taken into account when checking for overflow and we may end up missing the overflow condition can causing buffer overwrite.
This patch takes alignment into consideration when checking for overflow condition.
Message-id: [email protected]
--- hw/net/rtl8139.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/net/rtl8139.c +4 -2
@@ -1148,7 +1148,9 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t/* if receiver buffer is empty then avail == 0 */ -if (avail !=0 && size +8 >= avail) +#define RX_ALIGN (x) (((x) + 3) & ~0x3) + +if (avail !=0 &&RX_ALIGN (size +8 ) >= avail) { DPRINTF("rx overflow: rx buffer length %d head 0x%04x " "read 0x%04x === available 0x%04x need 0x%04x\n",
@@ -1176,7 +1178,7 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_trtl8139_write_buffer (s, (uint8_t *)&val,4 );/* correct buffer write pointer */ - s->RxBufAddr =MOD2 ((s->RxBufAddr +3 ) & ~0x3 , s->RxBufferSize); + s->RxBufAddr =MOD2 (RX_ALIGN (s->RxBufAddr), s->RxBufferSize);/* now we can signal we have received something */
Signature · 1 line
1.9.1
PATCH 14/40 rtl8139: Do not consume the packet during overflow in standard mode.
In reply to Michael RothFrom: Vladislav Yasevich <[email protected]>
When operation in standard mode, we currently return the size of packet during buffer overflow. This consumes the overflow packet. Return 0 instead so we can re-process the overflow packet when we have room.
This fixes issues with lost/dropped fragments of large messages.
Message-id: [email protected]
*removed dependency on b76f21a7
*removed context dependency on 4cbea598
--- hw/net/rtl8139.c | 2 +- tcg/aarch64/tcg-target.c | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-)
hw/net/rtl8139.c +1 -1
@@ -1159,7 +1159,7 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t s->IntrStatus |= RxOverflow; ++s->RxMissed;rtl8139_update_irq (s); -return size_; +return 0 ; } packet_header |= RxStatusOK;
tcg/aarch64/tcg-target.c +21 -7
@@ -56,6 +56,12 @@ static const int tcg_target_call_oarg_regs[1] = {#define TCG_REG_TMP TCG_REG_X30#ifndef CONFIG_SOFTMMU +/* Note that XZR cannot be encoded in the address base register slot, +as that actaully encodes SP. So if we need to zero-extend the guest +address, via the address index register slot, we need to load even +a zero guest base into a register. */ +#define USE_GUEST_BASE (GUEST_BASE != 0 || TARGET_LONG_BITS == 32) +# ifdef CONFIG_USE_GUEST_BASE # define TCG_REG_GUEST_BASE TCG_REG_X28# else
@@ -1216,9 +1222,13 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg data_reg, TCGReg addr_reg,add_qemu_ldst_label (s, true, oi, ext, data_reg, addr_reg, s->code_ptr, label_ptr);#else /* !CONFIG_SOFTMMU */ -tcg_out_qemu_ld_direct (s, memop, ext, data_reg, -GUEST_BASE ?TCG_REG_GUEST_BASE :TCG_REG_XZR , - otype, addr_reg); +if (USE_GUEST_BASE ) { +tcg_out_qemu_ld_direct (s, memop, ext, data_reg, +TCG_REG_GUEST_BASE , otype, addr_reg); + }else { +tcg_out_qemu_ld_direct (s, memop, ext, data_reg, + addr_reg,TCG_TYPE_I64 ,TCG_REG_XZR ); + }#endif /* CONFIG_SOFTMMU */ }
@@ -1238,9 +1248,13 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg data_reg, TCGReg addr_reg,add_qemu_ldst_label (s, false, oi, s_bits ==MO_64 , data_reg, addr_reg, s->code_ptr, label_ptr);#else /* !CONFIG_SOFTMMU */ -tcg_out_qemu_st_direct (s, memop, data_reg, -GUEST_BASE ?TCG_REG_GUEST_BASE :TCG_REG_XZR , - otype, addr_reg); +if (USE_GUEST_BASE ) { +tcg_out_qemu_st_direct (s, memop, data_reg, +TCG_REG_GUEST_BASE , otype, addr_reg); + }else { +tcg_out_qemu_st_direct (s, memop, data_reg, + addr_reg,TCG_TYPE_I64 ,TCG_REG_XZR ); + }#endif /* CONFIG_SOFTMMU */ }
@@ -1795,7 +1809,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) CPU_TEMP_BUF_NLONGS * sizeof(long));#if defined(CONFIG_USE_GUEST_BASE ) -if (GUEST_BASE ) { +if (USE_GUEST_BASE ) {tcg_out_movi (s,TCG_TYPE_PTR ,TCG_REG_GUEST_BASE ,GUEST_BASE );tcg_regset_set_reg (s->reserved_regs,TCG_REG_GUEST_BASE ); }
Signature · 1 line
1.9.1
PATCH 15/40 cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
In reply to Michael RothFrom: Aníbal Limón <[email protected]>
When QEMU starts the RCU thread executes qemu_mutex_lock_thread causing error "qemu:qemu_cpu_kick_thread: No such process" and exits.
This isn't occur frequently but in glibc the thread id can exist and this not guarantee that the thread is on active/running state. If is inserted a sleep(1) after newthread assignment [1] the issue appears.
So not make assumption that thread exist if first_cpu->thread is set then change the validation of cpu to created that is set into cpu threads (kvm, tcg, dummy).
Message-Id: <[email protected]>
--- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +1 -1
@@ -1166,7 +1166,7 @@ void qemu_mutex_lock_iothread(void)* TCG code execution. */ if (!tcg_enabled () ||qemu_in_vcpu_thread () || - !first_cpu || !first_cpu->thread) { + !first_cpu || !first_cpu->created) {qemu_mutex_lock (&qemu_global_mutex);atomic_dec (&iothread_requesting_mutex); }else {
Signature · 1 line
1.9.1
PATCH 16/40 virtio dataplane: adapt dataplane for virtio Version 1
In reply to Michael RothFrom: Pierre Morel <[email protected]>
Let dataplane allocate different region for the desc/avail/used ring regions.
Take VIRTIO_RING_F_EVENT_IDX into account to increase the used/avail rings accordingly.
[Fix 32-bit builds by changing 16lx format specifier to HWADDR_PRIx. --Stefan]
Message-id: [email protected] (changed __virtio16 into uint16_t,
map descriptor table and available ring read-only)
--- hw/virtio/dataplane/vring.c | 69 +++++++++++++++++++++++++++++-------- include/hw/virtio/dataplane/vring.h | 4 ++- 2 files changed, 58 insertions(+), 15 deletions(-)
hw/virtio/dataplane/vring.c +55 -14
@@ -67,22 +67,53 @@ static void vring_unmap(void *buffer, bool is_write)/* Map the guest's vring to host memory */ bool vring_setup (Vring *vring,VirtIODevice *vdev,int n) { -hwaddr vring_addr =virtio_queue_get_ring_addr (vdev, n); -hwaddr vring_size =virtio_queue_get_ring_size (vdev, n); -void *vring_ptr; +struct vring *vr = &vring->vr; +hwaddr addr; +hwaddr size; +void *ptr; vring->broken = false; - - vring_ptr =vring_map (&vring->mr, vring_addr, vring_size, true); -if (!vring_ptr) { -error_report ("Failed to map vring " -"addr %#" HWADDR_PRIx" size %" HWADDR_PRIu, - vring_addr, vring_size); - vring->broken = true; -return false; + vr->num =virtio_queue_get_num (vdev, n); + + addr =virtio_queue_get_desc_addr (vdev, n); + size =virtio_queue_get_desc_size (vdev, n); +/* Map the descriptor area as read only */ + ptr =vring_map (&vring->mr_desc, addr, size, false); +if (!ptr) { +error_report ("Failed to map 0x%" HWADDR_PRIx" byte for vring desc " +"at 0x%" HWADDR_PRIx, + size, addr); + goto out_err_desc; } - -vring_init (&vring->vr,virtio_queue_get_num (vdev, n), vring_ptr,4096 ); + vr->desc = ptr; + + addr =virtio_queue_get_avail_addr (vdev, n); + size =virtio_queue_get_avail_size (vdev, n); +/* Add the size of the used_event_idx */ + size +=sizeof (uint16_t ); +/* Map the driver area as read only */ + ptr =vring_map (&vring->mr_avail, addr, size, false); +if (!ptr) { +error_report ("Failed to map 0x%" HWADDR_PRIx" byte for vring avail " +"at 0x%" HWADDR_PRIx, + size, addr); + goto out_err_avail; + } + vr->avail = ptr; + + addr =virtio_queue_get_used_addr (vdev, n); + size =virtio_queue_get_used_size (vdev, n); +/* Add the size of the avail_event_idx */ + size +=sizeof (uint16_t ); +/* Map the device area as read-write */ + ptr =vring_map (&vring->mr_used, addr, size, true); +if (!ptr) { +error_report ("Failed to map 0x%" HWADDR_PRIx" byte for vring used " +"at 0x%" HWADDR_PRIx, + size, addr); + goto out_err_used; + } + vr->used = ptr; vring->last_avail_idx =virtio_queue_get_last_avail_idx (vdev, n); vring->last_used_idx =vring_get_used_idx (vdev, vring);
@@ -92,6 +123,14 @@ bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)trace_vring_setup (virtio_queue_get_ring_addr (vdev, n), vring->vr.desc, vring->vr.avail, vring->vr.used);return true; + +out_err_used: +memory_region_unref (vring->mr_avail); +out_err_avail: +memory_region_unref (vring->mr_desc); +out_err_desc: + vring->broken = true; +return false; }void vring_teardown (Vring *vring,VirtIODevice *vdev,int n)
@@ -99,7 +138,9 @@ void vring_teardown(Vring *vring, VirtIODevice *vdev, int n)virtio_queue_set_last_avail_idx (vdev, n, vring->last_avail_idx);virtio_queue_invalidate_signalled_used (vdev, n); -memory_region_unref (vring->mr); +memory_region_unref (vring->mr_desc); +memory_region_unref (vring->mr_avail); +memory_region_unref (vring->mr_used); }/* Disable guest->host notifies */
include/hw/virtio/dataplane/vring.h +3 -1
@@ -22,7 +22,9 @@#include "hw/virtio/virtio.h" typedef struct { - MemoryRegion *mr; /* memory region containing the vring */ + MemoryRegion *mr_desc; /* memory region for the vring desc */ + MemoryRegion *mr_avail; /* memory region for the vring avail */ + MemoryRegion *mr_used; /* memory region for the vring used */ struct vring vr; /* virtqueue vring mapped to host memory */ uint16_t last_avail_idx; /* last processed avail ring index */ uint16_t last_used_idx; /* last processed used ring index */
Signature · 1 line
1.9.1
PATCH 17/40 target-arm: Share all common TCG temporaries
In reply to Michael RothFrom: Richard Henderson <[email protected]>
This is a bug fix for aarch64. At present, we have branches using the 32-bit (translate.c) versions of cpu_[NZCV]F, but we set the flags using the 64-bit (translate-a64.c) versions of cpu_[NZCV]F. From the view of the TCG code generator, these are unrelated variables.
The bug is hard to see because we currently only read these variables from branches, and upon reaching a branch TCG will first spill live variables and then reload the arguments of the branch. Since the 32-bit versions were never live until reaching the branch, we'd re-read the data that had just been spilled from the 64-bit versions.
There is currently no such problem with the cpu_exclusive_* variables, but there's no point in tempting fate.
Message-id: [email protected]
--- target-arm/translate-a64.c | 22 ---------------------- target-arm/translate.c | 10 +++++----- target-arm/translate.h | 8 ++++++++ 3 files changed, 13 insertions(+), 27 deletions(-)
target-arm/translate-a64.c +0 -22
@@ -39,16 +39,9 @@static TCGv_i64 cpu_X[32 ];static TCGv_i64 cpu_pc; -static TCGv_i32 cpu_NF, cpu_ZF, cpu_CF, cpu_VF;/* Load/store exclusive handling */ -static TCGv_i64 cpu_exclusive_addr; -static TCGv_i64 cpu_exclusive_val;static TCGv_i64 cpu_exclusive_high; -#ifdef CONFIG_USER_ONLY -static TCGv_i64 cpu_exclusive_test; -static TCGv_i32 cpu_exclusive_info; -#endif static const char *regnames[] = {"x0" ,"x1" ,"x2" ,"x3" ,"x4" ,"x5" ,"x6" ,"x7" ,
@@ -104,23 +97,8 @@ void a64_translate_init(void) regnames[i]); } - cpu_NF =tcg_global_mem_new_i32 (TCG_AREG0 , offsetof(CPUARMState , NF),"NF" ); - cpu_ZF =tcg_global_mem_new_i32 (TCG_AREG0 , offsetof(CPUARMState , ZF),"ZF" ); - cpu_CF =tcg_global_mem_new_i32 (TCG_AREG0 , offsetof(CPUARMState , CF),"CF" ); - cpu_VF =tcg_global_mem_new_i32 (TCG_AREG0 , offsetof(CPUARMState , VF),"VF" ); - - cpu_exclusive_addr =tcg_global_mem_new_i64 (TCG_AREG0 , - offsetof(CPUARMState , exclusive_addr),"exclusive_addr" ); - cpu_exclusive_val =tcg_global_mem_new_i64 (TCG_AREG0 , - offsetof(CPUARMState , exclusive_val),"exclusive_val" ); cpu_exclusive_high =tcg_global_mem_new_i64 (TCG_AREG0 , offsetof(CPUARMState , exclusive_high),"exclusive_high" ); -#ifdef CONFIG_USER_ONLY - cpu_exclusive_test =tcg_global_mem_new_i64 (TCG_AREG0 , - offsetof(CPUARMState , exclusive_test),"exclusive_test" ); - cpu_exclusive_info =tcg_global_mem_new_i32 (TCG_AREG0 , - offsetof(CPUARMState , exclusive_info),"exclusive_info" ); -#endif }static inline ARMMMUIdx get_a64_user_mem_index (DisasContext *s)
target-arm/translate.c +5 -5
@@ -64,12 +64,12 @@ TCGv_ptr cpu_env;/* We reuse the same 64-bit temporaries for efficiency. */ static TCGv_i64 cpu_V0, cpu_V1, cpu_M0;static TCGv_i32 cpu_R[16 ]; -static TCGv_i32 cpu_CF, cpu_NF, cpu_VF, cpu_ZF; -static TCGv_i64 cpu_exclusive_addr; -static TCGv_i64 cpu_exclusive_val; +TCGv_i32 cpu_CF, cpu_NF, cpu_VF, cpu_ZF; +TCGv_i64 cpu_exclusive_addr; +TCGv_i64 cpu_exclusive_val;#ifdef CONFIG_USER_ONLY -static TCGv_i64 cpu_exclusive_test; -static TCGv_i32 cpu_exclusive_info; +TCGv_i64 cpu_exclusive_test; +TCGv_i32 cpu_exclusive_info;#endif /* FIXME: These should be removed. */
target-arm/translate.h +8 -0
@@ -62,7 +62,15 @@ typedef struct DisasContext {TCGv_i64 tmp_a64[TMP_A64_MAX ]; } DisasContext; +/* Share the TCG temporaries common between 32 and 64 bit modes. */ extern TCGv_ptr cpu_env; +extern TCGv_i32 cpu_NF, cpu_ZF, cpu_CF, cpu_VF; +extern TCGv_i64 cpu_exclusive_addr; +extern TCGv_i64 cpu_exclusive_val; +#ifdef CONFIG_USER_ONLY +extern TCGv_i64 cpu_exclusive_test; +extern TCGv_i32 cpu_exclusive_info; +#endif static inline int arm_dc_feature (DisasContext *dc,int feature) {
Signature · 1 line
1.9.1
PATCH 18/40 qcow2: Make size_to_clusters() return uint64_t
In reply to Michael RothFrom: Max Reitz <[email protected]>
Sadly, some images may have more clusters than what can be represented using a plain int. We should be prepared for that case (in qcow2_check_refcounts() we actually were trying to catch that case, but since size_to_clusters() truncated the returned value, that check never did anything useful).
Conflicts:
block/qcow2-cluster.c
block/qcow2.h
* removed context dependency on ff99129a
--- block/qcow2-cluster.c | 28 ++++++++++++++++++---------- block/qcow2-refcount.c | 12 ++++++++---- block/qcow2.h | 6 +++--- 3 files changed, 29 insertions(+), 17 deletions(-)
block/qcow2-cluster.c +18 -10
@@ -298,7 +298,7 @@ fail:* as contiguous. (This allows it, for example, to stop at the first compressed * cluster which may require a different handling) */ -static int count_contiguous_clusters (uint64_t nb_clusters,int cluster_size, +static int count_contiguous_clusters (int nb_clusters,int cluster_size,uint64_t *l2_table,uint64_t stop_flags) {int i;
@@ -321,7 +321,7 @@ static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size,return i; } -static int count_contiguous_free_clusters (uint64_t nb_clusters,uint64_t *l2_table) +static int count_contiguous_free_clusters (int nb_clusters,uint64_t *l2_table) {int i;
@@ -495,6 +495,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,if (nb_needed > nb_available) { nb_needed = nb_available; } +assert (nb_needed <=INT_MAX ); *cluster_offset =0 ;
@@ -530,6 +531,8 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset, l2_index = (offset >> s->cluster_bits) & (s->l2_size -1 ); *cluster_offset =be64_to_cpu (l2_table[l2_index]); + +/* nb_needed <= INT_MAX, thus nb_clusters <= INT_MAX, too */ nb_clusters =size_to_clusters (s, nb_needed <<9 ); ret =qcow2_get_cluster_type (*cluster_offset);
@@ -960,7 +963,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,int l2_index;uint64_t cluster_offset;uint64_t *l2_table; -unsigned int nb_clusters; +uint64_t nb_clusters;unsigned int keep_clusters;int ret;
@@ -979,6 +982,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset, l2_index =offset_to_l2_index (s, guest_offset); nb_clusters =MIN (nb_clusters, s->l2_size - l2_index); +assert (nb_clusters <=INT_MAX );/* Find L2 entry for the first involved cluster */ ret =get_cluster_table (bs, guest_offset, &l2_table, &l2_index);
@@ -1061,7 +1065,7 @@ out:* restarted, but the whole request should not be failed. */ static int do_alloc_cluster_offset (BlockDriverState *bs,uint64_t guest_offset, -uint64_t *host_offset,unsigned int *nb_clusters) +uint64_t *host_offset,uint64_t *nb_clusters) {BDRVQcowState *s = bs->opaque;
@@ -1079,7 +1083,7 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, *host_offset = cluster_offset;return 0 ; }else { -int ret =qcow2_alloc_clusters_at (bs, *host_offset, *nb_clusters); +int64_t ret =qcow2_alloc_clusters_at (bs, *host_offset, *nb_clusters);if (ret <0 ) {return ret; }
@@ -1115,7 +1119,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,int l2_index;uint64_t *l2_table;uint64_t entry; -unsigned int nb_clusters; +uint64_t nb_clusters;int ret;uint64_t alloc_cluster_offset;
@@ -1133,6 +1137,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, l2_index =offset_to_l2_index (s, guest_offset); nb_clusters =MIN (nb_clusters, s->l2_size - l2_index); +assert (nb_clusters <=INT_MAX );/* Find L2 entry for the first involved cluster */ ret =get_cluster_table (bs, guest_offset, &l2_table, &l2_index);
@@ -1426,7 +1431,8 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)* clusters. */ static int discard_single_l2 (BlockDriverState *bs,uint64_t offset, -unsigned int nb_clusters,enum qcow2_discard_type type,bool full_discard) +uint64_t nb_clusters,enum qcow2_discard_type type, +bool full_discard) {BDRVQcowState *s = bs->opaque;uint64_t *l2_table;
@@ -1441,6 +1447,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset,/* Limit nb_clusters to one L2 table */ nb_clusters =MIN (nb_clusters, s->l2_size - l2_index); +assert (nb_clusters <=INT_MAX );for (i =0 ; i < nb_clusters; i++) {uint64_t old_l2_entry;
@@ -1503,7 +1510,7 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset, {BDRVQcowState *s = bs->opaque;uint64_t end_offset; -unsigned int nb_clusters; +uint64_t nb_clusters;int ret; end_offset = offset + (nb_sectors <<BDRV_SECTOR_BITS );
@@ -1545,7 +1552,7 @@ fail:* clusters. */ static int zero_single_l2 (BlockDriverState *bs,uint64_t offset, -unsigned int nb_clusters) +uint64_t nb_clusters) {BDRVQcowState *s = bs->opaque;uint64_t *l2_table;
@@ -1560,6 +1567,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset,/* Limit nb_clusters to one L2 table */ nb_clusters =MIN (nb_clusters, s->l2_size - l2_index); +assert (nb_clusters <=INT_MAX );for (i =0 ; i < nb_clusters; i++) {uint64_t old_offset;
@@ -1584,7 +1592,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset,int qcow2_zero_clusters (BlockDriverState *bs,uint64_t offset,int nb_sectors) {BDRVQcowState *s = bs->opaque; -unsigned int nb_clusters; +uint64_t nb_clusters;int ret;/* The zero flag is only supported by version 3 and newer */
block/qcow2-refcount.c +8 -4
@@ -875,8 +875,8 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size)return offset; } -int qcow2_alloc_clusters_at (BlockDriverState *bs,uint64_t offset, -int nb_clusters) +int64_t qcow2_alloc_clusters_at (BlockDriverState *bs,uint64_t offset, +int64_t nb_clusters) {BDRVQcowState *s = bs->opaque;uint64_t cluster_index, refcount;
@@ -1259,7 +1259,7 @@ static size_t refcount_array_byte_size(BDRVQcowState *s, uint64_t entries)static int realloc_refcount_array (BDRVQcowState *s,void **array,int64_t *size,int64_t new_size) { -size_t old_byte_size, new_byte_size; +int64_t old_byte_size, new_byte_size;void *new_ptr;/* Round to clusters so the array can be directly written to disk */
@@ -1275,13 +1275,17 @@ static int realloc_refcount_array(BDRVQcowState *s, void **array,assert (new_byte_size >0 ); +if (new_byte_size >SIZE_MAX ) { +return -ENOMEM ; + } + new_ptr =g_try_realloc (*array, new_byte_size);if (!new_ptr) {return -ENOMEM ; }if (new_byte_size > old_byte_size) { -memset ((void *)((uintptr_t )new_ptr + old_byte_size),0 , +memset ((char *)new_ptr + old_byte_size,0 , new_byte_size - old_byte_size); }
block/qcow2.h +3 -3
@@ -412,7 +412,7 @@ static inline int64_t offset_into_cluster(BDRVQcowState *s, int64_t offset)return offset & (s->cluster_size -1 ); } -static inline int size_to_clusters (BDRVQcowState *s,int64_t size) +static inline uint64_t size_to_clusters (BDRVQcowState *s,uint64_t size) {return (size + (s->cluster_size -1 )) >> s->cluster_bits; }
@@ -506,8 +506,8 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index, enum qcow2_discard_type type);int64_t qcow2_alloc_clusters (BlockDriverState *bs,uint64_t size); -int qcow2_alloc_clusters_at (BlockDriverState *bs,uint64_t offset, -int nb_clusters); +int64_t qcow2_alloc_clusters_at (BlockDriverState *bs,uint64_t offset, +int64_t nb_clusters);int64_t qcow2_alloc_bytes (BlockDriverState *bs,int size); void qcow2_free_clusters(BlockDriverState *bs, int64_t offset, int64_t size,
Signature · 1 line
1.9.1
PATCH 19/40 ide: fix ATAPI command permissions
In reply to Michael RothFrom: John Snow <[email protected]>
We're a little too lenient with what we'll let an ATAPI drive handle. Clamp down on the IDE command execution table to remove CD_OK permissions from commands that are not and have never been ATAPI commands.
For ATAPI command validity, please see:
- ATA4 Section 6.5 ("PACKET Command feature set")
- ATA8/ACS Section 4.3 ("The PACKET feature set")
- ACS3 Section 4.3 ("The PACKET feature set")
ACS3 has a historical command validity table in Table B.4 ("Historical Command Assignments") that can be referenced to find when a command was introduced, deprecated, obsoleted, etc.
The only reference for ATAPI command validity is by checking that version's PACKET feature set section.
ATAPI was introduced by T13 into ATA4, all commands retired prior to ATA4 therefore are assumed to have never been ATAPI commands.
Mandatory commands, as listed in ATA8-ACS3, are:
- DEVICE RESET
- EXECUTE DEVICE DIAGNOSTIC
- IDENTIFY DEVICE
- IDENTIFY PACKET DEVICE
- NOP
- PACKET
- READ SECTOR(S)
- SET FEATURES
Optional commands as listed in ATA8-ACS3, are:
- FLUSH CACHE
- READ LOG DMA EXT
- READ LOG EXT
- WRITE LOG DMA EXT
- WRITE LOG EXT
All other commands are illegal to send to an ATAPI device and should be rejected by the device.
CD_OK removal justifications:
0x06 WIN_DSM Defined in ACS2. Not valid for ATAPI. 0x21 WIN_READ_ONCE Retired in ATA5. Not ATAPI in ATA4. 0x94 WIN_STANDBYNOW2 Retired in ATA4. Did not coexist with ATAPI. 0x95 WIN_IDLEIMMEDIATE2 Retired in ATA4. Did not coexist with ATAPI. 0x96 WIN_STANDBY2 Retired in ATA4. Did not coexist with ATAPI. 0x97 WIN_SETIDLE2 Retired in ATA4. Did not coexist with ATAPI. 0x98 WIN_CHECKPOWERMODE2 Retired in ATA4. Did not coexist with ATAPI. 0x99 WIN_SLEEPNOW2 Retired in ATA4. Did not coexist with ATAPI. 0xE0 WIN_STANDBYNOW1 Not part of ATAPI in ATA4, ACS or ACS3. 0xE1 WIN_IDLEIMMDIATE Not part of ATAPI in ATA4, ACS or ACS3. 0xE2 WIN_STANDBY Not part of ATAPI in ATA4, ACS or ACS3. 0xE3 WIN_SETIDLE1 Not part of ATAPI in ATA4, ACS or ACS3. 0xE4 WIN_CHECKPOWERMODE1 Not part of ATAPI in ATA4, ACS or ACS3. 0xE5 WIN_SLEEPNOW1 Not part of ATAPI in ATA4, ACS or ACS3. 0xF8 WIN_READ_NATIVE_MAX Obsoleted in ACS3. Not ATAPI in ATA4 or ACS.
This patch fixes a divide by zero fault that can be caused by sending the WIN_READ_NATIVE_MAX command to an ATAPI drive, which causes it to attempt to use zeroed CHS values to perform sector arithmetic.
Message-id: [email protected]
--- hw/ide/core.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
hw/ide/core.c +15 -15
@@ -1747,11 +1747,11 @@ static const struct { } ide_cmd_table[0x100] = {/* NOP not implemented, mandatory for CD */ [CFA_REQ_EXT_ERROR_CODE] = { cmd_cfa_req_ext_error_code, CFA_OK }, - [WIN_DSM] = { cmd_data_set_management, ALL_OK }, + [WIN_DSM] = { cmd_data_set_management, HD_CFA_OK }, [WIN_DEVICE_RESET] = { cmd_device_reset, CD_OK }, [WIN_RECAL] = { cmd_nop, HD_CFA_OK | SET_DSC}, [WIN_READ] = { cmd_read_pio, ALL_OK }, - [WIN_READ_ONCE] = { cmd_read_pio, ALL_OK }, + [WIN_READ_ONCE] = { cmd_read_pio, HD_CFA_OK }, [WIN_READ_EXT] = { cmd_read_pio, HD_CFA_OK }, [WIN_READDMA_EXT] = { cmd_read_dma, HD_CFA_OK }, [WIN_READ_NATIVE_MAX_EXT] = { cmd_read_native_max, HD_CFA_OK | SET_DSC },
@@ -1770,12 +1770,12 @@ static const struct { [CFA_TRANSLATE_SECTOR] = { cmd_cfa_translate_sector, CFA_OK }, [WIN_DIAGNOSE] = { cmd_exec_dev_diagnostic, ALL_OK }, [WIN_SPECIFY] = { cmd_nop, HD_CFA_OK | SET_DSC }, - [WIN_STANDBYNOW2] = { cmd_nop, ALL_OK }, - [WIN_IDLEIMMEDIATE2] = { cmd_nop, ALL_OK }, - [WIN_STANDBY2] = { cmd_nop, ALL_OK }, - [WIN_SETIDLE2] = { cmd_nop, ALL_OK }, - [WIN_CHECKPOWERMODE2] = { cmd_check_power_mode, ALL_OK | SET_DSC }, - [WIN_SLEEPNOW2] = { cmd_nop, ALL_OK }, + [WIN_STANDBYNOW2] = { cmd_nop, HD_CFA_OK }, + [WIN_IDLEIMMEDIATE2] = { cmd_nop, HD_CFA_OK }, + [WIN_STANDBY2] = { cmd_nop, HD_CFA_OK }, + [WIN_SETIDLE2] = { cmd_nop, HD_CFA_OK }, + [WIN_CHECKPOWERMODE2] = { cmd_check_power_mode, HD_CFA_OK | SET_DSC }, + [WIN_SLEEPNOW2] = { cmd_nop, HD_CFA_OK }, [WIN_PACKETCMD] = { cmd_packet, CD_OK }, [WIN_PIDENTIFY] = { cmd_identify_packet, CD_OK }, [WIN_SMART] = { cmd_smart, HD_CFA_OK | SET_DSC },
@@ -1789,19 +1789,19 @@ static const struct { [WIN_WRITEDMA] = { cmd_write_dma, HD_CFA_OK }, [WIN_WRITEDMA_ONCE] = { cmd_write_dma, HD_CFA_OK }, [CFA_WRITE_MULTI_WO_ERASE] = { cmd_write_multiple, CFA_OK }, - [WIN_STANDBYNOW1] = { cmd_nop, ALL_OK }, - [WIN_IDLEIMMEDIATE] = { cmd_nop, ALL_OK }, - [WIN_STANDBY] = { cmd_nop, ALL_OK }, - [WIN_SETIDLE1] = { cmd_nop, ALL_OK }, - [WIN_CHECKPOWERMODE1] = { cmd_check_power_mode, ALL_OK | SET_DSC }, - [WIN_SLEEPNOW1] = { cmd_nop, ALL_OK }, + [WIN_STANDBYNOW1] = { cmd_nop, HD_CFA_OK }, + [WIN_IDLEIMMEDIATE] = { cmd_nop, HD_CFA_OK }, + [WIN_STANDBY] = { cmd_nop, HD_CFA_OK }, + [WIN_SETIDLE1] = { cmd_nop, HD_CFA_OK }, + [WIN_CHECKPOWERMODE1] = { cmd_check_power_mode, HD_CFA_OK | SET_DSC }, + [WIN_SLEEPNOW1] = { cmd_nop, HD_CFA_OK }, [WIN_FLUSH_CACHE] = { cmd_flush_cache, ALL_OK }, [WIN_FLUSH_CACHE_EXT] = { cmd_flush_cache, HD_CFA_OK }, [WIN_IDENTIFY] = { cmd_identify, ALL_OK }, [WIN_SETFEATURES] = { cmd_set_features, ALL_OK | SET_DSC }, [IBM_SENSE_CONDITION] = { cmd_ibm_sense_condition, CFA_OK | SET_DSC }, [CFA_WEAR_LEVEL] = { cmd_cfa_erase_sectors, HD_CFA_OK | SET_DSC }, - [WIN_READ_NATIVE_MAX] = { cmd_read_native_max, ALL_OK | SET_DSC }, + [WIN_READ_NATIVE_MAX] = { cmd_read_native_max, HD_CFA_OK | SET_DSC }, };static bool ide_cmd_permitted (IDEState *s,uint32_t cmd)
Signature · 1 line
1.9.1
PATCH 20/40 gtk: use setlocale() for LC_MESSAGES only
In reply to Michael RothFrom: Alberto Garcia <[email protected]>
The QEMU code is not internationalized and assumes that it runs under the C locale, but if we use the GTK+ UI we'll end up importing the locale settings from the environment. This can break things, such as the JSON generator and iotest 120 in locales that use a decimal comma.
We do however have translations for a few simple strings for the GTK+ menu items, so in order to run QEMU using the C locale, and yet have a translated UI let's use setlocale() for LC_MESSAGES only.
--- ui/gtk.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
ui/gtk.c +20 -1
@@ -1941,7 +1941,8 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) s->free_scale = FALSE; -setlocale (LC_ALL ,"" ); +/* LC_MESSAGES only. See early_gtk_display_init() for details */ +setlocale (LC_MESSAGES ,"" );bindtextdomain ("qemu" ,CONFIG_QEMU_LOCALEDIR );textdomain ("qemu" );
@@ -2010,6 +2011,24 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)void early_gtk_display_init (int opengl) { +/* The QEMU code relies on the assumption that it's always run in +* the C locale. Therefore it is not prepared to deal with +* operations that produce different results depending on the +* locale, such as printf's formatting of decimal numbers, and +* possibly others. +* +* Since GTK+ calls setlocale() by default -importing the locale +* settings from the environment- we must prevent it from doing so +* using gtk_disable_setlocale(). +* +* QEMU's GTK+ UI, however, _does_ have translations for some of +* the menu items. As a trade-off between a functionally correct +* QEMU and a fully internationalized UI we support importing +* LC_MESSAGES from the environment (see the setlocale() call +* earlier in this file). This allows us to display translated +* messages leaving everything else untouched. +*/ +gtk_disable_setlocale (); gtkinit =gtk_init_check (NULL ,NULL );if (!gtkinit) {/* don't exit yet, that'll break -help */
Signature · 1 line
1.9.1
PATCH 21/40 spapr_pci: fix device tree props for MSI/MSI-X
In reply to Michael RothPAPR requires ibm,req#msi and ibm,req#msi-x to be present in the device node to define the number of msi/msi-x interrupts the device supports, respectively.
Currently we have ibm,req#msi-x hardcoded to a non-sensical constant that happens to be 2, and are missing ibm,req#msi entirely. The result of that is that msi-x capable devices get limited to 2 msi-x interrupts (which can impact performance), and msi-only devices likely wouldn't work at all. Additionally, if devices expect a minimum that exceeds 2, the guest driver may fail to load entirely.
SLOF still owns the generation of these properties at boot-time (although other device properties have since been offloaded to QEMU), but for hotplugged devices we rely on the values generated by QEMU and thus hit the limitations above.
Fix this by generating these properties in QEMU as expected by guests.
In the future it may make sense to modify SLOF to pass through these values directly as we do with other props since we're duplicating SLOF code.
--- hw/ppc/spapr_pci.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
hw/ppc/spapr_pci.c +10 -2
@@ -955,6 +955,7 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset,int pci_status, err;char *buf =NULL ;uint32_t drc_index =spapr_phb_get_pci_drc_index (sphb, dev); +uint32_t max_msi, max_msix;if (pci_default_read_config (dev,PCI_HEADER_TYPE ,1 ) ==PCI_HEADER_TYPE_BRIDGE ) {
@@ -1035,8 +1036,15 @@ static int spapr_populate_pci_child_dt(PCIDevice *dev, void *fdt, int offset, RESOURCE_CELLS_ADDRESS));_FDT (fdt_setprop_cell (fdt, offset,"#size-cells" ,RESOURCE_CELLS_SIZE )); -_FDT (fdt_setprop_cell (fdt, offset,"ibm,req#msi-x" , -RESOURCE_CELLS_SIZE )); + + max_msi =msi_nr_vectors_allocated (dev); +if (max_msi) { +_FDT (fdt_setprop_cell (fdt, offset,"ibm,req#msi" , max_msi)); + } + max_msix = dev->msix_entries_nr; +if (max_msix) { +_FDT (fdt_setprop_cell (fdt, offset,"ibm,req#msi-x" , max_msix)); + }populate_resource_props (dev, &rp);_FDT (fdt_setprop (fdt, offset,"reg" , (uint8_t *)rp.reg, rp.reg_len));
Signature · 1 line
1.9.1
PATCH 22/40 nbd: release exp->blk after all clients are closed
In reply to Michael RothFrom: Wen Congyang <[email protected]>
If the socket fd is shutdown, there may be some data which is received before shutdown. We will read the data and do read/write in nbd_trip(). But the exp's blk is NULL, and it will cause qemu crashed.
Message-Id: <[email protected]>
--- nbd.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
nbd.c +15 -6
@@ -1131,12 +1131,6 @@ void nbd_export_close(NBDExport *exp) }nbd_export_set_name (exp,NULL );nbd_export_put (exp); -if (exp->blk) { -blk_remove_aio_context_notifier (exp->blk, blk_aio_attached, - blk_aio_detach, exp); -blk_unref (exp->blk); - exp->blk =NULL ; - } }void nbd_export_get (NBDExport *exp)
@@ -1159,6 +1153,13 @@ void nbd_export_put(NBDExport *exp) exp->close (exp); } +if (exp->blk) { +blk_remove_aio_context_notifier (exp->blk, blk_aio_attached, + blk_aio_detach, exp); +blk_unref (exp->blk); + exp->blk =NULL ; + } +g_free (exp); } }
@@ -1305,6 +1306,14 @@ static void nbd_trip(void *opaque) goto invalid_request; } +if (client->closing) { +/* +* The client may be closed when we are blocked in +* nbd_co_receive_request() +*/ + goto done; + } +switch (command) {case NBD_CMD_READ :TRACE ("Request type is READ" );
Signature · 1 line
1.9.1
PATCH 23/40 slirp: Fix non blocking connect for w32
In reply to Michael RothFrom: Stefan Weil <[email protected]>
--- slirp/tcp_input.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
slirp/tcp_input.c +7 -1
@@ -584,7 +584,13 @@ findso: goto cont_input; } -if ((tcp_fconnect (so) ==-1 ) && (errno !=EINPROGRESS ) && (errno !=EWOULDBLOCK )) { +if ((tcp_fconnect (so) ==-1 ) && +#if defined(_WIN32) + socket_error() != WSAEWOULDBLOCK +#else + (errno != EINPROGRESS) && (errno != EWOULDBLOCK) +#endif + ) {u_char code=ICMP_UNREACH_NET ;DEBUG_MISC ((dfd," tcp fconnect errno = %d-%s\n" , errno,strerror (errno)));
Signature · 1 line
1.9.1
PATCH 24/40 ide: unify io_buffer_offset increments
In reply to Michael RothFrom: John Snow <[email protected]>
IDEState's io_buffer_offset was originally added to keep track of offsets in AHCI rather exclusively, but it was added to IDEState instead of an AHCI-specific structure.
AHCI fakes all PIO transfers using DMA and a scatter-gather list. When the core or atapi layers invoke HBA-specific mechanisms for transfers, they do not always know that it is being backed by DMA or a sglist, so this offset is not always updated by the HBA code everywhere.
If we modify it in dma_buf_commit, however, any HBA that needs to use this offset to manage operating on only part of a sglist will have access to it.
This will fix ATAPI PIO transfers performed through the AHCI HBA, which were previously not modifying this value appropriately.
This will fix ATAPI PIO transfers larger than one sector.
Message-id: [email protected]
--- hw/ide/ahci.c | 22 +++++++--------------- hw/ide/core.c | 5 ++--- hw/ide/internal.h | 1 + 3 files changed, 10 insertions(+), 18 deletions(-)
hw/ide/ahci.c +7 -15
@@ -50,7 +50,6 @@ static void ahci_reset_port(AHCIState *s, int port);static void ahci_write_fis_d2h (AHCIDevice *ad,uint8_t *cmd_fis);static void ahci_init_d2h (AHCIDevice *ad);static int ahci_dma_prepare_buf (IDEDMA *dma,int32_t limit); -static void ahci_commit_buf (IDEDMA *dma,uint32_t tx_bytes);static bool ahci_map_clb_address (AHCIDevice *ad);static bool ahci_map_fis_address (AHCIDevice *ad);static void ahci_unmap_clb_address (AHCIDevice *ad);
@@ -1290,7 +1289,7 @@ out: s->data_ptr = s->data_end;/* Update number of transferred bytes, destroy sglist */ -ahci_commit_buf (dma, size); +dma_buf_commit (s, size); s->end_transfer_func (s);
@@ -1332,9 +1331,8 @@ static void ahci_restart(IDEDMA *dma) }/** -* Called in DMA R/W chains to read the PRDT, utilizing ahci_populate_sglist. -* Not currently invoked by PIO R/W chains, -* which invoke ahci_populate_sglist via ahci_start_transfer. +* Called in DMA and PIO R/W chains to read the PRDT. +* Not shared with NCQ pathways. */ static int32_t ahci_dma_prepare_buf (IDEDMA *dma,int32_t limit) {
@@ -1353,21 +1351,16 @@ static int32_t ahci_dma_prepare_buf(IDEDMA *dma, int32_t limit) }/** -* Destroys the scatter-gather list, -* and updates the command header with a bytes-read value. -* called explicitly via ahci_dma_rw_buf (ATAPI DMA), -* and ahci_start_transfer (PIO R/W), -* and called via callback from ide_dma_cb for DMA R/W paths. +* Updates the command header with a bytes-read value. +* Called via dma_buf_commit, for both DMA and PIO paths. +* sglist destruction is handled within dma_buf_commit. */ static void ahci_commit_buf (IDEDMA *dma,uint32_t tx_bytes) {AHCIDevice *ad =DO_UPCAST (AHCIDevice, dma, dma); -IDEState *s = &ad->port.ifs[0 ]; tx_bytes +=le32_to_cpu (ad->cur_cmd->status); ad->cur_cmd->status =cpu_to_le32 (tx_bytes); - -qemu_sglist_destroy (&s->sg); }static int ahci_dma_rw_buf (IDEDMA *dma,int is_write)
@@ -1388,10 +1381,9 @@ static int ahci_dma_rw_buf(IDEDMA *dma, int is_write) }/* free sglist, update byte count */ -ahci_commit_buf (dma, l); +dma_buf_commit (s, l); s->io_buffer_index += l; - s->io_buffer_offset += l;DPRINTF (ad->port_no,"len=%#x\n" , l);
hw/ide/core.c +2 -3
@@ -591,7 +591,6 @@ static void ide_sector_read_cb(void *opaque, int ret) s->nsector -= n;/* Allow the guest to read the io_buffer */ ide_transfer_start (s, s->io_buffer, n *BDRV_SECTOR_SIZE , ide_sector_read); - s->io_buffer_offset +=512 * n;ide_set_irq (s->bus); }
@@ -635,11 +634,12 @@ static void ide_sector_read(IDEState *s) ide_sector_read_cb, s); } -static void dma_buf_commit (IDEState *s,uint32_t tx_bytes) +void dma_buf_commit (IDEState *s,uint32_t tx_bytes) {if (s->bus->dma->ops->commit_buf) { s->bus->dma->ops->commit_buf (s->bus->dma, tx_bytes); } + s->io_buffer_offset += tx_bytes;qemu_sglist_destroy (&s->sg); }
@@ -842,7 +842,6 @@ static void ide_sector_write_cb(void *opaque, int ret) n = s->req_nb_sectors; } s->nsector -= n; - s->io_buffer_offset +=512 * n;ide_set_sector (s,ide_get_sector (s) + n);if (s->nsector ==0 ) {
hw/ide/internal.h +1 -0
@@ -536,6 +536,7 @@ int64_t ide_get_sector(IDEState *s);void ide_set_sector (IDEState *s,int64_t sector_num);void ide_start_dma (IDEState *s,BlockCompletionFunc *cb); +void dma_buf_commit (IDEState *s,uint32_t tx_bytes);void ide_dma_error (IDEState *s);void ide_atapi_cmd_ok (IDEState *s);
Signature · 1 line
1.9.1
PATCH 25/40 qom: Do not reuse errp after a possible error
In reply to Michael RothFrom: Markus Armbruster <[email protected]>
The argument for an Error **errp parameter must point to a null pointer. If it doesn't, and an error happens, error_set() fails its assertion.
Instead of
foo(foos, errp);
bar(bars, errp);you need to do something like
Error *err = NULL;
foo(foos, &err);
if (err) {
error_propagate(errp, err);
goto out;
}
bar(bars, errp);out:
Screwed up in commit 0e55884 (v1.3.0): property_get_bool().
Screwed up in commit 1f21772 (v2.1.0): object_property_get_enum() and object_property_get_uint16List().
Screwed up in commit a8e3fbe (v2.4.0): property_get_enum(), property_set_enum().
Found by inspection, no actual crashes observed.
Fix them up.
--- qom/object.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-)
qom/object.c +35 -6
@@ -1079,6 +1079,7 @@ typedef struct EnumProperty {int object_property_get_enum (Object *obj,const char *name,const char *typename,Error **errp) { +Error *err =NULL ;StringOutputVisitor *sov;StringInputVisitor *siv;char *str;
@@ -1100,7 +1101,12 @@ int object_property_get_enum(Object *obj, const char *name, enumprop = prop->opaque; sov =string_output_visitor_new (false); -object_property_get (obj,string_output_get_visitor (sov), name, errp); +object_property_get (obj,string_output_get_visitor (sov), name, &err); +if (err) { +error_propagate (errp, err); +string_output_visitor_cleanup (sov); +return 0 ; + } str =string_output_get_string (sov); siv =string_input_visitor_new (str);string_output_visitor_cleanup (sov);
@@ -1116,21 +1122,27 @@ int object_property_get_enum(Object *obj, const char *name,void object_property_get_uint16List (Object *obj,const char *name,uint16List **list,Error **errp) { +Error *err =NULL ;StringOutputVisitor *ov;StringInputVisitor *iv;char *str; ov =string_output_visitor_new (false);object_property_get (obj,string_output_get_visitor (ov), - name, errp); + name, &err); +if (err) { +error_propagate (errp, err); + goto out; + } str =string_output_get_string (ov); iv =string_input_visitor_new (str);visit_type_uint16List (string_input_get_visitor (iv), list,NULL , errp);g_free (str); -string_output_visitor_cleanup (ov);string_input_visitor_cleanup (iv); +out: +string_output_visitor_cleanup (ov); } void object_property_parse(Object *obj, const char *string,
@@ -1646,8 +1658,14 @@ static void property_get_bool(Object *obj, Visitor *v, void *opaque, {BoolProperty *prop = opaque;bool value; +Error *err =NULL ; + + value = prop->get (obj, &err); +if (err) { +error_propagate (errp, err); +return ; + } - value = prop->get (obj, errp);visit_type_bool (v, &value, name, errp); }
@@ -1701,8 +1719,14 @@ static void property_get_enum(Object *obj, Visitor *v, void *opaque, {EnumProperty *prop = opaque;int value; +Error *err =NULL ; + + value = prop->get (obj, &err); +if (err) { +error_propagate (errp, err); +return ; + } - value = prop->get (obj, errp);visit_type_enum (v, &value, prop->strings,NULL , name, errp); }
@@ -1711,8 +1735,13 @@ static void property_set_enum(Object *obj, Visitor *v, void *opaque, {EnumProperty *prop = opaque;int value; +Error *err =NULL ; -visit_type_enum (v, &value, prop->strings,NULL , name, errp); +visit_type_enum (v, &value, prop->strings,NULL , name, &err); +if (err) { +error_propagate (errp, err); +return ; + } prop->set (obj, value, errp); }
Signature · 1 line
1.9.1
PATCH 26/40 qom: Fix invalid error check in property_get_str()
In reply to Michael RothFrom: Markus Armbruster <[email protected]>
When a function returns a null pointer on error and only on error, you can do
if (!foo(foos, errp)) {
... handle error ...
}instead of the more cumbersome
Error *err = NULL;
if (!foo(foos, &err)) {
error_propagate(errp, err);
... handle error ...
}A StringProperty's getter, however, may return null on success! We then fail to call visit_type_str().
Screwed up in 6a146eb, v1.1.
Fails tests/qom-test in my current, heavily hacked QAPI branch. No reproducer for master known (but I didn't look hard).
--- qom/object.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
qom/object.c +8 -4
@@ -1593,12 +1593,16 @@ static void property_get_str(Object *obj, Visitor *v, void *opaque, {StringProperty *prop = opaque;char *value; +Error *err =NULL ; - value = prop->get (obj, errp); -if (value) { -visit_type_str (v, &value, name, errp); -g_free (value); + value = prop->get (obj, &err); +if (err) { +error_propagate (errp, err); +return ; } + +visit_type_str (v, &value, name, errp); +g_free (value); } static void property_set_str(Object *obj, Visitor *v, void *opaque,
Signature · 1 line
1.9.1
PATCH 27/40 tcg/mips: Fix clobbering of qemu_ld inputs
In reply to Michael RothFrom: James Hogan <[email protected]>
The MIPS TCG backend implements qemu_ld with 64-bit targets using the v0 register (base) as a temporary to load the upper half of the QEMU TLB comparator (see line 5 below), however this happens before the input address is used (line 8 to mask off the low bits for the TLB comparison, and line 12 to add the host-guest offset). If the input address (addrl) also happens to have been placed in v0 (as in the second column below), it gets clobbered before it is used.
addrl in t2 addrl in v0
1 srl a0,t2,0x7 srl a0,v0,0x7 2 andi a0,a0,0x1fe0 andi a0,a0,0x1fe0 3 addu a0,a0,s0 addu a0,a0,s0 4 lw at,9136(a0) lw at,9136(a0) set TCG_TMP0 (at) 5 lw v0,9140(a0) lw v0,9140(a0) set base (v0) 6 li t9,-4093 li t9,-4093 7 lw a0,9160(a0) lw a0,9160(a0) set addend (a0) 8 and t9,t9,t2 and t9,t9,v0 use addrl 9 bne at,t9,0x836d8c8 bne at,t9,0x836d838 use TCG_TMP0 10 nop nop 11 bne v0,t8,0x836d8c8 bne v0,a1,0x836d838 use base 12 addu v0,a0,t2 addu v0,a0,v0 use addrl, addend 13 lw t0,0(v0) lw t0,0(v0)
Fix by using TCG_TMP0 (at) as the temporary instead of v0 (base), pushing the load on line 5 forward into the delay slot of the low comparison (line 10). The early load of the addend on line 7 also needs pushing even further for 64-bit targets, or it will clobber a0 before we're done with it. The output for 32-bit targets is unaffected.
srl a0,v0,0x7 andi a0,a0,0x1fe0 addu a0,a0,s0 lw at,9136(a0) -lw v0,9140(a0) load high comparator li t9,-4093 -lw a0,9160(a0) load addend and t9,t9,v0 bne at,t9,0x836d838 - nop + lw at,9140(a0) load high comparator +lw a0,9160(a0) load addend -bne v0,a1,0x836d838 +bne at,a1,0x836d838 addu v0,a0,v0 lw t0,0(v0)
--- tcg/mips/tcg-target.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
tcg/mips/tcg-target.c +15 -11
@@ -962,30 +962,34 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg base, TCGReg addrl, add_off -=0x7ff0 ; } -/* Load the tlb comparator. */ -if (TARGET_LONG_BITS ==64 ) { -tcg_out_opc_imm (s,OPC_LW ,TCG_TMP0 ,TCG_REG_A0 , cmp_off +LO_OFF ); -tcg_out_opc_imm (s,OPC_LW , base,TCG_REG_A0 , cmp_off +HI_OFF ); - }else { -tcg_out_opc_imm (s,OPC_LW ,TCG_TMP0 ,TCG_REG_A0 , cmp_off); - } +/* Load the (low half) tlb comparator. */ +tcg_out_opc_imm (s,OPC_LW ,TCG_TMP0 ,TCG_REG_A0 , + cmp_off + (TARGET_LONG_BITS ==64 ?LO_OFF :0 ));/* Mask the page bits, keeping the alignment bits to compare against. -In between, load the tlb addend for the fast path. */ +In between on 32-bit targets, load the tlb addend for the fast path. */ tcg_out_movi (s,TCG_TYPE_I32 ,TCG_TMP1 ,TARGET_PAGE_MASK | ((1 << s_bits) -1 )); -tcg_out_opc_imm (s,OPC_LW ,TCG_REG_A0 ,TCG_REG_A0 , add_off); +if (TARGET_LONG_BITS ==32 ) { +tcg_out_opc_imm (s,OPC_LW ,TCG_REG_A0 ,TCG_REG_A0 , add_off); + }tcg_out_opc_reg (s,OPC_AND ,TCG_TMP1 ,TCG_TMP1 , addrl); label_ptr[0 ] = s->code_ptr;tcg_out_opc_br (s,OPC_BNE ,TCG_TMP1 ,TCG_TMP0 ); +/* Load and test the high half tlb comparator. */ if (TARGET_LONG_BITS ==64 ) {/* delay slot */ -tcg_out_nop (s); +tcg_out_opc_imm (s,OPC_LW ,TCG_TMP0 ,TCG_REG_A0 , cmp_off +HI_OFF ); + +/* Load the tlb addend for the fast path. We can't do it earlier with +64-bit targets or we'll clobber a0 before reading the high half tlb +comparator. */ +tcg_out_opc_imm (s,OPC_LW ,TCG_REG_A0 ,TCG_REG_A0 , add_off); label_ptr[1 ] = s->code_ptr; -tcg_out_opc_br (s,OPC_BNE , addrh, base); +tcg_out_opc_br (s,OPC_BNE , addrh,TCG_TMP0 ); }/* delay slot */
Signature · 1 line
1.9.1
PATCH 28/40 target-ppc: fix vcipher, vcipherlast, vncipherlast and vpermxor
In reply to Michael RothFrom: Aurelien Jarno <[email protected]>
For vector instructions, the helpers get pointers to the vector register in arguments. Some operands might point to the same register, including the operand holding the result.
When emulating instructions which access the vector elements in a non-linear way, we need to store the result in an temporary variable.
This fixes openssl when emulating a POWER8 CPU.
--- target-ppc/int_helper.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
target-ppc/int_helper.c +14 -5
@@ -2327,24 +2327,28 @@ void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a)void helper_vcipher (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b) { +ppc_avr_t result;int i; VECTOR_FOR_INORDER_I(i, u32) { - r->AVRW (i) = b->AVRW (i) ^ + result.AVRW (i) = b->AVRW (i) ^ (AES_Te0[a->AVRB (AES_shifts[4 *i +0 ])] ^ AES_Te1[a->AVRB (AES_shifts[4 *i +1 ])] ^ AES_Te2[a->AVRB (AES_shifts[4 *i +2 ])] ^ AES_Te3[a->AVRB (AES_shifts[4 *i +3 ])]); } + *r = result; }void helper_vcipherlast (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b) { +ppc_avr_t result;int i; VECTOR_FOR_INORDER_I(i, u8) { - r->AVRB (i) = b->AVRB (i) ^ (AES_sbox[a->AVRB (AES_shifts[i])]); + result.AVRB (i) = b->AVRB (i) ^ (AES_sbox[a->AVRB (AES_shifts[i])]); } + *r = result; }void helper_vncipher (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b)
@@ -2369,11 +2373,13 @@ void helper_vncipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)void helper_vncipherlast (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b) { +ppc_avr_t result;int i; VECTOR_FOR_INORDER_I(i, u8) { - r->AVRB (i) = b->AVRB (i) ^ (AES_isbox[a->AVRB (AES_ishifts[i])]); + result.AVRB (i) = b->AVRB (i) ^ (AES_isbox[a->AVRB (AES_ishifts[i])]); } + *r = result; }#define ROTRu32 (v, n) (((v) >> (n)) | ((v) << (32-n)))
@@ -2460,16 +2466,19 @@ void helper_vshasigmad(ppc_avr_t *r, ppc_avr_t *a, uint32_t st_six)void helper_vpermxor (ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b,ppc_avr_t *c) { +ppc_avr_t result;int i; + VECTOR_FOR_INORDER_I(i, u8) {int indexA = c->u8[i] >>4 ;int indexB = c->u8[i] &0xF ;#if defined(HOST_WORDS_BIGENDIAN ) - r->u8[i] = a->u8[indexA] ^ b->u8[indexB]; + result.u8[i] = a->u8[indexA] ^ b->u8[indexB];#else - r->u8[i] = a->u8[15 -indexA] ^ b->u8[15 -indexB]; + result.u8[i] = a->u8[15 -indexA] ^ b->u8[15 -indexB];#endif } + *r = result; }#undef VECTOR_FOR_INORDER_I
Signature · 1 line
1.9.1
PATCH 29/40 target-ppc: fix xscmpodp and xscmpudp decoding
In reply to Michael RothFrom: Aurelien Jarno <[email protected]>
The xscmpodp and xscmpudp instructions only have the AX, BX bits in there encoding, the lowest bit (usually TX) is marked as an invalid bit. We therefore can't decode them with GEN_XX2FORM, which decodes the two lowest bit.
Introduce a new form GEN_XX2FORM, which decodes AX and BX and mark the lowest bit as invalid.
--- target-ppc/translate.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
target-ppc/translate.c +9 -2
@@ -10670,6 +10670,13 @@ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2), \ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 2, opc3, 0, PPC_NONE, fl2), \ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 3, opc3, 0, PPC_NONE, fl2) +#undef GEN_XX2IFORM +#define GEN_XX2IFORM (name, opc2, opc3, fl2) \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 1, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 1, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 2, opc3, 1, PPC_NONE, fl2), \ +GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 3, opc3, 1, PPC_NONE, fl2) +#undef GEN_XX3_RC_FORM#define GEN_XX3_RC_FORM (name, opc2, opc3, fl2) \ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0x00, opc3 | 0x00, 0, PPC_NONE, fl2), \
@@ -10731,8 +10738,8 @@ GEN_XX3FORM(xsnmaddadp, 0x04, 0x14, PPC2_VSX),GEN_XX3FORM (xsnmaddmdp,0x04 ,0x15 ,PPC2_VSX ),GEN_XX3FORM (xsnmsubadp,0x04 ,0x16 ,PPC2_VSX ),GEN_XX3FORM (xsnmsubmdp,0x04 ,0x17 ,PPC2_VSX ), -GEN_XX2FORM (xscmpodp,0x0C ,0x05 ,PPC2_VSX ), -GEN_XX2FORM (xscmpudp,0x0C ,0x04 ,PPC2_VSX ), +GEN_XX2IFORM (xscmpodp,0x0C ,0x05 ,PPC2_VSX ), +GEN_XX2IFORM (xscmpudp,0x0C ,0x04 ,PPC2_VSX ),GEN_XX3FORM (xsmaxdp,0x00 ,0x14 ,PPC2_VSX ),GEN_XX3FORM (xsmindp,0x00 ,0x15 ,PPC2_VSX ), GEN_XX2FORM(xscvdpsp, 0x12, 0x10, PPC2_VSX),
Signature · 1 line
1.9.1
PATCH 30/40 virtio: avoid leading underscores for helpers
In reply to Michael RothFrom: Cornelia Huck <[email protected]>
Commit ef546f1275f6563e8934dd5e338d29d9f9909ca6 ("virtio: add feature checking helpers") introduced a helper __virtio_has_feature. We don't want to use reserved identifiers, though, so let's rename __virtio_has_feature to virtio_has_feature and virtio_has_feature to virtio_vdev_has_feature.
(cherry picked from commit 95129d6fc9ead97155627a4ca0cfd37282883658)
* prereq for 1f8828e
--- hw/block/virtio-blk.c | 7 ++++--- hw/char/virtio-serial-bus.c | 2 +- hw/net/vhost_net.c | 2 +- hw/net/virtio-net.c | 31 ++++++++++++++++--------------- hw/scsi/virtio-scsi.c | 8 ++++---- hw/virtio/dataplane/vring.c | 10 +++++----- hw/virtio/vhost.c | 4 ++-- hw/virtio/virtio-balloon.c | 2 +- hw/virtio/virtio.c | 14 +++++++------- include/hw/virtio/virtio-access.h | 2 +- include/hw/virtio/virtio.h | 11 ++++++----- 11 files changed, 48 insertions(+), 45 deletions(-)
hw/block/virtio-blk.c +4 -3
@@ -731,7 +731,7 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,virtio_add_feature (&features,VIRTIO_BLK_F_GEOMETRY );virtio_add_feature (&features,VIRTIO_BLK_F_TOPOLOGY );virtio_add_feature (&features,VIRTIO_BLK_F_BLK_SIZE ); -if (__virtio_has_feature (features,VIRTIO_F_VERSION_1 )) { +if (virtio_has_feature (features,VIRTIO_F_VERSION_1 )) {if (s->conf.scsi) {error_setg (errp,"Please set scsi=off for virtio-blk devices in order to use virtio 1.0" );return 0 ;
@@ -782,10 +782,11 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)* * s->blk would erroneously be placed in writethrough mode. */ -if (!virtio_has_feature (vdev,VIRTIO_BLK_F_CONFIG_WCE )) { +if (!virtio_vdev_has_feature (vdev,VIRTIO_BLK_F_CONFIG_WCE )) {aio_context_acquire (blk_get_aio_context (s->blk));blk_set_enable_write_cache (s->blk, -virtio_has_feature (vdev,VIRTIO_BLK_F_WCE )); +virtio_vdev_has_feature (vdev, +VIRTIO_BLK_F_WCE ));aio_context_release (blk_get_aio_context (s->blk)); } }
hw/char/virtio-serial-bus.c +1 -1
@@ -76,7 +76,7 @@ static VirtIOSerialPort *find_port_by_name(char *name)static bool use_multiport (VirtIOSerial *vser) {VirtIODevice *vdev =VIRTIO_DEVICE (vser); -return virtio_has_feature (vdev,VIRTIO_CONSOLE_F_MULTIPORT ); +return virtio_vdev_has_feature (vdev,VIRTIO_CONSOLE_F_MULTIPORT ); } static size_t write_to_port(VirtIOSerialPort *port,
hw/net/vhost_net.c +1 -1
@@ -197,7 +197,7 @@ static int vhost_net_set_vnet_endian(VirtIODevice *dev, NetClientState *peer, {int r =0 ; -if (virtio_has_feature (dev,VIRTIO_F_VERSION_1 ) || +if (virtio_vdev_has_feature (dev,VIRTIO_F_VERSION_1 ) || (virtio_legacy_is_cross_endian (dev) && !virtio_is_big_endian (dev))) { r =qemu_set_vnet_le (peer, set);if (r) {
hw/net/virtio-net.c +16 -15
@@ -86,8 +86,8 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)memcpy (&netcfg, config, n->config_size); -if (!virtio_has_feature (vdev,VIRTIO_NET_F_CTRL_MAC_ADDR ) && - !virtio_has_feature (vdev,VIRTIO_F_VERSION_1 ) && +if (!virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_MAC_ADDR ) && + !virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 ) &&memcmp (netcfg.mac, n->mac,ETH_ALEN )) {memcpy (n->mac, netcfg.mac,ETH_ALEN );qemu_format_nic_info_str (qemu_get_queue (n->nic), n->mac);
@@ -304,7 +304,7 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc) info->multicast_table = str_list; info->vlan_table =get_vlan_table (n); -if (!virtio_has_feature (vdev,VIRTIO_NET_F_CTRL_VLAN )) { +if (!virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_VLAN )) { info->vlan =RX_STATE_ALL ; }else if (!info->vlan_table) { info->vlan =RX_STATE_NONE ;
@@ -529,13 +529,13 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)int i;virtio_net_set_multiqueue (n, -__virtio_has_feature (features,VIRTIO_NET_F_MQ )); +virtio_has_feature (features,VIRTIO_NET_F_MQ ));virtio_net_set_mrg_rx_bufs (n, -__virtio_has_feature (features, -VIRTIO_NET_F_MRG_RXBUF ), -__virtio_has_feature (features, -VIRTIO_F_VERSION_1 )); +virtio_has_feature (features, +VIRTIO_NET_F_MRG_RXBUF ), +virtio_has_feature (features, +VIRTIO_F_VERSION_1 ));if (n->has_vnet_hdr) { n->curr_guest_offloads =
@@ -552,7 +552,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)vhost_net_ack_features (get_vhost_net (nc->peer), features); } -if (__virtio_has_feature (features,VIRTIO_NET_F_CTRL_VLAN )) { +if (virtio_has_feature (features,VIRTIO_NET_F_CTRL_VLAN )) {memset (n->vlans,0 ,MAX_VLAN >>3 ); }else {memset (n->vlans,0xff ,MAX_VLAN >>3 );
@@ -599,7 +599,7 @@ static int virtio_net_handle_offloads(VirtIONet *n, uint8_t cmd,uint64_t offloads;size_t s; -if (!virtio_has_feature (vdev,VIRTIO_NET_F_CTRL_GUEST_OFFLOADS )) { +if (!virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_GUEST_OFFLOADS )) {return VIRTIO_NET_ERR ; }
@@ -1453,7 +1453,7 @@ static void virtio_net_save_device(VirtIODevice *vdev, QEMUFile *f) } } -if (virtio_has_feature (vdev,VIRTIO_NET_F_CTRL_GUEST_OFFLOADS )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_GUEST_OFFLOADS )) {qemu_put_be64 (f, n->curr_guest_offloads); } }
@@ -1479,7 +1479,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, n->vqs[0 ].tx_waiting =qemu_get_be32 (f);virtio_net_set_mrg_rx_bufs (n,qemu_get_be32 (f), -virtio_has_feature (vdev,VIRTIO_F_VERSION_1 )); +virtio_vdev_has_feature (vdev, +VIRTIO_F_VERSION_1 ));if (version_id >=3 ) n->status =qemu_get_be16 (f);
@@ -1562,7 +1563,7 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, } } -if (virtio_has_feature (vdev,VIRTIO_NET_F_CTRL_GUEST_OFFLOADS )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_GUEST_OFFLOADS )) { n->curr_guest_offloads =qemu_get_be64 (f); }else { n->curr_guest_offloads =virtio_net_supported_guest_offloads (n);
@@ -1589,8 +1590,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,qemu_get_subqueue (n->nic, i)->link_down = link_down; } -if (virtio_has_feature (vdev,VIRTIO_NET_F_GUEST_ANNOUNCE ) && -virtio_has_feature (vdev,VIRTIO_NET_F_CTRL_VQ )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_NET_F_GUEST_ANNOUNCE ) && +virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_VQ )) { n->announce_counter =SELF_ANNOUNCE_ROUNDS ;timer_mod (n->announce_timer,qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL )); }
hw/scsi/virtio-scsi.c +4 -4
@@ -145,7 +145,7 @@ static int virtio_scsi_parse_req(VirtIOSCSIReq *req,* * TODO: always disable this workaround for virtio 1.0 devices. */ -if (!virtio_has_feature (vdev,VIRTIO_F_ANY_LAYOUT )) { +if (!virtio_vdev_has_feature (vdev,VIRTIO_F_ANY_LAYOUT )) {if (req->elem.out_num) { req_size = req->elem.out_sg[0 ].iov_len; }
@@ -754,7 +754,7 @@ static void virtio_scsi_change(SCSIBus *bus, SCSIDevice *dev, SCSISense sense)VirtIOSCSI *s =container_of (bus, VirtIOSCSI, bus);VirtIODevice *vdev =VIRTIO_DEVICE (s); -if (virtio_has_feature (vdev,VIRTIO_SCSI_F_CHANGE ) && +if (virtio_vdev_has_feature (vdev,VIRTIO_SCSI_F_CHANGE ) && dev->type !=TYPE_ROM ) {virtio_scsi_push_event (s, dev,VIRTIO_SCSI_T_PARAM_CHANGE , sense.asc | (sense.ascq <<8 ));
@@ -778,7 +778,7 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,aio_context_release (s->ctx); } -if (virtio_has_feature (vdev,VIRTIO_SCSI_F_HOTPLUG )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_SCSI_F_HOTPLUG )) {virtio_scsi_push_event (s, sd,VIRTIO_SCSI_T_TRANSPORT_RESET ,VIRTIO_SCSI_EVT_RESET_RESCAN );
@@ -792,7 +792,7 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev,VirtIOSCSI *s =VIRTIO_SCSI (vdev);SCSIDevice *sd =SCSI_DEVICE (dev); -if (virtio_has_feature (vdev,VIRTIO_SCSI_F_HOTPLUG )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_SCSI_F_HOTPLUG )) {virtio_scsi_push_event (s, sd,VIRTIO_SCSI_T_TRANSPORT_RESET ,VIRTIO_SCSI_EVT_RESET_REMOVED );
hw/virtio/dataplane/vring.c +5 -5
@@ -146,7 +146,7 @@ void vring_teardown(Vring *vring, VirtIODevice *vdev, int n)/* Disable guest->host notifies */ void vring_disable_notification (VirtIODevice *vdev,Vring *vring) { -if (!virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) { +if (!virtio_vdev_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) {vring_set_used_flags (vdev, vring,VRING_USED_F_NO_NOTIFY ); } }
@@ -157,7 +157,7 @@ void vring_disable_notification(VirtIODevice *vdev, Vring *vring)*/ bool vring_enable_notification (VirtIODevice *vdev,Vring *vring) { -if (virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) {vring_avail_event (&vring->vr) = vring->vr.avail->idx; }else {vring_clear_used_flags (vdev, vring,VRING_USED_F_NO_NOTIFY );
@@ -176,12 +176,12 @@ bool vring_should_notify(VirtIODevice *vdev, Vring *vring)* interrupts. */ smp_mb (); -if (virtio_has_feature (vdev,VIRTIO_F_NOTIFY_ON_EMPTY ) && +if (virtio_vdev_has_feature (vdev,VIRTIO_F_NOTIFY_ON_EMPTY ) &&unlikely (!vring_more_avail (vdev, vring))) {return true; } -if (!virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) { +if (!virtio_vdev_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) {return !(vring_get_avail_flags (vdev, vring) &VRING_AVAIL_F_NO_INTERRUPT ); }
@@ -443,7 +443,7 @@ int vring_pop(VirtIODevice *vdev, Vring *vring,/* On success, increment avail index. */ vring->last_avail_idx++; -if (virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) {vring_avail_event (&vring->vr) =virtio_tswap16 (vdev, vring->last_avail_idx); }
hw/virtio/vhost.c +2 -2
@@ -742,7 +742,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,return -errno; } -if (!virtio_has_feature (vdev,VIRTIO_F_VERSION_1 ) && +if (!virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 ) &&virtio_legacy_is_cross_endian (vdev)) { r = vhost_virtqueue_set_vring_endian_legacy(dev, virtio_is_big_endian(vdev),
@@ -839,7 +839,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev,/* In the cross-endian case, we need to reset the vring endianness to * native as legacy devices expect so by default. */ -if (!virtio_has_feature (vdev,VIRTIO_F_VERSION_1 ) && +if (!virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 ) &&virtio_legacy_is_cross_endian (vdev)) { r = vhost_virtqueue_set_vring_endian_legacy(dev, !virtio_is_big_endian(vdev),
hw/virtio/virtio-balloon.c +1 -1
@@ -70,7 +70,7 @@ static inline void reset_stats(VirtIOBalloon *dev)static bool balloon_stats_supported (const VirtIOBalloon *s) {VirtIODevice *vdev =VIRTIO_DEVICE (s); -return virtio_has_feature (vdev,VIRTIO_BALLOON_F_STATS_VQ ); +return virtio_vdev_has_feature (vdev,VIRTIO_BALLOON_F_STATS_VQ ); }static bool balloon_stats_enabled (const VirtIOBalloon *s)
hw/virtio/virtio.c +7 -7
@@ -220,7 +220,7 @@ static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val)void virtio_queue_set_notification (VirtQueue *vq,int enable) { vq->notification = enable; -if (virtio_has_feature (vq->vdev,VIRTIO_RING_F_EVENT_IDX )) { +if (virtio_vdev_has_feature (vq->vdev,VIRTIO_RING_F_EVENT_IDX )) {vring_set_avail_event (vq,vring_avail_idx (vq)); }else if (enable) {vring_used_flags_unset_bit (vq,VRING_USED_F_NO_NOTIFY );
@@ -471,7 +471,7 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) max = vq->vring.num; i = head =virtqueue_get_head (vq, vq->last_avail_idx++); -if (virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) {vring_set_avail_event (vq, vq->last_avail_idx); }
@@ -560,7 +560,7 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val)VirtioDeviceClass *k =VIRTIO_DEVICE_GET_CLASS (vdev);trace_virtio_set_status (vdev, val); -if (virtio_has_feature (vdev,VIRTIO_F_VERSION_1 )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 )) {if (!(vdev->status &VIRTIO_CONFIG_S_FEATURES_OK ) && val &VIRTIO_CONFIG_S_FEATURES_OK ) {int ret =virtio_validate_features (vdev);
@@ -898,7 +898,7 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align)VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (qbus);/* virtio-1 compliant devices cannot change the alignment */ -if (virtio_has_feature (vdev,VIRTIO_F_VERSION_1 )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 )) {error_report ("tried to modify queue alignment for virtio-1 device" );return ; }
@@ -993,12 +993,12 @@ static bool vring_notify(VirtIODevice *vdev, VirtQueue *vq)/* We need to expose used array entries before checking used event. */ smp_mb ();/* Always notify when queue is empty (when feature acknowledge) */ -if (virtio_has_feature (vdev,VIRTIO_F_NOTIFY_ON_EMPTY ) && +if (virtio_vdev_has_feature (vdev,VIRTIO_F_NOTIFY_ON_EMPTY ) && !vq->inuse &&vring_avail_idx (vq) == vq->last_avail_idx) {return true; } -if (!virtio_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) { +if (!virtio_vdev_has_feature (vdev,VIRTIO_RING_F_EVENT_IDX )) {return !(vring_avail_flags (vq) &VRING_AVAIL_F_NO_INTERRUPT ); }
@@ -1035,7 +1035,7 @@ static bool virtio_device_endian_needed(void *opaque)VirtIODevice *vdev = opaque;assert (vdev->device_endian !=VIRTIO_DEVICE_ENDIAN_UNKNOWN ); -if (!virtio_has_feature (vdev,VIRTIO_F_VERSION_1 )) { +if (!virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 )) {return vdev->device_endian !=virtio_default_endian (); }/* Devices conforming to VIRTIO 1.0 or later are always LE. */
include/hw/virtio/virtio-access.h +1 -1
@@ -19,7 +19,7 @@static inline bool virtio_access_is_big_endian (VirtIODevice *vdev) { -if (virtio_has_feature (vdev,VIRTIO_F_VERSION_1 )) { +if (virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 )) {/* Devices conforming to VIRTIO 1.0 or later are always LE. */ return false; }
include/hw/virtio/virtio.h +6 -5
@@ -261,26 +261,27 @@ static inline void virtio_clear_feature(uint64_t *features, unsigned int fbit) *features &= ~(1ULL << fbit); } -static inline bool __virtio_has_feature (uint64_t features,unsigned int fbit) +static inline bool virtio_has_feature (uint64_t features,unsigned int fbit) {assert (fbit <64 );return !!(features & (1ULL << fbit)); } -static inline bool virtio_has_feature (VirtIODevice *vdev,unsigned int fbit) +static inline bool virtio_vdev_has_feature (VirtIODevice *vdev, +unsigned int fbit) { -return __virtio_has_feature (vdev->guest_features, fbit); +return virtio_has_feature (vdev->guest_features, fbit); }static inline bool virtio_host_has_feature (VirtIODevice *vdev,unsigned int fbit) { -return __virtio_has_feature (vdev->host_features, fbit); +return virtio_has_feature (vdev->host_features, fbit); }static inline bool virtio_is_big_endian (VirtIODevice *vdev) { -if (!virtio_has_feature (vdev,VIRTIO_F_VERSION_1 )) { +if (!virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 )) {assert (vdev->device_endian !=VIRTIO_DEVICE_ENDIAN_UNKNOWN );return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_BIG ; }
Signature · 1 line
1.9.1
PATCH 31/40 virtio-net: unbreak self announcement and guest offloads after migration
In reply to Michael RothFrom: Jason Wang <[email protected]>
After commit 019a3edbb25f1571e876f8af1ce4c55412939e5d ("virtio: make features 64bit wide"). Device's guest_features was actually set after vdc->load(). This breaks the assumption that device specific load() function can check guest_features. For virtio-net, self announcement and guest offloads won't work after migration.
Fixing this by defer them to virtio_net_load() where guest_features were guaranteed to be set. Other virtio devices looks fine.
("virtio: make features 64bit wide")
--- hw/net/virtio-net.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-)
hw/net/virtio-net.c +23 -17
@@ -1462,11 +1462,33 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) {VirtIONet *n = opaque;VirtIODevice *vdev =VIRTIO_DEVICE (n); +int ret;if (version_id <2 || version_id >VIRTIO_NET_VM_VERSION )return -EINVAL ; -return virtio_load (vdev, f, version_id); + ret =virtio_load (vdev, f, version_id); +if (ret) { +return ret; + } + +if (virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_GUEST_OFFLOADS )) { + n->curr_guest_offloads =qemu_get_be64 (f); + }else { + n->curr_guest_offloads =virtio_net_supported_guest_offloads (n); + } + +if (peer_has_vnet_hdr (n)) { +virtio_net_apply_guest_offloads (n); + } + +if (virtio_vdev_has_feature (vdev,VIRTIO_NET_F_GUEST_ANNOUNCE ) && +virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_VQ )) { + n->announce_counter =SELF_ANNOUNCE_ROUNDS ; +timer_mod (n->announce_timer,qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL )); + } + +return 0 ; } static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -1563,16 +1585,6 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, } } -if (virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_GUEST_OFFLOADS )) { - n->curr_guest_offloads =qemu_get_be64 (f); - }else { - n->curr_guest_offloads =virtio_net_supported_guest_offloads (n); - } - -if (peer_has_vnet_hdr (n)) { -virtio_net_apply_guest_offloads (n); - } -virtio_net_set_queues (n);/* Find the first multicast entry in the saved MAC filter */
@@ -1590,12 +1602,6 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,qemu_get_subqueue (n->nic, i)->link_down = link_down; } -if (virtio_vdev_has_feature (vdev,VIRTIO_NET_F_GUEST_ANNOUNCE ) && -virtio_vdev_has_feature (vdev,VIRTIO_NET_F_CTRL_VQ )) { - n->announce_counter =SELF_ANNOUNCE_ROUNDS ; -timer_mod (n->announce_timer,qemu_clock_get_ms (QEMU_CLOCK_VIRTUAL )); - } -return 0 ; }
Signature · 1 line
1.9.1
PATCH 32/40 vmxnet3: Drop net_vmxnet3_info.can_receive
In reply to Michael RothFrom: Fam Zheng <[email protected]>
Commit 6e99c63 ("net/socket: Drop net_socket_can_send") changed the semantics around .can_receive for sockets to now require the device to flush queued pkts when transitioning to a .can_receive=true state. But it's OK to drop incoming packets when the link is not active.
--- hw/net/vmxnet3.c | 1 - 1 file changed, 1 deletion(-)
hw/net/vmxnet3.c +0 -1
@@ -1988,7 +1988,6 @@ static void vmxnet3_set_link_status(NetClientState *nc)static NetClientInfo net_vmxnet3_info = { .type =NET_CLIENT_OPTIONS_KIND_NIC , .size =sizeof (NICState), - .can_receive = vmxnet3_can_receive, .receive = vmxnet3_receive, .link_status_changed = vmxnet3_set_link_status, };
Signature · 1 line
1.9.1
PATCH 33/40 qmp: Fix device-list-properties not to crash for abstract device
In reply to Michael RothFrom: Markus Armbruster <[email protected]>
Broken in commit f4eb32b "qmp: show QOM properties in device-list-properties", v2.1.
Message-Id: <[email protected]> (cherry picked from commit edb1523d90415cb79f60f83b4028ef3820d15612)
Conflicts:
tests/device-introspect-test.c
* removed hunk specific to QAPI introspection (not in 2.4)
--- qmp.c | 6 ++++++ 1 file changed, 6 insertions(+)
qmp.c +6 -0
@@ -514,6 +514,12 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,return NULL ; } +if (object_class_is_abstract (klass)) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"name" , +"non-abstract device type" ); +return NULL ; + } + obj =object_new (typename); QTAILQ_FOREACH(prop, &obj->properties, node) {
Signature · 1 line
1.9.1
PATCH 34/40 qdev: Protect device-list-properties against broken devices
In reply to Michael RothFrom: Markus Armbruster <[email protected]>
Several devices don't survive object_unref(object_new(T)): they crash or hang during cleanup, or they leave dangling pointers behind.
This breaks at least device-list-properties, because qmp_device_list_properties() needs to create a device to find its properties. Broken in commit f4eb32b "qmp: show QOM properties in device-list-properties", v2.1. Example reproducer:
$ qemu-system-aarch64 -nodefaults -display none -machine none -S -qmp stdio
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 4, "major": 2}, "package": ""}, "capabilities": []}}
{ "execute": "qmp_capabilities" }
{"return": {}}
{ "execute": "device-list-properties", "arguments": { "typename": "pxa2xx-pcmcia" } }
qemu-system-aarch64: /home/armbru/work/qemu/memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
Aborted (core dumped)
[Exit 134 (SIGABRT)]Unfortunately, I can't fix the problems in these devices right now. Instead, add DeviceClass member cannot_destroy_with_object_finalize_yet to mark them:
* Hang during cleanup (didn't debug, so I can't say why):
"realview_pci", "versatile_pci".
* Dangling pointer in cpus: most CPUs, plus "allwinner-a10", "digic", "fsl,imx25", "fsl,imx31", "xlnx,zynqmp", because they create such CPUs
* Assert kvm_enabled(): "host-x86_64-cpu", host-i386-cpu", "host-powerpc64-cpu", "host-embedded-powerpc-cpu", "host-powerpc-cpu" (the powerpc ones can't currently reach the assertion, because the CPUs are only registered when KVM is enabled, but the assertion is arguably in the wrong place all the same)
Make qmp_device_list_properties() fail cleanly when the device is so marked. This improves device-list-properties from "crashes, hangs or leaves dangling pointers behind" to "fails". Not a complete fix, just a better-than-nothing work-around. In the above reproducer, device-list-properties now fails with "Can't list properties of device 'pxa2xx-pcmcia'".
This also protects -device FOO,help, which uses the same machinery since commit ef52358 "qdev-monitor: include QOM properties in -device FOO, help output", v2.2. Example reproducer:
$ qemu-system-aarch64 -machine none -device pxa2xx-pcmcia,help
Before:
qemu-system-aarch64: .../memory.c:1307: memory_region_finalize: Assertion `((&mr->subregions)->tqh_first == ((void *)0))' failed.
After:
Can't list properties of device 'pxa2xx-pcmcia'
Message-Id: <[email protected]> (cherry picked from commit 4c315c27661502a0813b129e41c0bf640c34a8d6)
Conflicts:
hw/arm/fsl-imx25.c hw/arm/fsl-imx31.c target-tilegx/cpu.c tests/device-introspect-test.c
* removed hunks pertaining to devices/tests not in 2.4
--- hw/arm/allwinner-a10.c | 6 ++++++ hw/arm/digic.c | 6 ++++++ hw/arm/xlnx-zynqmp.c | 6 ++++++ hw/pci-host/versatile.c | 11 +++++++++++ include/hw/qdev-core.h | 13 +++++++++++++ qmp.c | 5 +++++ target-alpha/cpu.c | 7 +++++++ target-arm/cpu.c | 11 +++++++++++ target-cris/cpu.c | 7 +++++++ target-i386/cpu.c | 8 ++++++++ target-lm32/cpu.c | 7 +++++++ target-m68k/cpu.c | 7 +++++++ target-microblaze/cpu.c | 6 ++++++ target-mips/cpu.c | 7 +++++++ target-moxie/cpu.c | 7 +++++++ target-openrisc/cpu.c | 7 +++++++ target-ppc/kvm.c | 4 ++++ target-s390x/cpu.c | 7 +++++++ target-sh4/cpu.c | 7 +++++++ target-sparc/cpu.c | 7 +++++++ target-tricore/cpu.c | 6 ++++++ target-unicore32/cpu.c | 7 +++++++ target-xtensa/cpu.c | 7 +++++++ 23 files changed, 166 insertions(+)
hw/arm/allwinner-a10.c +6 -0
@@ -103,6 +103,12 @@ static void aw_a10_class_init(ObjectClass *oc, void *data)DeviceClass *dc =DEVICE_CLASS (oc); dc->realize = aw_a10_realize; + +/* +* Reason: creates an ARM CPU, thus use after free(), see +* arm_cpu_class_init() +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo aw_a10_type_info = {
hw/arm/digic.c +6 -0
@@ -97,6 +97,12 @@ static void digic_class_init(ObjectClass *oc, void *data)DeviceClass *dc =DEVICE_CLASS (oc); dc->realize = digic_realize; + +/* +* Reason: creates an ARM CPU, thus use after free(), see +* arm_cpu_class_init() +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo digic_type_info = {
hw/arm/xlnx-zynqmp.c +6 -0
@@ -248,6 +248,12 @@ static void xlnx_zynqmp_class_init(ObjectClass *oc, void *data) dc->props = xlnx_zynqmp_props; dc->realize = xlnx_zynqmp_realize; + +/* +* Reason: creates an ARM CPU, thus use after free(), see +* arm_cpu_class_init() +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo xlnx_zynqmp_type_info = {
hw/pci-host/versatile.c +11 -0
@@ -500,6 +500,8 @@ static void pci_vpb_class_init(ObjectClass *klass, void *data) dc->reset = pci_vpb_reset; dc->vmsd = &pci_vpb_vmstate; dc->props = pci_vpb_properties; +/* Reason: object_unref() hangs */ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo pci_vpb_info = {
@@ -521,10 +523,19 @@ static void pci_realview_init(Object *obj) s->mem_win_size[2 ] =0x08000000 ; } +static void pci_realview_class_init (ObjectClass *class,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (class); + +/* Reason: object_unref() hangs */ + dc->cannot_destroy_with_object_finalize_yet = true; +} +static const TypeInfo pci_realview_info = { .name ="realview_pci" , .parent =TYPE_VERSATILE_PCI , .instance_init = pci_realview_init, + .class_init = pci_realview_class_init, };static void versatile_pci_register_types (void )
include/hw/qdev-core.h +13 -0
@@ -114,6 +114,19 @@ typedef struct DeviceClass {* TODO remove once we're there */ bool cannot_instantiate_with_device_add_yet; +/* +* Does this device model survive object_unref(object_new(TNAME))? +* All device models should, and this flag shouldn't exist. Some +* devices crash in object_new(), some crash or hang in +* object_unref(). Makes introspecting properties with +* qmp_device_list_properties() dangerous. Bad, because it's used +* by -device FOO,help. This flag serves to protect that code. +* It should never be set without a comment explaining why it is +* set. +* TODO remove once we're there +*/ +bool cannot_destroy_with_object_finalize_yet; +bool hotpluggable;/* callbacks */
qmp.c +5 -0
@@ -520,6 +520,11 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,return NULL ; } +if (DEVICE_CLASS (klass)->cannot_destroy_with_object_finalize_yet) { +error_setg (errp,"Can't list properties of device '%s'" , typename); +return NULL ; + } + obj =object_new (typename); QTAILQ_FOREACH(prop, &obj->properties, node) {
target-alpha/cpu.c +7 -0
@@ -298,6 +298,13 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) dc->vmsd = &vmstate_alpha_cpu;#endif cc->gdb_num_core_regs =67 ; + +/* +* Reason: alpha_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo alpha_cpu_type_info = {
target-arm/cpu.c +11 -0
@@ -1403,6 +1403,17 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->debug_excp_handler = arm_debug_excp_handler; cc->disas_set_info = arm_disas_set_info; + +/* +* Reason: arm_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +* +* Once this is fixed, the devices that create ARM CPUs should be +* updated not to set cannot_destroy_with_object_finalize_yet, +* unless they still screw up something else. +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static void cpu_register (const ARMCPUInfo *info)
target-cris/cpu.c +7 -0
@@ -308,6 +308,13 @@ static void cris_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = cris_disas_set_info; + +/* +* Reason: cris_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo cris_cpu_type_info = {
target-i386/cpu.c +8 -0
@@ -1475,6 +1475,8 @@ static void host_x86_cpu_class_init(ObjectClass *oc, void *data)*/ dc->props = host_x86_cpu_properties; +/* Reason: host_x86_cpu_initfn() dies when !kvm_enabled() */ + dc->cannot_destroy_with_object_finalize_yet = true; }static void host_x86_cpu_initfn (Object *obj)
@@ -3200,6 +3202,12 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)#endif cc->cpu_exec_enter = x86_cpu_exec_enter; cc->cpu_exec_exit = x86_cpu_exec_exit; + +/* +* Reason: x86_cpu_initfn() calls cpu_exec_init(), which saves the +* object in cpus -> dangling pointer after final object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo x86_cpu_type_info = {
target-lm32/cpu.c +7 -0
@@ -275,6 +275,13 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =32 +7 ; cc->gdb_stop_before_watchpoint = true; cc->debug_excp_handler = lm32_debug_excp_handler; + +/* +* Reason: lm32_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static void lm32_register_cpu_type (const LM32CPUInfo *info)
target-m68k/cpu.c +7 -0
@@ -212,6 +212,13 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) dc->vmsd = &vmstate_m68k_cpu; cc->gdb_num_core_regs =18 ; cc->gdb_core_xml_file ="cf-core.xml" ; + +/* +* Reason: m68k_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static void register_cpu_type (const M68kCPUInfo *info)
target-microblaze/cpu.c +6 -0
@@ -264,6 +264,12 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =32 +5 ; cc->disas_set_info = mb_disas_set_info; + +/* +* Reason: mb_cpu_initfn() calls cpu_exec_init(), which saves the +* object in cpus -> dangling pointer after final object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo mb_cpu_type_info = {
target-mips/cpu.c +7 -0
@@ -153,6 +153,13 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->gdb_num_core_regs =73 ; cc->gdb_stop_before_watchpoint = true; + +/* +* Reason: mips_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo mips_cpu_type_info = {
target-moxie/cpu.c +7 -0
@@ -114,6 +114,13 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu;#endif + +/* +* Reason: moxie_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static void moxielite_initfn (Object *obj)
target-openrisc/cpu.c +7 -0
@@ -177,6 +177,13 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) dc->vmsd = &vmstate_openrisc_cpu;#endif cc->gdb_num_core_regs =32 +3 ; + +/* +* Reason: openrisc_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static void cpu_register (const OpenRISCCPUInfo *info)
target-ppc/kvm.c +4 -0
@@ -2188,6 +2188,7 @@ static void kvmppc_host_cpu_initfn(Object *obj)static void kvmppc_host_cpu_class_init (ObjectClass *oc,void *data) { +DeviceClass *dc =DEVICE_CLASS (oc);PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc);uint32_t vmx =kvmppc_get_vmx ();uint32_t dfp =kvmppc_get_dfp ();
@@ -2214,6 +2215,9 @@ static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data)if (icache_size !=-1 ) { pcc->l1_icache_size = icache_size; } + +/* Reason: kvmppc_host_cpu_initfn() dies when !kvm_enabled() */ + dc->cannot_destroy_with_object_finalize_yet = true; }bool kvmppc_has_cap_epr (void )
target-s390x/cpu.c +7 -0
@@ -353,6 +353,13 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)#endif cc->gdb_num_core_regs =S390_NUM_CORE_REGS ; cc->gdb_core_xml_file ="s390x-core64.xml" ; + +/* +* Reason: s390_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo s390_cpu_type_info = {
target-sh4/cpu.c +7 -0
@@ -290,6 +290,13 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data)#endif dc->vmsd = &vmstate_sh_cpu; cc->gdb_num_core_regs =59 ; + +/* +* Reason: superh_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo superh_cpu_type_info = {
target-sparc/cpu.c +7 -0
@@ -854,6 +854,13 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)#else cc->gdb_num_core_regs =72 ;#endif + +/* +* Reason: sparc_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo sparc_cpu_type_info = {
target-tricore/cpu.c +6 -0
@@ -170,6 +170,12 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->set_pc = tricore_cpu_set_pc; cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb; +/* +* Reason: tricore_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static void cpu_register (const TriCoreCPUInfo *info)
target-unicore32/cpu.c +7 -0
@@ -155,6 +155,13 @@ static void uc32_cpu_class_init(ObjectClass *oc, void *data) cc->get_phys_page_debug = uc32_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_uc32_cpu; + +/* +* Reason: uc32_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static void uc32_register_cpu_type (const UniCore32CPUInfo *info)
target-xtensa/cpu.c +7 -0
@@ -155,6 +155,13 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data)#endif cc->debug_excp_handler = xtensa_breakpoint_handler; dc->vmsd = &vmstate_xtensa_cpu; + +/* +* Reason: xtensa_cpu_initfn() calls cpu_exec_init(), which saves +* the object in cpus -> dangling pointer after final +* object_unref(). +*/ + dc->cannot_destroy_with_object_finalize_yet = true; }static const TypeInfo xtensa_cpu_type_info = {
Signature · 1 line
1.9.1
PATCH 35/40 Revert "qdev: Use qdev_get_device_class() for -device <type>, help"
In reply to Michael RothFrom: Markus Armbruster <[email protected]>
This reverts commit 31bed5509dfcbdfc293154ce81086a4dbd7a80b6.
The reverted commit changed qdev_device_help() to reject abstract devices and devices that have cannot_instantiate_with_device_add_yet set, to fix crash bugs like -device x86_64-cpu,help.
Rejecting abstract devices makes sense: they're purely internal, and the implementation of the help feature can't cope with them.
Rejecting non-pluggable devices makes less sense: even though you can't use them with -device, the help may still be useful elsewhere, for instance with -global. This is a regression: -device FOO,help used to help even for FOO that aren't pluggable.
The previous two commits fixed the crash bug at a lower layer, so reverting this one is now safe. Fixes the -device FOO,help regression, except for the broken devices marked cannot_even_create_with_object_new_yet. For those, the error message is improved.
Example of a device where the regression is fixed:
$ qemu-system-x86_64 -device PIIX4_PM,help
PIIX4_PM.command_serr_enable=bool (on/off)
PIIX4_PM.multifunction=bool (on/off)
PIIX4_PM.rombar=uint32
PIIX4_PM.romfile=str
PIIX4_PM.addr=int32 (Slot and optional function number, example: 06.0 or 06)
PIIX4_PM.memory-hotplug-support=bool
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=bool
PIIX4_PM.s4_val=uint8
PIIX4_PM.disable_s4=uint8
PIIX4_PM.disable_s3=uint8
PIIX4_PM.smb_io_base=uint32Example of a device where it isn't fixed:
$ qemu-system-x86_64 -device host-x86_64-cpu,help
Can't list properties of device 'host-x86_64-cpu'Both failed with "Parameter 'driver' expects pluggable device type" before.
Message-Id: <[email protected]>
--- qdev-monitor.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
qdev-monitor.c +6 -3
@@ -237,9 +237,12 @@ int qdev_device_help(QemuOpts *opts)return 0 ; } -qdev_get_device_class (&driver, &local_err); -if (local_err) { - goto error; +if (!object_class_by_name (driver)) { +const char *typename =find_typename_by_alias (driver); + +if (typename) { + driver = typename; + } } prop_list =qmp_device_list_properties (driver, &local_err);
Signature · 1 line
1.9.1
PATCH 36/40 misc: zynq_slcr: Fix MMIO writes
In reply to Michael RothFrom: Peter Crosthwaite <[email protected]>
The /4 for offset calculation in MMIO writes was happening twice giving wrong write offsets. Fix.
While touching the code, change the if-else to be a short returning if and convert the debug message to a GUEST_ERROR, which is more accurate for this condition.
--- hw/misc/zynq_slcr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/misc/zynq_slcr.c +4 -4
@@ -393,12 +393,12 @@ static void zynq_slcr_write(void *opaque, hwaddr offset,return ; } -if (!s->regs[LOCKSTA ]) { - s->regs[offset /4 ] = val; - }else { -DB_PRINT ("SCLR registers are locked. Unlock them first\n" ); +if (s->regs[LOCKSTA ]) { +qemu_log_mask (LOG_GUEST_ERROR , +"SCLR registers are locked. Unlock them first\n" );return ; } + s->regs[offset] = val;switch (offset) {case PSS_RST_CTRL :
Signature · 1 line
1.9.1
PATCH 37/40 s390x/kvm: Fix vector validity bit in device machine checks
In reply to Michael RothFrom: Christian Borntraeger <[email protected]>
Device hotplugs trigger a crw machine check. All machine checks have validity bits for certain register types. With vector support we also have to claim that vector registers are valid. This is a band-aid suitable for stable. Long term we should create the full mcic value dynamically depending on the active features in the kernel interrupt handler.
--- target-s390x/kvm.c | 3 +++ 1 file changed, 3 insertions(+)
target-s390x/kvm.c +3 -0
@@ -2079,6 +2079,9 @@ void kvm_s390_crw_mchk(void) .u.mchk.cr14 = 1 << 28, .u.mchk.mcic = 0x00400f1d40330000ULL, }; +if (kvm_check_extension (kvm_state,KVM_CAP_S390_VECTOR_REGISTERS )) { + irq.u.mchk.mcic |=0x0000004000000000ULL ; + }kvm_s390_floating_interrupt (&irq); }
Signature · 1 line
1.9.1
PATCH 38/40 util/qemu-config: fix missing machine command line options
In reply to Michael RothFrom: Tony Krowiak <[email protected]>
Commit 0a7cf217 ("util/qemu-config: fix regression of qmp_query_command_line_options") aimed to restore parsing of global machine options, but missed two: "aes-key-wrap" and "dea-key-wrap" (which were present in the initial version of that patch). Let's add them to the machine_opts again.
qmp_query_command_line_options")
Message-Id: <[email protected]>
--- util/qemu-config.c | 8 ++++++++ 1 file changed, 8 insertions(+)
util/qemu-config.c +8 -0
@@ -219,6 +219,14 @@ static QemuOptsList machine_opts = { .name = "suppress-vmdesc", .type = QEMU_OPT_BOOL, .help = "Set on to disable self-describing migration", + },{ + .name = "aes-key-wrap", + .type = QEMU_OPT_BOOL, + .help = "enable/disable AES key wrapping using the CPACF wrapping key", + },{ + .name = "dea-key-wrap", + .type = QEMU_OPT_BOOL, + .help = "enable/disable DEA key wrapping using the CPACF wrapping key", }, {/* End of list */ } }
Signature · 1 line
1.9.1
PATCH 39/40 Migration: Generate the completed event only when we complete
In reply to Michael RothFrom: "Dr. David Alan Gilbert" <[email protected]>
The current migration-completed event is generated a bit too early, which means that an eager libvirt that's ready to go as soon as it sees the event ends up racing with the actual end of migration.
This corresponds to RH bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1271145
--- migration/migration.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
migration/migration.c +7 -1
@@ -286,12 +286,12 @@ static void process_incoming_migration_co(void *opaque)migrate_decompress_threads_join ();exit (EXIT_FAILURE ); } -migrate_generate_event (MIGRATION_STATUS_COMPLETED );qemu_announce_self ();/* Make sure all file formats flush their mutable metadata */ bdrv_invalidate_cache_all (&local_err);if (local_err) { +migrate_generate_event (MIGRATION_STATUS_FAILED );error_report_err (local_err);migrate_decompress_threads_join ();exit (EXIT_FAILURE );
@@ -312,6 +312,12 @@ static void process_incoming_migration_co(void *opaque)runstate_set (global_state_get_runstate ()); }migrate_decompress_threads_join (); +/* +* This must happen after any state changes since as soon as an external +* observer sees this event they might start to prod at the VM assuming +* it's ready to use. +*/ +migrate_generate_event (MIGRATION_STATUS_COMPLETED ); }void process_incoming_migration (QEMUFile *f)
Signature · 1 line
1.9.1
PATCH 40/40 virtio-input: ignore events until the guest driver is ready
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
--- hw/input/virtio-input.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/input/virtio-input.c +4 -0
@@ -20,6 +20,10 @@ void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event)unsigned have, need;int i, len; +if (!vinput->active) { +return ; + } +/* queue up events ... */ if (vinput->qindex == vinput->qsize) { vinput->qsize++;
Signature · 1 line
1.9.1
Quoted 4 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.4.1:
Quoted 9 lines
https://github.com/mdroth/qemu/commits/stable-2.4-staging
The release is planned for 2015-11-03:
http://wiki.qemu.org/Planning/2.4
Please respond here or CC [email protected] on any patches you think should be included in the release.
The patches for CVE-2015-7295 seem to be missing, as referenced here:
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2015-7295
commit ce317461573bac12b10d67699b4ddf1f97cf066c
Author: Jason Wang <[email protected]> Date: Fri Sep 25 13:21:28 2015 +0800
virtio: introduce virtqueue_unmap_sg()
commit 29b9f5efd78ae0f9cc02dd169b6e80d2c404bade
Author: Jason Wang <[email protected]> Date: Fri Sep 25 13:21:29 2015 +0800
virtio: introduce virtqueue_discard()
commit 0cf33fb6b49a19de32859e2cdc6021334f448fb3
Author: Jason Wang <[email protected]> Date: Fri Sep 25 13:21:30 2015 +0800
virtio-net: correctly drop truncated packets
Thanks,
Cole
Quoting Cole Robinson (2015-10-21 13:05:03)
Quoted 28 lines · Michael Roth
Quoted 4 lines
Hi everyone,
The following new patches are queued for QEMU stable v2.4.1:
Quoted 9 lines
https://github.com/mdroth/qemu/commits/stable-2.4-staging
The release is planned for 2015-11-03:
http://wiki.qemu.org/Planning/2.4
Please respond here or CC [email protected] on any patches you think should be included in the release.
The patches for CVE-2015-7295 seem to be missing, as referenced here:
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2015-7295commit
ce317461573bac12b10d67699b4ddf1f97cf066cAuthor: Jason Wang <[email protected]> Date: Fri Sep 25 13:21:28 2015 +0800virtio: introduce
virtqueue_unmap_sg()commit
29b9f5efd78ae0f9cc02dd169b6e80d2c404badeAuthor: Jason Wang <[email protected]> Date: Fri Sep 25 13:21:29 2015 +0800
Quoted 7 lines
virtio: introduce
virtqueue_discard()commit
0cf33fb6b49a19de32859e2cdc6021334f448fb3Author: Jason Wang <[email protected]> Date: Fri Sep 25 13:21:30 2015 +0800virtio-net: correctly drop truncated packets
Thanks, pushed to staging tree now.
Quoted 5 lines
Thanks,
Cole
Quoted 7 lines · Cole Robinson
Quoted 6 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.4.1:
Quoted 8 lines
Quoted 7 lines
The release is planned for 2015-11-03:
http://wiki.qemu.org/Planning/2.4
Please respond here or CC [email protected] on any patches you think should be included in the release.
Another potential:
commit 98cf48f60aa4999f5b2808569a193a401a390e6a
Author: Paolo Bonzini <[email protected]> Date: Wed Sep 16 17:38:44 2015 +0200
trace: remove malloc tracing
Prevents qemu from dropping this stderr warning with latest glib:
(process:23283): GLib-WARNING **: gmem.c:482: custom memory allocation vtable not supported
Not sure if it meets the stable criteria, but the error is annoying and I'll be adding that patch to the fedora builds
Thanks,
Cole
I'm afraid
2d0583f qmp: Fix device-list-properties not to crash for abstract device 2874c65 qdev: Protect device-list-properties against broken devices 55b4efb Revert "qdev: Use qdev_get_device_class() for -device <type>,help"
unmask a bunch of device model bugs, so you need to pick their fixes, too:
ac98fa8 update-linux-headers: Rename SW_MAX to SW_MAX_ c6047e9 virtio-input: Fix device introspection on non-Linux hosts 2e2b8eb memory: allow destroying a non-empty MemoryRegion 81e0ab4 hw: do not pass NULL to memory_region_init from instance_init c710440 macio: move DBDMA_init from instance_init to realize
To check everything's sane, you can pick
e253c28 tests: Fix how qom-test is run
5fb48d9 libqtest: New hmp() & friends
2d1abb8 device-introspect-test: New, covering device introspection
and run make check.
I apologize for not communicating this better in the commit messages.
Quoting Markus Armbruster (2015-10-22 03:01:32)
Quoted 17 lines
I'm afraid
2d0583f qmp: Fix device-list-properties not to crash for abstract device 2874c65 qdev: Protect device-list-properties against broken devices 55b4efb Revert "qdev: Use
qdev_get_device_class()for -device <type>,help"unmask a bunch of device model bugs, so you need to pick their fixes, too:
ac98fa8 update-linux-headers: Rename
SW_MAXtoSW_MAX_c6047e9 virtio-input: Fix device introspection on non-Linux hosts 2e2b8eb memory: allow destroying a non-empty MemoryRegion 81e0ab4 hw: do not pass NULL tomemory_region_initfrominstance_initc710440 macio: moveDBDMA_initfrominstance_initto realizeTo check everything's sane, you can pick
Quoted 8 lines
e253c28 tests: Fix how qom-test is run
5fb48d9 libqtest: Newhmp()& friends
2d1abb8 device-introspect-test: New, covering device introspectionand run make check.
I apologize for not communicating this better in the commit messages.
Thanks for the heads up, all suggested patches applied and passing unit test.
Quoted 107 lines · Michael Roth
Hi everyone,
The following new patches are queued for QEMU stable v2.4.1:
https://github.com/mdroth/qemu/commits/stable-2.4-staging
The release is planned for 2015-11-03:
http://wiki.qemu.org/Planning/2.4Please respond here or CC [email protected] on any patches you think should be included in the release.
Testing/feedback is greatly appreciated.
Thanks!
----------------------------------------------------------------
Alberto Garcia (1):
gtk: usesetlocale()forLC_MESSAGESonlyAlexander Graf (1):
PPC: E500: Update u-boot to commit 79c884d7e4Aníbal Limón (1):
cpus.c:qemu_mutex_lock_iothreadfix race condition at cpu thread initAurelien Jarno (2):
target-ppc: fix vcipher, vcipherlast, vncipherlast and vpermxor
target-ppc: fix xscmpodp and xscmpudp decodingChristian Borntraeger (1):
s390x/kvm: Fix vector validity bit in device machine checksCornelia Huck (2):
s390x/css: start with cleared cstat/dstat
virtio: avoid leading underscores for helpersDr. David Alan Gilbert (1):
Migration: Generate the completed event only when we completeFam Zheng (2):
scsi-disk: Fix assertion failure on WRITE SAME
vmxnet3: Drop net_vmxnet3_info.can_receiveGerd Hoffmann (1):
virtio-input: ignore events until the guest driver is readyGonglei (1):
vhost-scsi: fix wrong vhost-scsi firmware pathJames Hogan (1):
tcg/mips: Fix clobbering ofqemu_ldinputsJason Wang (1):
virtio-net: unbreak self announcement and guest offloads after migrationJohn Snow (2):
ide: fix ATAPI command permissions
ide: unifyio_buffer_offsetincrementsKevin Wolf (1):
mirror: Fix coroutine reentranceMark Cave-Ayland (1):
mac_dbdma: always clear FLUSH bit once DBDMA channel flush is completeMarkus Armbruster (5):
qom: Do not reuse errp after a possible error
qom: Fix invalid error check inproperty_get_str()
qmp: Fix device-list-properties not to crash for abstract device
qdev: Protect device-list-properties against broken devices Revert "qdev: Useqdev_get_device_class()for -device <type>,help"Max Reitz (2):
qemu-img: Fix crash in amend invocation
qcow2: Makesize_to_clusters()returnuint64_tMichael Roth (1):
spapr_pci: fix device tree props for MSI/MSI-XMichael S. Tsirkin (1):
scripts/dump-guest-memory.py: fix after RAMBlock changePeter Crosthwaite (2):
exec-all: Translate TCI return addresses backwards too
misc:zynq_slcr: Fix MMIO writesPeter Lieven (2):
block/iscsi: validate block size returned from target block/nfs: fix calculation of allocated file sizePeter Maydell (1):
target-arm/arm-semi.c: Fix brokenSYS_WRITE0via gdbPierre Morel (1):
virtio dataplane: adapt dataplane for virtio Version 1Richard Henderson (1):
target-arm: Share all common TCG temporariesStefan Weil (1):
slirp: Fix non blocking connect for w32Tony Krowiak (1):
util/qemu-config: fix missing machine command line options
Quoted 6 lines
Vladislav Yasevich (2):
rtl8139: Fix receive buffer overflow check
rtl8139: Do not consume the packet during overflow in standard mode.Wen Congyang (1):
nbd: release exp->blk after all clients are closed
pls consider this:
[PATCH 4/4] migration: add missed aio_context_acquire into HMP snapshot code [PULL 08/12] virtio: sync the dataplane vring state to the virtqueue before virtio_save
Den