It is currently Sat, 04 Feb 2023 11:58:08 GMT



 
Author Message
 Wanted: Unaligned access exceptions
I am developping programs that are not only used on PCs, so I would
like to have unaligned accesses reported. The 486 can generate
exceptions for unaligned accesses if a certain bit in a status
register is set. Linux (at least 1.0 which I have) does not execute my
binary with these exceptions turned on. Is there a program that lets
me run binaries with these exceptions? (I assume it's not a good idea
to run everything with unaligned access exceptions, as some programs
rely on unaligned accesses).

Please reply by mail, I'll post a summary.

- anton
--
M. Anton Ertl                    Some things have to be seen to be believed
an...@mips.complang.tuwien.ac.at Most things have to be believed to be seen



 Sun, 24 Nov 1996 01:45:45 GMT   
 Wanted: Unaligned access exceptions
|> I am developping programs that are not only used on PCs, so I would
|> like to have unaligned accesses reported. The 486 can generate
|> exceptions for unaligned accesses if a certain bit in a status
|> register is set. Linux (at least 1.0 which I have) does not execute my
|> binary with these exceptions turned on. Is there a program that lets
|> me run binaries with these exceptions?

Thanks to Al Longyear and Alan Cox for their helpful comments.

The 486 has two bits: AC in the EFLAGS register turns alignment faults
on or off for privilege level 3 (i.e. user code). The AM flag in the
CR0 register controls whether the AC flag is working or is ignored
(i.e. no alignment faults, like on the 386).

Linux sets the AM flag on booting (i.e. the AC flag will be
heeded). The AC flag can be set by user code, which is the basis for
the solution. The line

__asm__("pushfl; popl %eax; orl $0x40000,%eax; pushl %eax; popfl;");

sets the AC bit. I put it at the start of the program I want to check,
i.e.,

#ifdef i386
__asm__("pushfl; popl %eax; orl $0x40000,%eax; pushl %eax; popfl;");
#endif

This should not have any adverse effect on the 386 (which does not
have an AC flag), but I have no 386 to check this.

Al Longyear also suggested changing kernel/fork.c to set the AC bit
(this would set it for all user processes) by changing

        p->tss.eflags = regs.eflags & 0xffffcfff;        /* iopl is always 0 for a new process */

to

        p->tss.eflags = (regs.eflags & 0xffffcfff) | 0x40000;    /* iopl is always 0 for a new process and send AC */

I tried this, but it did not have any noticable effect.

- anton
--
M. Anton Ertl                    Some things have to be seen to be believed
an...@mips.complang.tuwien.ac.at Most things have to be believed to be seen



 Tue, 26 Nov 1996 18:11:06 GMT   
 
   [ 2 post ] 

Similar Threads

1. Unaligned access (bus error) on Solaris on global variable

2. Signal handler for unaligned access: emulate and continue?

3. Signal handler for unaligned access: emulate and continue?

4. Fixing unaligned access Solaris 2.3

5. Help: Unaligned access?

6. unaligned access 3

7. unaligned access?!

8. Get GDB to stop at Unaligned access


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software