From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Andrew Lewis <andrew-lewis@netspace.net.au>
Cc: linuxppc-dev@ozlabs.org, paulus@samba.org
Subject: Re: [PATCH/RFC] powerpc: prevent memory corruption due to cache invalidation of unaligned DMA buffer
Date: Thu, 26 Jun 2008 20:55:48 +1000 [thread overview]
Message-ID: <1214477748.8011.464.camel@pasglop> (raw)
In-Reply-To: <48636161.6080603@netspace.net.au>
On Thu, 2008-06-26 at 17:29 +0800, Andrew Lewis wrote:
> On PowerPC processors with non-coherent cache architectures the DMA
> subsystem calls invalidate_dcache_range() before performing a DMA read
> operation. If the address and length of the DMA buffer are not aligned
> to a cache-line boundary this can result in memory outside of the DMA
> buffer being invalidated in the cache. If this memory has an
> uncommitted store then the data will be lost and a subsequent read of
> that address will result in an old value being returned from main memory.
Thanks for providing a fix. The problem is old and in fact was discussed
a while ago, unfortunately, it looks like the SCSI folks didn't fix it
yet.
In theory, on non-cache coherent architecture, buffers that can be
DMA'ed should not share cache lines with other objects. This is violated
by the SCSI code due to recent changes to the way the sense buffer is
allocated. Various solutions were proposed, including a __dma_buffer
alignment directive, but back then, the wind blew more toward changing
the way the buffer is allocated in the SCSI stack.
Some people started working on that and I lost track. It looks like it
wasn't properly fixed :-(
I'll ack your patch for now as workaround, though it would be good to
have some kind of debug option to make it WARN_ON when the unaligned
case happen, to track them down and help fix them. I'll try to catch up
with the SCSI folks to see what's up on this side.
In the meantime:
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
prev parent reply other threads:[~2008-06-26 11:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-26 9:29 [PATCH/RFC] powerpc: prevent memory corruption due to cache invalidation of unaligned DMA buffer Andrew Lewis
2008-06-26 10:32 ` Gerhard Pircher
2008-06-26 10:55 ` Benjamin Herrenschmidt [this message]
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=1214477748.8011.464.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=andrew-lewis@netspace.net.au \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.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;
as well as URLs for NNTP newsgroup(s).