Skip to contentSkip to conversation

ATAPI CDROM passthrough v5

PATCH In review Ian Jackson 7 participants 21 messages Aug 12, 2009 – Oct 19, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ATAPI CDROM passthrough v5

I've picked up Alex's patch series for this. Changes since v4:
* rebased to current tip as of approximately yesterday
* passthrough of firmware update is enabled by default
* fixed some build issues

Quoted 1 line · Anthony Liguori

This series breaks the cris-softmmu build.

I think I've fixed it up. It builds for me, anyway. If it now doesn't build do please tell me the error message and I'l fix it.

Quoted 2 lines

Also, I think Paul and I both requested that fw upgrade not be disabled by default.

As previously discussed I think this is a mistake, but it's a decision for qemu upstream to make so I have changed this.

Quoted 3 lines

I would also suggest that you only expose this as an option
through qdev properties instead of a new command line option as it should be controllable on a per-device basis.

The reason to disable it is not to prevent the guest breaking the hardware. It is to prevent the guest escaping the containment entirely, which it can probably do if firmware updates are allowed. This seems to me to be a general property of the guest, rather than of the device. So I think disabling it in one place is better.

Patches follow.

Thanks,
Ian.

#1 lore raw

PATCH 1/7 atapi: fix up a few comments

---
 hw/ide.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
