8/8 LTT for 2.5.33: MIPS trace support
PATCH 1/1 8/8 LTT for 2.5.33: MIPS trace support
This patch adds trace support for the MIPS. These files are modified:arch/mips/config.inarch/mips/ddb5476/irq.carch/mips/kernel/irq.carch/mips/kernel/scall_o32.Sarch/mips/kernel/time.carch/mips/kernel/traps.carch/mips/kernel/unaligned.carch/mips/kernel/fault.cinclude/asm-mips/trace.h
This patch needed some revision. I have received updates for it. I post it only for completeness. Once the updates are integrated I will post it again.
arch/mips/config.in +2 -0
@@ -477,6 +477,8 @@ source drivers/usb/Config.in +source drivers/trace/Config.in + mainmenu_option next_comment comment 'Kernel hacking'
arch/mips/ddb5476/irq.c +10 -0
@@ -3,6 +3,10 @@* * Copyright (C) 2000 Geert Uytterhoeven <[email protected]> * Sony Software Development Center Europe (SDCE), Brussels +* +* ---- for LTT patch ---- +* Copyright (C) 2001 Takuzo O'Hara ([email protected]). +* */ #include <linux/config.h> #include <linux/init.h>
@@ -12,6 +16,8 @@#include <linux/interrupt.h> #include <linux/ioport.h> +#include <linux/trace.h> +#include <asm/io.h> #include <asm/irq.h> #include <asm/ptrace.h>
@@ -184,6 +190,7 @@/* Handle the timer interrupt first */ if (mask & (1 <<NILE4_INT_GPT )) {nile4_disable_irq (NILE4_INT_GPT ); +TRACE_IRQ_ENTRY (nile4_to_irq (NILE4_INT_GPT ), ((regs->cp0_status &ST0_KSU ) ==KSU_KERNEL ));do_IRQ (nile4_to_irq (NILE4_INT_GPT ), regs);nile4_enable_irq (NILE4_INT_GPT ); mask &= ~(1 <<NILE4_INT_GPT );
@@ -193,8 +200,10 @@nile4_disable_irq (nile4_irq);if (nile4_irq ==NILE4_INT_INTC ) {int i8259_irq =nile4_i8259_iack (); +TRACE_IRQ_ENTRY (i8259_irq, ((regs->cp0_status &ST0_KSU ) ==KSU_KERNEL ));i8259_do_irq (i8259_irq, regs); }else { +TRACE_IRQ_ENTRY (nile4_to_irq (nile4_irq), ((regs->cp0_status &ST0_KSU ) ==KSU_KERNEL ));do_IRQ (nile4_to_irq (nile4_irq), regs); }nile4_enable_irq (nile4_irq);
@@ -204,6 +213,7 @@ddb5476_led_d3 (0 );ddb5476_led_hex (nesting <16 ? nesting :15 );#endif +TRACE_IRQ_EXIT (); }void ddb_local1_irqdispatch (void )
arch/mips/kernel/irq.c +10 -0
@@ -7,6 +7,10 @@* * Copyright (C) 1992 Linus Torvalds * Copyright (C) 1994 - 2000 Ralf Baechle +* +* ---- for LTT patch ---- +* Copyright (C) 2001 Takuzo O'Hara ([email protected]). +* */ #include <linux/kernel.h> #include <linux/irq.h>
@@ -19,6 +23,8 @@#include <linux/sched.h> #include <linux/seq_file.h> +#include <linux/trace.h> +#include <asm/system.h> /*
@@ -244,6 +250,8 @@struct irqaction * action;unsigned int status; +TRACE_IRQ_ENTRY (irq, ((regs->cp0_status &ST0_KSU ) ==KSU_KERNEL )); + kstat.irqs[cpu][irq]++;spin_lock (&desc->lock); desc->handler->ack (irq);
@@ -302,6 +310,8 @@*/ desc->handler->end (irq);spin_unlock (&desc->lock); + +TRACE_IRQ_EXIT ();if (softirq_pending (cpu))do_softirq ();
arch/mips/kernel/scall_o32.S +38 -0
@@ -4,7 +4,12 @@ * for more details. * * Copyright (C) 1997, 1998, 1999, 2000 by Ralf Baechle + * + * ---- for LTT patch ---- + * Copyright (C) 2001 Takuzo O'Hara ([email protected]). + * */ + #include <asm/asm.h> #include <linux/errno.h> #include <asm/current.h>
@@ -48,6 +53,10 @@ bgez t0, stackargs stack_done: +#if (CONFIG_TRACE || CONFIG_TRACE_MODULE) + sw a3, PT_R26(sp) # save for syscall restart + b ltt_trace_a_syscall +#endif /* (CONFIG_TRACE || CONFIG_TRACE_MODULE) */ sw a3, PT_R26(sp) # save for syscall restart #error lw t0, TASK_PTRACE($28) # syscall tracing enabled? andi t0, PT_TRACESYS
@@ -95,6 +104,35 @@ SAVE_STATIC jal schedule b o32_ret_from_sys_call + +/* ------------------------------------------------------------------------ */ + +#if (CONFIG_TRACE || CONFIG_TRACE_MODULE) +ltt_trace_a_syscall: + SAVE_STATIC + sw t2, PT_R1(sp) + move a0, sp + jal trace_real_syscall_entry + lw t2, PT_R1(sp) + + lw a0, PT_R4(sp) # Restore argument registers + lw a1, PT_R5(sp) + lw a2, PT_R6(sp) + lw a3, PT_R7(sp) + jalr t2 + + li t0, -EMAXERRNO - 1 # error? + sltu t0, t0, v0 + sw t0, PT_R7(sp) # set error flag + beqz t0, 1f + + negu v0 # error + sw v0, PT_R0(sp) # set flag for syscall restarting +1: sw v0, PT_R2(sp) # result + + jal trace_real_syscall_exit + j o32_ret_from_sys_call +#endif /* (CONFIG_TRACE || CONFIG_TRACE_MODULE) */ /* ------------------------------------------------------------------------ */
arch/mips/kernel/time.c +4 -0
@@ -368,6 +368,8 @@ {int cpu =smp_processor_id (); +TRACE_IRQ_ENTRY (irq, ((regs->cp0_status &ST0_KSU ) ==KSU_KERNEL )); +irq_enter (cpu, irq); kstat.irqs[cpu][irq]++;
@@ -375,6 +377,8 @@timer_interrupt (irq,NULL , regs);irq_exit (cpu, irq); + +TRACE_IRQ_EXIT ();if (softirq_pending (cpu))do_softirq ();
arch/mips/kernel/traps.c +126 -5
271 lines not on this page · raw message
arch/mips/kernel/unaligned.c +12 -1
@@ -8,6 +8,9 @@* Copyright (C) 1996, 1998 by Ralf Baechle * Copyright (C) 1999 Silicon Graphics, Inc. * +* ---- for LTT patch ---- +* Copyright (C) 2001 Takuzo O'Hara ([email protected]). +* * This file contains exception handler for address error exception with the * special capability to execute faulting instructions in software. The * handler does not try to handle the case when the program counter points
@@ -78,6 +81,8 @@#include <linux/smp.h> #include <linux/smp_lock.h> +#include <linux/trace.h> +#include <asm/asm.h> #include <asm/branch.h> #include <asm/byteorder.h>
@@ -400,6 +405,8 @@return ; } +// TRACE_TRAP_ENTRY(EXC_CODE(regs->cp0_cause), regs->cp0_epc); +/* * Did we catch a fault trying to load an instruction? * This also catches attempts to activate MIPS16 code on
@@ -409,8 +416,10 @@ goto sigbus; pc = regs->cp0_epc + ((regs->cp0_cause &CAUSEF_BD ) ?4 :0 ); -if (compute_return_epc (regs)) +if (compute_return_epc (regs)){ +// TRACE_TRAP_EXIT(); return ; + }if ((current->thread.mflags &MF_FIXADE ) ==0 ) goto sigbus;
@@ -419,11 +428,13 @@ unaligned_instructions++;#endif +// TRACE_TRAP_EXIT(); return ; sigbus:die_if_kernel ("Kernel unaligned instruction access" , regs);force_sig (SIGBUS , current); +// TRACE_TRAP_EXIT(); return ; }
arch/mips/mm/fault.c +15 -0
@@ -4,6 +4,10 @@* for more details. * * Copyright (C) 1995 - 2000 by Ralf Baechle +* +* ---- for LTT patch ---- +* Copyright (C) 2001 Takuzo O'Hara ([email protected]). +* */ #include <linux/signal.h> #include <linux/sched.h>
@@ -19,12 +23,18 @@#include <linux/smp_lock.h> #include <linux/version.h> +#include <linux/trace.h> +#include <asm/hardirq.h> #include <asm/pgalloc.h> #include <asm/mmu_context.h> #include <asm/softirq.h> #include <asm/system.h> #include <asm/uaccess.h> +#include <asm/mipsregs.h> +#include <asm/unistd.h> + +#define EXC_CODE (x) ((CAUSEF_EXCCODE & (x)) >> CAUSEB_EXCCODE)#define development_version (LINUX_VERSION_CODE & 0x100)
@@ -87,6 +97,10 @@* we can handle it.. */ good_area: +// takuzo: +// I only made this to log page faults for reasonable usermode context. +// page faults in kernel, fixups, sigbuses are siliently ignored... +TRACE_TRAP_ENTRY (EXC_CODE (regs->cp0_cause), regs->cp0_epc); info.si_code =SEGV_ACCERR ;if (write) {
@@ -116,6 +130,7 @@ }up_read (&mm->mmap_sem); +// TRACE_TRAP_EXIT(); return ;/*
include/asm-mips/trace.h +15 -0
@@ -0,0 +1,15 @@ +/* +* linux/include/asm-mips/trace.h +* +* Copyright (C) 2002, Karim Yaghmour +* +* MIPS definitions for tracing system +*/ + +#include <linux/trace.h> + +/* Current arch type */ +#define TRACE_ARCH_TYPE TRACE_ARCH_TYPE_MIPS + +/* Current variant type */ +#define TRACE_ARCH_VARIANT TRACE_ARCH_VARIANT_NONE