From: Alex Williamson <alex.williamson@hp.com>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] ide: fix ATAPI read drive structure command
Date: Mon, 26 May 2008 23:25:17 -0600 [thread overview]
Message-ID: <1211865917.8201.56.camel@bling> (raw)
In-Reply-To: 5b31733c0709081221l5915a81bs9954de3cfb4f2452@mail.gmail.com
I've found that the introduction of support for the ATAPI
GPCMD_READ_DVD_STRUCTURE command causes a problem for Windows Vista
guests under QEMU. To test the bug, simply boot a Vista VM under QEMU
with a DVD image loaded using the -cdrom option. If you now run
diskpart.exe, the command will hang indefinitely.
The main issue is that the read disk structure command contains a field
indicating the maximum length to be returned. We ignore this field and
always return the maximum possible table size. I also found that we're
getting the format byte from the wrong field in the request (byte 2 is
the MSB of the address field, we want byte 7). The patch below fixes
these issues for me and adds a few extra comments. Perhaps Filip can
confirm whether it still works for the original usage on Darwin/x86.
Thanks,
Alex
Fix ATAPI read drive structure command
Make use of the allocation length field in the command and only return
the number of bytes requested. Fix location of format byte in command.
Add comments for more fields as we fill them in.
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
--
diff -r 1f1541286539 trunk/hw/ide.c
--- a/trunk/hw/ide.c Sun May 25 15:01:05 2008 -0600
+++ b/trunk/hw/ide.c Mon May 26 23:15:06 2008 -0600
@@ -1652,13 +1652,15 @@ static void ide_atapi_cmd(IDEState *s)
{
int media = packet[1];
int layer = packet[6];
- int format = packet[2];
+ int format = packet[7];
+ int length = ube16_to_cpu(packet + 8);
uint64_t total_sectors;
if (media != 0 || layer != 0)
{
ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST,
ASC_INV_FIELD_IN_CMD_PACKET);
+ break;
}
switch (format) {
@@ -1671,20 +1673,28 @@ static void ide_atapi_cmd(IDEState *s)
break;
}
- memset(buf, 0, 2052);
+ if (length == 0)
+ length = 2048 + 4;
+ if (length < 20) {
+ ide_atapi_cmd_error(s, SENSE_ILLEGAL_REQUEST,
+ ASC_INV_FIELD_IN_CMD_PACKET);
+ break;
+ }
+
+ memset(buf, 0, length);
buf[4] = 1; // DVD-ROM, part version 1
buf[5] = 0xf; // 120mm disc, maximum rate unspecified
buf[6] = 0; // one layer, embossed data
- buf[7] = 0;
+ buf[7] = 0; // default densities
- cpu_to_ube32(buf + 8, 0);
- cpu_to_ube32(buf + 12, total_sectors - 1);
- cpu_to_ube32(buf + 16, total_sectors - 1);
+ cpu_to_ube32(buf + 8, 0); // start sector
+ cpu_to_ube32(buf + 12, total_sectors - 1); // end sector
+ cpu_to_ube32(buf + 16, total_sectors - 1); // l0 end sector
- cpu_to_be16wu((uint16_t *)buf, 2048 + 4);
+ cpu_to_be16wu((uint16_t *)buf, length);
- ide_atapi_cmd_reply(s, 2048 + 3, 2048 + 4);
+ ide_atapi_cmd_reply(s, length, length);
break;
default:
next reply other threads:[~2008-05-27 5:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-27 5:25 Alex Williamson [this message]
2008-05-27 7:46 ` [Qemu-devel] [PATCH] ide: fix ATAPI read drive structure command Alexander Graf
2008-05-28 19:48 ` Alex Williamson
2008-06-02 10:33 ` Alexander Graf
2008-06-02 14:58 ` Alex Williamson
2008-06-02 15:42 ` Alexander Graf
2008-06-02 22:12 ` [Qemu-devel] [PATCH] ide: fix ATAPI read drive structure command (v3) Alex Williamson
2008-06-02 22:45 ` Alex Williamson
2008-06-03 13:48 ` Alexander Graf
2008-06-03 14:21 ` Alex Williamson
2008-06-03 18:01 ` Carlo Marcelo Arenas Belon
2008-06-03 16:59 ` Anthony Liguori
2008-06-04 12:30 ` Alex Williamson
2008-06-04 14:35 ` Anthony Liguori
2008-06-04 14:49 ` Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1211865917.8201.56.camel@bling \
--to=alex.williamson@hp.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).