hw/ide.c +6 -6
index bebda7c..675a06d 100644
@@ -1682,9 +1682,9 @@ static void ide_atapi_cmd(IDEState *s)
             switch(action) {
             case 0: /* current values */
                 switch(code) {
-                case 0x01: /* error recovery */
+                case 0x01: /* read write error recovery parameters */
                     cpu_to_ube16(&buf[0], 16 + 6);
-                    buf[2] = 0x70;
+                    buf[2] = 0x70; /* Obsolete: medium type code */
                     buf[3] = 0;
                     buf[4] = 0;
                     buf[5] = 0;
@@ -1701,17 +1701,17 @@ static void ide_atapi_cmd(IDEState *s)
                     buf[15] = 0x00;
                     ide_atapi_cmd_reply(s, 16, max_len);
                     break;
-                case 0x2a:
+                case 0x2a: /* CD/DVD capabilities & mechanical status */
                     cpu_to_ube16(&buf[0], 28 + 6);
-                    buf[2] = 0x70;
+                    buf[2] = 0x70; /* Obsolete: medium type code */
                     buf[3] = 0;
                     buf[4] = 0;
                     buf[5] = 0;
                     buf[6] = 0;
                     buf[7] = 0;
 
-                    buf[8] = 0x2a;
-                    buf[9] = 0x12;
+                    buf[8] = 0x2a; /* page code */
+                    buf[9] = 0x12; /* page length */
                     buf[10] = 0x00;
                     buf[11] = 0x00;
 
Signature · 1 line
1.4.4.4
#2 lore raw

PATCH 2/7 atapi: protocol define updates

In reply to Ian Jackson

Add some missing ATAPI protocol defintions, and fix up some whitespaces and comments on the way.

---
 hw/ide.c |   77 ++++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 60 insertions(+), 17 deletions(-)
hw/ide.c +60 -17
index 675a06d..bc36f65 100644
@@ -216,13 +216,17 @@
 
 #define ATAPI_PACKET_SIZE 12
 
-/* The generic packet command opcodes for CD/DVD Logical Units,
- * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
+/*********************************************************************
+ * Generic Packet commands, MMC commands, and such
+ *********************************************************************/
+
+ /* The generic packet command opcodes for CD/DVD Logical Units,
+  * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
 #define GPCMD_BLANK			    0xa1
 #define GPCMD_CLOSE_TRACK		    0x5b
 #define GPCMD_FLUSH_CACHE		    0x35
 #define GPCMD_FORMAT_UNIT		    0x04
-#define GPCMD_GET_CONFIGURATION		    0x46
+#define GPCMD_GET_CONFIGURATION             0x46
 #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
 #define GPCMD_GET_PERFORMANCE		    0xac
 #define GPCMD_INQUIRY			    0x12
@@ -238,6 +242,8 @@
 #define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL  0x1e
 #define GPCMD_READ_10			    0x28
 #define GPCMD_READ_12			    0xa8
+#define GPCMD_READ_BUFFER		    0x3c
+#define GPCMD_READ_BUFFER_CAPACITY	    0x5c
 #define GPCMD_READ_CDVD_CAPACITY	    0x25
 #define GPCMD_READ_CD			    0xbe
 #define GPCMD_READ_CD_MSF		    0xb9
@@ -246,15 +252,16 @@
 #define GPCMD_READ_FORMAT_CAPACITIES	    0x23
 #define GPCMD_READ_HEADER		    0x44
 #define GPCMD_READ_TRACK_RZONE_INFO	    0x52
-#define GPCMD_READ_SUBCHANNEL		    0x42
-#define GPCMD_READ_TOC_PMA_ATIP		    0x43
+#define GPCMD_READ_SUBCHANNEL	            0x42
+#define GPCMD_READ_TOC_PMA_ATIP             0x43
 #define GPCMD_REPAIR_RZONE_TRACK	    0x58
 #define GPCMD_REPORT_KEY		    0xa4
 #define GPCMD_REQUEST_SENSE		    0x03
 #define GPCMD_RESERVE_RZONE_TRACK	    0x53
+#define GPCMD_SEND_CUE_SHEET		    0x5d
 #define GPCMD_SCAN			    0xba
 #define GPCMD_SEEK			    0x2b
-#define GPCMD_SEND_DVD_STRUCTURE	    0xad
+#define GPCMD_SEND_DVD_STRUCTURE	    0xbf
 #define GPCMD_SEND_EVENT		    0xa2
 #define GPCMD_SEND_KEY			    0xa3
 #define GPCMD_SEND_OPC			    0x54
@@ -263,9 +270,11 @@
 #define GPCMD_START_STOP_UNIT		    0x1b
 #define GPCMD_STOP_PLAY_SCAN		    0x4e
 #define GPCMD_TEST_UNIT_READY		    0x00
-#define GPCMD_VERIFY_10			    0x2f
+#define GPCMD_VERIFY_10                     0x2f
 #define GPCMD_WRITE_10			    0x2a
+#define GPCMD_WRITE_12			    0xaa
 #define GPCMD_WRITE_AND_VERIFY_10	    0x2e
+#define GPCMD_WRITE_BUFFER		    0x3b
 /* This is listed as optional in ATAPI 2.6, but is (curiously)
  * missing from Mt. Fuji, Table 57.  It _is_ mentioned in Mt. Fuji
  * Table 377 as an MMC command for SCSi devices though...  Most ATAPI
@@ -279,18 +288,20 @@
  * older drives only.
  */
 #define GPCMD_GET_MEDIA_STATUS		    0xda
-#define GPCMD_MODE_SENSE_6		    0x1a
+#define GPCMD_MODE_SENSE_6                  0x1a
 
 /* Mode page codes for mode sense/set */
+#define GPMODE_VENDOR_PAGE		0x00
 #define GPMODE_R_W_ERROR_PAGE		0x01
 #define GPMODE_WRITE_PARMS_PAGE		0x05
+#define GPMODE_WCACHING_PAGE		0x08
 #define GPMODE_AUDIO_CTL_PAGE		0x0e
 #define GPMODE_POWER_PAGE		0x1a
 #define GPMODE_FAULT_FAIL_PAGE		0x1c
 #define GPMODE_TO_PROTECT_PAGE		0x1d
 #define GPMODE_CAPABILITIES_PAGE	0x2a
 #define GPMODE_ALL_PAGES		0x3f
-/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor
+/* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor
  * of MODE_SENSE_POWER_PAGE */
 #define GPMODE_CDROM_PAGE		0x0d
 
@@ -304,10 +315,26 @@
  */
 
 /* Some generally useful CD-ROM information */
-#define CD_MINS                       80 /* max. minutes per CD */
-#define CD_SECS                       60 /* seconds per minute */
-#define CD_FRAMES                     75 /* frames per second */
-#define CD_FRAMESIZE                2048 /* bytes per frame, "cooked" mode */
+#define CD_MINS              80 /* max. minutes per CD */
+#define CD_SECS              60 /* seconds per minute */
+#define CD_FRAMES            75 /* frames per second */
+#define CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
+#define CD_MSF_OFFSET       150 /* MSF numbering offset of first frame */
+#define CD_CHUNK_SIZE        24 /* lowest-level "data bytes piece" */
+#define CD_NUM_OF_CHUNKS     98 /* chunks per frame */
+#define CD_FRAMESIZE_SUB     96 /* subchannel data "frame" size */
+#define CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
+#define CD_SUBHEAD_SIZE       8 /* subheader bytes per raw XA data frame */
+#define CD_EDC_SIZE           4 /* bytes EDC per most raw data frame types */
+#define CD_ZERO_SIZE          8 /* bytes zero per yellow book mode 1 frame */
+#define CD_ECC_SIZE         276 /* bytes ECC per most raw data frame types */
+#define CD_FRAMESIZE       2048 /* bytes per frame, "cooked" mode */
+#define CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
+#define CD_FRAMESIZE_RAWER 2646 /* The maximum possible returned bytes */
+/* most drives don't deliver everything: */
+#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/
+#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/
+
 #define CD_MAX_BYTES       (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE)
 #define CD_MAX_SECTORS     (CD_MAX_BYTES / 512)
 
@@ -346,12 +373,15 @@
 #define MMC_PROFILE_HDDVD_RW_DL         0x005A
 #define MMC_PROFILE_INVALID             0xFFFF
 
+
 #define ATAPI_INT_REASON_CD             0x01 /* 0 = data transfer */
 #define ATAPI_INT_REASON_IO             0x02 /* 1 = transfer to the host */
 #define ATAPI_INT_REASON_REL            0x04
 #define ATAPI_INT_REASON_TAG            0xf8
 
 /* same constants as bochs */
+#define ASC_NONE                             0x00
+#define ASC_READ_ERROR                       0x11
 #define ASC_ILLEGAL_OPCODE                   0x20
 #define ASC_LOGICAL_BLOCK_OOR                0x21
 #define ASC_INV_FIELD_IN_CMD_PACKET          0x24
@@ -367,10 +397,23 @@
 #define CFA_INVALID_ADDRESS     0x21
 #define CFA_ADDRESS_OVERFLOW    0x2f
 
-#define SENSE_NONE            0
-#define SENSE_NOT_READY       2
-#define SENSE_ILLEGAL_REQUEST 5
-#define SENSE_UNIT_ATTENTION  6
+/* Sense keys */
+#define SENSE_NONE             0
+#define SENSE_RECOVERED_ERROR  1
+#define SENSE_NOT_READY        2
+#define SENSE_MEDIUM_ERROR     3
+#define SENSE_HARDWARE_ERROR   4
+#define SENSE_ILLEGAL_REQUEST  5
+#define SENSE_UNIT_ATTENTION   6
+#define SENSE_DATA_PROTECT     7
+#define SENSE_BLANK_CHECK      8
+#define SENSE_VENDOR_SPECIFIC  9
+#define SENSE_COPY_ABORTED     10
+#define SENSE_ABORTED_COMMAND  11
+#define SENSE_VOLUME_OVERFLOW  13
+#define SENSE_MISCOMPARE       14
+
+#define IO_BUFFER_MAX_SIZE      (IDE_DMA_BUF_SECTORS * 512 + 4)
 
 struct IDEState;
 
Signature · 1 line
1.4.4.4
#3 lore raw

PATCH 3/7 atapi: guessing if the cdrom device is a scsi device.

In reply to Ian Jackson

ATAPI pass through code is enabled when the block device is a scsi device. So we have to guess if the block device is a scsi device in cdrom_open().

---
 block/raw-posix.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
block/raw-posix.c +8 -0
index bdee07f..ebb13d4 100644
@@ -1305,6 +1305,14 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags)
     s->type = FTYPE_CD;
 
     /* open will not fail even if no CD is inserted, so add O_NONBLOCK */
+#if defined(__linux__) && defined(CONFIG_AIO)
+    if (strstart(filename, "/dev/sg", NULL) ||
+        strstart(filename, "/dev/cd", NULL) ||
+        strstart(filename, "/dev/dvd", NULL) ||
+        strstart(filename, "/dev/sr", NULL)) {
+        bs->sg = 1;
+    }
+#endif
     return raw_open_common(bs, filename, flags, O_NONBLOCK);
 }
 
