|
From: <sv...@va...> - 2014-06-26 11:29:15
|
Author: tom
Date: Thu Jun 26 11:29:05 2014
New Revision: 14107
Log:
Add support for the SG_IO ioctl.
Patch from Daniel Kamil Kozar via BZ#333817.
Modified:
trunk/NEWS
trunk/coregrind/m_syswrap/syswrap-linux.c
trunk/docs/internals/3_9_BUGSTATUS.txt
trunk/include/vki/vki-linux.h
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Thu Jun 26 11:29:05 2014
@@ -154,6 +154,8 @@
333428 ldr.w pc [rD, #imm] instruction leads to assertion
333666 Recognize MPX instructions and bnd prefix.
333788 Valgrind does not support the CDROM_DISC_STATUS ioctl (has patch)
+333817 Valgrind reports the memory areas written to by the SG_IO
+ ioctl as untouched
334049 lzcnt fails silently (x86_32)
334705 sendmsg and recvmsg should guard against bogus msghdr fields.
334727 Build fails with -Werror=format-security
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-linux.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c Thu Jun 26 11:29:05 2014
@@ -5761,7 +5761,15 @@
PRE_MEM_READ( "ioctl(SG_SET_COMMAND_Q)", ARG3, sizeof(int) );
break;
case VKI_SG_IO:
- PRE_MEM_WRITE( "ioctl(SG_IO)", ARG3, sizeof(vki_sg_io_hdr_t) );
+ PRE_MEM_READ( "ioctl(SG_IO)", ARG3, sizeof(vki_sg_io_hdr_t) );
+ {
+ vki_sg_io_hdr_t *sgio = (vki_sg_io_hdr_t*)ARG3;
+ PRE_MEM_READ( "ioctl(SG_IO)", (Addr)sgio->cmdp, sgio->cmd_len );
+ if ( sgio->dxfer_direction == VKI_SG_DXFER_TO_DEV ||
+ sgio->dxfer_direction == VKI_SG_DXFER_TO_FROM_DEV ) {
+ PRE_MEM_READ( "ioctl(SG_IO)", (Addr)sgio->dxferp, sgio->dxfer_len );
+ }
+ }
break;
case VKI_SG_GET_SCSI_ID:
PRE_MEM_WRITE( "ioctl(SG_GET_SCSI_ID)", ARG3, sizeof(vki_sg_scsi_id_t) );
@@ -7189,7 +7197,17 @@
case VKI_SG_SET_COMMAND_Q:
break;
case VKI_SG_IO:
- POST_MEM_WRITE(ARG3, sizeof(vki_sg_io_hdr_t));
+ {
+ vki_sg_io_hdr_t *sgio = (vki_sg_io_hdr_t*)ARG3;
+ if ( sgio->sbp ) {
+ POST_MEM_WRITE( (Addr)sgio->sbp, sgio->sb_len_wr );
+ }
+ if ( sgio->dxfer_direction == VKI_SG_DXFER_FROM_DEV ||
+ sgio->dxfer_direction == VKI_SG_DXFER_TO_FROM_DEV ) {
+ int transferred = sgio->dxfer_len - sgio->resid;
+ POST_MEM_WRITE( (Addr)sgio->dxferp, transferred );
+ }
+ }
break;
case VKI_SG_GET_SCSI_ID:
POST_MEM_WRITE(ARG3, sizeof(vki_sg_scsi_id_t));
Modified: trunk/docs/internals/3_9_BUGSTATUS.txt
==============================================================================
--- trunk/docs/internals/3_9_BUGSTATUS.txt (original)
+++ trunk/docs/internals/3_9_BUGSTATUS.txt Thu Jun 26 11:29:05 2014
@@ -57,8 +57,6 @@
333434 In some weird corner case Valgrind cannot execute
executable files symlinked by /proc/self/fd (related to 331311?)
333051 handling hugepages (is largely broken)
-333817 Valgrind reports the memory areas written to by the SG_IO
- ioctl as untouched
334585 recvmmsg unhandled (+patch) (arm)
=== Debuginfo reader ===================================================
Modified: trunk/include/vki/vki-linux.h
==============================================================================
--- trunk/include/vki/vki-linux.h (original)
+++ trunk/include/vki/vki-linux.h Thu Jun 26 11:29:05 2014
@@ -1769,6 +1769,14 @@
unsigned int info; /* [o] auxiliary information */
} vki_sg_io_hdr_t; /* 64 bytes long (on i386) */
+#define VKI_SG_DXFER_NONE -1 /* e.g. a SCSI Test Unit Ready command */
+#define VKI_SG_DXFER_TO_DEV -2 /* e.g. a SCSI WRITE command */
+#define VKI_SG_DXFER_FROM_DEV -3 /* e.g. a SCSI READ command */
+#define VKI_SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the
+ additional property than during indirect
+ IO the user buffer is copied into the
+ kernel buffers before the transfer */
+
typedef struct vki_sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */
int host_no; /* as in "scsi<n>" where 'n' is one of 0, 1, 2 etc */
int channel;
|