All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: "Török Edwin" <edwintorok@gmail.com>
Cc: "Thomas Gleixner mingo@redhat.com" <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: gcc-4.3 considers unaligned accesses on X86 as undefined
Date: Tue, 25 Mar 2008 13:56:41 -0700	[thread overview]
Message-ID: <47E96709.9060904@zytor.com> (raw)
In-Reply-To: <47E965BD.7010604@gmail.com>

Török Edwin wrote:
> Hello x86 architecture maintainers,
> 
> GCC-4.3 now considers that it is undefined behaviour to access memory
> through an int*  that is not aligned to sizeof(int).
> At -O3 it generates vectorized code that  _relies_  on the fact that
> pointers are always aligned (unless you use packed attributes, etc.),
> and the resulting code crashes if the pointer is unaligned.  (-O3 -msse
> on 32-bit, and simply -O3 on 64-bit since -msse is default)
> See this gcc bugreport: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35653
> [I do not really agree with this sudden change, because unaligned
> accesses have always been possible on x86, but the C99 standard does say
> it is undefined behaviour ...]
> 
> I thought to inform you of this change in gcc's behaviour, because
> include/asm-x86/unaligned.h is no longer safe in the above context,
> especially that it is being used in a loop:
> http://lxr.linux.no/linux/net/bluetooth/bnep/core.c#L153
> 
> P.S.: I only compile my kernels with -O2, so I don't know if it actually
> crashes or not at -O3.
> 

Generating vectorized code in the kernel is death anyway, so I don't 
think the change in alignment is an issue.  We CANNOT ALLOW vectorized 
code in the kernel under any circumstances (well, except when surrounded 
by the appropriate protection constructs.)

	-hpa

  reply	other threads:[~2008-03-25 20:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-25 20:51 gcc-4.3 considers unaligned accesses on X86 as undefined Török Edwin
2008-03-25 20:56 ` H. Peter Anvin [this message]
2008-03-25 21:11 ` Alan Cox
2008-03-26  5:30 ` Andi Kleen

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=47E96709.9060904@zytor.com \
    --to=hpa@zytor.com \
    --cc=edwintorok@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.