Signature · 1 line
1.4.4.4
#4 lore raw

PATCH 4/7 atapi: adds header guards to hw/pcmia.h

In reply to Ian Jackson
---
 hw/pcmcia.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
hw/pcmcia.h +5 -0
index 7171504..3c59698 100644
@@ -1,5 +1,8 @@
 /* PCMCIA/Cardbus */
 
+#ifndef PCMCIA_H
+#define PCMCIA_H
+
 #include "qemu-common.h"
 
 typedef struct {
@@ -49,3 +52,5 @@ struct PCMCIACardState {
 
 /* dscm1xxxx.c */
 PCMCIACardState *dscm1xxxx_init(BlockDriverState *bdrv);
+
+#endif
Signature · 1 line
1.4.4.4
#5 lore raw

PATCH 5/7 atapi: adds header guards to hw/mac_dbdma.h

In reply to Ian Jackson
---
 hw/mac_dbdma.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
hw/mac_dbdma.h +5 -0
index d236c5b..fc37590 100644
@@ -20,6 +20,9 @@
  * THE SOFTWARE.
  */
 
+#ifndef MAC_DBDMA_H
+#define MAC_DBDMA_H
+
 typedef struct DBDMA_io DBDMA_io;
 
 typedef void (*DBDMA_flush)(DBDMA_io *io);
@@ -41,3 +44,5 @@ void DBDMA_register_channel(void *dbdma, int nchan, qemu_irq irq,
                             void *opaque);
 void DBDMA_schedule(void);
 void* DBDMA_init (int *dbdma_mem_index);
+
+#endif /* !MAC_DBDMA_H */
Signature · 1 line
1.4.4.4
#6 lore raw

PATCH 6/7 atapi: made some part of ide.c public and moved some part to atapi.

In reply to Ian Jackson
---
 hw/atapi-data.c    |  269 ++++++++++++++++++++++++
 hw/atapi-defines.h |  234 +++++++++++++++++++++
 hw/ide.c           |  545 ++-----------------------------------------------
 hw/ide.h           |  579 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1095 insertions(+), 532 deletions(-)
hw/atapi-data.c new file +269 -0
new file mode 100644
index 0000000..b995b77
@@ -0,0 +1,269 @@
+/*
+ * ATAPI pass through addition data
+ *
+ * Copyright (c) 2009 Alexandre Bique
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "atapi-defines.h"
+
+/* The generic packet command opcodes for CD/DVD Logical Units,
+ * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
+static const struct {
+    unsigned short packet_command;
+    const char * const text;
+} packet_command_texts[] = {
+    { GPCMD_TEST_UNIT_READY, "Test Unit Ready" },
+    { GPCMD_REQUEST_SENSE, "Request Sense" },
+    { GPCMD_FORMAT_UNIT, "Format Unit" },
+    { GPCMD_INQUIRY, "Inquiry" },
+    { GPCMD_START_STOP_UNIT, "Start/Stop Unit" },
+    { GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, "Prevent/Allow Medium Removal" },
+    { GPCMD_READ_FORMAT_CAPACITIES, "Read Format Capacities" },
+    { GPCMD_READ_CDVD_CAPACITY, "Read Cd/Dvd Capacity" },
+    { GPCMD_READ_10, "Read 10" },
+    { GPCMD_WRITE_10, "Write 10" },
+    { GPCMD_SEEK, "Seek" },
+    { GPCMD_WRITE_AND_VERIFY_10, "Write and Verify 10" },
+    { GPCMD_VERIFY_10, "Verify 10" },
+    { GPCMD_FLUSH_CACHE, "Flush Cache" },
+    { GPCMD_READ_SUBCHANNEL, "Read Subchannel" },
+    { GPCMD_READ_TOC_PMA_ATIP, "Read Table of Contents" },
+    { GPCMD_READ_HEADER, "Read Header" },
+    { GPCMD_PLAY_AUDIO_10, "Play Audio 10" },
+    { GPCMD_GET_CONFIGURATION, "Get Configuration" },
+    { GPCMD_PLAY_AUDIO_MSF, "Play Audio MSF" },
+    { GPCMD_PLAYAUDIO_TI, "Play Audio TrackIndex" },
+    { GPCMD_GET_EVENT_STATUS_NOTIFICATION,
+      "Get Event Status Notification" },
+    { GPCMD_PAUSE_RESUME, "Pause/Resume" },
+    { GPCMD_STOP_PLAY_SCAN, "Stop Play/Scan" },
+    { GPCMD_READ_DISC_INFO, "Read Disc Info" },
+    { GPCMD_READ_TRACK_RZONE_INFO, "Read Track Rzone Info" },
+    { GPCMD_RESERVE_RZONE_TRACK, "Reserve Rzone Track" },
+    { GPCMD_SEND_OPC, "Send OPC" },
+    { GPCMD_MODE_SELECT_10, "Mode Select 10" },
+    { GPCMD_REPAIR_RZONE_TRACK, "Repair Rzone Track" },
+    { GPCMD_MODE_SENSE_10, "Mode Sense 10" },
+    { GPCMD_CLOSE_TRACK, "Close Track" },
+    { GPCMD_BLANK, "Blank" },
+    { GPCMD_SEND_EVENT, "Send Event" },
+    { GPCMD_SEND_KEY, "Send Key" },
+    { GPCMD_REPORT_KEY, "Report Key" },
+    { GPCMD_LOAD_UNLOAD, "Load/Unload" },
+    { GPCMD_SET_READ_AHEAD, "Set Read-ahead" },
+    { GPCMD_READ_12, "Read 12" },
+    { GPCMD_GET_PERFORMANCE, "Get Performance" },
+    { GPCMD_SEND_DVD_STRUCTURE, "Send DVD Structure" },
+    { GPCMD_READ_DVD_STRUCTURE, "Read DVD Structure" },
+    { GPCMD_SET_STREAMING, "Set Streaming" },
+    { GPCMD_READ_CD_MSF, "Read CD MSF" },
+    { GPCMD_SCAN, "Scan" },
+    { GPCMD_SET_SPEED, "Set Speed" },
+    { GPCMD_PLAY_CD, "Play CD" },
+    { GPCMD_MECHANISM_STATUS, "Mechanism Status" },
+    { GPCMD_READ_CD, "Read CD" },
+    { GPCMD_READ_BUFFER_CAPACITY, "Read Buffer Capacity" },
+    { GPCMD_READ_BUFFER, "Read Buffer" },
+    { GPCMD_SEND_CUE_SHEET, "Send Cue Sheet" },
+    { 0, 0 }
+};
+
+const char *atapi_cmd_to_str(int cmd)
+{
+    int i;
+
+    for (i = 0; packet_command_texts[i].text; ++i)
+        if (packet_command_texts[i].packet_command == cmd)
+            return packet_command_texts[i].text;
+    return 0;
+}
+
+/* From Table 303 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
+const char * const sense_key_texts[16] = {
+    "No sense data",
+    "Recovered error",
+    "Not ready",
+    "Medium error",
+    "Hardware error",
+    "Illegal request",
+    "Unit attention",
+    "Data protect",
+    "Blank check",
+    "(reserved)",
+    "(reserved)",
+    "Aborted command",
+    "(reserved)",
+    "(reserved)",
+    "Miscompare",
+    "(reserved)",
+};
+
+/* From Table 304 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
+static const struct {
+    unsigned long asc_ascq;
+    const char * const text;
+} sense_data_texts[] = {
+    { 0x000000, "No additional sense information" },
+    { 0x000011, "Play operation in progress" },
+    { 0x000012, "Play operation paused" },
+    { 0x000013, "Play operation successfully completed" },
+    { 0x000014, "Play operation stopped due to error" },
+    { 0x000015, "No current audio status to return" },
+    { 0x010c0a, "Write error - padding blocks added" },
+    { 0x011700, "Recovered data with no error correction applied" },
+    { 0x011701, "Recovered data with retries" },
+    { 0x011702, "Recovered data with positive head offset" },
+    { 0x011703, "Recovered data with negative head offset" },
+    { 0x011704, "Recovered data with retries and/or CIRC applied" },
+    { 0x011705, "Recovered data using previous sector ID" },
+    { 0x011800, "Recovered data with error correction applied" },
+    { 0x011801, "Recovered data with error correction and retries applied"},
+    { 0x011802, "Recovered data - the data was auto-reallocated" },
+    { 0x011803, "Recovered data with CIRC" },
+    { 0x011804, "Recovered data with L-EC" },
+    { 0x015d00, "Failure prediction threshold exceeded"
+      " - Predicted logical unit failure" },
+    { 0x015d01, "Failure prediction threshold exceeded"
+      " - Predicted media failure" },
+    { 0x015dff, "Failure prediction threshold exceeded - False" },
+    { 0x017301, "Power calibration area almost full" },
+    { 0x020400, "Logical unit not ready - cause not reportable" },
+    /* Following is misspelled in ATAPI 2.6, _and_ in Mt. Fuji */
+    { 0x020401, "Logical unit not ready"
+      " - in progress [sic] of becoming ready" },
+    { 0x020402, "Logical unit not ready - initializing command required" },
+    { 0x020403, "Logical unit not ready - manual intervention required" },
+    { 0x020404, "Logical unit not ready - format in progress" },
+    { 0x020407, "Logical unit not ready - operation in progress" },
+    { 0x020408, "Logical unit not ready - long write in progress" },
+    { 0x020600, "No reference position found (media may be upside down)" },
+    { 0x023000, "Incompatible medium installed" },
+    { 0x023a00, "Medium not present" },
+    { 0x025300, "Media load or eject failed" },
+    { 0x025700, "Unable to recover table of contents" },
+    { 0x030300, "Peripheral device write fault" },
+    { 0x030301, "No write current" },
+    { 0x030302, "Excessive write errors" },
+    { 0x030c00, "Write error" },
+    { 0x030c01, "Write error - Recovered with auto reallocation" },
+    { 0x030c02, "Write error - auto reallocation failed" },
+    { 0x030c03, "Write error - recommend reassignment" },
+    { 0x030c04, "Compression check miscompare error" },
+    { 0x030c05, "Data expansion occurred during compress" },
+    { 0x030c06, "Block not compressible" },
+    { 0x030c07, "Write error - recovery needed" },
+    { 0x030c08, "Write error - recovery failed" },
+    { 0x030c09, "Write error - loss of streaming" },
+    { 0x031100, "Unrecovered read error" },
+    { 0x031106, "CIRC unrecovered error" },
+    { 0x033101, "Format command failed" },
+    { 0x033200, "No defect spare location available" },
+    { 0x033201, "Defect list update failure" },
+    { 0x035100, "Erase failure" },
+    { 0x037200, "Session fixation error" },
+    { 0x037201, "Session fixation error writin lead-in" },
+    { 0x037202, "Session fixation error writin lead-out" },
+    { 0x037300, "CD control error" },
+    { 0x037302, "Power calibration area is full" },
+    { 0x037303, "Power calibration area error" },
+    { 0x037304, "Program memory area / RMA update failure" },
+    { 0x037305, "Program memory area / RMA is full" },
+    { 0x037306, "Program memory area / RMA is (almost) full" },
+    { 0x040200, "No seek complete" },
+    { 0x040300, "Write fault" },
+    { 0x040900, "Track following error" },
+    { 0x040901, "Tracking servo failure" },
+    { 0x040902, "Focus servo failure" },
+    { 0x040903, "Spindle servo failure" },
+    { 0x041500, "Random positioning error" },
+    { 0x041501, "Mechanical positioning or changer error" },
+    { 0x041502, "Positioning error detected by read of medium" },
+    { 0x043c00, "Mechanical positioning or changer error" },
+    { 0x044000, "Diagnostic failure on component (ASCQ)" },
+    { 0x044400, "Internal CD/DVD logical unit failure" },
+    { 0x04b600, "Media load mechanism failed" },
+    { 0x051a00, "Parameter list length error" },
+    { 0x052000, "Invalid command operation code" },
+    { 0x052100, "Logical block address out of range" },
+    { 0x052102, "Invalid address for write" },
+    { 0x052400, "Invalid field in command packet" },
+    { 0x052600, "Invalid field in parameter list" },
+    { 0x052601, "Parameter not supported" },
+    { 0x052602, "Parameter value invalid" },
+    { 0x052700, "Write protected media" },
+    { 0x052c00, "Command sequence error" },
+    { 0x052c03, "Current program area is not empty" },
+    { 0x052c04, "Current program area is empty" },
+    { 0x053001, "Cannot read medium - unknown format" },
+    { 0x053002, "Cannot read medium - incompatible format" },
+    { 0x053900, "Saving parameters not supported" },
+    { 0x054e00, "Overlapped commands attempted" },
+    { 0x055302, "Medium removal prevented" },
+    { 0x055500, "System resource failure" },
+    { 0x056300, "End of user area encountered on this track" },
+    { 0x056400, "Illegal mode for this track or incompatible medium" },
+    { 0x056f00, "Copy protection key exchange failure"
+      " - Authentication failure" },
+    { 0x056f01, "Copy protection key exchange failure - Key not present" },
+    { 0x056f02, "Copy protection key exchange failure"
+      " - Key not established" },
+    { 0x056f03, "Read of scrambled sector without authentication" },
+    { 0x056f04, "Media region code is mismatched to logical unit" },
+    { 0x056f05, "Drive region must be permanent"
+      " / region reset count error" },
+    { 0x057203, "Session fixation error - incomplete track in session" },
+    { 0x057204, "Empty or partially written reserved track" },
+    { 0x057205, "No more RZONE reservations are allowed" },
+    { 0x05bf00, "Loss of streaming" },
+    { 0x062800, "Not ready to ready transition, medium may have changed" },
+    { 0x062900, "Power on, reset or hardware reset occurred" },
+    { 0x062a00, "Parameters changed" },
+    { 0x062a01, "Mode parameters changed" },
+    { 0x062e00, "Insufficient time for operation" },
+    { 0x063f00, "Logical unit operating conditions have changed" },
+    { 0x063f01, "Microcode has been changed" },
+    { 0x065a00, "Operator request or state change input (unspecified)" },
+    { 0x065a01, "Operator medium removal request" },
+    { 0x0bb900, "Play operation aborted" },
+    /* Here we use 0xff for the key (not a valid key) to signify
+     * that these can have _any_ key value associated with them... */
+    { 0xff0401, "Logical unit is in process of becoming ready" },
+    { 0xff0400, "Logical unit not ready, cause not reportable" },
+    { 0xff0402, "Logical unit not ready, initializing command required" },
+    { 0xff0403, "Logical unit not ready, manual intervention required" },
+    { 0xff0500, "Logical unit does not respond to selection" },
+    { 0xff0800, "Logical unit communication failure" },
+    { 0xff0802, "Logical unit communication parity error" },
+    { 0xff0801, "Logical unit communication time-out" },
+    { 0xff2500, "Logical unit not supported" },
+    { 0xff4c00, "Logical unit failed self-configuration" },
+    { 0xff3e00, "Logical unit has not self-configured yet" },
+};
+
+const char *atapi_ascq_to_str(int ascq)
+{
+    int i;
+
+    for (i = 0; sense_data_texts[i].text; ++i)
+        if (sense_data_texts[i].asc_ascq == ascq)
+            return sense_data_texts[i].text;
+    return 0;
+}
hw/atapi-defines.h new file +234 -0

234 lines not on this page · raw message

hw/ide.c +13 -532

625 lines not on this page · raw message

hw/ide.h new file +579 -0

579 lines not on this page · raw message

Signature · 1 line
1.4.4.4
#7 lore raw

PATCH 7/7 atapi: introducing atapi pass through

In reply to Ian Jackson

This patch introduces atapi pass through. The pass through code is used by default when the underlying block device is a scsi device.

This brings one new option to the command line interface:
-cdrom-reject-fw-upgrade
which blocks firmware upgrades by the guest. By default these are *allowed* which could be a security problem in some setups. See the WRITE_BUFFER command for more details.

---
 Makefile.target |    9 +++--
 hw/ide.c        |   31 +++++++---------
 hw/ide.h        |  104 ++++++++++++++++++++++++++++++++++++++++++++++---------
 qemu-options.hx |    7 ++++
 sysemu.h        |    1 +
 vl.c            |    6 +++
 6 files changed, 121 insertions(+), 37 deletions(-)
Makefile.target +6 -3
index 3f5d24a..a035e64 100644
@@ -184,6 +184,7 @@ obj-y += wdt_ib700.o wdt_i6300esb.o
 
 # Hardware support
 obj-i386-y = ide.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o
+obj-i386-y += atapi-pt.o atapi-data.o
 obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
 obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
 obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
@@ -191,6 +192,7 @@ obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o
 
 # shared objects
 obj-ppc-y = ppc.o ide.o vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o
+obj-ppc-y += atapi-pt.o atapi-data.o
 # PREP target
 obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o
 obj-ppc-y += prep_pci.o ppc_prep.o
@@ -212,6 +214,7 @@ obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
 obj-mips-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o
 obj-mips-y += g364fb.o jazz_led.o dp8393x.o
 obj-mips-y += ide.o gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
+obj-mips-y += atapi-pt.o atapi-data.o
 obj-mips-y += piix_pci.o parallel.o cirrus_vga.o isa-bus.o pcspk.o $(sound-obj-y)
 obj-mips-y += mipsnet.o
 obj-mips-y += pflash_cfi01.o
@@ -242,7 +245,7 @@ obj-cris-y += etraxfs_ser.o
 obj-cris-y += pflash_cfi02.o
 
 ifeq ($(TARGET_ARCH), sparc64)
-obj-sparc-y = sun4u.o ide.o isa-bus.o pckbd.o vga.o apb_pci.o
+obj-sparc-y = sun4u.o ide.o atapi-pt.o atapi-data.o isa-bus.o pckbd.o vga.o apb_pci.o
 obj-sparc-y += fdc.o mc146818rtc.o serial.o
 obj-sparc-y += cirrus_vga.o parallel.o
 else
@@ -261,7 +264,7 @@ obj-arm-y += arm-semi.o
 obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
 obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
 obj-arm-y += pflash_cfi01.o gumstix.o
-obj-arm-y += zaurus.o ide.o serial.o spitz.o tosa.o tc6393xb.o
+obj-arm-y += zaurus.o ide.o atapi-pt.o atapi-data.o serial.o spitz.o tosa.o tc6393xb.o
 obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o
 obj-arm-y += omap2.o omap_dss.o soc_dma.o
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
@@ -275,7 +278,7 @@ obj-arm-y += syborg_virtio.o
 
 obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
 obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o serial.o
-obj-sh4-y += ide.o
+obj-sh4-y += ide.o atapi-pt.o atapi-data.o
 
 obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
 obj-m68k-y += m68k-semi.o dummy_m68k.o
hw/ide.c +14 -17
index 83d7acc..78c0d79 100644
@@ -22,21 +22,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include "hw.h"
-#include "pc.h"
-#include "pci.h"
-#include "scsi-disk.h"
-#include "pcmcia.h"
-#include "block.h"
-#include "block_int.h"
-#include "qemu-timer.h"
-#include "sysemu.h"
-#include "ppc_mac.h"
-#include "mac_dbdma.h"
-#include "sh.h"
-#include "dma.h"
 #include "ide.h"
-#include "atapi-defines.h"
+#include "atapi-pt.h"
 
 /* debug IDE devices */
 //#define DEBUG_IDE
@@ -44,6 +31,7 @@
 //#define DEBUG_AIO
 #define USE_DMA_CDROM
 
+
 /* XXX: DVDs that could fit on a CD will be reported as a CD */
 static inline int media_present(IDEState *s)
 {
@@ -62,7 +50,6 @@ static inline int media_is_cd(IDEState *s)
 
 static void ide_dma_restart(IDEState *s);
 static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret);
-static void ide_atapi_cmd_error(IDEState *s, int sense_key, int asc);
 
 static void padstr(char *str, const char *src, int len)
 {
@@ -1978,7 +1965,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
             /* ATAPI commands */
         case WIN_PIDENTIFY:
             if (s->is_cdrom) {
-                ide_atapi_identify(s);
+                s->atapi_identify(s);
                 s->status = READY_STAT | SEEK_STAT;
                 ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop);
             } else {
@@ -2016,7 +2003,7 @@ static void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val)
             s->atapi_dma = s->feature & 1;
             s->nsector = 1;
             ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE,
-                               ide_atapi_cmd);
+                               s->atapi_cmd);
             break;
         /* CF-ATA commands */
         case CFA_REQ_EXT_ERROR_CODE:
