Skip to content

Commit 3dab04e

Browse files
committed
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-2.6-mn10300
* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-2.6-mn10300: MN10300: gcc 4.6 vs am33 inline assembly MN10300: Deprecate gdbstub MN10300: Allow KGDB to use the MN10300 serial ports MN10300: Emulate single stepping in KGDB on MN10300 MN10300: Generalise kernel debugger kernel halt, reboot or power off hook KGDB: Notify GDB of machine halt, reboot or power off MN10300: Use KGDB MN10300: Create generic kernel debugger hooks MN10300: Create general kernel debugger cache flushing MN10300: Introduce a general config option for kernel debugger hooks MN10300: The icache invalidate functions should disable the icache first MN10300: gdbstub: Restrict single-stepping to non-preemptable non-SMP configs
2 parents 6d1e9a4 + 5a4b65a commit 3dab04e

39 files changed

+1924
-502
lines changed

arch/mn10300/Kconfig

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ config MN10300
33
select HAVE_OPROFILE
44
select HAVE_GENERIC_HARDIRQS
55
select GENERIC_HARDIRQS_NO_DEPRECATED
6+
select HAVE_ARCH_TRACEHOOK
7+
select HAVE_ARCH_KGDB
68

79
config AM33_2
810
def_bool n
@@ -401,9 +403,9 @@ comment "[!] NOTE: A lower number/level indicates a higher priority (0 is highes
401403
comment "____Non-maskable interrupt levels____"
402404
comment "The following must be set to a higher priority than local_irq_disable() and on-chip serial"
403405

404-
config GDBSTUB_IRQ_LEVEL
405-
int "GDBSTUB interrupt priority"
406-
depends on GDBSTUB
406+
config DEBUGGER_IRQ_LEVEL
407+
int "DEBUGGER interrupt priority"
408+
depends on KERNEL_DEBUGGER
407409
range 0 1 if LINUX_CLI_LEVEL = 2
408410
range 0 2 if LINUX_CLI_LEVEL = 3
409411
range 0 3 if LINUX_CLI_LEVEL = 4
@@ -437,7 +439,7 @@ config LINUX_CLI_LEVEL
437439
EPSW.IM from 7. Any interrupt is permitted for which the level is
438440
lower than EPSW.IM.
439441

440-
Certain interrupts, such as GDBSTUB and virtual MN10300 on-chip
442+
Certain interrupts, such as DEBUGGER and virtual MN10300 on-chip
441443
serial DMA interrupts are allowed to interrupt normal disabled
442444
sections.
443445

arch/mn10300/Kconfig.debug

+16-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ config KPROBES
3636

3737
config GDBSTUB
3838
bool "Remote GDB kernel debugging"
39-
depends on DEBUG_KERNEL
39+
depends on DEBUG_KERNEL && DEPRECATED
4040
select DEBUG_INFO
4141
select FRAME_POINTER
4242
help
@@ -46,6 +46,9 @@ config GDBSTUB
4646
RAM to avoid excessive linking time. This is only useful for kernel
4747
hackers. If unsure, say N.
4848

49+
This is deprecated in favour of KGDB and will be removed in a later
50+
version.
51+
4952
config GDBSTUB_IMMEDIATE
5053
bool "Break into GDB stub immediately"
5154
depends on GDBSTUB
@@ -54,6 +57,14 @@ config GDBSTUB_IMMEDIATE
5457
possible, leaving the program counter at the beginning of
5558
start_kernel() in init/main.c.
5659

60+
config GDBSTUB_ALLOW_SINGLE_STEP
61+
bool "Allow software single-stepping in GDB stub"
62+
depends on GDBSTUB && !SMP && !PREEMPT
63+
help
64+
Allow GDB stub to perform software single-stepping through the
65+
kernel. This doesn't work very well on SMP or preemptible kernels as
66+
it uses temporary breakpoints to emulate single-stepping.
67+
5768
config GDB_CONSOLE
5869
bool "Console output to GDB"
5970
depends on GDBSTUB
@@ -142,3 +153,7 @@ config GDBSTUB_ON_TTYSx
142153
default y
143154

