aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/traps.c
diff options
context:
space:
mode:
authorLeonid Yegoshin <Leonid.Yegoshin@imgtec.com>2013-12-04 11:39:34 -0500
committerRalf Baechle <ralf@linux-mips.org>2014-03-26 18:09:13 -0400
commit078dde5e21dba9f4186ebfc2aef06341fd20efb4 (patch)
tree7d2bcea5f8bfc5bdc8bbe0a525ab7359e6721a25 /arch/mips/kernel/traps.c
parentb08a9c95f80f2f760f62d70fcd5a869c425d17b6 (diff)
MIPS: traps: Set correct address limit for breakpoints and traps
When a breakpoint or trap happens when operating in kernel mode but on users behalf (eg syscall) it is necessary to change the address limit to KERNEL_DS so any address checking can be bypassed and print the correct stack trace. Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Diffstat (limited to 'arch/mips/kernel/traps.c')
-rw-r--r--arch/mips/kernel/traps.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 1a76d114e84b..074e857ced28 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -865,6 +865,11 @@ asmlinkage void do_bp(struct pt_regs *regs)
865 enum ctx_state prev_state; 865 enum ctx_state prev_state;
866 unsigned long epc; 866 unsigned long epc;
867 u16 instr[2]; 867 u16 instr[2];
868 mm_segment_t seg;
869
870 seg = get_fs();
871 if (!user_mode(regs))
872 set_fs(KERNEL_DS);
868 873
869 prev_state = exception_enter(); 874 prev_state = exception_enter();
870 if (get_isa16_mode(regs->cp0_epc)) { 875 if (get_isa16_mode(regs->cp0_epc)) {
@@ -924,6 +929,7 @@ asmlinkage void do_bp(struct pt_regs *regs)
924 do_trap_or_bp(regs, bcode, "Break"); 929 do_trap_or_bp(regs, bcode, "Break");
925 930
926out: 931out:
932 set_fs(seg);
927 exception_exit(prev_state); 933 exception_exit(prev_state);
928 return; 934 return;
929 935
@@ -937,8 +943,13 @@ asmlinkage void do_tr(struct pt_regs *regs)
937 u32 opcode, tcode = 0; 943 u32 opcode, tcode = 0;
938 enum ctx_state prev_state; 944 enum ctx_state prev_state;
939 u16 instr[2]; 945 u16 instr[2];
946 mm_segment_t seg;
940 unsigned long epc = msk_isa16_mode(exception_epc(regs)); 947 unsigned long epc = msk_isa16_mode(exception_epc(regs));
941 948
949 seg = get_fs();
950 if (!user_mode(regs))
951 set_fs(get_ds());
952
942 prev_state = exception_enter(); 953 prev_state = exception_enter();
943 if (get_isa16_mode(regs->cp0_epc)) { 954 if (get_isa16_mode(regs->cp0_epc)) {
944 if (__get_user(instr[0], (u16 __user *)(epc + 0)) || 955 if (__get_user(instr[0], (u16 __user *)(epc + 0)) ||
@@ -959,6 +970,7 @@ asmlinkage void do_tr(struct pt_regs *regs)
959 do_trap_or_bp(regs, tcode, "Trap"); 970 do_trap_or_bp(regs, tcode, "Trap");
960 971
961out: 972out:
973 set_fs(seg);
962 exception_exit(prev_state); 974 exception_exit(prev_state);
963 return; 975 return;
964 976