mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Hogan <james@albanarts.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fbdev@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Dave Airlie <airlied@redhat.com>,
	Marcin Slusarz <marcin.slusarz@gmail.com>,
	Florian Tobias Schandinat <FlorianSchandinat@gmx.de>,
	Denys Vlasenko <vda.linux@googlemail.com>,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	James Simmons <jsimmons@infradead.org>
Subject: Re: [PATCH] fbmem: Fix fb_read, fb_write unaligned accesses.
Date: Wed, 22 Sep 2010 01:00:19 +0100	[thread overview]
Message-ID: <201009220100.27090.james@albanarts.com> (raw)
In-Reply-To: <20100921161950.b7f45273.akpm@linux-foundation.org>

[-- Attachment #1: Type: Text/Plain, Size: 2217 bytes --]

On Wednesday 22 September 2010 00:19:50 Andrew Morton wrote:
> On Sat, 18 Sep 2010 01:23:47 +0100
> 
> James Hogan <james@albanarts.com> wrote:
> > Apologies for corrupted patch. I'll try again.
> > Comments? I'd also appreciate if somebody familiar with sbus on sparc
> > could check this patch is sane since I know virtually nothing about sbus
> > and am not in a position to compile for sparc, let alone test on it:
> > 
> > fb_{read,write} access the framebuffer using lots of fb_{read,write}l's
> > but don't check that the file position is aligned which can cause
> > problems on some architectures which do not support unaligned accesses.
> 
> What are these "problems"?

On the arch I hit this on (which isn't in tree) I experienced a fault at the 
point of the unaligned write in kernel code, but this is only because 
unaligned access checking is switched on which isn't always possible 
(otherwise the write would have just silently failed/done something else). It 
terminated the program, but didn't cause any other problems.
Documentation/unaligned-memory-access.txt also mentions that some 
architectures raise exceptions that can't be worked around, or fail silently 
and may actually perform different writes to the one requested.

> I'd have thought they would be fairly fatal, in which case this is a
> high-priority patch.  But I'd also have thought that the problems would
> have been noted before now.

The common way to access the framebuffer is by mmapping it into userland, so I 
don't think the read/write syscalls are commonly used on it, and in any case 
colour data tends to be naturally aligned so unaligned writes would be 
uncommon.

> 
> So I assume that you're doing something which nobody has done before.
> 
> Confused.  Help?

The actualy case that hit this is admitedly rather silly. I did a quick test 
of the framebuffer by typing this at a shell:
yes > /dev/fb0
I'd have to check it again to see exactly how lots of 2 byte writes ("y\n") 
ended up unaligned, but at the point of the crash the dest pointer was 
definitely unaligned (the hex address ended in a 5) and the patch fixed it for 
me.

Hope that helps.

Cheers
James

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2010-09-22  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-18  0:23 James Hogan
2010-09-18  3:17 ` David Miller
2010-09-20 19:27 ` Florian Tobias Schandinat
2010-09-21 23:19 ` Andrew Morton
2010-09-22  0:00   ` James Hogan [this message]
     [not found] <201009092338.59880.james@albanarts.com>
2010-09-17 23:57 ` James Hogan
2010-09-18  0:15   ` David Miller

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=201009220100.27090.james@albanarts.com \
    --to=james@albanarts.com \
    --cc=FlorianSchandinat@gmx.de \
    --cc=airlied@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=jbarnes@virtuousgeek.org \
    --cc=jsimmons@infradead.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin.slusarz@gmail.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=vda.linux@googlemail.com \
    /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

all inboxes | Powered by JetHome®