144155
endmenu
156+
157+
config KERNEL_DEBUGGER
158+
def_bool y
159+
depends on GDBSTUB || KGDB

arch/mn10300/include/asm/debugger.h

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* Kernel debugger for MN10300
2+
*
3+
* Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
4+
* Written by David Howells ([email protected])
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU General Public Licence
8+
* as published by the Free Software Foundation; either version
9+
* 2 of the Licence, or (at your option) any later version.
10+
*/
11+
12+
#ifndef _ASM_DEBUGGER_H
13+
#define _ASM_DEBUGGER_H
14+
15+
#if defined(CONFIG_KERNEL_DEBUGGER)
16+
17+
extern int debugger_intercept(enum exception_code, int, int, struct pt_regs *);
18+
extern int at_debugger_breakpoint(struct pt_regs *);
19+
20+
#ifndef CONFIG_MN10300_DEBUGGER_CACHE_NO_FLUSH
21+
extern void debugger_local_cache_flushinv(void);
22+
extern void debugger_local_cache_flushinv_one(u8 *);
23+
#else
24+
static inline void debugger_local_cache_flushinv(void) {}
25+
static inline void debugger_local_cache_flushinv_one(u8 *addr) {}
26+
#endif
27+
28+
#else /* CONFIG_KERNEL_DEBUGGER */
29+
30+
static inline int debugger_intercept(enum exception_code excep,
31+
int signo, int si_code,
32+
struct pt_regs *regs)
33+
{
34+
return 0;
35+
}
36+
37+
static inline int at_debugger_breakpoint(struct pt_regs *regs)
38+
{
39+
return 0;
40+
}
41+
42+
#endif /* CONFIG_KERNEL_DEBUGGER */
43+
#endif /* _ASM_DEBUGGER_H */

arch/mn10300/include/asm/div64.h

+17-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515

1616
extern void ____unhandled_size_in_do_div___(void);
1717

18+
/*
19+
* Beginning with gcc 4.6, the MDR register is represented explicitly. We
20+
* must, therefore, at least explicitly clobber the register when we make
21+
* changes to it. The following assembly fragments *could* be rearranged in
22+
* order to leave the moves to/from the MDR register to the compiler, but the
23+
* gains would be minimal at best.
24+
*/
25+
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
26+
# define CLOBBER_MDR_CC "mdr", "cc"
27+
#else
28+
# define CLOBBER_MDR_CC "cc"
29+
#endif
30+
1831
/*
1932
* divide n by base, leaving the result in n and returning the remainder
2033
* - we can do this quite efficiently on the MN10300 by cascading the divides
@@ -29,7 +42,7 @@ extern void ____unhandled_size_in_do_div___(void);
2942
"mov mdr,%1 \n" \
3043
: "+r"(n), "=d"(__rem) \
3144
: "r"(base), "1"(__rem) \
32-
: "cc" \
45+
: CLOBBER_MDR_CC \
3346
); \
3447
} else if (sizeof(n) <= 8) { \
3548
union { \
@@ -48,7 +61,7 @@ extern void ____unhandled_size_in_do_div___(void);
4861
: "=d"(__rem), "=r"(__quot.w[1]), "=r"(__quot.w[0]) \
4962
: "r"(base), "0"(__rem), "1"(__quot.w[1]), \
5063
"2"(__quot.w[0]) \
51-
: "cc" \
64+
: CLOBBER_MDR_CC \
5265
); \
5366
n = __quot.l; \
5467
} else { \
@@ -72,7 +85,7 @@ unsigned __muldiv64u(unsigned val, unsigned mult, unsigned div)
7285
* MDR = MDR:val%div */
7386
: "=r"(result)
7487
: "0"(val), "ir"(mult), "r"(div)
75-
: "cc"
88+
: CLOBBER_MDR_CC
7689
);
7790

