lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 31 Jan 2014 13:52:40 +0000
From:	David Laight <David.Laight@...LAB.COM>
To:	'Peter Stuge' <peter@...ge.se>
CC:	'Sarah Sharp' <sarah.a.sharp@...ux.intel.com>,
	"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	David Miller <davem@...emloft.net>,
	Dan Williams <dan.j.williams@...el.com>,
	"Nyman, Mathias" <mathias.nyman@...el.com>,
	Mark Lord <mlord@...ox.com>,
	"Alan Stern" <stern@...land.harvard.edu>,
	Freddy Xin <freddy@...x.com.tw>
Subject: RE: [PATCH RFC 1/1] usb: Tell xhci when usb data might be	misaligned

From: Peter Stuge [mailto:peter@...ge.se]
> > Userspace doesn't care since everything gets copied into aligned
> > kernel fragments - otherwise the other usb controllers wouldn't work.
> 
> OK, but not so great if someone wants to squeeze the most performance
> possible out of USB also from userspace.
> 
> I'm going off on a tangent now but would it make sense to allow
> userspace to do alignment if it wants to, and have a way to tell
> the kernel when urb buffers are pre-aligned?

I can only see that mattering if either:
1) The userspace buffers are (say) 4n+1 aligned and the kernel
   decides to align the copy_from_user().
2) The code is doing buffer-loaning.

Personally I'm not at all sure how often buffer-loaning helps
(given the cost of the TLB shootdowns that it often implies).
I guess it might be ok if the memory doesn't have to be given
a KVA and the user program avoids any COW.
In any case and such code could be limited to page-aligned transfers.
And/or the user code would have to know at least some of the constraints.

The other usb controllers only support 'message' aligned transfers
(512 bytes for USB2). All the code I've found achieves this by using
page aligned (maybe 4k aligned) fragments. xhci trivially supports this
(it has since the 'ring expansion' code was added).

xhci can also easily support:
1) Arbitrary fragmentation for a limited number of fragments
   (by constraining the fragments to a single ring segment).
2) Arbitrary fragmentation provided all the fragments (except the
   last) exceed some minimal length (by splitting the current or
   previous fragment at the appropriate boundary).

The code for the second is probably worth adding just in case
a 4k fragment crosses a 64k boundary.

Since arbitrarily fragmented packets can't be sent to other controllers
it does seem sensible for the code generating the urb so say that
it is (or might be) fragmented like that.

	David

 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