Skip to content

Commit 6ebda44

Browse files
Leonid Yegoshinralfbaechle
authored andcommitted
MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes
When flushing the icache, make sure the address limit is correct so the appropriate 'cache' instruction will be used. This has no impact on cores operating in non-eva mode. However, when EVA is enabled, we ensure that 'cache' will be used instead of 'cachee'. Signed-off-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
1 parent de8974e commit 6ebda44

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎arch/mips/kernel/ftrace.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,18 @@ static inline void ftrace_dyn_arch_init_insns(void)
9090
static int ftrace_modify_code(unsigned long ip, unsigned int new_code)
9191
{
9292
int faulted;
93+
mm_segment_t old_fs;
9394

9495
/* *(unsigned int *)ip = new_code; */
9596
safe_store_code(new_code, ip, faulted);
9697

9798
if (unlikely(faulted))
9899
return -EFAULT;
99100

101+
old_fs = get_fs();
102+
set_fs(get_ds());
100103
flush_icache_range(ip, ip + 8);
104+
set_fs(old_fs);
101105

102106
return 0;
103107
}

‎arch/mips/kernel/kgdb.c‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <asm/cacheflush.h>
3333
#include <asm/processor.h>
3434
#include <asm/sigcontext.h>
35+
#include <asm/uaccess.h>
3536

3637
static struct hard_trap_info {
3738
unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
@@ -208,7 +209,14 @@ void arch_kgdb_breakpoint(void)
208209

209210
static void kgdb_call_nmi_hook(void *ignored)
210211
{
212+
mm_segment_t old_fs;
213+
214+
old_fs = get_fs();
215+
set_fs(get_ds());
216+
211217
kgdb_nmicallback(raw_smp_processor_id(), NULL);
218+
219+
set_fs(old_fs);
212220
}
213221

214222
void kgdb_roundup_cpus(unsigned long flags)
@@ -282,6 +290,7 @@ static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
282290
struct die_args *args = (struct die_args *)ptr;
283291
struct pt_regs *regs = args->regs;
284292
int trap = (regs->cp0_cause & 0x7c) >> 2;
293+
mm_segment_t old_fs;
285294

286295
#ifdef CONFIG_KPROBES
287296
/*
@@ -296,11 +305,17 @@ static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
296305
if (user_mode(regs))
297306
return NOTIFY_DONE;
298307

308+
/* Kernel mode. Set correct address limit */
309+
old_fs = get_fs();
310+
set_fs(get_ds());
311+
299312
if (atomic_read(&kgdb_active) != -1)
300313
kgdb_nmicallback(smp_processor_id(), regs);
301314

302-
if (kgdb_handle_exception(trap, compute_signal(trap), cmd, regs))
315+
if (kgdb_handle_exception(trap, compute_signal(trap), cmd, regs)) {
316+
set_fs(old_fs);
303317
return NOTIFY_DONE;
318+
}
304319

305320
if (atomic_read(&kgdb_setting_breakpoint))
306321
if ((trap == 9) && (regs->cp0_epc == (unsigned long)breakinst))
@@ -310,6 +325,7 @@ static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
310325
local_irq_enable();
311326
__flush_cache_all();
312327

328+
set_fs(old_fs);
313329
return NOTIFY_STOP;
314330
}
315331

0 commit comments

Comments
 (0)