7891
return result;
@@ -93,7 +106,7 @@ signed __muldiv64s(signed val, signed mult, signed div)
93106
* MDR = MDR:val%div */
94107
: "=r"(result)
95108
: "0"(val), "ir"(mult), "r"(div)
96-
: "cc"
109+
: CLOBBER_MDR_CC
97110
);
98111

99112
return result;

arch/mn10300/include/asm/fpu.h

-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ static inline void clear_using_fpu(struct task_struct *tsk)
5555

5656
extern asmlinkage void fpu_kill_state(struct task_struct *);
5757
extern asmlinkage void fpu_exception(struct pt_regs *, enum exception_code);
58-
extern asmlinkage void fpu_invalid_op(struct pt_regs *, enum exception_code);
5958
extern asmlinkage void fpu_init_state(void);
6059
extern asmlinkage void fpu_save(struct fpu_state_struct *);
6160
extern int fpu_setup_sigcontext(struct fpucontext *buf);
@@ -113,7 +112,6 @@ static inline void flush_fpu(void)
113112

114113
extern asmlinkage
115114
void unexpected_fpu_exception(struct pt_regs *, enum exception_code);
116-
#define fpu_invalid_op unexpected_fpu_exception
117115
#define fpu_exception unexpected_fpu_exception
118116

119117
struct task_struct;

arch/mn10300/include/asm/irqflags.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/*
2121
* interrupt control
2222
* - "disabled": run in IM1/2
23-
* - level 0 - GDB stub
23+
* - level 0 - kernel debugger
2424
* - level 1 - virtual serial DMA (if present)
2525
* - level 5 - normal interrupt priority
2626
* - level 6 - timer interrupt

arch/mn10300/include/asm/kgdb.h

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* Kernel debugger for MN10300
2+
*
3+
* Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
4+
* Written by David Howells ([email protected])
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU General Public Licence
8+
* as published by the Free Software Foundation; either version
9+
* 2 of the Licence, or (at your option) any later version.
10+
*/
11+
12+
#ifndef _ASM_KGDB_H
13+
#define _ASM_KGDB_H
14+
15+
/*
16+
* BUFMAX defines the maximum number of characters in inbound/outbound
17+
* buffers at least NUMREGBYTES*2 are needed for register packets
18+
* Longer buffer is needed to list all threads
19+
*/
20+
#define BUFMAX 1024
21+
22+
/*
23+
* Note that this register image is in a different order than the register
24+
* image that Linux produces at interrupt time.
25+
*/
26+
enum regnames {
27+
GDB_FR_D0 = 0,
28+
GDB_FR_D1 = 1,
29+
GDB_FR_D2 = 2,
30+
GDB_FR_D3 = 3,
31+
GDB_FR_A0 = 4,
32+
GDB_FR_A1 = 5,
33+
GDB_FR_A2 = 6,
34+
GDB_FR_A3 = 7,
35+
36+
GDB_FR_SP = 8,
37+
GDB_FR_PC = 9,
38+
GDB_FR_MDR = 10,
39+
GDB_FR_EPSW = 11,
40+
GDB_FR_LIR = 12,
41+
GDB_FR_LAR = 13,
42+
GDB_FR_MDRQ = 14,
43+
44+
GDB_FR_E0 = 15,
45+
GDB_FR_E1 = 16,
46+
GDB_FR_E2 = 17,
47+
GDB_FR_E3 = 18,
48+
GDB_FR_E4 = 19,
49+
GDB_FR_E5 = 20,
50+
GDB_FR_E6 = 21,
51+
GDB_FR_E7 = 22,
52+
53+
GDB_FR_SSP = 23,
54+
GDB_FR_MSP = 24,
55+
GDB_FR_USP = 25,
56+
GDB_FR_MCRH = 26,
57+
GDB_FR_MCRL = 27,
58+
GDB_FR_MCVF = 28,
59+
60+
GDB_FR_FPCR = 29,
61+
GDB_FR_DUMMY0 = 30,
62+
GDB_FR_DUMMY1 = 31,
63+
64+
GDB_FR_FS0 = 32,
65+
66+
GDB_FR_SIZE = 64,
67+
};
68+
69+
#define GDB_ORIG_D0 41
70+
#define NUMREGBYTES (GDB_FR_SIZE*4)
71+
72+
static inline void arch_kgdb_breakpoint(void)
73+
{
74+
asm(".globl __arch_kgdb_breakpoint; __arch_kgdb_breakpoint: break");
75+
}
76+
extern u8 __arch_kgdb_breakpoint;
77+
78+
#define BREAK_INSTR_SIZE 1
79+
#define CACHE_FLUSH_IS_SAFE 1
80+
81+
#endif /* _ASM_KGDB_H */

