From b60c2c74f39e7aa6b84beb945fee544871d1661f Mon Sep 17 00:00:00 2001 From: Artyom Tarasenko Date: Sun, 13 Dec 2009 11:32:36 +0100 Subject: scsi-disk: Inquiry with allocation length of CDB < 36 (v4) According to the SCSI-2 specification, http://ldkelley.com/SCSI2/SCSI2/SCSI2/SCSI2-08.html#8.2.5 , "if the allocation length of the command descriptor block (CDB) is too small to transfer all of the parameters, the additional length shall not be adjusted to reflect the truncation." The 36 mandatory bytes of response are written to outbuf, and then only the length requested in CDB is transferred. Signed-off-by: Artyom Tarasenko Signed-off-by: Blue Swirl --- hw/scsi-disk.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 2e7a57b2d..eb5b5a847 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -5,6 +5,12 @@ * Based on code by Fabrice Bellard * * Written by Paul Brook + * Modifications: + * 2009-Dec-12 Artyom Tarasenko : implemented stamdard inquiry for the case + * when the allocation length of CDB is smaller + * than 36. + * 2009-Oct-13 Artyom Tarasenko : implemented the block descriptor in the + * MODE SENSE response. * * This code is licenced under the LGPL. * @@ -406,11 +412,6 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) return -1; } - if (req->cmd.xfer < 36) { - BADF("Error: Inquiry (STANDARD) buffer size %zd " - "is less than 36 (TODO: only 5 required)\n", req->cmd.xfer); - } - buflen = req->cmd.xfer; if (buflen > SCSI_MAX_INQUIRY_LEN) buflen = SCSI_MAX_INQUIRY_LEN; @@ -436,7 +437,15 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf) Some later commands are also implemented. */ outbuf[2] = 3; outbuf[3] = 2; /* Format 2 */ - outbuf[4] = buflen - 5; /* Additional Length = (Len - 1) - 4 */ + + if (buflen > 36) { + outbuf[4] = buflen - 5; /* Additional Length = (Len - 1) - 4 */ + } else { + /* If the allocation length of CDB is too small, + the additional length is not adjusted */ + outbuf[4] = 36 - 5; + } + /* Sync data transfer and TCQ. */ outbuf[7] = 0x10 | (req->bus->tcq ? 0x02 : 0); return buflen; -- cgit v1.2.3 From e470436f19f85660b2e9a4dc25827000f0ea2078 Mon Sep 17 00:00:00 2001 From: Artyom Tarasenko Date: Sun, 13 Dec 2009 13:30:44 +0000 Subject: fdc/sparc32: don't hang on detection under OBP Stepping through the SS-5's OBP initialization routines it looks like reading fdc main status register should clear the fd interrupt. The patch doesn't fix problems with fdc on sparc platform, it only fixes fdc detection. Signed-off-by: Artyom Tarasenko Signed-off-by: Blue Swirl --- hw/fdc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/fdc.c b/hw/fdc.c index 139333727..0579b0372 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -935,6 +935,12 @@ static uint32_t fdctrl_read_main_status (fdctrl_t *fdctrl) fdctrl->dsr &= ~FD_DSR_PWRDOWN; fdctrl->dor |= FD_DOR_nRESET; + /* Sparc mutation */ + if (fdctrl->sun4m) { + retval |= FD_MSR_DIO; + fdctrl_reset_irq(fdctrl); + }; + FLOPPY_DPRINTF("main status register: 0x%02x\n", retval); return retval; -- cgit v1.2.3 From 65e8c5192803c4739a51bc8d11ddcacb66f1f100 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Sat, 19 Dec 2009 15:16:08 +0000 Subject: user_only: compile everything with -fpie We really need compile _all_ sources for user target with -fpie when use --enable-user-pie. It's regression introduced by commit add16157d72454. Signed-off-by: Kirill A. Shutemov Cc: Blue Swirl Signed-off-by: Juan Quintela [blauwirbel@gmail.com: combined 299060a0 and 58faa1a6 to avoid breakage] Signed-off-by: Blue Swirl --- Makefile.user | 7 ++++++- configure | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile.user b/Makefile.user index 907e74bd9..7daedeff6 100644 --- a/Makefile.user +++ b/Makefile.user @@ -2,10 +2,15 @@ include ../config-host.mak include $(SRC_PATH)/rules.mak +-include config.mak .PHONY: all -VPATH=$(SRC_PATH) +# Do not take %.o from $(SRC_PATH), only %.c and %.h +# All %.o for user targets should be built with -fpie, when +# configured with --enable-user-pie, so we don't want to +# take %.o from $(SRC_PATH), since they built without -fpie +vpath %.c %.h $(SRC_PATH) QEMU_CFLAGS+=-I.. diff --git a/configure b/configure index 273b6b7c6..5f463b05b 100755 --- a/configure +++ b/configure @@ -2652,3 +2652,6 @@ d=libuser mkdir -p $d rm -f $d/Makefile ln -s $source_path/Makefile.user $d/Makefile +if test "$static" = "no" -a "$user_pie" = "yes" ; then + echo "QEMU_CFLAGS+=-fpie" > $d/config.mak +fi -- cgit v1.2.3 From eacdccbb3e79deb04056bd2096ec9f679b6761ae Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Sun, 20 Dec 2009 10:27:44 +0000 Subject: alpha: fix compile Signed-off-by: Blue Swirl --- target-alpha/op_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c index fe222dccd..7a3bf9c0f 100644 --- a/target-alpha/op_helper.c +++ b/target-alpha/op_helper.c @@ -46,10 +46,10 @@ uint64_t helper_load_fpcr (void) { uint64_t ret = 0; #ifdef CONFIG_SOFTFLOAT - ret |= env->fp_status.float_exception_flags << 52; + ret |= (uint64_t)env->fp_status.float_exception_flags << 52; if (env->fp_status.float_exception_flags) ret |= 1ULL << 63; - env->ipr[IPR_EXC_SUM] &= ~0x3E: + env->ipr[IPR_EXC_SUM] &= ~0x3E; env->ipr[IPR_EXC_SUM] |= env->fp_status.float_exception_flags << 1; #endif switch (env->fp_status.float_rounding_mode) { -- cgit v1.2.3 From da0266005ab8951186ce0a77e643f78472487f4a Mon Sep 17 00:00:00 2001 From: Aurelien Jarno Date: Sun, 20 Dec 2009 21:18:57 +0100 Subject: cpu-all.h: fix cpu_get_real_ticks() #ifdef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-by: Hervé Poussineau Signed-off-by: Aurelien Jarno (cherry picked from commit 9706c06d9c93b6d94785b6b14565b61ddae95a04) --- cpu-all.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpu-all.h b/cpu-all.h index e21437499..57b69f886 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -1017,7 +1017,8 @@ static inline int64_t cpu_get_real_ticks (void) #endif } -#elif (defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__) +#elif defined(__mips__) && \ + ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__)) /* * binutils wants to use rdhwr only on mips32r2 * but as linux kernel emulate it, it's fine -- cgit v1.2.3 From 41193c50fac2b6d78122514826770b43318dca8d Mon Sep 17 00:00:00 2001 From: Scott Tsai Date: Wed, 23 Dec 2009 04:30:18 +0800 Subject: USB: Improve usbdevice error messages When an non-existent USB device is specified on the command line, print "qemu: could not add USB device 'X'". Likewise for the usb_{add,del} monitor commands. Signed-off-by: Scott Tsai Signed-off-by: Aurelien Jarno (cherry picked from commit 59d1c1c2d774cccb0a88ff73501f97bea190c154) --- vl.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 8be3648f4..ee9c3f947 100644 --- a/vl.c +++ b/vl.c @@ -2689,17 +2689,28 @@ static int usb_device_del(const char *devname) static int usb_parse(const char *cmdline) { - return usb_device_add(cmdline, 0); + int r; + r = usb_device_add(cmdline, 0); + if (r < 0) { + fprintf(stderr, "qemu: could not add USB device '%s'\n", cmdline); + } + return r; } void do_usb_add(Monitor *mon, const QDict *qdict) { - usb_device_add(qdict_get_str(qdict, "devname"), 1); + const char *devname = qdict_get_str(qdict, "devname"); + if (usb_device_add(devname, 1) < 0) { + qemu_error("could not add USB device '%s'\n", devname); + } } void do_usb_del(Monitor *mon, const QDict *qdict) { - usb_device_del(qdict_get_str(qdict, "devname")); + const char *devname = qdict_get_str(qdict, "devname"); + if (usb_device_del(devname) < 0) { + qemu_error("could not delete USB device '%s'\n", devname); + } } /***********************************************************/ -- cgit v1.2.3 From dcc0da8297bd610e582b851d1b3f9c62c335a6d2 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 22 Dec 2009 11:57:02 +0200 Subject: Don't load options roms intended to be loaded by the bios in qemu The first such option rom will load at address 0, which isn't very nice, and the second will report a conflict and abort, which is horrible. Signed-off-by: Avi Kivity Signed-off-by: Aurelien Jarno (cherry picked from commit e405a2ba91b68817cae2a428de55fe9616a4cf37) --- hw/loader.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/loader.c b/hw/loader.c index 2ceb8eba4..eef385eb5 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -636,6 +636,9 @@ static void rom_reset(void *unused) Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { + if (rom->fw_file) { + continue; + } if (rom->data == NULL) continue; cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize); @@ -654,6 +657,9 @@ int rom_load_all(void) Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { + if (rom->fw_file) { + continue; + } if (addr > rom->addr) { fprintf(stderr, "rom: requested regions overlap " "(rom %s. free=0x" TARGET_FMT_plx @@ -752,7 +758,7 @@ void do_info_roms(Monitor *mon) Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { - if (rom->addr) { + if (!rom->fw_file) { monitor_printf(mon, "addr=" TARGET_FMT_plx " size=0x%06zx mem=%s name=\"%s\" \n", rom->addr, rom->romsize, -- cgit v1.2.3