@@ -2355,6 +2342,16 @@ static void ide_init2(IDEState *ide_state,
 
             if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {
                 s->is_cdrom = 1;
+                if (!bdrv_is_sg(s->bs)) {
+                    s->atapi_cmd = ide_atapi_cmd;
+                    s->atapi_identify = ide_atapi_identify;
+                }
+#if CONFIG_ATAPI_PT
+                else {
+                    s->atapi_cmd = ide_atapi_pt_cmd;
+                    s->atapi_identify = ide_atapi_pt_identify;
+                }
+#endif /* CONFIG_ATAPI_PT */
 		bdrv_set_change_cb(s->bs, cdrom_change_cb, s);
             }
         }
hw/ide.h +87 -17

139 lines not on this page · raw message

qemu-options.hx +7 -0
index 38989f1..4992bf9 100644
@@ -91,6 +91,13 @@ Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and
 using @file{/dev/cdrom} as filename (@pxref{host_drives}).
 ETEXI
 
+DEF("cdrom-reject-fw-upgrade", 0, QEMU_OPTION_cdrom_reject_fw_upgrade,
+    "-cdrom-reject-fw-upgrade     prevent the guest from upgrading cdrom firmware.\n")
+STEXI
+@item -cdrom-reject-fw-upgrade
+Prevent Qemu from passing through ATAPI firmware upgrade command.
+ETEXI
+
 DEF("drive", HAS_ARG, QEMU_OPTION_drive,
     "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
     "       [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
sysemu.h +1 -0
index dffb2f1..9904c82 100644
@@ -122,6 +122,7 @@ extern int no_quit;
 extern int semihosting_enabled;
 extern int old_param;
 extern int boot_menu;
+extern int atapi_pt_reject_fw_upgrade;
 
 #ifdef CONFIG_KQEMU
 extern int kqemu_allowed;
vl.c +6 -0
index 8b2b289..28cd424 100644
@@ -142,6 +142,7 @@ int main(int argc, char **argv)
 #include "hw/smbios.h"
 #include "hw/xen.h"
 #include "hw/qdev.h"
+#include "hw/atapi-pt.h"
 #include "bt-host.h"
 #include "net.h"
 #include "monitor.h"
@@ -248,6 +249,7 @@ unsigned int nb_prom_envs = 0;
 const char *prom_envs[MAX_PROM_ENVS];
 #endif
 int boot_menu;
+int atapi_pt_reject_fw_upgrade;
 
 int nb_numa_nodes;
 uint64_t node_mem[MAX_NODES];
@@ -1793,6 +1795,7 @@ static int bt_parse(const char *opt)
 
 #define HD_ALIAS "index=%d,media=disk"
 #define CDROM_ALIAS "index=2,media=cdrom"
+#define CDROM_PT_ALIAS "index=2,media=cdrompt"
 #define FD_ALIAS "index=%d,if=floppy"
 #define PFLASH_ALIAS "if=pflash"
 #define MTD_ALIAS "if=mtd"
@@ -5068,6 +5071,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_cdrom:
                 drive_add(optarg, CDROM_ALIAS);
                 break;
+            case QEMU_OPTION_cdrom_reject_fw_upgrade:
+                atapi_pt_reject_fw_upgrade = 1;
+                break;
             case QEMU_OPTION_boot:
                 {
                     static const char * const params[] = {
Signature · 1 line
1.4.4.4
#8 lore raw
In reply to Ian Jackson
Quoted 2 lines · I wrote:

I think I've fixed it up. It builds for me, anyway. If it now doesn't build do please tell me the error message and I'l fix it.

I did have to do this, to fix an unrelated `may be used initialised' warning. I'm not sure if it's the right fix.

Ian.

hw/pci-hotplug.c +1 -1
index 4da916c..2efd21c 100644
@@ -99,7 +99,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
                                            const char *opts)
 {
     PCIDevice *dev;
-    DriveInfo *dinfo;
+    DriveInfo *dinfo=0;
     int type = -1;
     char buf[128];
 
#9 lore raw
In reply to Ian Jackson
Quoted 4 lines · Ian Jackson

I've picked up Alex's patch series for this. Changes since v4:
* rebased to current tip as of approximately yesterday
* passthrough of firmware update is enabled by default
* fixed some build issues

If you resend patch from someone else the normal convention is to put a

From: Original Author <[email protected]>

into the patch body so that it's obvious who the author is.

#10 lore raw

Christoph Hellwig writes ("Re: [Qemu-devel] [PATCH 0/7] ATAPI CDROM passthrough v5"):

Quoted 4 lines

If you resend patch from someone else the normal convention is to put a
From: Original Author <[email protected]>
into the patch body so that it's obvious who the author is.

OK, I will do that next time.

(I thought the Signed-Off-By would be sufficient but I'm happy to do whatever people think best.)

Ian.

#11 lore raw
In reply to Ian Jackson
Quoted 10 lines · Ian Jackson
Quoted 3 lines

I would also suggest that you only expose this as an option
through qdev properties instead of a new command line option as it should be controllable on a per-device basis.

The reason to disable it is not to prevent the guest breaking the hardware. It is to prevent the guest escaping the containment entirely, which it can probably do if firmware updates are allowed. This seems to me to be a general property of the guest, rather than of the device. So I think disabling it in one place is better.

If you go back to the original thread, the argument against this was that some devices abuse other atapi commands to do firmware updates so you cannot 100% reliably contain this.

But more importantly, and the reason I originally requested this, having a global option bakes knowledge of atapi pass through into vl.c. Making it a qdev property means vl.c does not need explicit knowledge of this mechanism.

I think this is an important change to make for merging.

Regards,

Anthony Liguori

Quoted 7 lines

Patches follow.

Thanks,
Ian.

#12 lore raw
In reply to Ian Jackson
Quoted 21 lines · On Wednesday 12 August 2009 17:18:13 Ian Jackson wrote:

I've picked up Alex's patch series for this. Changes since v4:
* rebased to current tip as of approximately yesterday
* passthrough of firmware update is enabled by default
* fixed some build issues

Quoted 1 line · Anthony Liguori

This series breaks the cris-softmmu build.

I think I've fixed it up. It builds for me, anyway. If it now doesn't build do please tell me the error message and I'l fix it.

Quoted 2 lines

Also, I think Paul and I both requested that fw upgrade not be disabled by default.

As previously discussed I think this is a mistake, but it's a decision for qemu upstream to make so I have changed this.

Quoted 3 lines

I would also suggest that you only expose this as an option
through qdev properties instead of a new command line option as it should be controllable on a per-device basis.

Quoted 7 lines

The reason to disable it is not to prevent the guest breaking the hardware. It is to prevent the guest escaping the containment entirely, which it can probably do if firmware updates are allowed. This seems to me to be a general property of the guest, rather than of the device. So I think disabling it in one place is better.

Patches follow.

Hi Ian,

Are you going to continue to work on this patch queue or do you want me to finish the job ?

Thanks a lot.

Signature · 1 line
Alexandre Bique
#13 lore raw
Quoted 8 lines · Bique Alexandre
Quoted 6 lines · On Wednesday 12 August 2009 17:18:13 Ian Jackson wrote:
Quoted 3 lines

Also, I think Paul and I both requested that fw upgrade not be disabled by default.

As previously discussed I think this is a mistake, but it's a decision for qemu upstream to make so I have changed this.

Anyone up for writing a security advisory about this?

Regards,
Carl-Daniel

#14 lore raw
Quoted 9 lines · Carl-Daniel Hailfinger
Quoted 7 lines · Bique Alexandre
Quoted 4 lines · On Wednesday 12 August 2009 17:18:13 Ian Jackson wrote:
Quoted 4 lines

Also, I think Paul and I both requested that fw upgrade not be disabled by default.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

As previously discussed I think this is a mistake, but it's a decision for qemu upstream to make so I have changed this.

Anyone up for writing a security advisory about this?\

Eh?

If you do hardware passthrough, the guest can mess up the device. This is always going to be true and it's a security problem IMHO to make the user think anything other than that.

Regards,

Anthony Liguori

Quoted 5 lines

Regards,
Carl-Daniel

#15 lore raw
Quoted 11 lines · Anthony Liguori
Quoted 10 lines · Carl-Daniel Hailfinger
Quoted 7 lines · Bique Alexandre
Quoted 5 lines · On Wednesday 12 August 2009 17:18:13 Ian Jackson wrote:
Quoted 3 lines

Also, I think Paul and I both requested that fw upgrade not be disabled by default.

As previously discussed I think this is a mistake, but it's a decision for qemu upstream to make so I have changed this.

Quoted 7 lines
Quoted 1 line

Anyone up for writing a security advisory about this?

Eh?

If you do hardware passthrough, the guest can mess up the device. This is always going to be true and it's a security problem IMHO to make the user think anything other than that.

The guest can also mess up other devices with the help of specially crafted firmware. So even if the user does not care about the effects on a particular device, a firmware upgrade might affect other devices (which are not used by Qemu in any way) as well. As a result, this is essentially a "break out of qemu or DoS the machine under certain conditions" feature. If that particular side effect / feature is documented, users who read the documentation won't get any nasty surprises. If that's what you intended to say, I apologize for the misunderstanding.

Regards,
Carl-Daniel

Quoted 3 lines

Regards,

Anthony Liguori

#16 lore raw
Quoted 4 lines · Carl-Daniel Hailfinger

The guest can also mess up other devices with the help of specially crafted firmware. So even if the user does not care about the effects on a particular device, a firmware upgrade might affect other devices (which are not used by Qemu in any way) as well.

Please be more specific. How is this any different than PCI passthrough with VT-d or USB passthrough?

Quoted 5 lines

As a result, this is
essentially a "break out of qemu or DoS the machine under certain conditions" feature. If that particular side effect / feature is documented, users who read the documentation won't get any nasty surprises.

A user will get a really nasty surprise if they think they can use a flag or rely on QEMU to prevent a VM from doing something nasty with a device. If they have this feeling of security, they're likely to chmod the device to allow unprivileged users to access it.

But how a device handles ATAPI commands is totally up to the device. If you issue the wrong sequence, I'm sure there are devices out there that totally hose themselves. Are you absolutely confident that every ATAPI device out there is completely safe against hostile code provided that you simply prevent the FW update commands? I'm certainly not.

Regards,

Anthony Liguori

#17 lore raw
Quoted 14 lines · Anthony Liguori
Quoted 4 lines · Carl-Daniel Hailfinger

The guest can also mess up other devices with the help of specially crafted firmware. So even if the user does not care about the effects on a particular device, a firmware upgrade might affect other devices (which are not used by Qemu in any way) as well.

Please be more specific. How is this any different than PCI passthrough with VT-d or USB passthrough?

Quoted 5 lines

As a result, this is
essentially a "break out of qemu or DoS the machine under certain conditions" feature. If that particular side effect / feature is documented, users who read the documentation won't get any nasty surprises.

Quoted 3 lines

A user will get a really nasty surprise if they think they can use a flag or rely on QEMU to prevent a VM from doing something nasty with a device. If they have this feeling of security, they're likely to chmod the device to allow unprivileged users to access it.

But how a device handles ATAPI commands is totally up to the device. If you issue the wrong sequence, I'm sure there are devices out there that totally hose themselves. Are you absolutely confident that every ATAPI device out there is completely safe against hostile code provided that you simply prevent the FW update commands? I'm certainly not.

Ping?

Alex

#18 lore raw
Quoted 6 lines · Alexander Graf
Quoted 4 lines

A user will get a really nasty surprise if they think they can use a flag or rely on QEMU to prevent a VM from doing something nasty with a device. If they have this feeling of security, they're likely to chmod the device to allow unprivileged users to access it.

But how a device handles ATAPI commands is totally up to the device. If you issue the wrong sequence, I'm sure there are devices out there that totally hose themselves. Are you absolutely confident that every ATAPI device out there is completely safe against hostile code provided that you simply prevent the FW update commands? I'm certainly not.

Ping?

Who are you pinging?

Regards,

Anthony Liguori

Quoted 4 lines

Alex

#19 lore raw

Am 19.10.2010 um 02:10 schrieb Anthony Liguori <[email protected]>:

Quoted 9 lines · Alexander Graf
Quoted 6 lines
Quoted 4 lines

A user will get a really nasty surprise if they think they can use a flag or rely on QEMU to prevent a VM from doing something nasty with a device. If they have this feeling of security, they're likely to chmod the device to allow unprivileged users to access it.

But how a device handles ATAPI commands is totally up to the device. If you issue the wrong sequence, I'm sure there are devices out there that totally hose themselves. Are you absolutely confident that every ATAPI device out there is completely safe against hostile code provided that you simply prevent the FW update commands? I'm certainly not.

Ping?

Who are you pinging?

Mostly Ian. I haven't seen any follow-up on this discussion and would like to know why and if there's still plans to upstream this code :).

Alex

Quoted 1 line
#20 lore raw
Quoted 6 lines · Alexander Graf

Am 19.10.2010 um 02:10 schrieb Anthony Liguori <[email protected]>:

Quoted 3 lines · Alexander Graf
Quoted 2 lines
Quoted 2 lines

A user will get a really nasty surprise if they think they can use a flag or rely on QEMU to prevent a VM from doing something nasty with a device.  If they have this feeling of security, they're likely to chmod the device to allow unprivileged users to access it.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

But how a device handles ATAPI commands is totally up to the device.  If you issue the wrong sequence, I'm sure there are devices out there that totally hose themselves.  Are you absolutely confident that every ATAPI device out there is completely safe against hostile code provided that you simply prevent the FW update commands?  I'm certainly not.

Ping?

Who are you pinging?

Mostly Ian. I haven't seen any follow-up on this discussion and would like to know why and if there's still plans to upstream this code :).

Why is allowing ATAPI passthrough such a problem?

Sure if your boot drive is on the same IDE cable as the device you may have issues but other than that the device may just stop working if it is not designed to handle incorrect command gracefully (ie it is broken).

I am sure there are devices that also break under issuing correct commands or commands that look vaguely sane. Eg. there are CD-ROMs that would lock up the whole system when you boot certain vintage of Linux (not tested with current Linux due to lack of old hardware) on a machine with the Intel BX chipset and one of these CD-ROMs attached over IDE cable.

However, assuming random hardware breakage you cannot allow anything.

Perhaps the ATAPI passthrough should be designed to allow any commands and some command profiles could be selected to allow for some sane/conservative subset, burning, LightScribe, LabelFlash, disc T@tto, FW upgrade, ..

It would be nice if these subsets were defined in a configuration file so that people can create their own 'default' combination or just install a new set when a new fancy feature comes out.

Thanks

Michal