[ia64] sanitize elf_access_gpreg()
The function takes the register number, finds the corresponding field
of pt_regs for registers that are saved there or does the unwind for the
registers that end up spilled on the kernel stack. Then it reads from
or writes to the resulting location.
Unfortunately, finding the required pt_regs field is done by rather
horrible switch. It's microoptimized in all the wrong places - it
even uses the knowledge that fields for r8..r11 follow each other
in pt_regs layout, while r12..r13 are not adjacent to those, etc.
All of that is to encode the mapping from register numbers to offsets +
the information that r4..r7 are not to be found in pt_regs.
It's deeply in nasal demon territory, at that - the games it plays
with pointer arithmetics on addresses of structure members are
undefined behaviour.
Valid C ends up with better code in this case: just initialize a constant
array with offsets of relevant pt_regs fields and we don't need that
switch anymore.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing
Please register or sign in to comment