Subject: Data Abort Exceptions
To: None <>
From: Jay Monkman <>
List: port-arm
Date: 07/22/2002 11:37:06
I'm trying to figure out how NetBSD handles misaligned data accesses
on the ARM, and from what I can see, it doesn't. There'a a comment in 
arm32/fault.c : data_abort_handler():
        case FAULT_ALIGN_0:              /* Alignment Fault */
        case FAULT_ALIGN_1:              /* Alignment Fault */
                 * Really this should just kill the process.
                 * Alignment faults are turned off in the kernel
                 * in order to get better performance from shorts with
                 * GCC so an alignment fault means somebody has played
                 * with the control register in the CPU. Might as well
                 * panic as the kernel was not compiled for aligned

How can this work? What if someone wants to compile an application 
something like the following:
        typedef struct {
             char c  __attribute__ ((packed));
             long l  __attribute__ ((packed));
        } foo_t;

        void func1(void);
        void func2(long *p);

        void func1(void)
             foo_t foo;

             foo.c = 'a';
             foo.l = 0x12345678;


        void func2(long *p)
             printf("%p : %x\n", p, *p);

        int main(void)

Isn't this guaranteed to cause a data abort? Does NetBSD just kill the 
process that does it?

Jay Monkman         The truth knocks on the door and you say "Go away, I'm 
                    looking for the truth," and so it goes away. Puzzling.
                     - from _Zen_and_the_Art_of_Motorcycle_Maintenance_