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] [day] [month] [year] [list]
Date:   Thu, 15 Dec 2022 10:10:25 +0900
From:   Sergey Senozhatsky <senozhatsky@...omium.org>
To:     Laurent Pinchart <laurent.pinchart@...asonboard.com>
Cc:     Ricardo Ribalda <ribalda@...omium.org>,
        Yunke Cao <yunkec@...omium.org>,
        Max Staudt <mstaudt@...gle.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Sergey Senozhatsky <senozhatsky@...omium.org>,
        linux-kernel@...r.kernel.org, linux-media@...r.kernel.org
Subject: Re: [PATCH] media: uvcvideo: Do not alloc dev->status

On (22/12/14 14:45), Laurent Pinchart wrote:
> On Wed, Dec 14, 2022 at 12:23:41PM +0100, Ricardo Ribalda wrote:
> > UVC_MAX_STATUS_SIZE is 16, simplify the code by inlining dev->status.
> 
> The reason why uvc_status is allocated dynamically is to ensure cache
> line alignment, as the USB host controller may DMA to the buffer.

Oh, that's a very subtle detail.

> > +struct uvc_status_streaming {
> > +	u8	button;
> > +} __packed;
> > +
> > +struct uvc_status_control {
> > +	u8	bSelector;
> > +	u8	bAttribute;
> > +	u8	bValue[11];
> > +} __packed;
> > +
> > +struct uvc_status {
> > +	u8	bStatusType;
> > +	u8	bOriginator;
> > +	u8	bEvent;
> > +	union {
> > +		struct uvc_status_control control;
> > +		struct uvc_status_streaming streaming;
> > +	};
> > +} __packed;
> > +
> >  struct uvc_device {
> >  	struct usb_device *udev;
> >  	struct usb_interface *intf;
> > @@ -559,7 +579,7 @@ struct uvc_device {
> >  	/* Status Interrupt Endpoint */
> >  	struct usb_host_endpoint *int_ep;
> >  	struct urb *int_urb;
> > -	u8 *status;
> > +	struct uvc_status status;

So we can do something like this maybe?

+	struct uvc_status status ____cacheline_aligned;

And this actually even improves code readability, IMHO, in a
sense that we explicitly say that it has to be cache aligned.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