Patch Round-up for stable 1.2.2, freeze Wednesday
Hi everyone,
The following new patches are queued for QEMU stable v1.2.2:
https://github.com/mdroth/qemu/commits/stable-1.2-staging
The release is planned for Tuesday, 12-11-2012:
http://wiki.qemu.org/Planning/1.2
Please CC [email protected] on any patches you think should be included in the release. The cut-off date is 12-05-2012 for new patches.
Testing/feedback is greatly appreciated.
Thanks!
e1a0ffb e1000: Discard packets that are too long if !SBP and !LPE (Michael Contreras) 178ef3a stream: fix ratelimit_set_speed (Dietmar Maurer)
cd00334 usb: fail usbdevice_create() when there is no USB bus (Stefan Hajnoczi) 8c9283c qxl: reload memslots after migration, when qxl is in UNDEFINED mode (Yonit Halperin) bf47da4 virtio-scsi: Fix subtle (guest) endian bug (David Gibson)
ea08f3a virtio-scsi: Fix some endian bugs with virtio-scsi (David Gibson) cef2566 iscsi: do not assume device is zero initialized (Peter Lieven)
707f2b6 iscsi: fix deadlock during login (Peter Lieven)
972a2bf iscsi: fix segfault in url parsing (Peter Lieven)
ffffff0 qapi: fix qapi_dealloc_type_size parameter type (Bruce Rogers)
54c6c5a qapi: handle visitor->type_size() in QapiDeallocVisitor (Stefan Hajnoczi) f05a3da qom: fix refcount of non-heap-allocated objects (Paolo Bonzini)
0aad8f1 PPC: Fix missing TRACE exception (Julio Guerra)
a99cb0d hmp: do not crash on invalid SCSI hotplug (Paolo Bonzini)
5e19e49 qom: dynamic_cast of NULL is always NULL (Paolo Bonzini)
4fb9656 block: Fix regression for MinGW (assertion caused by short string) (Stefan Weil) 38c6d17 tci: Fix type of tci_read_label (Richard Henderson)
600a9ef qcow2: Fix refcount table size calculation (Kevin Wolf)
ea79e15 configure: avoid compiler warning in pipe2 detection (Bruce Rogers) 4a8e490 target-openrisc: remove conflicting definitions from cpu.h (Aurelien Jarno) ede76ed tcg/arm: fix cross-endian qemu_st16 (Aurelien Jarno)
ac914c1 tcg/arm: fix TLB access in qemu-ld/st ops (Aurelien Jarno)
357414d target-mips: fix wrong microMIPS opcode encoding (陳韋任 (Wei-Ren Chen)) f6b803d mips/malta: fix CBUS UART interrupt pin (Aurelien Jarno)
879c264 nbd: fixes to read-only handling (Paolo Bonzini)
382a582 m68k: Return semihosting errno values correctly (Meador Inge)
5c0d5ae tools: initialize main loop before block layer (Paolo Bonzini)
3dd59b4 xhci: fix usb name in caps (Gerd Hoffmann)
03e0441 target-sparc64: disable VGA cirrus (Aurelien Jarno)
db6e5ab PPC: Bamboo: Fix memory size DT property (Alexander Graf)
7817b8d s390x: fix -initrd in virtio machine (Alexander Graf)
0dfd821 memory: fix rendering of a region obscured by another (Avi Kivity) e16d81d e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty (Dmitry Fleytman) 3dfbc51 target-i386: Allow tsc-frequency to be larger then 2.147G (Don Slutz) eb63b0c hw: Fix return value check for bdrv_read, bdrv_write (Stefan Weil) 4843c92 rtc: fix overflow in mktimegm (Paolo Bonzini)
a106eaa qxl: always update displaysurface on resize (Gerd Hoffmann)
472da83 hw/qxl: qxl_dirty_surfaces: use uintptr_t (Alon Levy)
85c91ea uhci: Raise interrupt when requested even for non active tds (Hans de Goede) 5af7caa vnc: fix "info vnc" with "-vnc ..., reverse=on" (Paolo Bonzini)
0ae18b3 ui/vnc: Only report/use TIGHT_PNG encoding if enabled. (Joel Martin) 5a99c8c fix CONFIG_QEMU_HELPERDIR generation again (Michael Tokarev)
029eae1 configure: Fix CONFIG_QEMU_HELPERDIR generation (Jan Kiszka)
block.c | 3 +- block/iscsi.c | 260 +++++++++++------------------------ block/qcow2-refcount.c | 3 +- configure | 5 +- cutils.c | 2 +- default-configs/sparc64-softmmu.mak | 1 - hw/e1000.c | 17 ++- hw/mips_malta.c | 3 +- hw/nand.c | 34 +++-- hw/onenand.c | 2 +- hw/pci-hotplug.c | 8 +- hw/ppc440_bamboo.c | 2 +- hw/qxl-render.c | 4 - hw/qxl.c | 5 +- hw/s390-virtio.c | 4 +- hw/sd.c | 16 ++- hw/usb/bus.c | 7 + hw/usb/hcd-uhci.c | 10 +- hw/usb/hcd-xhci.c | 4 +- hw/virtio-scsi.c | 12 +- include/qemu/ratelimit.h | 2 +- memory.c | 12 +- nbd.c | 25 ++-- qapi/qapi-dealloc-visitor.c | 6 + qemu-img.c | 3 +- qemu-io.c | 3 +- qom/object.c | 6 +- target-i386/cpu.c | 2 +- target-m68k/m68k-semi.c | 2 +- target-mips/translate.c | 2 +- target-openrisc/cpu.h | 18 --- target-ppc/translate.c | 3 +- tcg/arm/tcg-target.c | 98 ++++++++----- tci.c | 4 +- tests/rtc-test.c | 45 ++++++ ui/vnc.c | 6 + 36 files changed, 316 insertions(+), 323 deletions(-)
PATCH 1/43 configure: Fix CONFIG_QEMU_HELPERDIR generation
From: Jan Kiszka <[email protected]>
We need to evaluate $libexecdir in configure, otherwise we literally end up with "${prefix}/libexec" instead of the absolute path as CONFIG_QEMU_HELPERDIR.
Conflicts:
configure
--- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
@@ -3191,7 +3191,7 @@ echo "sysconfdir=$sysconfdir" >> $config_host_mak echo "qemu_confdir=$qemu_confdir" >> $config_host_mak echo "qemu_datadir=$qemu_datadir" >> $config_host_mak echo "qemu_docdir=$qemu_docdir" >> $config_host_mak -echo "CONFIG_QEMU_HELPERDIR=\"$libexecdir\"" >> $config_host_mak +echo "CONFIG_QEMU_HELPERDIR=\"`eval echo $libexecdir`\"" >> $config_host_mak echo "ARCH=$ARCH" >> $config_host_mak if test "$debug_tcg" = "yes" ; then
Signature · 1 line
1.7.9.5
PATCH 2/43 fix CONFIG_QEMU_HELPERDIR generation again
In reply to Michael RothFrom: Michael Tokarev <[email protected]>
commit 38f419f35225 fixed a breakage with CONFIG_QEMU_HELPERDIR which has been introduced by 8bf188aa18ef7a8. But while techinically that fix has been correct, all other similar variables are handled differently. Make it consistent, and let scripts/create_config expand and capitalize the variable properly like for all other qemu_*dir variables.
Conflicts:
configure
--- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
@@ -3191,7 +3191,7 @@ echo "sysconfdir=$sysconfdir" >> $config_host_mak echo "qemu_confdir=$qemu_confdir" >> $config_host_mak echo "qemu_datadir=$qemu_datadir" >> $config_host_mak echo "qemu_docdir=$qemu_docdir" >> $config_host_mak -echo "CONFIG_QEMU_HELPERDIR=\"`eval echo $libexecdir`\"" >> $config_host_mak +echo "qemu_helperdir=$libexecdir" >> $config_host_mak echo "ARCH=$ARCH" >> $config_host_mak if test "$debug_tcg" = "yes" ; then
Signature · 1 line
1.7.9.5
PATCH 3/43 ui/vnc: Only report/use TIGHT_PNG encoding if enabled.
In reply to Michael RothFrom: Joel Martin <[email protected]>
If TIGHT_PNG is not enabled by the --enable-vnc-png configure flag then do not report to the client that it is supported.
Also, since TIGHT_PNG is the same as the TIGHT encoding but with the filter/copy replaced with PNG data, adding it to the supported encodings list when it is disabled will cause the TIGHT encoding to be used even though the client requested TIGHT_PNG.
--- ui/vnc.c | 2 ++ 1 file changed, 2 insertions(+)
ui/vnc.c +2 -0
@@ -1802,10 +1802,12 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) vs->features |=VNC_FEATURE_TIGHT_MASK ; vs->vnc_encoding = enc;break ; +#ifdef CONFIG_VNC_PNG case VNC_ENCODING_TIGHT_PNG : vs->features |=VNC_FEATURE_TIGHT_PNG_MASK ; vs->vnc_encoding = enc;break ; +#endif case VNC_ENCODING_ZLIB : vs->features |=VNC_FEATURE_ZLIB_MASK ; vs->vnc_encoding = enc;
Signature · 1 line
1.7.9.5
PATCH 4/43 vnc: fix "info vnc" with "-vnc ..., reverse=on"
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
When reverse connection is in use, there is no active VNC server socket. Because of this, getsockopt(-1, ...) is attempted and the following error is emitted:
$ socat TCP-LISTEN:5900,reuseaddr TCP-LISTEN:5901,reuseaddr &
$ x86_64-softmmu/qemu-system-x86_64 -vnc localhost:5900,reverse -monitor stdio
QEMU 1.2.50 monitor - type 'help' for more information
(qemu) info vnc
An undefined error has occurredBecause however the host, family, service and auth fields are optional, we can just exit if there is no active server socket.
$ x86_64-softmmu/qemu-system-x86_64 -vnc localhost:5900,reverse -monitor stdio
QEMU 1.2.50 monitor - type 'help' for more information
(qemu) info vnc
Server:
Client:
address: 127.0.0.1:5900
x509_dname: none
username: none--- ui/vnc.c | 4 ++++ 1 file changed, 4 insertions(+)
ui/vnc.c +4 -0
@@ -372,6 +372,10 @@ VncInfo *qmp_query_vnc(Error **errp) } } +if (vnc_display->lsock ==-1 ) { +return info; + } +if (getsockname (vnc_display->lsock, (struct sockaddr *)&sa, &salen) ==-1 ) {error_set (errp,QERR_UNDEFINED_ERROR );
Signature · 1 line
1.7.9.5
PATCH 5/43 uhci: Raise interrupt when requested even for non active tds
In reply to Michael RothFrom: Hans de Goede <[email protected]>
According to the spec we must raise an interrupt when one is requested even for non active tds.
Linux depends on this, for bulk transfers it runs an inactivity timer to work around a bug in early uhci revisions, when we take longer then 200 ms to process a packet, this timer goes of, and as part of the handling Linux then unlinks the qh, and relinks it after the frindex has increased by atleast 1, the problem is Linux only checks for the frindex increases on an interrupt, and we don't send that, causing the qh to go inactive for more then 32 frames, at which point we consider the packet cancelled.
--- hw/usb/hcd-uhci.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
hw/usb/hcd-uhci.c +9 -1
@@ -826,8 +826,16 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td,USBEndpoint *ep;/* Is active ? */ -if (!(td->ctrl &TD_CTRL_ACTIVE )) +if (!(td->ctrl &TD_CTRL_ACTIVE )) { +/* +* ehci11d spec page 22: "Even if the Active bit in the TD is already +* cleared when the TD is fetched ... an IOC interrupt is generated" +*/ +if (td->ctrl &TD_CTRL_IOC ) { + *int_mask |=0x01 ; + }return TD_RESULT_NEXT_QH ; + } async =uhci_async_find_td (s, addr, td);if (async) {
Signature · 1 line
1.7.9.5
PATCH 6/43 hw/qxl: qxl_dirty_surfaces: use uintptr_t
In reply to Michael RothFrom: Alon Levy <[email protected]>
As suggested by Paolo Bonzini, to avoid possible integer overflow issues.
--- hw/qxl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/qxl.c +2 -2
@@ -1703,7 +1703,7 @@ static void qxl_hw_text_update(void *opaque, console_ch_t *chardata)static void qxl_dirty_surfaces (PCIQXLDevice *qxl) { -intptr_t vram_start; +uintptr_t vram_start;int i;if (qxl->mode !=QXL_MODE_NATIVE && qxl->mode !=QXL_MODE_COMPAT ) {
@@ -1714,7 +1714,7 @@ static void qxl_dirty_surfaces(PCIQXLDevice *qxl)qxl_set_dirty (&qxl->vga.vram, qxl->shadow_rom.draw_area_offset, qxl->shadow_rom.surface0_area_size); - vram_start = (intptr_t )memory_region_get_ram_ptr (&qxl->vram_bar); + vram_start = (uintptr_t )memory_region_get_ram_ptr (&qxl->vram_bar);/* dirty the off-screen surfaces */ for (i =0 ; i <NUM_SURFACES ; i++) {
Signature · 1 line
1.7.9.5
PATCH 7/43 qxl: always update displaysurface on resize
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
Don't try to be clever and skip displaysurface reinitialization in case the size hasn't changed. Other parameters might have changed nevertheless, for example depth or stride, resulting in rendering being broken then.
Trigger: boot linux guest with vesafb, start X11, make sure both vesafb and X11 use the display same resolution. Then watch X11 screen being upside down.
--- hw/qxl-render.c | 4 ---- 1 file changed, 4 deletions(-)
hw/qxl-render.c +0 -4
@@ -99,7 +99,6 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl) {VGACommonState *vga = &qxl->vga;int i; -DisplaySurface *surface = vga->ds->surface;if (qxl->guest_primary.resized) { qxl->guest_primary.resized =0 ;
@@ -112,9 +111,6 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl) qxl->guest_primary.qxl_stride, qxl->guest_primary.bytes_pp, qxl->guest_primary.bits_pp); - } -if (surface->width != qxl->guest_primary.surface.width || - surface->height != qxl->guest_primary.surface.height) {if (qxl->guest_primary.qxl_stride >0 ) {qemu_free_displaysurface (vga->ds); qemu_create_displaysurface_from(qxl->guest_primary.surface.width,
Signature · 1 line
1.7.9.5
PATCH 8/43 rtc: fix overflow in mktimegm
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
When setting a date in 1980, Linux is actually disregarding the century byte and setting the year to 2080. This causes a year-2038 overflow in mktimegm. Fix this by doing the days-to-seconds computation in 64-bit math.
--- cutils.c | 2 +- tests/rtc-test.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-)
cutils.c +1 -1
@@ -115,7 +115,7 @@ time_t mktimegm(struct tm *tm) m +=12 ; y--; } - t =86400 * (d + (153 * m -457 ) /5 +365 * y + y /4 - y /100 + + t =86400ULL * (d + (153 * m -457 ) /5 +365 * y + y /4 - y /100 + y /400 -719469 ); t +=3600 * tm->tm_hour +60 * tm->tm_min + tm->tm_sec;return t;
tests/rtc-test.c +45 -0
57 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 9/43 hw: Fix return value check for bdrv_read, bdrv_write
In reply to Michael RothFrom: Stefan Weil <[email protected]>
Those functions return -errno in case of an error. The old code would typically only detect EPERM (1) errors.
--- hw/nand.c | 34 ++++++++++++++++++++++------------ hw/onenand.c | 2 +- hw/sd.c | 16 +++++++++------- 3 files changed, 32 insertions(+), 20 deletions(-)
hw/nand.c +22 -12
@@ -654,7 +654,7 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s) sector =SECTOR (s->addr); off = (s->addr &PAGE_MASK ) + s->offset; soff =SECTOR_OFFSET (s->addr); -if (bdrv_read (s->bdrv, sector, iobuf,PAGE_SECTORS ) ==-1 ) { +if (bdrv_read (s->bdrv, sector, iobuf,PAGE_SECTORS ) <0 ) {printf ("%s: read error in sector %" PRIu64"\n" , __func__, sector);return ; }
@@ -666,21 +666,23 @@ static void glue(nand_blk_write_, PAGE_SIZE)(NANDFlashState *s) MIN(OOB_SIZE, off + s->iolen - PAGE_SIZE)); } -if (bdrv_write (s->bdrv, sector, iobuf,PAGE_SECTORS ) ==-1 ) +if (bdrv_write (s->bdrv, sector, iobuf,PAGE_SECTORS ) <0 ) {printf ("%s: write error in sector %" PRIu64"\n" , __func__, sector); + } }else { off =PAGE_START (s->addr) + (s->addr &PAGE_MASK ) + s->offset; sector = off >>9 ; soff = off &0x1ff ; -if (bdrv_read (s->bdrv, sector, iobuf,PAGE_SECTORS +2 ) ==-1 ) { +if (bdrv_read (s->bdrv, sector, iobuf,PAGE_SECTORS +2 ) <0 ) {printf ("%s: read error in sector %" PRIu64"\n" , __func__, sector);return ; }mem_and (iobuf + soff, s->io, s->iolen); -if (bdrv_write (s->bdrv, sector, iobuf,PAGE_SECTORS +2 ) ==-1 ) +if (bdrv_write (s->bdrv, sector, iobuf,PAGE_SECTORS +2 ) <0 ) {printf ("%s: write error in sector %" PRIu64"\n" , __func__, sector); + } } s->offset =0 ; }
@@ -704,31 +706,37 @@ static void glue(nand_blk_erase_, PAGE_SIZE)(NANDFlashState *s) i =SECTOR (addr); page =SECTOR (addr + (ADDR_SHIFT + s->erase_shift));for (; i < page; i ++) -if (bdrv_write (s->bdrv, i, iobuf,1 ) ==-1 ) +if (bdrv_write (s->bdrv, i, iobuf,1 ) <0 ) {printf ("%s: write error in sector %" PRIu64"\n" , __func__, i); + } }else { addr =PAGE_START (addr); page = addr >>9 ; -if (bdrv_read (s->bdrv, page, iobuf,1 ) ==-1 ) +if (bdrv_read (s->bdrv, page, iobuf,1 ) <0 ) {printf ("%s: read error in sector %" PRIu64"\n" , __func__, page); + }memset (iobuf + (addr &0x1ff ),0xff , (~addr &0x1ff ) +1 ); -if (bdrv_write (s->bdrv, page, iobuf,1 ) ==-1 ) +if (bdrv_write (s->bdrv, page, iobuf,1 ) <0 ) {printf ("%s: write error in sector %" PRIu64"\n" , __func__, page); + }memset (iobuf,0xff ,0x200 ); i = (addr & ~0x1ff ) +0x200 ;for (addr += ((PAGE_SIZE +OOB_SIZE ) << s->erase_shift) -0x200 ; i < addr; i +=0x200 ) -if (bdrv_write (s->bdrv, i >>9 , iobuf,1 ) ==-1 ) +if (bdrv_write (s->bdrv, i >>9 , iobuf,1 ) <0 ) {printf ("%s: write error in sector %" PRIu64"\n" , __func__, i >>9 ); + } page = i >>9 ; -if (bdrv_read (s->bdrv, page, iobuf,1 ) ==-1 ) +if (bdrv_read (s->bdrv, page, iobuf,1 ) <0 ) {printf ("%s: read error in sector %" PRIu64"\n" , __func__, page); + }memset (iobuf,0xff , ((addr -1 ) &0x1ff ) +1 ); -if (bdrv_write (s->bdrv, page, iobuf,1 ) ==-1 ) +if (bdrv_write (s->bdrv, page, iobuf,1 ) <0 ) {printf ("%s: write error in sector %" PRIu64"\n" , __func__, page); + } } }
@@ -740,18 +748,20 @@ static void glue(nand_blk_load_, PAGE_SIZE)(NANDFlashState *s,if (s->bdrv) {if (s->mem_oob) { -if (bdrv_read (s->bdrv,SECTOR (addr), s->io,PAGE_SECTORS ) ==-1 ) +if (bdrv_read (s->bdrv,SECTOR (addr), s->io,PAGE_SECTORS ) <0 ) {printf ("%s: read error in sector %" PRIu64"\n" , __func__,SECTOR (addr)); + }memcpy (s->io +SECTOR_OFFSET (s->addr) +PAGE_SIZE , s->storage + (PAGE (s->addr) <<OOB_SHIFT ),OOB_SIZE ); s->ioaddr = s->io +SECTOR_OFFSET (s->addr) + offset; }else {if (bdrv_read (s->bdrv,PAGE_START (addr) >>9 , - s->io, (PAGE_SECTORS +2 )) ==-1 ) + s->io, (PAGE_SECTORS +2 )) <0 ) {printf ("%s: read error in sector %" PRIu64"\n" , __func__,PAGE_START (addr) >>9 ); + } s->ioaddr = s->io + (PAGE_START (addr) &0x1ff ) + offset; } }else {
hw/onenand.c +1 -1
@@ -351,7 +351,7 @@ static inline int onenand_erase(OneNANDState *s, int sec, int num)for (; num >0 ; num--, sec++) {if (s->bdrv_cur) {int erasesec = s->secs_cur + (sec >>5 ); -if (bdrv_write (s->bdrv_cur, sec, blankbuf,1 )) { +if (bdrv_write (s->bdrv_cur, sec, blankbuf,1 ) <0 ) { goto fail; }if (bdrv_read (s->bdrv_cur, erasesec, tmpbuf,1 ) <0 ) {
hw/sd.c +9 -7
@@ -1407,7 +1407,7 @@ static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len)DPRINTF ("sd_blk_read: addr = 0x%08llx, len = %d\n" , (unsigned long long ) addr, len); -if (!sd->bdrv ||bdrv_read (sd->bdrv, addr >>9 , sd->buf,1 ) ==-1 ) { +if (!sd->bdrv ||bdrv_read (sd->bdrv, addr >>9 , sd->buf,1 ) <0 ) {fprintf (stderr,"sd_blk_read: read error on host side\n" );return ; }
@@ -1415,7 +1415,7 @@ static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len)if (end > (addr & ~511 ) +512 ) {memcpy (sd->data, sd->buf + (addr &511 ),512 - (addr &511 )); -if (bdrv_read (sd->bdrv, end >>9 , sd->buf,1 ) ==-1 ) { +if (bdrv_read (sd->bdrv, end >>9 , sd->buf,1 ) <0 ) {fprintf (stderr,"sd_blk_read: read error on host side\n" );return ; }
@@ -1429,29 +1429,31 @@ static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len)uint64_t end = addr + len;if ((addr &511 ) || len <512 ) -if (!sd->bdrv ||bdrv_read (sd->bdrv, addr >>9 , sd->buf,1 ) ==-1 ) { +if (!sd->bdrv ||bdrv_read (sd->bdrv, addr >>9 , sd->buf,1 ) <0 ) {fprintf (stderr,"sd_blk_write: read error on host side\n" );return ; }if (end > (addr & ~511 ) +512 ) {memcpy (sd->buf + (addr &511 ), sd->data,512 - (addr &511 )); -if (bdrv_write (sd->bdrv, addr >>9 , sd->buf,1 ) ==-1 ) { +if (bdrv_write (sd->bdrv, addr >>9 , sd->buf,1 ) <0 ) {fprintf (stderr,"sd_blk_write: write error on host side\n" );return ; } -if (bdrv_read (sd->bdrv, end >>9 , sd->buf,1 ) ==-1 ) { +if (bdrv_read (sd->bdrv, end >>9 , sd->buf,1 ) <0 ) {fprintf (stderr,"sd_blk_write: read error on host side\n" );return ; }memcpy (sd->buf, sd->data +512 - (addr &511 ), end &511 ); -if (bdrv_write (sd->bdrv, end >>9 , sd->buf,1 ) ==-1 ) +if (bdrv_write (sd->bdrv, end >>9 , sd->buf,1 ) <0 ) {fprintf (stderr,"sd_blk_write: write error on host side\n" ); + } }else {memcpy (sd->buf + (addr &511 ), sd->data, len); -if (!sd->bdrv ||bdrv_write (sd->bdrv, addr >>9 , sd->buf,1 ) ==-1 ) +if (!sd->bdrv ||bdrv_write (sd->bdrv, addr >>9 , sd->buf,1 ) <0 ) {fprintf (stderr,"sd_blk_write: write error on host side\n" ); + } } }
Signature · 1 line
1.7.9.5
PATCH 10/43 target-i386: Allow tsc-frequency to be larger then 2.147G
In reply to Michael RothFrom: Don Slutz <[email protected]>
The check using INT_MAX (2147483647) is wrong in this case.
--- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-i386/cpu.c +1 -1
@@ -846,7 +846,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, {X86CPU *cpu =X86_CPU (obj);const int64_t min =0 ; -const int64_t max =INT_MAX ; +const int64_t max =INT64_MAX ;int64_t value;visit_type_int (v, &value, name, errp);
Signature · 1 line
1.7.9.5
PATCH 11/43 e1000: drop check_rxov, always treat RX ring with RDH == RDT as empty
In reply to Michael RothFrom: Dmitry Fleytman <[email protected]>
Real HW always treats RX ring with RDH == RDT as empty. Emulation is supposed to behave the same.
--- hw/e1000.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
hw/e1000.c +2 -5
@@ -92,7 +92,6 @@ typedef struct E1000State_st {uint32_t rxbuf_size;uint32_t rxbuf_min_shift; -int check_rxov;struct e1000_tx {unsigned char header[256 ];unsigned char vlan_header[4 ];
@@ -741,11 +740,11 @@ static bool e1000_has_rxbufs(E1000State *s, size_t total_size)int bufs;/* Fast-path short packets */ if (total_size <= s->rxbuf_size) { -return s->mac_reg[RDH ] != s->mac_reg[RDT ] || !s->check_rxov; +return s->mac_reg[RDH ] != s->mac_reg[RDT ]; }if (s->mac_reg[RDH ] < s->mac_reg[RDT ]) { bufs = s->mac_reg[RDT ] - s->mac_reg[RDH ]; - }else if (s->mac_reg[RDH ] > s->mac_reg[RDT ] || !s->check_rxov) { + }else if (s->mac_reg[RDH ] > s->mac_reg[RDT ]) { bufs = s->mac_reg[RDLEN ] /sizeof (struct e1000_rx_desc ) + s->mac_reg[RDT ] - s->mac_reg[RDH ]; }else {
@@ -848,7 +847,6 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size)if (++s->mac_reg[RDH ] *sizeof (desc) >= s->mac_reg[RDLEN ]) s->mac_reg[RDH ] =0 ; - s->check_rxov =1 ;/* see comment in start_xmit; same here */ if (s->mac_reg[RDH ] == rdh_start) { DBGOUT(RXERR, "RDH wraparound @%x, RDT %x, RDLEN %x\n",
@@ -925,7 +923,6 @@ mac_writereg(E1000State *s, int index, uint32_t val)static void set_rdt (E1000State *s,int index,uint32_t val) { - s->check_rxov =0 ; s->mac_reg[index] = val &0xffff ;if (e1000_has_rxbufs (s,1 )) {qemu_flush_queued_packets (&s->nic->nc);
Signature · 1 line
1.7.9.5
PATCH 12/43 memory: fix rendering of a region obscured by another
In reply to Michael RothFrom: Avi Kivity <[email protected]>
The memory core drops regions that are hidden by another region (for example, during BAR sizing), but it doesn't do so correctly if the lower address of the existing range is below the lower address of the new range.
Example (qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta
-append "console=ttyS0" -nographic -vga cirrus):
Existing range: 10000000-107fffff New range: 100a0000-100bffff
Correct behaviour: drop new range
Incorrect behaviour: add new range
Fix by taking this case into account (previously we only considered equal lower boundaries).
--- memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
memory.c +6 -6
@@ -538,12 +538,12 @@ static void render_memory_region(FlatView *view, offset_in_region +=int128_get64 (now);int128_subfrom (&remain, now); } -if (int128_eq (base, view->ranges[i].addr.start)) { - now =int128_min (remain, view->ranges[i].addr.size); -int128_addto (&base, now); - offset_in_region +=int128_get64 (now); -int128_subfrom (&remain, now); - } + now =int128_sub (int128_min (int128_add (base, remain), +addrrange_end (view->ranges[i].addr)), + base); +int128_addto (&base, now); + offset_in_region +=int128_get64 (now); +int128_subfrom (&remain, now); }if (int128_nz (remain)) { fr.mr = mr;
Signature · 1 line
1.7.9.5
PATCH 13/43 s390x: fix -initrd in virtio machine
In reply to Michael RothFrom: Alexander Graf <[email protected]>
When using -initrd in the virtio machine, we need to indicate the initrd start and size inside the kernel image. These parameters need to be stored in native endianness.
--- hw/s390-virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/s390-virtio.c +2 -2
@@ -284,8 +284,8 @@ static void s390_init(ram_addr_t my_ram_size, }/* we have to overwrite values in the kernel image, which are "rom" */ -memcpy (rom_ptr (INITRD_PARM_START ), &initrd_offset,8 ); -memcpy (rom_ptr (INITRD_PARM_SIZE ), &initrd_size,8 ); +stq_p (rom_ptr (INITRD_PARM_START ), initrd_offset); +stq_p (rom_ptr (INITRD_PARM_SIZE ), initrd_size); }if (rom_ptr (KERN_PARM_AREA )) {
Signature · 1 line
1.7.9.5
PATCH 14/43 PPC: Bamboo: Fix memory size DT property
In reply to Michael RothFrom: Alexander Graf <[email protected]>
Device tree properties need to be specified in big endian. Fix the bamboo memory size property accordingly.
--- hw/ppc440_bamboo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc440_bamboo.c +1 -1
@@ -59,7 +59,7 @@ static int bamboo_load_device_tree(target_phys_addr_t addr, {int ret =-1 ;#ifdef CONFIG_FDT -uint32_t mem_reg_property[] = {0 ,0 , ramsize }; +uint32_t mem_reg_property[] = {0 ,0 ,cpu_to_be32 (ramsize) };char *filename;int fdt_size;void *fdt;
Signature · 1 line
1.7.9.5
PATCH 15/43 target-sparc64: disable VGA cirrus
In reply to Michael RothFrom: Aurelien Jarno <[email protected]>
OpenBIOS on sparc64 only support Standard VGA and not Cirrus VGA. Don't build Cirrus VGA support so that it can't be selected.
This fixes the breakage introduced by commit f2898771.
--- default-configs/sparc64-softmmu.mak | 1 - 1 file changed, 1 deletion(-)
default-configs/sparc64-softmmu.mak +0 -1
@@ -6,7 +6,6 @@ CONFIG_M48T59=y CONFIG_PTIMER=y CONFIG_VGA=y CONFIG_VGA_PCI=y -CONFIG_VGA_CIRRUS=y CONFIG_SERIAL=y CONFIG_PARALLEL=y CONFIG_PCKBD=y
Signature · 1 line
1.7.9.5
PATCH 16/43 xhci: fix usb name in caps
In reply to Michael RothFrom: Gerd Hoffmann <[email protected]>
Used to be "UTB" not "USB".
--- hw/usb/hcd-xhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/usb/hcd-xhci.c +2 -2
@@ -2098,7 +2098,7 @@ static uint32_t xhci_cap_read(XHCIState *xhci, uint32_t reg) ret =0x02000402 ;/* USB 2.0 */ break ;case 0x24 :/* Supported Protocol:04 */ - ret =0x20425455 ;/* "USB " */ + ret =0x20425355 ;/* "USB " */ break ;case 0x28 :/* Supported Protocol:08 */ ret =0x00000001 | (USB2_PORTS <<8 );
@@ -2110,7 +2110,7 @@ static uint32_t xhci_cap_read(XHCIState *xhci, uint32_t reg) ret =0x03000002 ;/* USB 3.0 */ break ;case 0x34 :/* Supported Protocol:04 */ - ret =0x20425455 ;/* "USB " */ + ret =0x20425355 ;/* "USB " */ break ;case 0x38 :/* Supported Protocol:08 */ ret =0x00000000 | (USB2_PORTS +1 ) | (USB3_PORTS <<8 );
Signature · 1 line
1.7.9.5
PATCH 17/43 tools: initialize main loop before block layer
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Tools were broken because they initialized the block layer while qemu_aio_context was still NULL.
--- qemu-img.c | 3 +-- qemu-io.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
qemu-img.c +1 -2
@@ -1698,14 +1698,13 @@ int main(int argc, char **argv)error_set_progname (argv[0 ]); +qemu_init_main_loop ();bdrv_init ();if (argc <2 )help (); cmdname = argv[1 ]; argc--; argv++; -qemu_init_main_loop (); -/* find the command */ for (cmd = img_cmds; cmd->name !=NULL ; cmd++) {if (!strcmp (cmdname, cmd->name)) {
qemu-io.c +1 -2
@@ -1892,9 +1892,8 @@ int main(int argc, char **argv)exit (1 ); } -bdrv_init (); -qemu_init_main_loop (); +bdrv_init ();/* initialize commands */ quit_init ();
Signature · 1 line
1.7.9.5
PATCH 18/43 m68k: Return semihosting errno values correctly
In reply to Michael RothFrom: Meador Inge <[email protected]>
Fixing a simple typo, s/errno/err/, that caused the error status from GDB semihosted system calls to be returned incorrectly.
--- target-m68k/m68k-semi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-m68k/m68k-semi.c +1 -1
@@ -150,7 +150,7 @@ static void m68k_semi_cb(CPUM68KState *env, target_ulong ret, target_ulong err) }/* FIXME - handle put_user() failure */ put_user_u32 (ret, args); -put_user_u32 (errno, args +4 ); +put_user_u32 (err, args +4 ); }#define ARG (n) \
Signature · 1 line
1.7.9.5
PATCH 19/43 nbd: fixes to read-only handling
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
We do not need BLKROSET if the kernel supports setting flags. Also, always do BLKROSET even for a read-write export, otherwise the read-only state remains "sticky" after the invocation of "qemu-nbd -r".
--- nbd.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
nbd.c +12 -13
@@ -399,24 +399,23 @@ int nbd_init(int fd, int csock, uint32_t flags, off_t size, size_t blocksize)return -serrno; } -if (flags &NBD_FLAG_READ_ONLY ) { -int read_only =1 ; -TRACE ("Setting readonly attribute" ); - -if (ioctl (fd,BLKROSET , (unsigned long ) &read_only) <0 ) { +if (ioctl (fd,NBD_SET_FLAGS , flags) <0 ) { +if (errno ==ENOTTY ) { +int read_only = (flags &NBD_FLAG_READ_ONLY ) !=0 ; +TRACE ("Setting readonly attribute" ); + +if (ioctl (fd,BLKROSET , (unsigned long ) &read_only) <0 ) { +int serrno = errno; +LOG ("Failed setting read-only attribute" ); +return -serrno; + } + }else {int serrno = errno; -LOG ("Failed setting read-only attribute" ); +LOG ("Failed setting flags" );return -serrno; } } -if (ioctl (fd,NBD_SET_FLAGS , flags) <0 - && errno !=ENOTTY ) { -int serrno = errno; -LOG ("Failed setting flags" ); -return -serrno; - } -TRACE ("Negotiation ended" );return 0 ;
Signature · 1 line
1.7.9.5
PATCH 20/43 mips/malta: fix CBUS UART interrupt pin
In reply to Michael RothFrom: Aurelien Jarno <[email protected]>
According to the MIPS Malta Developement Platform User's Manual, the i8259 interrupt controller is supposed to be connected to the hardware IRQ0, and the CBUS UART to the hardware interrupt 2.
In QEMU they are both connected to hardware interrupt 0, the CBUS UART interrupt being wrong. This patch fixes that. It should be noted that the irq array in QEMU includes the software interrupts, hence env->irq[2] is the first hardware interrupt.
--- hw/mips_malta.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/mips_malta.c +2 -1
@@ -860,7 +860,8 @@ void mips_malta_init (ram_addr_t ram_size, be =0 ;#endif /* FPGA */ -malta_fpga_init (system_memory,FPGA_ADDRESS , env->irq[2 ], serial_hds[2 ]); +/* The CBUS UART is attached to the MIPS CPU INT2 pin, ie interrupt 4 */ +malta_fpga_init (system_memory,FPGA_ADDRESS , env->irq[4 ], serial_hds[2 ]);/* Load firmware in flash / BIOS. */ dinfo =drive_get (IF_PFLASH ,0 , fl_idx);
Signature · 1 line
1.7.9.5
PATCH 21/43 target-mips: fix wrong microMIPS opcode encoding
In reply to Michael RothFrom: "陳韋任 (Wei-Ren Chen)" <[email protected]>
While reading microMIPS decoding, I found a possible wrong opcode encoding. According to [1] page 166, the bits 13..12 for MULTU is 0x01 rather than 0x00. Please review, thanks.
[1] MIPS Architecture for Programmers VolumeIV-e: The MIPS DSP Application-Specific Extension to the microMIPS32 Architecture
--- target-mips/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-mips/translate.c +1 -1
@@ -9486,7 +9486,7 @@ enum {/* bits 13..12 for 0x32 */ MULT_ACC =0x0 , -MULTU_ACC =0x0 , +MULTU_ACC =0x1 ,/* bits 15..12 for 0x2c */ SEB = 0x2,
Signature · 1 line
1.7.9.5
PATCH 22/43 tcg/arm: fix TLB access in qemu-ld/st ops
In reply to Michael RothFrom: Aurelien Jarno <[email protected]>
The TCG arm backend considers likely that the offset to the TLB entries does not exceed 12 bits for mem_index = 0. In practice this is not true for at least the MIPS target.
The current patch fixes that by loading the bits 23-12 with a separate instruction, and using loads with address writeback, independently of the value of mem_idx. In total this allow a 24-bit offset, which is a lot more than needed.
--- tcg/arm/tcg-target.c | 78 +++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 36 deletions(-)
tcg/arm/tcg-target.c +42 -36
@@ -630,6 +630,22 @@ static inline void tcg_out_ld32_12(TCGContext *s, int cond, (rn << 16) | (rd << 12) | ((-im) & 0xfff)); } +/* Offset pre-increment with base writeback. */ +static inline void tcg_out_ld32_12wb (TCGContext *s,int cond, +int rd,int rn,tcg_target_long im) +{ +/* ldr with writeback and both register equals is UNPREDICTABLE */ +assert (rd != rn); + +if (im >=0 ) { +tcg_out32 (s, (cond <<28 ) |0x05b00000 | + (rn <<16 ) | (rd <<12 ) | (im &0xfff )); + }else { +tcg_out32 (s, (cond <<28 ) |0x05300000 | + (rn <<16 ) | (rd <<12 ) | ((-im) &0xfff )); + } +} +static inline void tcg_out_st32_12 (TCGContext *s,int cond,int rd,int rn,tcg_target_long im) {
@@ -1062,7 +1078,7 @@ static inline void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc) {int addr_reg, data_reg, data_reg2, bswap;#ifdef CONFIG_SOFTMMU -int mem_index, s_bits; +int mem_index, s_bits, tlb_offset;TCGReg argreg;# if TARGET_LONG_BITS ==64 int addr_reg2;
@@ -1102,19 +1118,15 @@ static inline void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc) TCG_REG_R0, TCG_REG_R8, CPU_TLB_SIZE - 1);tcg_out_dat_reg (s,COND_AL ,ARITH_ADD ,TCG_REG_R0 ,TCG_AREG0 ,TCG_REG_R0 ,SHIFT_IMM_LSL (CPU_TLB_ENTRY_BITS )); -/* In the -* ldr r1 [r0, #(offsetof(CPUArchState, tlb_table[mem_index][0].addr_read))] -* below, the offset is likely to exceed 12 bits if mem_index != 0 and -* not exceed otherwise, so use an -* add r0, r0, #(mem_index * sizeof *CPUArchState.tlb_table) -* before. -*/ -if (mem_index) +/* We assume that the offset is contained within 20 bits. */ + tlb_offset = offsetof(CPUArchState, tlb_table[mem_index][0].addr_read); +assert (tlb_offset & ~0xfffff ==0 ); +if (tlb_offset >0xfff ) {tcg_out_dat_imm (s,COND_AL ,ARITH_ADD ,TCG_REG_R0 ,TCG_REG_R0 , - (mem_index << (TLB_SHIFT &1 )) | - ((16 - (TLB_SHIFT >>1 )) <<8 )); -tcg_out_ld32_12 (s,COND_AL ,TCG_REG_R1 ,TCG_REG_R0 , - offsetof(CPUArchState, tlb_table[0][0].addr_read)); +0xa00 | (tlb_offset >>12 )); + tlb_offset &=0xfff ; + } +tcg_out_ld32_12wb (s,COND_AL ,TCG_REG_R1 ,TCG_REG_R0 , tlb_offset);tcg_out_dat_reg (s,COND_AL ,ARITH_CMP ,0 ,TCG_REG_R1 ,TCG_REG_R8 ,SHIFT_IMM_LSL (TARGET_PAGE_BITS ));/* Check alignment. */
@@ -1122,15 +1134,14 @@ static inline void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)tcg_out_dat_imm (s,COND_EQ ,ARITH_TST ,0 , addr_reg, (1 << s_bits) -1 );# if TARGET_LONG_BITS ==64 -/* XXX: possibly we could use a block data load or writeback in -* the first access. */ -tcg_out_ld32_12 (s,COND_EQ ,TCG_REG_R1 ,TCG_REG_R0 , - offsetof(CPUArchState, tlb_table[0][0].addr_read) + 4); +/* XXX: possibly we could use a block data load in the first access. */ +tcg_out_ld32_12 (s,COND_EQ ,TCG_REG_R1 ,TCG_REG_R0 ,4 );tcg_out_dat_reg (s,COND_EQ ,ARITH_CMP ,0 ,TCG_REG_R1 , addr_reg2,SHIFT_IMM_LSL (0 ));# endif tcg_out_ld32_12 (s,COND_EQ ,TCG_REG_R1 ,TCG_REG_R0 , - offsetof(CPUArchState, tlb_table[0][0].addend)); + offsetof(CPUTLBEntry , addend) + - offsetof(CPUTLBEntry , addr_read));switch (opc) {case 0 :
@@ -1288,7 +1299,7 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc) {int addr_reg, data_reg, data_reg2, bswap;#ifdef CONFIG_SOFTMMU -int mem_index, s_bits; +int mem_index, s_bits, tlb_offset;TCGReg argreg;# if TARGET_LONG_BITS ==64 int addr_reg2;
@@ -1325,19 +1336,15 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc) TCG_REG_R0, TCG_REG_R8, CPU_TLB_SIZE - 1);tcg_out_dat_reg (s,COND_AL ,ARITH_ADD ,TCG_REG_R0 ,TCG_AREG0 ,TCG_REG_R0 ,SHIFT_IMM_LSL (CPU_TLB_ENTRY_BITS )); -/* In the -* ldr r1 [r0, #(offsetof(CPUArchState, tlb_table[mem_index][0].addr_write))] -* below, the offset is likely to exceed 12 bits if mem_index != 0 and -* not exceed otherwise, so use an -* add r0, r0, #(mem_index * sizeof *CPUArchState.tlb_table) -* before. -*/ -if (mem_index) +/* We assume that the offset is contained within 20 bits. */ + tlb_offset = offsetof(CPUArchState, tlb_table[mem_index][0].addr_write); +assert (tlb_offset & ~0xfffff ==0 ); +if (tlb_offset >0xfff ) {tcg_out_dat_imm (s,COND_AL ,ARITH_ADD ,TCG_REG_R0 ,TCG_REG_R0 , - (mem_index << (TLB_SHIFT &1 )) | - ((16 - (TLB_SHIFT >>1 )) <<8 )); -tcg_out_ld32_12 (s,COND_AL ,TCG_REG_R1 ,TCG_REG_R0 , - offsetof(CPUArchState, tlb_table[0][0].addr_write)); +0xa00 | (tlb_offset >>12 )); + tlb_offset &=0xfff ; + } +tcg_out_ld32_12wb (s,COND_AL ,TCG_REG_R1 ,TCG_REG_R0 , tlb_offset);tcg_out_dat_reg (s,COND_AL ,ARITH_CMP ,0 ,TCG_REG_R1 ,TCG_REG_R8 ,SHIFT_IMM_LSL (TARGET_PAGE_BITS ));/* Check alignment. */
@@ -1345,15 +1352,14 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)tcg_out_dat_imm (s,COND_EQ ,ARITH_TST ,0 , addr_reg, (1 << s_bits) -1 );# if TARGET_LONG_BITS ==64 -/* XXX: possibly we could use a block data load or writeback in -* the first access. */ -tcg_out_ld32_12 (s,COND_EQ ,TCG_REG_R1 ,TCG_REG_R0 , - offsetof(CPUArchState, tlb_table[0][0].addr_write) + 4); +/* XXX: possibly we could use a block data load in the first access. */ +tcg_out_ld32_12 (s,COND_EQ ,TCG_REG_R1 ,TCG_REG_R0 ,4 );tcg_out_dat_reg (s,COND_EQ ,ARITH_CMP ,0 ,TCG_REG_R1 , addr_reg2,SHIFT_IMM_LSL (0 ));# endif tcg_out_ld32_12 (s,COND_EQ ,TCG_REG_R1 ,TCG_REG_R0 , - offsetof(CPUArchState, tlb_table[0][0].addend)); + offsetof(CPUTLBEntry , addend) + - offsetof(CPUTLBEntry , addr_write));switch (opc) {case 0 :
Signature · 1 line
1.7.9.5
Re: [Qemu-devel] [PATCH 22/43] tcg/arm: fix TLB access in qemu-ld/st ops
Quoted 1 line · Michael Roth
+
assert(tlb_offset & ~0xfffff == 0);
This doesn't compile if configured with --enable-debug:
In file included from /home/petmay01/git/qemu/tcg/tcg.c:174:0:/home/petmay01/git/qemu/tcg/arm/tcg-target.c: In function ‘tcg_out_qemu_ld’:/home/petmay01/git/qemu/tcg/arm/tcg-target.c:1148:5: error: suggest parentheses around comparison in operand of ‘&’ [-Werror=parentheses] /home/petmay01/git/qemu/tcg/arm/tcg-target.c: In function ‘tcg_out_qemu_st’:/home/petmay01/git/qemu/tcg/arm/tcg-target.c:1357:5: error: suggest parentheses around comparison in operand of ‘&’ [-Werror=parentheses]
(ubuntu gcc 4.6.3-1ubuntu5)
I think this patch went into stable too :-)
-- PMM
PATCH 23/43 tcg/arm: fix cross-endian qemu_st16
In reply to Michael RothFrom: Aurelien Jarno <[email protected]>
The bswap16 TCG opcode assumes that the high bytes of the temp equal to 0 before calling it. The ARM backend implementation takes this assumption to slightly optimize the generated code.
The same implementation is called for implementing the cross-endian qemu_st16 opcode, where this assumption is not true anymore. One way to fix that would be to zero the high bytes before calling it. Given the store instruction just ignore them, it is possible to provide a slightly more optimized version. With ARMv6+ the rev16 instruction does the work correctly. For lower ARM versions the patch provides a version which behaves correctly with non-zero high bytes, but fill them with junk.
--- tcg/arm/tcg-target.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
tcg/arm/tcg-target.c +18 -2
@@ -602,6 +602,22 @@ static inline void tcg_out_bswap16(TCGContext *s, int cond, int rd, int rn) } } +/* swap the two low bytes assuming that the two high input bytes and the +two high output bit can hold any value. */ +static inline void tcg_out_bswap16st (TCGContext *s,int cond,int rd,int rn) +{ +if (use_armv6_instructions) { +/* rev16 */ +tcg_out32 (s,0x06bf0fb0 | (cond <<28 ) | (rd <<12 ) | rn); + }else { +tcg_out_dat_reg (s, cond,ARITH_MOV , +TCG_REG_R8 ,0 , rn,SHIFT_IMM_LSR (8 )); +tcg_out_dat_imm (s, cond,ARITH_AND ,TCG_REG_R8 ,TCG_REG_R8 ,0xff ); +tcg_out_dat_reg (s, cond,ARITH_ORR , + rd,TCG_REG_R8 , rn,SHIFT_IMM_LSL (8 )); + } +} +static inline void tcg_out_bswap32 (TCGContext *s,int cond,int rd,int rn) {if (use_armv6_instructions) {
@@ -1367,7 +1383,7 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)break ;case 1 :if (bswap) { -tcg_out_bswap16 (s,COND_EQ ,TCG_REG_R0 , data_reg); +tcg_out_bswap16st (s,COND_EQ ,TCG_REG_R0 , data_reg);tcg_out_st16_r (s,COND_EQ ,TCG_REG_R0 , addr_reg,TCG_REG_R1 ); }else {tcg_out_st16_r (s,COND_EQ , data_reg, addr_reg,TCG_REG_R1 );
@@ -1453,7 +1469,7 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)break ;case 1 :if (bswap) { -tcg_out_bswap16 (s,COND_AL ,TCG_REG_R0 , data_reg); +tcg_out_bswap16st (s,COND_AL ,TCG_REG_R0 , data_reg);tcg_out_st16_8 (s,COND_AL ,TCG_REG_R0 , addr_reg,0 ); }else {tcg_out_st16_8 (s,COND_AL , data_reg, addr_reg,0 );
Signature · 1 line
1.7.9.5
PATCH 24/43 target-openrisc: remove conflicting definitions from cpu.h
In reply to Michael RothFrom: Aurelien Jarno <[email protected]>
On an ARM host, the registers definitions from cpu.h clash with /usr/include/sys/ucontext.h. As there are unused, just remove them.
--- target-openrisc/cpu.h | 18 ------------------ 1 file changed, 18 deletions(-)
target-openrisc/cpu.h +0 -18
@@ -89,24 +89,6 @@ enum {/* Interrupt */ #define NR_IRQS 32 -/* Registers */ -enum { -R0 =0 ,R1 ,R2 ,R3 ,R4 ,R5 ,R6 ,R7 ,R8 ,R9 ,R10 , -R11 ,R12 ,R13 ,R14 ,R15 ,R16 ,R17 ,R18 ,R19 ,R20 , -R21 ,R22 ,R23 ,R24 ,R25 ,R26 ,R27 ,R28 ,R29 ,R30 , -R31 -}; - -/* Register aliases */ -enum { -R_ZERO =R0 , -R_SP =R1 , -R_FP =R2 , -R_LR =R9 , -R_RV =R11 , -R_RVH =R12 -}; -/* Unit presece register */ enum {UPR_UP = (1 <<0 ),
Signature · 1 line
1.7.9.5
PATCH 25/43 configure: avoid compiler warning in pipe2 detection
In reply to Michael RothFrom: Bruce Rogers <[email protected]>
When building qemu-kvm for openSUSE:Factory, I am getting a warning in the pipe2 detection performed by configure, which prevents using --enable-werror.
Change detection code to use return value of pipe2.
--- configure | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
configure +1 -2
@@ -2389,8 +2389,7 @@ cat > $TMPC << EOF int main(void) { int pipefd[2]; - pipe2(pipefd, O_CLOEXEC); - return 0; + return pipe2(pipefd, O_CLOEXEC); } EOF if compile_prog "" "" ; then
Signature · 1 line
1.7.9.5
PATCH 26/43 qcow2: Fix refcount table size calculation
In reply to Michael RothFrom: Kevin Wolf <[email protected]>
A missing factor for the refcount table entry size in the calculation could mean that too little memory was allocated for the in-memory representation of the table, resulting in a buffer overflow.
--- block/qcow2-refcount.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/qcow2-refcount.c +2 -1
@@ -301,7 +301,8 @@ static int alloc_refcount_block(BlockDriverState *bs,uint64_t last_table_size;uint64_t blocks_clusters; do { - uint64_t table_clusters = size_to_clusters(s, table_size); + uint64_t table_clusters = + size_to_clusters(s, table_size * sizeof(uint64_t)); blocks_clusters = 1 + ((table_clusters + refcount_block_clusters - 1) / refcount_block_clusters);
Signature · 1 line
1.7.9.5
PATCH 27/43 tci: Fix type of tci_read_label
In reply to Michael RothFrom: Richard Henderson <[email protected]>
Fixes the pointer truncation that was occurring for branches.
--- tci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tci.c +2 -2
@@ -338,9 +338,9 @@ static uint64_t tci_read_ri64(uint8_t **tb_ptr) }#endif -static target_ulong tci_read_label (uint8_t **tb_ptr) +static tcg_target_ulong tci_read_label (uint8_t **tb_ptr) { -target_ulong label =tci_read_i (tb_ptr); +tcg_target_ulong label =tci_read_i (tb_ptr);assert (label !=0 );return label; }
Signature · 1 line
1.7.9.5
PATCH 28/43 block: Fix regression for MinGW (assertion caused by short string)
In reply to Michael RothFrom: Stefan Weil <[email protected]>
The local string tmp_filename is passed to function get_tmp_filename which expects a string with minimum size MAX_PATH for w32 hosts.
MAX_PATH is 260 and PATH_MAX is 259, so tmp_filename was too short.
Commit eba25057b9a5e19d10ace2bc7716667a31297169 introduced this regression.
--- block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block.c +2 -1
@@ -739,7 +739,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags, BlockDriver *drv) {int ret; -char tmp_filename[PATH_MAX ]; +/* TODO: extra byte is a hack to ensure MAX_PATH space on Windows. */ +char tmp_filename[PATH_MAX +1 ];if (flags &BDRV_O_SNAPSHOT ) {BlockDriverState *bs1;
Signature · 1 line
1.7.9.5
PATCH 29/43 qom: dynamic_cast of NULL is always NULL
From: Paolo Bonzini <[email protected]>
Trying to cast a NULL value will cause a crash. Returning NULL is also sensible, and it is also what the type-unsafe DO_UPCAST macro does.
--- qom/object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
qom/object.c +2 -2
@@ -417,7 +417,7 @@ void object_delete(Object *obj)Object *object_dynamic_cast (Object *obj,const char *typename) { -if (object_class_dynamic_cast (object_get_class (obj), typename)) { +if (obj &&object_class_dynamic_cast (object_get_class (obj), typename)) {return obj; }
@@ -430,7 +430,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename) inst =object_dynamic_cast (obj, typename); -if (!inst) { +if (!inst && obj) {fprintf (stderr,"Object %p is not an instance of type %s\n" , obj, typename);abort ();
Signature · 1 line
1.7.9.5
PATCH 30/43 hmp: do not crash on invalid SCSI hotplug
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
Commit 0d93692 (qdev: Convert busses to QEMU Object Model, 2012-05-02) removed a check on the type of the bus where a SCSI disk is hotplugged. However, hot-plugging to the wrong kind of device now causes a crash due to either a NULL pointer dereference (avoided by the previous patch) or a failed QOM cast.
Instead, in this case we need to use object_dynamic_cast and check for the result, similar to what was done before that commit.
--- hw/pci-hotplug.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/pci-hotplug.c +7 -1
@@ -80,7 +80,13 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,SCSIBus *scsibus;SCSIDevice *scsidev; - scsibus =SCSI_BUS (QLIST_FIRST (&adapter->child_bus)); + scsibus = (SCSIBus *) +object_dynamic_cast (OBJECT (QLIST_FIRST (&adapter->child_bus)), +TYPE_SCSI_BUS ); +if (!scsibus) { +error_report ("Device is not a SCSI adapter" ); +return -1 ; + }/* * drive_init() tries to find a default for dinfo->unit. Doesn't
Signature · 1 line
1.7.9.5
PATCH 31/43 PPC: Fix missing TRACE exception
In reply to Michael RothFrom: Julio Guerra <[email protected]>
This patch fixes bug 1031698 :
https://bugs.launchpad.net/qemu/+bug/1031698
If we look at the (truncated) translation of the conditional branch instruction in the test submitted in the bug post, the call to the exception helper is missing in the "bne-false" chunk of translated code :
IN:
bne- 0x1800278
OUT:0xb544236d: jne 0xb5442396
0xb5442373: mov %ebp,(%esp)
0xb5442376: mov $0x44,%ebx
0xb544237b: mov %ebx,0x4(%esp)
0xb544237f: mov $0x1800278,%ebx
0xb5442384: mov %ebx,0x25c(%ebp)
0xb544238a: call 0x827475a
^^^^^^^^^^^^^^^^^^0xb5442396: mov %ebp,(%esp) 0xb5442399: mov $0x44,%ebx 0xb544239e: mov %ebx,0x4(%esp) 0xb54423a2: mov $0x1800270,%ebx 0xb54423a7: mov %ebx,0x25c(%ebp)
Indeed, gen_exception(ctx, excp) called by gen_goto_tb (called by gen_bcond) changes ctx->exception's value to excp's :
gen_bcond()
{
gen_goto_tb(ctx, 0, ctx->nip + li - 4); /* ctx->exception value is POWERPC_EXCP_BRANCH */
gen_goto_tb(ctx, 1, ctx->nip);
/* ctx->exception now value is POWERPC_EXCP_TRACE */
}
Making the following gen_goto_tb()'s test false during the second call :
if ((ctx->singlestep_enabled &
(CPU_BRANCH_STEP | CPU_SINGLE_STEP)) &&
ctx->exception == POWERPC_EXCP_BRANCH /* false...*/) {
target_ulong tmp = ctx->nip;
ctx->nip = dest;
/* ... and this is the missing call */
gen_exception(ctx, POWERPC_EXCP_TRACE);
ctx->nip = tmp;
}So the patch simply adds the missing matching case, fixing our problem.
--- target-ppc/translate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
target-ppc/translate.c +2 -1
@@ -3466,7 +3466,8 @@ static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest)if (unlikely (ctx->singlestep_enabled)) {if ((ctx->singlestep_enabled & (CPU_BRANCH_STEP |CPU_SINGLE_STEP )) && - ctx->exception ==POWERPC_EXCP_BRANCH ) { + (ctx->exception ==POWERPC_EXCP_BRANCH || + ctx->exception ==POWERPC_EXCP_TRACE )) {target_ulong tmp = ctx->nip; ctx->nip = dest;gen_exception (ctx,POWERPC_EXCP_TRACE );
Signature · 1 line
1.7.9.5
PATCH 32/43 qom: fix refcount of non-heap-allocated objects
In reply to Michael RothFrom: Paolo Bonzini <[email protected]>
The reference count for embedded objects is always one too low, because object_initialize_with_type returns with zero references to the object. This causes premature finalization of the object (or an assertion failure) after calling object_ref to add an extra reference and object_unref to remove it.
The fix is to move the initial object_ref call from object_new_with_type to object_initialize_with_type.
--- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qom/object.c +1 -1
@@ -307,6 +307,7 @@ void object_initialize_with_type(void *data, TypeImpl *type)memset (obj,0 , type->instance_size); obj->class = type->class; +object_ref (obj);QTAILQ_INIT (&obj->properties);object_init_with_type (obj, type); }
@@ -395,7 +396,6 @@ Object *object_new_with_type(Type type) obj =g_malloc (type->instance_size);object_initialize_with_type (obj, type); -object_ref (obj);return obj; }
Signature · 1 line
1.7.9.5
PATCH 33/43 qapi: handle visitor->type_size() in QapiDeallocVisitor
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
visit_type_size() requires either visitor->type_size() or visitor_uint64() to be implemented, otherwise a NULL function pointer is invoked.
It is possible to trigger this crash as follows:
$ qemu-system-x86_64 -netdev tap,sndbuf=0,id=netdev0 \
-device virtio-blk-pci,netdev=netdev0The 'sndbuf' option has type "size".
--- qapi/qapi-dealloc-visitor.c | 6 ++++++ 1 file changed, 6 insertions(+)
qapi/qapi-dealloc-visitor.c +6 -0
@@ -132,6 +132,11 @@ static void qapi_dealloc_type_number(Visitor *v, double *obj, const char *name, { } +static void qapi_dealloc_type_size (Visitor *v,size_t *obj,const char *name, +Error **errp) +{ +} +static void qapi_dealloc_type_enum (Visitor *v,int *obj,const char *strings[],const char *kind,const char *name,Error **errp)
@@ -164,6 +169,7 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void) v->visitor.type_bool = qapi_dealloc_type_bool; v->visitor.type_str = qapi_dealloc_type_str; v->visitor.type_number = qapi_dealloc_type_number; + v->visitor.type_size = qapi_dealloc_type_size;QTAILQ_INIT (&v->stack);
Signature · 1 line
1.7.9.5
PATCH 34/43 qapi: fix qapi_dealloc_type_size parameter type
In reply to Michael RothFrom: Bruce Rogers <[email protected]>
The second parameter to qapi_dealloc_type_size should be a uint64_t *, not a size_t *. This was causing our 32 bit x86 build to fail, since warnings are treated as errors.
--- qapi/qapi-dealloc-visitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
qapi/qapi-dealloc-visitor.c +1 -1
@@ -132,7 +132,7 @@ static void qapi_dealloc_type_number(Visitor *v, double *obj, const char *name, { } -static void qapi_dealloc_type_size (Visitor *v,size_t *obj,const char *name, +static void qapi_dealloc_type_size (Visitor *v,uint64_t *obj,const char *name,Error **errp) { }
Signature · 1 line
1.7.9.5
PATCH 35/43 iscsi: fix segfault in url parsing
In reply to Michael RothFrom: Peter Lieven <[email protected]>
If an invalid URL is specified iscsi_get_error(iscsi) is called with iscsi == NULL.
--- block/iscsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/iscsi.c +1 -2
@@ -951,8 +951,7 @@ static int iscsi_open(BlockDriverState *bs, const char *filename, int flags) iscsi_url =iscsi_parse_full_url (iscsi, filename);if (iscsi_url ==NULL ) { -error_report ("Failed to parse URL : %s %s" , filename, -iscsi_get_error (iscsi)); +error_report ("Failed to parse URL : %s" , filename); ret = -EINVAL ; goto out; }
Signature · 1 line
1.7.9.5
PATCH 36/43 iscsi: fix deadlock during login
In reply to Michael RothFrom: Peter Lieven <[email protected]>
If the connection is interrupted before the first login is successfully completed qemu-kvm is waiting forever in qemu_aio_wait().
This is fixed by performing an sync login to the target. If the connection breaks after the first successful login errors are handled internally by libiscsi.
--- block/iscsi.c | 251 ++++++++++++++++----------------------------------------- 1 file changed, 70 insertions(+), 181 deletions(-)
block/iscsi.c +70 -181
@@ -65,13 +65,6 @@ typedef struct IscsiAIOCB {#endif } IscsiAIOCB; -struct IscsiTask { -IscsiLun *iscsilun; -BlockDriverState *bs; -int status; -int complete; -}; -static void iscsi_bh_cb (void *p) {
@@ -384,7 +377,7 @@ iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num, *(uint16_t *)&acb->task->cdb[7 ] =htons (num_sectors);break ; } - + if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task, iscsi_aio_read16_cb, NULL,
@@ -669,163 +662,6 @@ iscsi_getlength(BlockDriverState *bs)return len; } -static void -iscsi_readcapacity16_cb (struct iscsi_context *iscsi,int status, -void *command_data,void *opaque) -{ -struct IscsiTask *itask = opaque; -struct scsi_readcapacity16 *rc16; -struct scsi_task *task = command_data; - -if (status !=0 ) { -error_report ("iSCSI: Failed to read capacity of iSCSI lun. %s" , -iscsi_get_error (iscsi)); - itask->status =1 ; - itask->complete =1 ; -scsi_free_scsi_task (task); -return ; - } - - rc16 =scsi_datain_unmarshall (task); -if (rc16 ==NULL ) { -error_report ("iSCSI: Failed to unmarshall readcapacity16 data." ); - itask->status =1 ; - itask->complete =1 ; -scsi_free_scsi_task (task); -return ; - } - - itask->iscsilun->block_size = rc16->block_length; - itask->iscsilun->num_blocks = rc16->returned_lba +1 ; - itask->bs->total_sectors = itask->iscsilun->num_blocks * - itask->iscsilun->block_size /BDRV_SECTOR_SIZE ; - - itask->status =0 ; - itask->complete =1 ; -scsi_free_scsi_task (task); -} - -static void -iscsi_readcapacity10_cb (struct iscsi_context *iscsi,int status, -void *command_data,void *opaque) -{ -struct IscsiTask *itask = opaque; -struct scsi_readcapacity10 *rc10; -struct scsi_task *task = command_data; - -if (status !=0 ) { -error_report ("iSCSI: Failed to read capacity of iSCSI lun. %s" , -iscsi_get_error (iscsi)); - itask->status =1 ; - itask->complete =1 ; -scsi_free_scsi_task (task); -return ; - } - - rc10 =scsi_datain_unmarshall (task); -if (rc10 ==NULL ) { -error_report ("iSCSI: Failed to unmarshall readcapacity10 data." ); - itask->status =1 ; - itask->complete =1 ; -scsi_free_scsi_task (task); -return ; - } - - itask->iscsilun->block_size = rc10->block_size; -if (rc10->lba ==0 ) { -/* blank disk loaded */ - itask->iscsilun->num_blocks =0 ; - }else { - itask->iscsilun->num_blocks = rc10->lba +1 ; - } - itask->bs->total_sectors = itask->iscsilun->num_blocks * - itask->iscsilun->block_size /BDRV_SECTOR_SIZE ; - - itask->status =0 ; - itask->complete =1 ; -scsi_free_scsi_task (task); -} - -static void -iscsi_inquiry_cb (struct iscsi_context *iscsi,int status,void *command_data, -void *opaque) -{ -struct IscsiTask *itask = opaque; -struct scsi_task *task = command_data; -struct scsi_inquiry_standard *inq; - -if (status !=0 ) { - itask->status =1 ; - itask->complete =1 ; -scsi_free_scsi_task (task); -return ; - } - - inq =scsi_datain_unmarshall (task); -if (inq ==NULL ) { -error_report ("iSCSI: Failed to unmarshall inquiry data." ); - itask->status =1 ; - itask->complete =1 ; -scsi_free_scsi_task (task); -return ; - } - - itask->iscsilun->type = inq->periperal_device_type; - -scsi_free_scsi_task (task); - -switch (itask->iscsilun->type) { -case TYPE_DISK : - task =iscsi_readcapacity16_task (iscsi, itask->iscsilun->lun, - iscsi_readcapacity16_cb, opaque); -if (task ==NULL ) { -error_report ("iSCSI: failed to send readcapacity16 command." ); - itask->status =1 ; - itask->complete =1 ; -return ; - } -break ; -case TYPE_ROM : - task =iscsi_readcapacity10_task (iscsi, itask->iscsilun->lun, -0 ,0 , - iscsi_readcapacity10_cb, opaque); -if (task ==NULL ) { -error_report ("iSCSI: failed to send readcapacity16 command." ); - itask->status =1 ; - itask->complete =1 ; -return ; - } -break ; -default : - itask->status =0 ; - itask->complete =1 ; - } -} - -static void -iscsi_connect_cb (struct iscsi_context *iscsi,int status,void *command_data, -void *opaque) -{ -struct IscsiTask *itask = opaque; -struct scsi_task *task; - -if (status !=0 ) { - itask->status =1 ; - itask->complete =1 ; -return ; - } - - task =iscsi_inquiry_task (iscsi, itask->iscsilun->lun, -0 ,0 ,36 , - iscsi_inquiry_cb, opaque); -if (task ==NULL ) { -error_report ("iSCSI: failed to send inquiry command." ); - itask->status =1 ; - itask->complete =1 ; -return ; - } -} -static int parse_chap (struct iscsi_context *iscsi,const char *target) {QemuOptsList *list;
@@ -938,7 +774,10 @@ static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)IscsiLun *iscsilun = bs->opaque;struct iscsi_context *iscsi =NULL ;struct iscsi_url *iscsi_url =NULL ; -struct IscsiTask task; +struct scsi_task *task =NULL ; +struct scsi_inquiry_standard *inq =NULL ; +struct scsi_readcapacity10 *rc10 =NULL ; +struct scsi_readcapacity16 *rc16 =NULL ;char *initiator_name =NULL ;int ret;
@@ -1001,33 +840,80 @@ static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)/* check if we got HEADER_DIGEST via the options */ parse_header_digest (iscsi, iscsi_url->target); - task.iscsilun = iscsilun; - task.status =0 ; - task.complete =0 ; - task.bs = bs; +if (iscsi_full_connect_sync (iscsi, iscsi_url->portal, iscsi_url->lun) !=0 ) { +error_report ("iSCSI: Failed to connect to LUN : %s" , +iscsi_get_error (iscsi)); + ret = -EINVAL ; + goto out; + } iscsilun->iscsi = iscsi; iscsilun->lun = iscsi_url->lun; -if (iscsi_full_connect_async (iscsi, iscsi_url->portal, iscsi_url->lun, - iscsi_connect_cb, &task) - !=0 ) { -error_report ("iSCSI: Failed to start async connect." ); + task =iscsi_inquiry_sync (iscsi, iscsilun->lun,0 ,0 ,36 ); + +if (task ==NULL || task->status !=SCSI_STATUS_GOOD ) { +error_report ("iSCSI: failed to send inquiry command." ); ret = -EINVAL ; goto out; } -while (!task.complete) { -iscsi_set_events (iscsilun); -qemu_aio_wait (); - } -if (task.status !=0 ) { -error_report ("iSCSI: Failed to connect to LUN : %s" , -iscsi_get_error (iscsi)); + inq =scsi_datain_unmarshall (task); +if (inq ==NULL ) { +error_report ("iSCSI: Failed to unmarshall inquiry data." ); ret = -EINVAL ; goto out; } + iscsilun->type = inq->periperal_device_type; + +scsi_free_scsi_task (task); + +switch (iscsilun->type) { +case TYPE_DISK : + task =iscsi_readcapacity16_sync (iscsi, iscsilun->lun); +if (task ==NULL || task->status !=SCSI_STATUS_GOOD ) { +error_report ("iSCSI: failed to send readcapacity16 command." ); + ret = -EINVAL ; + goto out; + } + rc16 =scsi_datain_unmarshall (task); +if (rc16 ==NULL ) { +error_report ("iSCSI: Failed to unmarshall readcapacity16 data." ); + ret = -EINVAL ; + goto out; + } + iscsilun->block_size = rc16->block_length; + iscsilun->num_blocks = rc16->returned_lba +1 ; +break ; +case TYPE_ROM : + task =iscsi_readcapacity10_sync (iscsi, iscsilun->lun,0 ,0 ); +if (task ==NULL || task->status !=SCSI_STATUS_GOOD ) { +error_report ("iSCSI: failed to send readcapacity10 command." ); + ret = -EINVAL ; + goto out; + } + rc10 =scsi_datain_unmarshall (task); +if (rc10 ==NULL ) { +error_report ("iSCSI: Failed to unmarshall readcapacity10 data." ); + ret = -EINVAL ; + goto out; + } + iscsilun->block_size = rc10->block_size; +if (rc10->lba ==0 ) { +/* blank disk loaded */ + iscsilun->num_blocks =0 ; + }else { + iscsilun->num_blocks = rc10->lba +1 ; + } +break ; +default : +break ; + } + + bs->total_sectors = iscsilun->num_blocks * + iscsilun->block_size /BDRV_SECTOR_SIZE ; +/* Medium changer or tape. We dont have any emulation for this so this must * be sg ioctl compatible. We force it to be sg, otherwise qemu will try * to read from the device to guess the image format.
@@ -1046,6 +932,9 @@ out:if (iscsi_url !=NULL ) {iscsi_destroy_url (iscsi_url); } +if (task !=NULL ) { +scsi_free_scsi_task (task); + }if (ret) {if (iscsi !=NULL ) {
Signature · 1 line
1.7.9.5
PATCH 37/43 iscsi: do not assume device is zero initialized
In reply to Michael RothFrom: Peter Lieven <[email protected]>
Without any complex checks we can't assume that an iscsi target is initialized to zero.
--- block/iscsi.c | 6 ++++++ 1 file changed, 6 insertions(+)
block/iscsi.c +6 -0
@@ -955,6 +955,11 @@ static void iscsi_close(BlockDriverState *bs)memset (iscsilun,0 ,sizeof (IscsiLun)); } +static int iscsi_has_zero_init (BlockDriverState *bs) +{ +return 0 ; +} +static BlockDriver bdrv_iscsi = { .format_name ="iscsi" , .protocol_name ="iscsi" ,
@@ -970,6 +975,7 @@ static BlockDriver bdrv_iscsi = { .bdrv_aio_flush = iscsi_aio_flush, .bdrv_aio_discard = iscsi_aio_discard, + .bdrv_has_zero_init = iscsi_has_zero_init, #ifdef __linux__ .bdrv_ioctl = iscsi_ioctl,
Signature · 1 line
1.7.9.5
PATCH 38/43 virtio-scsi: Fix some endian bugs with virtio-scsi
In reply to Michael RothFrom: David Gibson <[email protected]>
The virtio-scsi specification does not specify the correct endianness for fields in the request structure. It's therefore best to assume that it is "guest native" endian since that's the (stupid and poorly defined) norm in virtio.
However, the qemu device for virtio-scsi has no byteswaps at all, and so will break if the guest has different endianness from the host. This patch fixes it by adding tswap() calls for the sense_len and resid fields in the request structure. In theory status_qualifier needs swaps as well, but that field is never actually touched. The tag field is a uint64_t, but since its value is completely arbitrary, it might as well be uint8_t[8] and so it does not need swapping.
--- hw/virtio-scsi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
hw/virtio-scsi.c +5 -3
@@ -424,15 +424,17 @@ static void virtio_scsi_command_complete(SCSIRequest *r, uint32_t status, size_t resid) {VirtIOSCSIReq *req = r->hba_private; +uint32_t sense_len; req->resp.cmd->response =VIRTIO_SCSI_S_OK ; req->resp.cmd->status = status;if (req->resp.cmd->status ==GOOD ) { - req->resp.cmd->resid = resid; + req->resp.cmd->resid =tswap32 (resid); }else { req->resp.cmd->resid =0 ; - req->resp.cmd->sense_len = -scsi_req_get_sense (r, req->resp.cmd->sense,VIRTIO_SCSI_SENSE_SIZE ); + sense_len =scsi_req_get_sense (r, req->resp.cmd->sense, +VIRTIO_SCSI_SENSE_SIZE ); + req->resp.cmd->sense_len =tswap32 (sense_len); }virtio_scsi_complete_req (req); }
Signature · 1 line
1.7.9.5
PATCH 39/43 virtio-scsi: Fix subtle (guest) endian bug
In reply to Michael RothFrom: David Gibson <[email protected]>
The virtio-scsi config space is, by specification, in guest endian (which is ill-defined, but there you go). In virtio_scsi_get_config() we set up all the fields in there, using stl_raw(). Which is a problem for the max_channel and max_target fields, which are 16-bit, not 32-bit. For little-endian targets we get away with it by accident, since the first two bytes will still be correct, and the extra two bytes written (with zeroes) will be overwritten correctly by the next store.
But for big-endian guests, this means the max_target field ends up as zero, which means the guest will only recognize a single disk on the virtio-scsi bus. This patch fixes the problem.
--- hw/virtio-scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio-scsi.c +2 -2
@@ -534,8 +534,8 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,stl_raw (&scsiconf->event_info_size,sizeof (VirtIOSCSIEvent));stl_raw (&scsiconf->sense_size, s->sense_size);stl_raw (&scsiconf->cdb_size, s->cdb_size); -stl_raw (&scsiconf->max_channel,VIRTIO_SCSI_MAX_CHANNEL ); -stl_raw (&scsiconf->max_target,VIRTIO_SCSI_MAX_TARGET ); +stw_raw (&scsiconf->max_channel,VIRTIO_SCSI_MAX_CHANNEL ); +stw_raw (&scsiconf->max_target,VIRTIO_SCSI_MAX_TARGET );stl_raw (&scsiconf->max_lun,VIRTIO_SCSI_MAX_LUN ); }
Signature · 1 line
1.7.9.5
PATCH 40/43 qxl: reload memslots after migration, when qxl is in UNDEFINED mode
In reply to Michael RothFrom: Yonit Halperin <[email protected]>
The devram memslot stays active when qxl enters UNDEFINED mode (i.e, no primary surface). If migration has occurred while the device is in UNDEFINED stae, the memslots have to be reloaded at the destination.
Fixes rhbz#874574
--- hw/qxl.c | 1 + 1 file changed, 1 insertion(+)
hw/qxl.c +1 -0
@@ -2042,6 +2042,7 @@ static int qxl_post_load(void *opaque, int version)switch (newmode) {case QXL_MODE_UNDEFINED : +qxl_create_memslots (d);break ;case QXL_MODE_VGA :qxl_create_memslots (d);
Signature · 1 line
1.7.9.5
PATCH 41/43 usb: fail usbdevice_create() when there is no USB bus
In reply to Michael RothFrom: Stefan Hajnoczi <[email protected]>
Report an error instead of segfaulting when attaching a USB device to a machine with no USB busses:
$ qemu-system-arm -machine vexpress-a9 \
-sd Fedora-17-armhfp-vexpress-mmcblk0.img \
-kernel vmlinuz-3.4.2-3.fc17.armv7hl \
-initrd initramfs-3.4.2-3.fc17.armv7hl.img \
-usbdevice disk:format=raw:test.imgNote that the vexpress-a9 machine does not have a USB host controller.
--- hw/usb/bus.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/usb/bus.c +7 -0
@@ -585,6 +585,13 @@ USBDevice *usbdevice_create(const char *cmdline)return NULL ; } +if (!bus) { +error_report ("Error: no usb bus to attach usbdevice %s, " +"please try -machine usb=on and check that " +"the machine model supports USB" , driver); +return NULL ; + } +if (!f->usbdevice_init) {if (*params) {error_report ("usbdevice %s accepts no params" , driver);
Signature · 1 line
1.7.9.5
PATCH 42/43 stream: fix ratelimit_set_speed
In reply to Michael RothFrom: Dietmar Maurer <[email protected]>
The formula to compute slice_quota was wrong since commit 6ef228fc.
--- include/qemu/ratelimit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/qemu/ratelimit.h +1 -1
@@ -42,7 +42,7 @@ static inline void ratelimit_set_speed(RateLimit *limit, uint64_t speed, uint64_t slice_ns) { limit->slice_ns = slice_ns; - limit->slice_quota = ((double )speed *1000000000ULL ) / slice_ns; + limit->slice_quota = ((double )speed * slice_ns)/1000000000ULL ; }#endif
Signature · 1 line
1.7.9.5
PATCH 43/43 e1000: Discard packets that are too long if !SBP and !LPE
In reply to Michael RothFrom: Michael Contreras <[email protected]>
The e1000_receive function for the e1000 needs to discard packets longer than 1522 bytes if the SBP and LPE flags are disabled. The linux driver assumes this behavior and allocates memory based on this assumption.
--- hw/e1000.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/e1000.c +10 -0
@@ -59,6 +59,9 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);#define PNPMMIO_SIZE 0x20000#define MIN_BUF_SIZE 60/* Min. octets in an ethernet frame sans FCS */ +/* this is the size past which hardware will drop packets when setting LPE=0 */ +#define MAXIMUM_ETHERNET_VLAN_SIZE 1522 +/* * HW models: * E1000_DEV_ID_82540EM works with Windows and Linux
@@ -795,6 +798,13 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) size =sizeof (min_buf); } +/* Discard oversized packets if !LPE and !SBP. */ +if (size >MAXIMUM_ETHERNET_VLAN_SIZE + && !(s->mac_reg[RCTL ] &E1000_RCTL_LPE ) + && !(s->mac_reg[RCTL ] &E1000_RCTL_SBP )) { +return size; + } +if (!receive_filter (s, buf, size))return size;
Signature · 1 line
1.7.9.5