From patchwork Thu Nov 10 16:01:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 124914 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E287DB6F65 for ; Fri, 11 Nov 2011 03:02:02 +1100 (EST) Received: from localhost ([::1]:33458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROX4i-0007v7-7g for incoming@patchwork.ozlabs.org; Thu, 10 Nov 2011 11:02:00 -0500 Received: from eggs.gnu.org ([140.186.70.92]:58898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROX4B-0006lr-7X for qemu-devel@nongnu.org; Thu, 10 Nov 2011 11:01:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROX48-0002qi-6T for qemu-devel@nongnu.org; Thu, 10 Nov 2011 11:01:27 -0500 Received: from mail-ww0-f53.google.com ([74.125.82.53]:35465) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROX47-0002qd-Rl for qemu-devel@nongnu.org; Thu, 10 Nov 2011 11:01:24 -0500 Received: by wwg7 with SMTP id 7so3785315wwg.10 for ; Thu, 10 Nov 2011 08:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=PFiNgwz5FJEqQMd8Ods8tzBXW8BaLqm7Ng/4txe07qY=; b=kS5/z7s/ow90/mqeNt2SqTIzfZbAjW89jWAdmvnbFH9AZMnJ1VIdPSBgp5i5gmVwxo vJaEbOLaJ4zy1ukt5S201IW0J6WkM2Xc54ecSeo93EV6YNdYm+rEiTToOGb7W+TdtRub VPk1iZPlZRcQZYMSn32IrSn3GLjCpYrE5JwCM= Received: by 10.180.80.98 with SMTP id q2mr9378450wix.53.1320940883129; Thu, 10 Nov 2011 08:01:23 -0800 (PST) Received: from localhost.localdomain (nat-pool-mxp-t.redhat.com. [209.132.186.18]) by mx.google.com with ESMTPS id x8sm5122081wix.17.2011.11.10.08.01.21 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 Nov 2011 08:01:22 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 10 Nov 2011 17:01:08 +0100 Message-Id: <1320940872-4940-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.7.1 In-Reply-To: <1320940872-4940-1-git-send-email-pbonzini@redhat.com> References: <1320940872-4940-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.53 Cc: kwolf@redhat.com, kraxel@redhat.com, scdbackup@gmx.net Subject: [Qemu-devel] [PATCH 1/5] atapi: kill MODE SENSE(6), fix MODE SENSE(10) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Mode page 2A of emulated ATAPI DVD-ROM should have page length 0x14 like SCSI CD-ROM, rather than 0x12. Mode page length is off by 8, as it should contain the length of the payload after the first two bytes. MODE SENSE(6) should be thrown out of ATAPI DVD-ROM emulation. It is not specified in the ATAPI list of MMC-2, and MMC-5 prescribes to use MODE SENSE(10). Anyway, its implementation is wrong. Reported-by: Thomas Schmitt Signed-off-by: Paolo Bonzini --- hw/ide/atapi.c | 21 ++++++++------------- 1 files changed, 8 insertions(+), 13 deletions(-) diff --git a/hw/ide/atapi.c b/hw/ide/atapi.c index d4179a0..cf0e66b 100644 --- a/hw/ide/atapi.c +++ b/hw/ide/atapi.c @@ -689,12 +689,7 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) int action, code; int max_len; - if (buf[0] == GPCMD_MODE_SENSE_10) { - max_len = ube16_to_cpu(buf + 7); - } else { - max_len = buf[4]; - } - + max_len = ube16_to_cpu(buf + 7); action = buf[2] >> 6; code = buf[2] & 0x3f; @@ -702,7 +697,7 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) case 0: /* current values */ switch(code) { case MODE_PAGE_R_W_ERROR: /* error recovery */ - cpu_to_ube16(&buf[0], 16 + 6); + cpu_to_ube16(&buf[0], 16 - 2); buf[2] = 0x70; buf[3] = 0; buf[4] = 0; @@ -717,11 +712,10 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) buf[12] = 0x00; buf[13] = 0x00; buf[14] = 0x00; - buf[15] = 0x00; ide_atapi_cmd_reply(s, 16, max_len); break; case MODE_PAGE_AUDIO_CTL: - cpu_to_ube16(&buf[0], 24 + 6); + cpu_to_ube16(&buf[0], 24 - 2); buf[2] = 0x70; buf[3] = 0; buf[4] = 0; @@ -740,7 +734,7 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) ide_atapi_cmd_reply(s, 24, max_len); break; case MODE_PAGE_CAPABILITIES: - cpu_to_ube16(&buf[0], 28 + 6); + cpu_to_ube16(&buf[0], 30 - 2); buf[2] = 0x70; buf[3] = 0; buf[4] = 0; @@ -749,7 +743,7 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) buf[7] = 0; buf[8] = MODE_PAGE_CAPABILITIES; - buf[9] = 28 - 10; + buf[9] = 30 - 10; buf[10] = 0x3b; /* read CDR/CDRW/DVDROM/DVDR/DVDRAM */ buf[11] = 0x00; @@ -771,7 +765,9 @@ static void cmd_mode_sense(IDEState *s, uint8_t *buf) buf[25] = 0; buf[26] = 0; buf[27] = 0; - ide_atapi_cmd_reply(s, 28, max_len); + buf[28] = 0; + buf[29] = 0; + ide_atapi_cmd_reply(s, 30, max_len); break; default: goto error_cmd; @@ -1037,7 +1033,6 @@ static const struct { [ 0x00 ] = { cmd_test_unit_ready, CHECK_READY }, [ 0x03 ] = { cmd_request_sense, ALLOW_UA }, [ 0x12 ] = { cmd_inquiry, ALLOW_UA }, - [ 0x1a ] = { cmd_mode_sense, /* (6) */ 0 }, [ 0x1b ] = { cmd_start_stop_unit, 0 }, /* [1] */ [ 0x1e ] = { cmd_prevent_allow_medium_removal, 0 }, [ 0x25 ] = { cmd_read_cdvd_capacity, CHECK_READY },