Skip to contentSkip to conversation

unaligned access

DISCUSSION sathesh babu 6 participants 11 messages Feb 22, 2007 – Feb 24, 2007 MIPS

lore
Share & tools
lore
#0 lore raw

Hi,
I have ported linux-2.6.12 kernel on MIPS processor.I would like to
print the warning messges whenenver kernel or user code try to access unaligned address ( including proceor ID ).
Is there any configuration option avaliable in the kernel to view
the unaligned address?

Thanks in advance.

Regards,
Sathesh

---------------------------------
Here’s a new way to find what you're looking for - Yahoo! Answers

#1 lore raw
Quoted 6 lines · sathesh babu

Hi,
I have ported linux-2.6.12 kernel on MIPS processor.I would like to
print the warning messges whenenver kernel or user code try to access unaligned address ( including proceor ID ).
Is there any configuration option avaliable in the kernel to view
the unaligned address?

Ummm ... not sure about MIPS, but in i386, exception 17 is raised for every unaligned access. alignment_check() is invoked for every such access.

Regards,

Rajat

#2 lore raw

Thanks Rajan.

In case of arm processor, the alignment trap behavior can be changed by simply echo a number into /proc/sys/debug/alignment

bit behavior when set
--- -----------------
0 A user process performing an unaligned memory access
will cause the kernel to print a message indicating process name, pid, pc, instruction, address, and the fault code.
1 The kernel will attempt to fix up the user process
performing the unaligned access. This is of course slow (think about the floating point emulator) and not recommended for production use.
2 The kernel will send a SIGBUS signal to the user process
performing the unaligned access.

I would like to know Is there similar type of implimentation avalilable for MIPS processor in linux-2.6.12 kernel to view or log the unaligned access addresses and corresponding processor ID.

Regards,
Sathesh

Rajat Jain <[email protected]> wrote:

Quoted 6 lines · sathesh babu

Hi,
I have ported linux-2.6.12 kernel on MIPS processor.I would like to print the warning messges whenenver kernel or user code try to access unaligned address ( including proceor ID ).
Is there any configuration option avaliable in the kernel to view the unaligned address?

Ummm ... not sure about MIPS, but in i386, exception 17 is raised for every unaligned access. alignment_check() is invoked for every such access.

Regards,

Rajat

---------------------------------
Here’s a new way to find what you're looking for - Yahoo! Answers

#3 lore raw

Default behavior in MIPS is to silently fix up and emulate. A MIPS-specific system call (sys_sysmips with the command argument of MIPS_FIXADE
and a parameter agument of zero) allows for this to be overridden, so that such accesses will be fatal. It looks as if there was once support to log the events to syslog, independently of whether or not they were fixed up, but it doesn't look to me as if that still works in 2.6.x kernels.

Regards,

Kevin K.
----- Original Message -----
From: sathesh babu
To: Rajat Jain
Cc: [email protected]
Sent: Thursday, February 22, 2007 10:18 AM
Subject: Re: unaligned access

Thanks Rajan.

In case of arm processor, the alignment trap behavior can be changed by simply echo a number into /proc/sys/debug/alignment

  bit             behavior when set
  ---             -----------------
  0               A user process performing an unaligned memory access

will cause the kernel to print a message indicating process name, pid, pc, instruction, address, and the fault code.
1 The kernel will attempt to fix up the user process
performing the unaligned access. This is of course slow (think about the floating point emulator) and not recommended for production use.
2 The kernel will send a SIGBUS signal to the user process
performing the unaligned access.

I would like to know Is there similar type of implimentation avalilable for MIPS processor in linux-2.6.12 kernel to view or log the unaligned access addresses and corresponding processor ID.

Regards,
Sathesh

Rajat Jain <[email protected]> wrote:
On 2/22/07, sathesh babu wrote:
> Hi,
> I have ported linux-2.6.12 kernel on MIPS processor.I would like to > print the warning messges whenenver kernel or user code try to access > unaligned address ( including proceor ID ).
> Is there any configuration option avaliable in the kernel to view > the unaligned address?

Ummm ... not sure about MIPS, but in i386, exception 17 is raised for every unaligned access. alignment_check() is invoked for every such access.

Regards,

Rajat

------------------------------------------------------------------------------
Here's a new way to find what you're looking for - Yahoo! Answers

#4 lore raw
Quoted 6 lines · Kevin D. Kissell

Default behavior in MIPS is to silently fix up and emulate. A MIPS-specific system call (sys_sysmips with the command argument of MIPS_FIXADE
and a parameter agument of zero) allows for this to be overridden, so that such accesses will be fatal. It looks as if there was once support to log the events to syslog, independently of whether or not they were fixed up, but it doesn't look to me as if that still works in 2.6.x kernels.

There used to be a configuration option to allow logging which was a leftover from the times when I implemented the unaligned emulation. I did never find it useful later on, so I removed that in almost 9 years ago and nobody missed it since :-)

But I don't mind putting it back, controllable by sysctl if there is any demand for it.

Ralf

#5 lore raw
Quoted 7 lines · Ralf Baechle

There used to be a configuration option to allow logging which was a leftover from the times when I implemented the unaligned emulation. I did never find it useful later on, so I removed that in almost 9 years ago and nobody missed it since :-)

But I don't mind putting it back, controllable by sysctl if there is any demand for it.

