From: tsbogend@alpha.franken.de (Thomas Bogendoerfer)
To: Jeff Garzik <jeff@garzik.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Jens Axboe <jens.axboe@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: cdrom: use kmalloced buffers instead of buffers on stack
Date: Tue, 22 Apr 2008 07:48:58 +0200 [thread overview]
Message-ID: <20080422054857.GA5940@alpha.franken.de> (raw)
In-Reply-To: <480D46F6.3080305@garzik.org>
On Mon, Apr 21, 2008 at 10:01:26PM -0400, Jeff Garzik wrote:
> > cdrom: use kmalloced buffers instead of buffers on stack
> >
> > If cdrom commands are issued to a scsi drive in most cases the buffer
> > will be
> > filled via dma. This leads to bad stack corruption on non coherent
> > platforms,
> > because the buffers are neither cache line aligned nor is the size a
> > multiple
> > of the cache line size. Using kmalloced buffers avoids this.
> >
> > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
> >---
> > drivers/cdrom/cdrom.c | 274
> > ++++++++++++++++++++++++++++++++-----------------
> > 1 files changed, 181 insertions(+), 93 deletions(-)
>
> Eh... AFAICS this is only really useful in two of the cases converted.
>
> For all the other cases (<= 32 bytes), it is _far_ less complex, far
> less code to simply communicate the additional alignment requirements to
> the compiler.
>
> What about __attribute__ __aligned__? Was that tried?
I used that while narrowing down the bug. But not only the alignment is
important, but also size needs to be a multiple of the cache line size.
Which means it needs to be 128 bytes for most SGI machines. That
and the following in DMA-mapping.txt
"This rule also means that you may use neither kernel image addresses
(items in data/text/bss segments), nor module image addresses, nor
stack addresses for DMA."
let me choose the kmalloc() solution.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea. [ RFC1925, 2.3 ]
next prev parent reply other threads:[~2008-04-22 6:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200804220100.m3M10sva024025@hera.kernel.org>
2008-04-22 2:01 ` cdrom: use kmalloced buffers instead of buffers on stack Jeff Garzik
2008-04-22 2:03 ` David Miller
2008-04-22 5:48 ` Thomas Bogendoerfer [this message]
2008-04-22 6:33 ` Jens Axboe
2008-04-22 11:47 ` FUJITA Tomonori
2008-04-22 11:55 ` Jens Axboe
2008-04-22 11:59 ` FUJITA Tomonori
2008-04-22 12:04 ` Jens Axboe
2008-04-22 12:25 ` FUJITA Tomonori
2008-04-22 12:30 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080422054857.GA5940@alpha.franken.de \
--to=tsbogend@alpha.franken.de \
--cc=akpm@linux-foundation.org \
--cc=jeff@garzik.org \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox