[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <47E96709.9060904@zytor.com>
Date: Tue, 25 Mar 2008 13:56:41 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: Török Edwin <edwintorok@...il.com>
CC: "Thomas Gleixner mingo@...hat.com" <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: gcc-4.3 considers unaligned accesses on X86 as undefined
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists