Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K30Sw-0001iV-1F for qemu-devel@nongnu.org; Sun, 01 Jun 2008 23:12:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K30Su-0001hi-M2 for qemu-devel@nongnu.org; Sun, 01 Jun 2008 23:12:08 -0400 Received: from [199.232.76.173] (port=39897 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K30Su-0001hd-Ai for qemu-devel@nongnu.org; Sun, 01 Jun 2008 23:12:08 -0400 Received: from savannah.gnu.org ([199.232.41.3]:33993 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K30Su-0002Y4-2X for qemu-devel@nongnu.org; Sun, 01 Jun 2008 23:12:08 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1K30St-00064H-4Q for qemu-devel@nongnu.org; Mon, 02 Jun 2008 03:12:07 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1K30Ss-00063y-Re for qemu-devel@nongnu.org; Mon, 02 Jun 2008 03:12:07 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Mon, 02 Jun 2008 03:12:06 +0000 Subject: [Qemu-devel] [4649] Fix ATAPI GET_CONFIGURATION function (Alexander Graf, Carlo Marcelo Arenas Belon). Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4649 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4649 Author: balrog Date: 2008-06-02 03:12:06 +0000 (Mon, 02 Jun 2008) Log Message: ----------- Fix ATAPI GET_CONFIGURATION function (Alexander Graf, Carlo Marcelo Arenas Belon). The current implementation of GET_CONFIGURATION in the ATAPI stack of qemu replies a different length depending on the buffer, the data should be written into. On the other hand the SCSI spec defines that length information has to be consistent and independent of return buffer lengths. This patch makes the ATAPI emulation behave according to the spec and fixes the Darwin DVD driver. Signed-off-by: Alexander Graf Signed-off-by: Kevin Wolf Modified Paths: -------------- trunk/hw/ide.c Modified: trunk/hw/ide.c =================================================================== --- trunk/hw/ide.c 2008-06-02 02:29:26 UTC (rev 4648) +++ trunk/hw/ide.c 2008-06-02 03:12:06 UTC (rev 4649) @@ -1715,6 +1715,7 @@ case GPCMD_GET_CONFIGURATION: { uint32_t len; + uint8_t index = 0; /* only feature 0 is supported */ if (packet[2] != 0 || packet[3] != 0) { @@ -1725,12 +1726,13 @@ /* XXX: could result in alignment problems in some architectures */ max_len = ube16_to_cpu(packet + 7); + /* - * XXX: avoid overflow for io_buffer if max_len is bigger than the - * size of that buffer (dimensioned to max number of sectors - * to transfer at once) + * XXX: avoid overflow for io_buffer if max_len is bigger than + * the size of that buffer (dimensioned to max number of + * sectors to transfer at once) * - * Only a problem if the feature/profiles grow exponentially. + * Only a problem if the feature/profiles grow. */ if (max_len > 512) /* XXX: assume 1 sector */ max_len = 512; @@ -1743,22 +1745,17 @@ * XXX: fails to detect correctly DVDs with less data burned * than what a CD can hold */ - if ((s -> nb_sectors)) { - if ((s -> nb_sectors > CD_MAX_SECTORS)) + if (s -> nb_sectors) { + if (s -> nb_sectors > CD_MAX_SECTORS) cpu_to_ube16(buf + 6, MMC_PROFILE_DVD_ROM); else cpu_to_ube16(buf + 6, MMC_PROFILE_CD_ROM); } - len = 8; /* header completed */ - if (max_len > len) { - uint8_t index = 0; - - buf[10] = 0x02 | 0x01; /* persistent and current */ - len += 4; /* header */ - len += ide_atapi_set_profile(buf, &index, MMC_PROFILE_DVD_ROM); - len += ide_atapi_set_profile(buf, &index, MMC_PROFILE_CD_ROM); - } + buf[10] = 0x02 | 0x01; /* persistent and current */ + len = 12; /* headers: 8 + 4 */ + len += ide_atapi_set_profile(buf, &index, MMC_PROFILE_DVD_ROM); + len += ide_atapi_set_profile(buf, &index, MMC_PROFILE_CD_ROM); cpu_to_ube32(buf, len - 4); /* data length */ ide_atapi_cmd_reply(s, len, max_len);