Sometimes I want to know a value of unaligned_instructions variable, to make sure nobody is causing such exceptions. I just wanted to know the statistics and did not want to control it, but showing name of the process and PC would help to find out who is guilty. I wonder if anybody really want to handle the exception manually.

So how about this interface?

1. echo show > /sys/kernel/unaligned_action

Show register dump and processor name at each unaligned exception, using show_regs() or someting.

2. echo quiet > /sys/kernel/unaligned_action

Siliently fixup unaligned exceptions.

3. cat /sys/kernel/unaligned_instructions

Print unaligned_instructions variable.

Creating files in /sys/kernel is fairly simple:

	subsys_create_file(&kernel_subsys, &foo_attr);

Any comments?
---
Atsushi Nemoto

#10 lore raw
In reply to Ralf Baechle

It would be good idea to know which process hitting unaligned access and PC.
So that we can try to fix unaligned access when it causes the performance bottleneck.

Could you please share details about logging the unaligned accesses using sysctl.

Thanks in advance

Regards,
Sathesh

Ralf Baechle <[email protected]> wrote:

Quoted 6 lines · Kevin D. Kissell

Default behavior in MIPS is to silently fix up and emulate. A MIPS-specific system call (sys_sysmips with the command argument of MIPS_FIXADE
and a parameter agument of zero) allows for this to be overridden, so that such accesses will be fatal. It looks as if there was once support to log the events to syslog, independently of whether or not they were fixed up, but it doesn't look to me as if that still works in 2.6.x kernels.

There used to be a configuration option to allow logging which was a leftover from the times when I implemented the unaligned emulation. I did never find it useful later on, so I removed that in almost 9 years ago and nobody missed it since :-)

But I don't mind putting it back, controllable by sysctl if there is any demand for it.

Ralf

---------------------------------
Here’s a new way to find what you're looking for - Yahoo! Answers

#6 lore raw
In reply to Atsushi Nemoto
Quoted 13 lines

So how about this interface?

1. echo show > /sys/kernel/unaligned_action

Show register dump and processor name at each unaligned exception, using show_regs() or someting.

2. echo quiet > /sys/kernel/unaligned_action

Siliently fixup unaligned exceptions.

3. cat /sys/kernel/unaligned_instructions

Quoted 8 lines

Print unaligned_instructions variable.

Creating files in /sys/kernel is fairly simple:

subsys_create_file(&kernel_subsys, &foo_attr);

Any comments?

One thing about the current, system-call based interface that is kind-of cool, and different from both what you propose and what was described as being implemented for ARM, is that Ralf's scheme is per-thread. I don't know if that power really outweighs the ease-of-use aspect of being able to manipuate it from the shell command line, but it's not something to throw away lightly. I have no issues with moving the log data, should it be resurrected, from syslog to /sys/kernel/whatever, though.

Regards,

Kevin K.

#7 lore raw
Quoted 8 lines · Kevin D. Kissell

One thing about the current, system-call based interface that is kind-of cool, and different from both what you propose and what was described as being implemented for ARM, is that Ralf's scheme is per-thread. I don't know if that power really outweighs the ease-of-use aspect of being able to manipuate it from the shell command line, but it's not something to throw away lightly. I have no issues with moving the log data, should it be resurrected, from syslog to /sys/kernel/whatever, though.

Well, /sys/kernel method can coexist with per-thread FIXADE method. We can use /sys/kernel (or something) to change default action. And sysmips() or something can be used to override it.

---
Atsushi Nemoto

#8 lore raw
In reply to Kevin D. Kissell
Quoted 8 lines · Kevin D. Kissell

One thing about the current, system-call based interface that is kind-of cool, and different from both what you propose and what was described as being implemented for ARM, is that Ralf's scheme is per-thread. I don't know if that power really outweighs the ease-of-use aspect of being able to manipuate it from the shell command line, but it's not something to throw away lightly. I have no issues with moving the log data, should it be resurrected, from syslog to /sys/kernel/whatever, though.

There are two different things here that need to be sorted out - but for years nobody noticed so this never really did show up on the radar:

o sysmips is really a compatibility interface meant to support software that did originate on IRIX, RISC/os and maybe even MIPS/os. But sysmips(MIPS_FIXADE,...) is a new operation that I came up with for Linux. So I'd like this interface to die.
o sysmips(MIPS_FIXADE, ...) does control only the fixup operation of the kernel on a per thread base. Loggin is not controlled by it; that was available in the dark past only as a compile time option.
o The MIPS_FIXADE setting is inherited across clone and fork. I could almost bet no software relying on this feature is actually explicitly enabling it. Maybe the default should be off to make programmers aware of this kind of issue in their code?
o The MIPS_FIXADE setting is valid for both kernel and user mode. So if for example the TCP stack is taking an unaligned exception to process an incoming packet, it will look at the setting of the process that just happens to be running on the CPU.
o I think it would be handy to have a method to externally control the MIPS_FIXADE setting of a process.
o Logging unaligned accesses is a dangerous thing; it can easily reach a DoS-like volume.

Ralf

#9 lore raw
Quoted 2 lines · Ralf Baechle

o Logging unaligned accesses is a dangerous thing; it can easily reach a DoS-like volume.

Providing a damn good incentive to fix your broken software?

Maciej