aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze
diff options
context:
space:
mode:
authorMichal Simek <monstr@monstr.eu>2010-08-03 05:26:51 -0400
committerMichal Simek <monstr@monstr.eu>2010-08-04 04:45:16 -0400
commit751f1605e03533a6279ccf456e938e9595c7d888 (patch)
tree1bff483f2d0f1151c5794d409c00e1c5293656b4 /arch/microblaze
parent958063e67b775bc1be85eb3761c85202597a87aa (diff)
microblaze: Support brki rX, 0x18 for user application debugging
This is the first patch which add support for user application debugging through brki rX, 0x18 vector. This patch has side effect which also remove security issue to use brki rX, 0x18 to freeze kernel. Support for old gdb support via priviledged exception (brk r0, r0) is still there. It will be remove in future. Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze')
-rw-r--r--arch/microblaze/kernel/entry.S30
-rw-r--r--arch/microblaze/kernel/exceptions.c8
2 files changed, 19 insertions, 19 deletions
diff --git a/arch/microblaze/kernel/entry.S b/arch/microblaze/kernel/entry.S
index 397754cd31c9..5a5cb5842938 100644
--- a/arch/microblaze/kernel/entry.S
+++ b/arch/microblaze/kernel/entry.S
@@ -778,19 +778,22 @@ C_ENTRY(_debug_exception):
778 778
779 addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ 779 addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */
780 SAVE_REGS; 780 SAVE_REGS;
781 swi r17, r1, PTO+PT_R17;
782 swi r16, r1, PTO+PT_R16;
783 swi r16, r1, PTO+PT_PC; /* Save LP */
781 784
782 swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */ 785 swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */
783 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 786 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP));
784 swi r11, r1, PTO+PT_R1; /* Store user SP. */ 787 swi r11, r1, PTO+PT_R1; /* Store user SP. */
7852: 7882: lwi CURRENT_TASK, r0, TOPHYS(PER_CPU(CURRENT_SAVE));
786 tovirt(r1,r1) 789 tovirt(r1,r1)
787 790
788 set_vms; 791 set_vms;
789 addi r5, r0, SIGTRAP /* send the trap signal */ 792 addik r5, r1, PTO;
790 add r6, r0, CURRENT_TASK; /* Get current task ptr into r11 */
791 addk r7, r0, r0 /* 3rd param zero */
792dbtrap_call: rtbd r0, send_sig;
793 addik r15, r0, dbtrap_call; 793 addik r15, r0, dbtrap_call;
794dbtrap_call: /* return point for kernel/user entry */
795 rtbd r0, sw_exception
796 nop
794 797
795 set_bip; /* Ints masked for state restore*/ 798 set_bip; /* Ints masked for state restore*/
796 lwi r11, r1, PTO + PT_MODE; 799 lwi r11, r1, PTO + PT_MODE;
@@ -838,6 +841,8 @@ dbtrap_call: rtbd r0, send_sig;
838 tophys(r1,r1); 841 tophys(r1,r1);
839 842
840 RESTORE_REGS 843 RESTORE_REGS
844 lwi r17, r1, PTO+PT_R17;
845 lwi r16, r1, PTO+PT_R16;
841 addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */ 846 addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space. */
842 847
843 848
@@ -854,11 +859,10 @@ dbtrap_call: rtbd r0, send_sig;
854 tovirt(r1,r1); 859 tovirt(r1,r1);
8556: 8606:
856DBTRAP_return: /* Make global symbol for debugging */ 861DBTRAP_return: /* Make global symbol for debugging */
857 rtbd r14, 0; /* Instructions to return from an IRQ */ 862 rtbd r16, 0; /* Instructions to return from an IRQ */
858 nop; 863 nop;
859 864
860 865
861
862ENTRY(_switch_to) 866ENTRY(_switch_to)
863 /* prepare return value */ 867 /* prepare return value */
864 addk r3, r0, CURRENT_TASK 868 addk r3, r0, CURRENT_TASK
@@ -946,13 +950,6 @@ ENTRY(_switch_to)
946ENTRY(_reset) 950ENTRY(_reset)
947 brai 0x70; /* Jump back to FS-boot */ 951 brai 0x70; /* Jump back to FS-boot */
948 952
949ENTRY(_break)
950 mfs r5, rmsr
951 swi r5, r0, 0x250 + TOPHYS(r0_ram)
952 mfs r5, resr
953 swi r5, r0, 0x254 + TOPHYS(r0_ram)
954 bri 0
955
956 /* These are compiled and loaded into high memory, then 953 /* These are compiled and loaded into high memory, then
957 * copied into place in mach_early_setup */ 954 * copied into place in mach_early_setup */
958 .section .init.ivt, "ax" 955 .section .init.ivt, "ax"
@@ -964,12 +961,9 @@ ENTRY(_break)
964 nop 961 nop
965 brai TOPHYS(_user_exception); /* syscall handler */ 962 brai TOPHYS(_user_exception); /* syscall handler */
966 brai TOPHYS(_interrupt); /* Interrupt handler */ 963 brai TOPHYS(_interrupt); /* Interrupt handler */
967 brai TOPHYS(_break); /* nmi trap handler */ 964 brai TOPHYS(_debug_exception); /* debug trap handler */
968 brai TOPHYS(_hw_exception_handler); /* HW exception handler */ 965 brai TOPHYS(_hw_exception_handler); /* HW exception handler */
969 966
970 .org 0x60
971 brai TOPHYS(_debug_exception); /* debug trap handler*/
972
973.section .rodata,"a" 967.section .rodata,"a"
974#include "syscall_table.S" 968#include "syscall_table.S"
975 969
diff --git a/arch/microblaze/kernel/exceptions.c b/arch/microblaze/kernel/exceptions.c
index 02cbdfe5aa8d..e0c6f8c2bd9d 100644
--- a/arch/microblaze/kernel/exceptions.c
+++ b/arch/microblaze/kernel/exceptions.c
@@ -48,6 +48,12 @@ void die(const char *str, struct pt_regs *fp, long err)
48 do_exit(err); 48 do_exit(err);
49} 49}
50 50
51/* for user application debugging */
52void sw_exception(struct pt_regs *regs)
53{
54 _exception(SIGTRAP, regs, TRAP_BRKPT, regs->r16);
55}
56
51void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr) 57void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)
52{ 58{
53 siginfo_t info; 59 siginfo_t info;
@@ -143,7 +149,7 @@ asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
143#ifdef CONFIG_MMU 149#ifdef CONFIG_MMU
144 case MICROBLAZE_PRIVILEGED_EXCEPTION: 150 case MICROBLAZE_PRIVILEGED_EXCEPTION:
145 pr_debug(KERN_WARNING "Privileged exception\n"); 151 pr_debug(KERN_WARNING "Privileged exception\n");
146 /* "brk r0,r0" - used as debug breakpoint */ 152 /* "brk r0,r0" - used as debug breakpoint - old toolchain */
147 if (get_user(code, (unsigned long *)regs->pc) == 0 153 if (get_user(code, (unsigned long *)regs->pc) == 0
148 && code == 0x980c0000) { 154 && code == 0x980c0000) {
149 _exception(SIGTRAP, regs, TRAP_BRKPT, addr); 155 _exception(SIGTRAP, regs, TRAP_BRKPT, addr);