* [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes"
@ 2021-02-10 16:16 Thomas Bogendoerfer
2021-02-10 16:16 ` [PATCH 2/2] MIPS: Simplify EVA cache handling Thomas Bogendoerfer
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Thomas Bogendoerfer @ 2021-02-10 16:16 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar, linux-mips, linux-kernel
This reverts commit 6ebda44f366478d1eea180d93154e7d97b591f50.
All icache flushes in this code paths are done via flush_icache_range(),
which only uses normal cache instruction. And this is the correct thing
for EVA mode, too. So no need to do set_fs(KERNEL_DS) here.
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
arch/mips/kernel/ftrace.c | 4 ----
arch/mips/kernel/kgdb.c | 18 +-----------------
2 files changed, 1 insertion(+), 21 deletions(-)
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index f57e68f40a34..666b9969c1bd 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -73,7 +73,6 @@ static inline void ftrace_dyn_arch_init_insns(void)
static int ftrace_modify_code(unsigned long ip, unsigned int new_code)
{
int faulted;
- mm_segment_t old_fs;
/* *(unsigned int *)ip = new_code; */
safe_store_code(new_code, ip, faulted);
@@ -81,10 +80,7 @@ static int ftrace_modify_code(unsigned long ip, unsigned int new_code)
if (unlikely(faulted))
return -EFAULT;
- old_fs = get_fs();
- set_fs(KERNEL_DS);
flush_icache_range(ip, ip + 8);
- set_fs(old_fs);
return 0;
}
diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c
index ea781b29f7f1..de779e23faf2 100644
--- a/arch/mips/kernel/kgdb.c
+++ b/arch/mips/kernel/kgdb.c
@@ -32,7 +32,6 @@
#include <asm/cacheflush.h>
#include <asm/processor.h>
#include <asm/sigcontext.h>
-#include <linux/uaccess.h>
#include <asm/irq_regs.h>
static struct hard_trap_info {
@@ -210,14 +209,7 @@ void arch_kgdb_breakpoint(void)
void kgdb_call_nmi_hook(void *ignored)
{
- mm_segment_t old_fs;
-
- old_fs = get_fs();
- set_fs(KERNEL_DS);
-
kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
-
- set_fs(old_fs);
}
static int compute_signal(int tt)
@@ -302,7 +294,6 @@ static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
struct die_args *args = (struct die_args *)ptr;
struct pt_regs *regs = args->regs;
int trap = (regs->cp0_cause & 0x7c) >> 2;
- mm_segment_t old_fs;
#ifdef CONFIG_KPROBES
/*
@@ -317,17 +308,11 @@ static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
if (user_mode(regs))
return NOTIFY_DONE;
- /* Kernel mode. Set correct address limit */
- old_fs = get_fs();
- set_fs(KERNEL_DS);
-
if (atomic_read(&kgdb_active) != -1)
kgdb_nmicallback(smp_processor_id(), regs);
- if (kgdb_handle_exception(trap, compute_signal(trap), cmd, regs)) {
- set_fs(old_fs);
+ if (kgdb_handle_exception(trap, compute_signal(trap), cmd, regs))
return NOTIFY_DONE;
- }
if (atomic_read(&kgdb_setting_breakpoint))
if ((trap == 9) && (regs->cp0_epc == (unsigned long)breakinst))
@@ -337,7 +322,6 @@ static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
local_irq_enable();
__flush_cache_all();
- set_fs(old_fs);
return NOTIFY_STOP;
}
--
2.29.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] MIPS: Simplify EVA cache handling 2021-02-10 16:16 [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" Thomas Bogendoerfer @ 2021-02-10 16:16 ` Thomas Bogendoerfer 2021-02-13 9:06 ` Thomas Bogendoerfer 2021-02-10 19:11 ` [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" Christoph Hellwig 2021-02-13 9:05 ` Thomas Bogendoerfer 2 siblings, 1 reply; 6+ messages in thread From: Thomas Bogendoerfer @ 2021-02-10 16:16 UTC (permalink / raw) To: linux-mips, linux-kernel protected_cache_op is only used for flushing user addresses, so we only need to define protected_cache_op different in EVA mode and be done with it. Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> --- arch/mips/include/asm/r4kcache.h | 67 ++++++-------------------------- 1 file changed, 11 insertions(+), 56 deletions(-) diff --git a/arch/mips/include/asm/r4kcache.h b/arch/mips/include/asm/r4kcache.h index 15ab16f99f28..af3788589ee6 100644 --- a/arch/mips/include/asm/r4kcache.h +++ b/arch/mips/include/asm/r4kcache.h @@ -23,7 +23,6 @@ #include <asm/mipsmtregs.h> #include <asm/mmzone.h> #include <asm/unroll.h> -#include <linux/uaccess.h> /* for uaccess_kernel() */ extern void (*r4k_blast_dcache)(void); extern void (*r4k_blast_icache)(void); @@ -102,14 +101,17 @@ static inline void flush_scache_line(unsigned long addr) cache_op(Hit_Writeback_Inv_SD, addr); } -#define protected_cache_op(op,addr) \ +#ifdef CONFIG_EVA + +#define protected_cache_op(op, addr) \ ({ \ int __err = 0; \ __asm__ __volatile__( \ " .set push \n" \ " .set noreorder \n" \ - " .set "MIPS_ISA_ARCH_LEVEL" \n" \ - "1: cache %1, (%2) \n" \ + " .set mips0 \n" \ + " .set eva \n" \ + "1: cachee %1, (%2) \n" \ "2: .insn \n" \ " .set pop \n" \ " .section .fixup,\"ax\" \n" \ @@ -123,17 +125,16 @@ static inline void flush_scache_line(unsigned long addr) : "i" (op), "r" (addr), "i" (-EFAULT)); \ __err; \ }) +#else - -#define protected_cachee_op(op,addr) \ +#define protected_cache_op(op, addr) \ ({ \ int __err = 0; \ __asm__ __volatile__( \ " .set push \n" \ " .set noreorder \n" \ - " .set mips0 \n" \ - " .set eva \n" \ - "1: cachee %1, (%2) \n" \ + " .set "MIPS_ISA_ARCH_LEVEL" \n" \ + "1: cache %1, (%2) \n" \ "2: .insn \n" \ " .set pop \n" \ " .section .fixup,\"ax\" \n" \ @@ -147,6 +148,7 @@ static inline void flush_scache_line(unsigned long addr) : "i" (op), "r" (addr), "i" (-EFAULT)); \ __err; \ }) +#endif /* * The next two are for badland addresses like signal trampolines. @@ -158,11 +160,7 @@ static inline int protected_flush_icache_line(unsigned long addr) return protected_cache_op(Hit_Invalidate_I_Loongson2, addr); default: -#ifdef CONFIG_EVA - return protected_cachee_op(Hit_Invalidate_I, addr); -#else return protected_cache_op(Hit_Invalidate_I, addr); -#endif } } @@ -174,20 +172,12 @@ static inline int protected_flush_icache_line(unsigned long addr) */ static inline int protected_writeback_dcache_line(unsigned long addr) { -#ifdef CONFIG_EVA - return protected_cachee_op(Hit_Writeback_Inv_D, addr); -#else return protected_cache_op(Hit_Writeback_Inv_D, addr); -#endif } static inline int protected_writeback_scache_line(unsigned long addr) { -#ifdef CONFIG_EVA - return protected_cachee_op(Hit_Writeback_Inv_SD, addr); -#else return protected_cache_op(Hit_Writeback_Inv_SD, addr); -#endif } /* @@ -307,43 +297,8 @@ static inline void prot##extra##blast_##pfx##cache##_range(unsigned long start, } \ } -#ifndef CONFIG_EVA - __BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_, ) __BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_, ) - -#else - -#define __BUILD_PROT_BLAST_CACHE_RANGE(pfx, desc, hitop) \ -static inline void protected_blast_##pfx##cache##_range(unsigned long start,\ - unsigned long end) \ -{ \ - unsigned long lsize = cpu_##desc##_line_size(); \ - unsigned long addr = start & ~(lsize - 1); \ - unsigned long aend = (end - 1) & ~(lsize - 1); \ - \ - if (!uaccess_kernel()) { \ - while (1) { \ - protected_cachee_op(hitop, addr); \ - if (addr == aend) \ - break; \ - addr += lsize; \ - } \ - } else { \ - while (1) { \ - protected_cache_op(hitop, addr); \ - if (addr == aend) \ - break; \ - addr += lsize; \ - } \ - \ - } \ -} - -__BUILD_PROT_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D) -__BUILD_PROT_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I) - -#endif __BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_, ) __BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I_Loongson2, \ protected_, loongson2_) -- 2.29.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] MIPS: Simplify EVA cache handling 2021-02-10 16:16 ` [PATCH 2/2] MIPS: Simplify EVA cache handling Thomas Bogendoerfer @ 2021-02-13 9:06 ` Thomas Bogendoerfer 0 siblings, 0 replies; 6+ messages in thread From: Thomas Bogendoerfer @ 2021-02-13 9:06 UTC (permalink / raw) To: linux-mips, linux-kernel On Wed, Feb 10, 2021 at 05:16:14PM +0100, Thomas Bogendoerfer wrote: > protected_cache_op is only used for flushing user addresses, so > we only need to define protected_cache_op different in EVA mode and > be done with it. > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> > --- > arch/mips/include/asm/r4kcache.h | 67 ++++++-------------------------- > 1 file changed, 11 insertions(+), 56 deletions(-) applied to mips-next. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" 2021-02-10 16:16 [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" Thomas Bogendoerfer 2021-02-10 16:16 ` [PATCH 2/2] MIPS: Simplify EVA cache handling Thomas Bogendoerfer @ 2021-02-10 19:11 ` Christoph Hellwig 2021-02-10 21:19 ` Thomas Bogendoerfer 2021-02-13 9:05 ` Thomas Bogendoerfer 2 siblings, 1 reply; 6+ messages in thread From: Christoph Hellwig @ 2021-02-10 19:11 UTC (permalink / raw) To: Thomas Bogendoerfer; +Cc: Steven Rostedt, Ingo Molnar, linux-mips, linux-kernel On Wed, Feb 10, 2021 at 05:16:13PM +0100, Thomas Bogendoerfer wrote: > This reverts commit 6ebda44f366478d1eea180d93154e7d97b591f50. > > All icache flushes in this code paths are done via flush_icache_range(), > which only uses normal cache instruction. And this is the correct thing > for EVA mode, too. So no need to do set_fs(KERNEL_DS) here. > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de> ... it might be time to kill off the remaining set_fs() users in mips code as well ... ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" 2021-02-10 19:11 ` [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" Christoph Hellwig @ 2021-02-10 21:19 ` Thomas Bogendoerfer 0 siblings, 0 replies; 6+ messages in thread From: Thomas Bogendoerfer @ 2021-02-10 21:19 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Steven Rostedt, Ingo Molnar, linux-mips, linux-kernel On Wed, Feb 10, 2021 at 07:11:00PM +0000, Christoph Hellwig wrote: > On Wed, Feb 10, 2021 at 05:16:13PM +0100, Thomas Bogendoerfer wrote: > > This reverts commit 6ebda44f366478d1eea180d93154e7d97b591f50. > > > > All icache flushes in this code paths are done via flush_icache_range(), > > which only uses normal cache instruction. And this is the correct thing > > for EVA mode, too. So no need to do set_fs(KERNEL_DS) here. > > > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> > > Looks good, > > Reviewed-by: Christoph Hellwig <hch@lst.de> > > ... it might be time to kill off the remaining set_fs() users in mips > code as well ... I already have patches for that. Still needs some cleaning and testing before sending/applying it. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" 2021-02-10 16:16 [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" Thomas Bogendoerfer 2021-02-10 16:16 ` [PATCH 2/2] MIPS: Simplify EVA cache handling Thomas Bogendoerfer 2021-02-10 19:11 ` [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" Christoph Hellwig @ 2021-02-13 9:05 ` Thomas Bogendoerfer 2 siblings, 0 replies; 6+ messages in thread From: Thomas Bogendoerfer @ 2021-02-13 9:05 UTC (permalink / raw) To: Steven Rostedt, Ingo Molnar, linux-mips, linux-kernel On Wed, Feb 10, 2021 at 05:16:13PM +0100, Thomas Bogendoerfer wrote: > This reverts commit 6ebda44f366478d1eea180d93154e7d97b591f50. > > All icache flushes in this code paths are done via flush_icache_range(), > which only uses normal cache instruction. And this is the correct thing > for EVA mode, too. So no need to do set_fs(KERNEL_DS) here. > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> > --- > arch/mips/kernel/ftrace.c | 4 ---- > arch/mips/kernel/kgdb.c | 18 +----------------- > 2 files changed, 1 insertion(+), 21 deletions(-) applied to mips-next. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-02-13 9:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-10 16:16 [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" Thomas Bogendoerfer
2021-02-10 16:16 ` [PATCH 2/2] MIPS: Simplify EVA cache handling Thomas Bogendoerfer
2021-02-13 9:06 ` Thomas Bogendoerfer
2021-02-10 19:11 ` [PATCH 1/2] Revert "MIPS: kernel: {ftrace,kgdb}: Set correct address limit for cache flushes" Christoph Hellwig
2021-02-10 21:19 ` Thomas Bogendoerfer
2021-02-13 9:05 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).