Commit b4b8ac524d9b6ed7229017145afa1d7afbea4a48

Authored by Jason Wessel
Committed by Ingo Molnar
1 parent 64e9ee3095

kgdb: fix optional arch functions and probe_kernel_*

Fix two regressions dealing with the kgdb core.

1) kgdb_skipexception and kgdb_post_primary_code are optional
functions that are only required on archs that need special exception
fixups.

2) The kernel address space scope must be set on any probe_kernel_*
function or archs such as ARCH=arm will not allow access to the kernel
memory space.  As an example, it is required to allow the full kernel
address space is when you the kernel debugger to inspect a system
call.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 2 changed files with 17 additions and 0 deletions Side-by-side Diff

... ... @@ -200,6 +200,17 @@
200 200 return 0;
201 201 }
202 202  
  203 +int __weak kgdb_skipexception(int exception, struct pt_regs *regs)
  204 +{
  205 + return 0;
  206 +}
  207 +
  208 +void __weak
  209 +kgdb_post_primary_code(struct pt_regs *regs, int e_vector, int err_code)
  210 +{
  211 + return;
  212 +}
  213 +
203 214 /**
204 215 * kgdb_disable_hw_debug - Disable hardware debugging while we in kgdb.
205 216 * @regs: Current &struct pt_regs.
... ... @@ -17,11 +17,14 @@
17 17 long probe_kernel_read(void *dst, void *src, size_t size)
18 18 {
19 19 long ret;
  20 + mm_segment_t old_fs = get_fs();
20 21  
  22 + set_fs(KERNEL_DS);
21 23 pagefault_disable();
22 24 ret = __copy_from_user_inatomic(dst,
23 25 (__force const void __user *)src, size);
24 26 pagefault_enable();
  27 + set_fs(old_fs);
25 28  
26 29 return ret ? -EFAULT : 0;
27 30 }
28 31  
29 32  
... ... @@ -39,10 +42,13 @@
39 42 long probe_kernel_write(void *dst, void *src, size_t size)
40 43 {
41 44 long ret;
  45 + mm_segment_t old_fs = get_fs();
42 46  
  47 + set_fs(KERNEL_DS);
43 48 pagefault_disable();
44 49 ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
45 50 pagefault_enable();
  51 + set_fs(old_fs);
46 52  
47 53 return ret ? -EFAULT : 0;
48 54 }