arch/mn10300/include/asm/smp.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#define LOCAL_TIMER_IPI 193
3535
#define FLUSH_CACHE_IPI 194
3636
#define CALL_FUNCTION_NMI_IPI 195
37-
#define GDB_NMI_IPI 196
37+
#define DEBUGGER_NMI_IPI 196
3838

3939
#define SMP_BOOT_IRQ 195
4040

@@ -43,6 +43,7 @@
4343
#define LOCAL_TIMER_GxICR_LV GxICR_LEVEL_4
4444
#define FLUSH_CACHE_GxICR_LV GxICR_LEVEL_0
4545
#define SMP_BOOT_GxICR_LV GxICR_LEVEL_0
46+
#define DEBUGGER_GxICR_LV CONFIG_DEBUGGER_IRQ_LEVEL
4647

4748
#define TIME_OUT_COUNT_BOOT_IPI 100
4849
#define DELAY_TIME_BOOT_IPI 75000
@@ -61,8 +62,9 @@
6162
* An alternate way of dealing with this could be to use the EPSW.S bits to
6263
* cache this information for systems with up to four CPUs.
6364
*/
65+
#define arch_smp_processor_id() (CPUID)
6466
#if 0
65-
#define raw_smp_processor_id() (CPUID)
67+
#define raw_smp_processor_id() (arch_smp_processor_id())
6668
#else
6769
#define raw_smp_processor_id() (current_thread_info()->cpu)
6870
#endif

arch/mn10300/include/asm/thread_info.h

+4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ static inline unsigned long current_stack_pointer(void)
131131
kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
132132
#endif
133133

134+
#ifndef CONFIG_KGDB
134135
#define free_thread_info(ti) kfree((ti))
136+
#else
137+
extern void free_thread_info(struct thread_info *);
138+
#endif
135139
#define get_thread_info(ti) get_task_struct((ti)->task)
136140
#define put_thread_info(ti) put_task_struct((ti)->task)
137141

arch/mn10300/kernel/Makefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ obj-$(CONFIG_GDBSTUB) += gdb-stub.o gdb-low.o
2121
obj-$(CONFIG_GDBSTUB_ON_TTYSx) += gdb-io-serial.o gdb-io-serial-low.o
2222
obj-$(CONFIG_GDBSTUB_ON_TTYSMx) += gdb-io-ttysm.o gdb-io-ttysm-low.o
2323

24-
ifeq ($(CONFIG_MN10300_CACHE_ENABLED),y)
25-
obj-$(CONFIG_GDBSTUB) += gdb-cache.o
26-
endif
27-
2824
obj-$(CONFIG_MN10300_RTC) += rtc.o
2925
obj-$(CONFIG_PROFILE) += profile.o profile-low.o
3026
obj-$(CONFIG_MODULES) += module.o
3127
obj-$(CONFIG_KPROBES) += kprobes.o
28+
obj-$(CONFIG_KGDB) += kgdb.o

0 commit comments

Comments
 (0)