Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 14: Kernel Activities


Alternatively, the registers can also be copied to a location in address space that is not identical to the
stack. In this case,do_IRQreceives as its parameter a pointer topt_regs, which does not change the fact
that the register contents have been saved and can be read by the C code.

The definition ofstruct pt_regsis platform-dependent because different processors provide different
register sets. The registers used by the kernel are held inpt_regs. Registers not listed here may be used
by user mode applications only. On IA-32 systems,pt_regsis typically defined as follows:

include/asm-x86/ptrace.h
struct pt_regs {
long ebx;
long ecx;
long edx;
long esi;
long edi;
long ebp;
long eax;
int xds;
int xes;
long orig_eax;
long eip;
int xcs;
long eflags;
long esp;
int xss;
};

PA-Risc processors, for instance, use a totally different set of registers:

include/asm-parisc/ptrace.h
struct pt_regs {
unsigned long gr[32]; /* PSW is in gr[0] */
__u64 fr[32];
unsigned long sr[ 8];
unsigned long iasq[2];
unsigned long iaoq[2];
unsigned long cr27;
unsigned long pad0; /* available for other uses */
unsigned long orig_r28;
unsigned long ksp;
unsigned long kpc;
unsigned long sar; /* CR11 */
unsigned long iir; /* CR19 */
unsigned long isr; /* CR20 */
unsigned long ior; /* CR21 */
unsigned long ipsw; /* CR22 */
};

The general trend in 64-bit architectures is to provide more and more registers, with the result that
pt_regsdefinitions are becoming larger and larger. IA-64 has, for example, almost 50 entries inpt_regs,
reason enough not to include the definition here.
Free download pdf