Skip to content

Commit

Permalink
x86: Rename trap_no to trap_nr in thread_struct
Browse files Browse the repository at this point in the history
There are precedences of trap number being referred to as
trap_nr. However thread struct refers trap number as trap_no.
Change it to trap_nr.

Also use enum instead of left-over literals for trap values.

This is pure cleanup, no functional change intended.

Suggested-by: Ingo Molnar <mingo@eltu.hu>
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Jim Keniston <jkenisto@linux.vnet.ibm.com>
Cc: Linux-mm <linux-mm@kvack.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120312092555.5379.942.sendpatchset@srdronam.in.ibm.com
[ Fixed the math-emu build ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Srikar Dronamraju authored and Ingo Molnar committed Mar 13, 2012
1 parent e898c67 commit 51e7dc7
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion arch/x86/ia32/ia32_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
put_user_ex(regs->dx, &sc->dx);
put_user_ex(regs->cx, &sc->cx);
put_user_ex(regs->ax, &sc->ax);
put_user_ex(current->thread.trap_no, &sc->trapno);
put_user_ex(current->thread.trap_nr, &sc->trapno);
put_user_ex(current->thread.error_code, &sc->err);
put_user_ex(regs->ip, &sc->ip);
put_user_ex(regs->cs, (unsigned int __user *)&sc->cs);
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ struct thread_struct {
unsigned long ptrace_dr7;
/* Fault info: */
unsigned long cr2;
unsigned long trap_no;
unsigned long trap_nr;
unsigned long error_code;
/* floating point and extended processor state */
struct fpu fpu;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/dumpstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
#endif
printk("\n");
if (notify_die(DIE_OOPS, str, regs, err,
current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP)
return 1;

show_registers(regs);
Expand Down
3 changes: 2 additions & 1 deletion arch/x86/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <asm/prctl.h>
#include <asm/proto.h>
#include <asm/hw_breakpoint.h>
#include <asm/traps.h>

#include "tls.h"

Expand Down Expand Up @@ -1425,7 +1426,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
int error_code, int si_code,
struct siginfo *info)
{
tsk->thread.trap_no = 1;
tsk->thread.trap_nr = X86_TRAP_DB;
tsk->thread.error_code = error_code;

memset(info, 0, sizeof(*info));
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
put_user_ex(regs->r15, &sc->r15);
#endif /* CONFIG_X86_64 */

put_user_ex(current->thread.trap_no, &sc->trapno);
put_user_ex(current->thread.trap_nr, &sc->trapno);
put_user_ex(current->thread.error_code, &sc->err);
put_user_ex(regs->ip, &sc->ip);
#ifdef CONFIG_X86_32
Expand Down
16 changes: 8 additions & 8 deletions arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
trap_signal:
#endif
/*
* We want error_code and trap_no set for userspace faults and
* We want error_code and trap_nr set for userspace faults and
* kernelspace faults which result in die(), but not
* kernelspace faults which are fixed up. die() gives the
* process no chance to handle the signal and notice the
Expand All @@ -141,7 +141,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
* delivered, faults. See also do_general_protection below.
*/
tsk->thread.error_code = error_code;
tsk->thread.trap_no = trapnr;
tsk->thread.trap_nr = trapnr;

#ifdef CONFIG_X86_64
if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
Expand All @@ -164,7 +164,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
kernel_trap:
if (!fixup_exception(regs)) {
tsk->thread.error_code = error_code;
tsk->thread.trap_no = trapnr;
tsk->thread.trap_nr = trapnr;
die(str, regs, error_code);
}
return;
Expand Down Expand Up @@ -240,7 +240,7 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);

tsk->thread.error_code = error_code;
tsk->thread.trap_no = X86_TRAP_DF;
tsk->thread.trap_nr = X86_TRAP_DF;

/*
* This is always a kernel trap and never fixable (and thus must
Expand Down Expand Up @@ -268,7 +268,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
goto gp_in_kernel;

tsk->thread.error_code = error_code;
tsk->thread.trap_no = X86_TRAP_GP;
tsk->thread.trap_nr = X86_TRAP_GP;

if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
printk_ratelimit()) {
Expand All @@ -295,7 +295,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
return;

tsk->thread.error_code = error_code;
tsk->thread.trap_no = X86_TRAP_GP;
tsk->thread.trap_nr = X86_TRAP_GP;
if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
X86_TRAP_GP, SIGSEGV) == NOTIFY_STOP)
return;
Expand Down Expand Up @@ -475,7 +475,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
{
if (!fixup_exception(regs)) {
task->thread.error_code = error_code;
task->thread.trap_no = trapnr;
task->thread.trap_nr = trapnr;
die(str, regs, error_code);
}
return;
Expand All @@ -485,7 +485,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
* Save the info for the exception handler and clear the error.
*/
save_init_fpu(task);
task->thread.trap_no = trapnr;
task->thread.trap_nr = trapnr;
task->thread.error_code = error_code;
info.si_signo = SIGFPE;
info.si_errno = 0;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/vm86_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ int handle_vm86_trap(struct kernel_vm86_regs *regs, long error_code, int trapno)
}
if (trapno != 1)
return 1; /* we let this handle by the calling routine */
current->thread.trap_no = trapno;
current->thread.trap_nr = trapno;
current->thread.error_code = error_code;
force_sig(SIGTRAP, current);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/vsyscall_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static bool write_ok_or_segv(unsigned long ptr, size_t size)

thread->error_code = 6; /* user fault, no page, write */
thread->cr2 = ptr;
thread->trap_no = 14;
thread->trap_nr = X86_TRAP_PF;

memset(&info, 0, sizeof(info));
info.si_signo = SIGSEGV;
Expand Down
5 changes: 3 additions & 2 deletions arch/x86/math-emu/fpu_entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/regset.h>

#include <asm/uaccess.h>
#include <asm/traps.h>
#include <asm/desc.h>
#include <asm/user.h>
#include <asm/i387.h>
Expand Down Expand Up @@ -269,7 +270,7 @@ void math_emulate(struct math_emu_info *info)
FPU_EIP = FPU_ORIG_EIP; /* Point to current FPU instruction. */

RE_ENTRANT_CHECK_OFF;
current->thread.trap_no = 16;
current->thread.trap_nr = X86_TRAP_MF;
current->thread.error_code = 0;
send_sig(SIGFPE, current, 1);
return;
Expand Down Expand Up @@ -662,7 +663,7 @@ static int valid_prefix(u_char *Byte, u_char __user **fpu_eip,
void math_abort(struct math_emu_info *info, unsigned int signal)
{
FPU_EIP = FPU_ORIG_EIP;
current->thread.trap_no = 16;
current->thread.trap_nr = X86_TRAP_MF;
current->thread.error_code = 0;
send_sig(signal, current, 1);
RE_ENTRANT_CHECK_OFF;
Expand Down
10 changes: 5 additions & 5 deletions arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ pgtable_bad(struct pt_regs *regs, unsigned long error_code,
dump_pagetable(address);

tsk->thread.cr2 = address;
tsk->thread.trap_no = 14;
tsk->thread.trap_nr = X86_TRAP_PF;
tsk->thread.error_code = error_code;

if (__die("Bad pagetable", regs, error_code))
Expand All @@ -636,7 +636,7 @@ no_context(struct pt_regs *regs, unsigned long error_code,
/* Are we prepared to handle this kernel fault? */
if (fixup_exception(regs)) {
if (current_thread_info()->sig_on_uaccess_error && signal) {
tsk->thread.trap_no = 14;
tsk->thread.trap_nr = X86_TRAP_PF;
tsk->thread.error_code = error_code | PF_USER;
tsk->thread.cr2 = address;

Expand Down Expand Up @@ -676,7 +676,7 @@ no_context(struct pt_regs *regs, unsigned long error_code,
printk(KERN_EMERG "Thread overran stack, or stack corrupted\n");

tsk->thread.cr2 = address;
tsk->thread.trap_no = 14;
tsk->thread.trap_nr = X86_TRAP_PF;
tsk->thread.error_code = error_code;

sig = SIGKILL;
Expand Down Expand Up @@ -754,7 +754,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
/* Kernel addresses are always protection faults: */
tsk->thread.cr2 = address;
tsk->thread.error_code = error_code | (address >= TASK_SIZE);
tsk->thread.trap_no = 14;
tsk->thread.trap_nr = X86_TRAP_PF;

force_sig_info_fault(SIGSEGV, si_code, address, tsk, 0);

Expand Down Expand Up @@ -838,7 +838,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,

tsk->thread.cr2 = address;
tsk->thread.error_code = error_code;
tsk->thread.trap_no = 14;
tsk->thread.trap_nr = X86_TRAP_PF;

#ifdef CONFIG_MEMORY_FAILURE
if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
Expand Down

0 comments on commit 51e7dc7

Please sign in to comment.