Re: targ dir issue

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Mon, 30 Aug 2021 17:12:23 UTC
Hi,

On 30.08.2021 12:51, Kenneth D. Merry wrote:
> On Wed, Aug 25, 2021 at 04:14:38 +0900, ??? ?????? wrote:
>> * { margin: 0; font-size: 13px; font-family: 'MS P????????????', sans-serif;}a { color: #0064c8; text-decoration: none;}a:hover { color: #0057af; text-decoration: underline;}a:active { color: #004c98;}
>> Hi
>>
>> I port ncv to eps for NCR53C500. And Support targ at esp.
>>
>> I have question for targ.
>>
>> inquery data is send by scsi_target apprication by CAM_DIR_IN.
>>
>> But CAM_DIR_IN not copyin.
>>
>> https://svnweb.freebsd.org/base/head/sys/cam/cam_periph.c?view=markup#l929
>>
>> Why different ?
> 
> I think that may be a bug.  I see that if you have an XPT_CONT_TARGET_IO
> CCB, for an INQUIRY, as you would in your case, it would be CAM_DIR_IN, but
> would need to copy the data from userland into the kernel.
> 
> It looks like it changed in SVN revision 345656.
> 
> I have CCed Alexander Motin, he originally wrote that change and can take a
> look at it.

It seems like a bug indeed.  XPT_CONT_TARGET_IO has opposite meaning of
IN/OUT, since those are always interpreted as seen by initiator, so the
dirs[i] != CAM_DIR_IN should become dirs[i] != CAM_DIR_OUT for
XPT_CONT_TARGET_IO, and respectively b_iocmd setting below and in
cam_periph_unmapmem().  It went unnoticed because CTL does not use this
code, while I don't know anybody using user-space target targ(4) API.

It would be good to both fix this issue for targ(4) (I'd appreciate a
tested patch, since I am not using targ(4)), and if you are testing
esp(4) in target mode, test it with CTL also.

-- 
Alexander Motin