usbmon in 2.6.13: peeking into DMA areas
I am not completely confident in this patch, so while the fix is being requested by users, I would like to have it postponed until 2.6.13.
This code looks at urb->transfer_dma, maps the page and takes the data. I am looking for volunteers to contribute architectures other than i386 or to develop an architecure-neutral API for it (or point me that it was done already).
Signed-off-by Pete Zaitcev <[email protected]>
drivers/usb/mon/Makefile +1 -1
@@ -2,7 +2,7 @@ # Makefile for USB Core files and filesystem # -usbmon-objs := mon_main.o mon_stat.o mon_text.o +usbmon-objs := mon_main.o mon_stat.o mon_text.o mon_dma.o # This does not use CONFIG_USB_MON because we want this to use a tristate. obj-$(CONFIG_USB) += usbmon.o
drivers/usb/mon/mon_dma.c +55 -0
55 lines not on this page · raw message
drivers/usb/mon/mon_text.c +17 -18
@@ -91,25 +91,11 @@ static inline char mon_text_get_data(str int len, char ev_type) { int pipe = urb->pipe; -unsigned char *data; - -/* -* The check to see if it's safe to poke at data has an enormous -* number of corner cases, but it seems that the following is -* more or less safe. -* -* We do not even try to look transfer_buffer, because it can -* contain non-NULL garbage in case the upper level promised to -* set DMA for the HCD. -*/ -if (urb->transfer_flags &URB_NO_TRANSFER_DMA_MAP ) -return 'D' ;if (len <=0 )return 'L' ; - -if ((data = urb->transfer_buffer) ==NULL ) -return 'Z' ;/* '0' would be not as pretty. */ +if (len >=DATA_MAX ) + len =DATA_MAX ;/* * Bulk is easy to shortcut reliably.
@@ -126,8 +112,21 @@ static inline char mon_text_get_data(str } } -if (len >=DATA_MAX ) - len =DATA_MAX ; +/* +* The check to see if it's safe to poke at data has an enormous +* number of corner cases, but it seems that the following is +* more or less safe. +* +* We do not even try to look transfer_buffer, because it can +* contain non-NULL garbage in case the upper level promised to +* set DMA for the HCD. +*/ +if (urb->transfer_flags &URB_NO_TRANSFER_DMA_MAP ) +return mon_dmapeek (ep->data, urb->transfer_dma, len); + +if (urb->transfer_buffer ==NULL ) +return 'Z' ;/* '0' would be not as pretty. */ +memcpy (ep->data, urb->transfer_buffer, len);return 0 ; }
drivers/usb/mon/usb_mon.h +4 -0
@@ -43,6 +45,10 @@ struct mon_reader {void mon_reader_add (struct mon_bus *mbus,struct mon_reader *r);void mon_reader_del (struct mon_bus *mbus,struct mon_reader *r); +/* +*/ +extern char mon_dmapeek (unsigned char *dst,dma_addr_t dma_addr,int len); +extern struct semaphore mon_lock;extern struct file_operations mon_fops_text;