Re: Unaligned access on Alpha

2004-02-29 Thread Steve Langasek
On Sun, Feb 29, 2004 at 11:02:30AM -0600, Kelledin wrote:
 Lately I've been looking closely at the compile logs on my EV56 
 box, and I've noticed a particular gcc warning occurring 
 frequently:

 cast increases required alignment of target type.

 This worries me almost as much as casts between integers and 
 pointers of different size, but...even with all the warnings, I 
 don't get too many crashes.  Still, I'm compelled to wonder 
 about the effect of unaligned accesses, i.e. how severe is an 
 unaligned access in user-space?  How about in kernel-space?  How 
 does the system handle them?

 I have a pretty clear idea what it would take to fix that warning 
 condition, but it occurs so frequently that I'm not sure it 
 would be worth the time. :/

As of Linux 2.6, unaligned memory access is no longer handled for you by
the kernel on alpha.  These will instead generate SIGBUS errors, just as
they have forever on Linux sparc.  Any such bugs should be fixed,
therefore.

And in some cases, such as the evms case that currently came up on this
list, such casts hide more serious bugs still.  However, not all such
warnings are actual bugs at all:  you may be seeing the result of a
pointer being down-cast and then up-cast again, which is a little sloppy
(mostly from the standpoint that it causes compiler warnings), but
shouldn't cause problems when running the app.

Cheers,
-- 
Steve Langasek
postmodern programmer


signature.asc
Description: Digital signature


Re: Unaligned access on Alpha

2004-02-29 Thread Falk Hueffner
Steve Langasek [EMAIL PROTECTED] writes:

 As of Linux 2.6, unaligned memory access is no longer handled for you by
 the kernel on alpha.  These will instead generate SIGBUS errors, just as
 they have forever on Linux sparc.

Are you sure? This was not the case with 2.6.0-test3, and the code
still seems to be there in 2.6.3 (traps.c/do_entUnaUser).

-- 
Falk




Re: Unaligned access on Alpha

2004-02-29 Thread Falk Hueffner
Kelledin [EMAIL PROTECTED] writes:

 Lately I've been looking closely at the compile logs on my EV56 
 box, and I've noticed a particular gcc warning occurring 
 frequently:
 
 cast increases required alignment of target type.
 
 This worries me almost as much as casts between integers and 
 pointers of different size, but...even with all the warnings, I 
 don't get too many crashes.

Well, not surprising, since this will only lead to a problem if a) the
pointer is actually dereferenced and b) the alignment is actually
wrong. Often this cannot occur and the warning is bogus.

 Still, I'm compelled to wonder about the effect of unaligned
 accesses, i.e. how severe is an unaligned access in user-space?  How
 about in kernel-space?  How does the system handle them?

A trap to PALcode occurs and the firmware hands over to the operating
system. The OS emulates the access and resumes the program. Takes
probably about 100-200 cycles.

 I have a pretty clear idea what it would take to fix that warning
 condition, but it occurs so frequently that I'm not sure it would be
 worth the time. :/

I don't think so, unless you actually see unaligned accesses in the
syslog.

-- 
Falk




Re: Unaligned access on Alpha

2004-02-29 Thread Steve Langasek
On Sun, Feb 29, 2004 at 07:38:16PM +0100, Falk Hueffner wrote:
 Steve Langasek [EMAIL PROTECTED] writes:

  As of Linux 2.6, unaligned memory access is no longer handled for you by
  the kernel on alpha.  These will instead generate SIGBUS errors, just as
  they have forever on Linux sparc.

 Are you sure? This was not the case with 2.6.0-test3, and the code
 still seems to be there in 2.6.3 (traps.c/do_entUnaUser).

I'm not sure, as I've yet to run 2.6 on my alphas, but I have seen
reports of SIGBUS on alpha under 2.6, which has definitely never
happened before.  (Maybe this behavior is now optional?)

-- 
Steve Langasek
postmodern programmer


signature.asc
Description: Digital signature


Re: Unaligned access on Alpha

2004-02-29 Thread Juraj Holtak
many (i can say all for me) kernel unaligned accesses happen in the 
netfilter code. so if u r running a firewall of any kind on EV56 u have a 
real problem.
i wrote a small stupid (but working perfectly) patch that eliminates them to 
zero.
if interessted just ask and i will post it (again)

Linux alpha 2.4.23-grsec #2 Tue Dec 2 22:05:21 CET 2003 alpha unknown
20:54:17 up 7 days, 18:38,  8 users,  load average: 1.00, 1.00, 1.00
(dont care about the load the box is used for searching for big primes and the 
load is just OK)
cpu : Alpha
cpu model   : EV56
cpu variation   : 0
cpu revision: 0
cpu serial number   : Linux_is_Great!
system type : Miata
system variation: 0
system revision : 0
system serial number: MILO-2.2-17
cycle frequency [Hz]: 433061852 est.
timer frequency [Hz]: 1024.00
page size [bytes]   : 8192
phys. address bits  : 40
max. addr. space #  : 127
BogoMIPS: 860.60
kernel unaligned acc: 0 (pc=0,va=0)
user unaligned acc  : 27 (pc=120305e88,va=1204ceae4)
platform string : N/A
cpus detected   : 0

the box is also my internet gateway and runs NAT and statefull packet filter
as u can see
no kernel un acc`s at all
some in userspace, but thats ok
the box is rock stable even under nonstop 100% load
(i had to reboot because of power failure a week ago)
the box gets hot as hell!

cheers,

Juraj Holtak


On Sunday 29 February 2004 18:10, Falk Hueffner wrote:
 Kelledin [EMAIL PROTECTED] writes:
  Lately I've been looking closely at the compile logs on my EV56
  box, and I've noticed a particular gcc warning occurring
  frequently:
 
  cast increases required alignment of target type.
 
  This worries me almost as much as casts between integers and
  pointers of different size, but...even with all the warnings, I
  don't get too many crashes.

 Well, not surprising, since this will only lead to a problem if a) the
 pointer is actually dereferenced and b) the alignment is actually
 wrong. Often this cannot occur and the warning is bogus.

  Still, I'm compelled to wonder about the effect of unaligned
  accesses, i.e. how severe is an unaligned access in user-space?  How
  about in kernel-space?  How does the system handle them?

 A trap to PALcode occurs and the firmware hands over to the operating
 system. The OS emulates the access and resumes the program. Takes
 probably about 100-200 cycles.

  I have a pretty clear idea what it would take to fix that warning
  condition, but it occurs so frequently that I'm not sure it would be
  worth the time. :/

 I don't think so, unless you actually see unaligned accesses in the
 syslog.

 --
   Falk




Re: Unaligned access on Alpha

2004-02-29 Thread Kelledin
On Sunday 29 February 2004 01:37 pm, Juraj Holtak wrote:
 many (i can say all for me) kernel unaligned accesses happen
 in the netfilter code. so if u r running a firewall of any
 kind on EV56 u have a real problem.
 i wrote a small stupid (but working perfectly) patch that
 eliminates them to zero.
 if interessted just ask and i will post it (again)

Hmmm...I take it that an unaligned access in kernel-land causes a 
crash/oops?

In that case, I would very much like a copy of your patch!

TIA,

-- 
Kelledin
If a server crashes in a server farm and no one pings it, does 
it still cost four figures to fix?




Re: Unaligned access on Alpha

2004-02-29 Thread Falk Hueffner
Kelledin [EMAIL PROTECTED] writes:

 Hmmm...I take it that an unaligned access in kernel-land causes a
 crash/oops?

No, it gets fixed up, too.

-- 
Falk