Skip to content

Commit 9fde034

Browse files
Christoph Hellwiggeertu
authored andcommitted
m68k: Remove set_fs()
Add a m68k-only set_fc helper to set the SFC and DFC registers for the few places that need to override it for special MM operations, but disconnect that from the deprecated kernel-wide set_fs() API. Note that the SFC/DFC registers are context switched, so there is no need to disable preemption. Partially based on an earlier patch from Linus Torvalds <[email protected]>. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Michael Schmitz <[email protected]> Tested-by: Michael Schmitz <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 8ade833 commit 9fde034

File tree

22 files changed

+46
-117
lines changed

22 files changed

+46
-117
lines changed

arch/m68k/68000/entry.S

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <asm/unistd.h>
1616
#include <asm/errno.h>
1717
#include <asm/setup.h>
18-
#include <asm/segment.h>
1918
#include <asm/traps.h>
2019
#include <asm/asm-offsets.h>
2120
#include <asm/entry.h>

arch/m68k/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ config M68K
2929
select NO_DMA if !MMU && !COLDFIRE
3030
select OLD_SIGACTION
3131
select OLD_SIGSUSPEND3
32-
select SET_FS
3332
select UACCESS_MEMCPY if !MMU
3433
select VIRT_TO_BUS
3534
select ZONE_DMA

arch/m68k/coldfire/entry.S

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <asm/thread_info.h>
3232
#include <asm/errno.h>
3333
#include <asm/setup.h>
34-
#include <asm/segment.h>
3534
#include <asm/asm-offsets.h>
3635
#include <asm/entry.h>
3736

arch/m68k/include/asm/processor.h

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#define __ASM_M68K_PROCESSOR_H
1010

1111
#include <linux/thread_info.h>
12-
#include <asm/segment.h>
1312
#include <asm/fpu.h>
1413
#include <asm/ptrace.h>
1514

@@ -75,11 +74,37 @@ static inline void wrusp(unsigned long usp)
7574
#define TASK_UNMAPPED_BASE 0
7675
#endif
7776

77+
/* Address spaces (or Function Codes in Motorola lingo) */
78+
#define USER_DATA 1
79+
#define USER_PROGRAM 2
80+
#define SUPER_DATA 5
81+
#define SUPER_PROGRAM 6
82+
#define CPU_SPACE 7
83+
84+
#ifdef CONFIG_CPU_HAS_ADDRESS_SPACES
85+
/*
86+
* Set the SFC/DFC registers for special MM operations. For most normal
87+
* operation these remain set to USER_DATA for the uaccess routines.
88+
*/
89+
static inline void set_fc(unsigned long val)
90+
{
91+
WARN_ON_ONCE(in_interrupt());
92+
93+
__asm__ __volatile__ ("movec %0,%/sfc\n\t"
94+
"movec %0,%/dfc\n\t"
95+
: /* no outputs */ : "r" (val) : "memory");
96+
}
97+
#else
98+
static inline void set_fc(unsigned long val)
99+
{
100+
}
101+
#endif /* CONFIG_CPU_HAS_ADDRESS_SPACES */
102+
78103
struct thread_struct {
79104
unsigned long ksp; /* kernel stack pointer */
80105
unsigned long usp; /* user stack pointer */
81106
unsigned short sr; /* saved status register */
82-
unsigned short fs; /* saved fs (sfc, dfc) */
107+
unsigned short fc; /* saved fc (sfc, dfc) */
83108
unsigned long crp[2]; /* cpu root pointer */
84109
unsigned long esp0; /* points to SR of stack frame */
85110
unsigned long faddr; /* info about last fault */
@@ -92,7 +117,7 @@ struct thread_struct {
92117
#define INIT_THREAD { \
93118
.ksp = sizeof(init_stack) + (unsigned long) init_stack, \
94119
.sr = PS_S, \
95-
.fs = __KERNEL_DS, \
120+
.fc = USER_DATA, \
96121
}
97122

98123
/*

arch/m68k/include/asm/segment.h

Lines changed: 0 additions & 59 deletions
This file was deleted.

arch/m68k/include/asm/thread_info.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <asm/types.h>
66
#include <asm/page.h>
7-
#include <asm/segment.h>
87

98
/*
109
* On machines with 4k pages we default to an 8k thread size, though we
@@ -27,7 +26,6 @@
2726
struct thread_info {
2827
struct task_struct *task; /* main task structure */
2928
unsigned long flags;
30-
mm_segment_t addr_limit; /* thread address space */
3129
int preempt_count; /* 0 => preemptable, <0 => BUG */
3230
__u32 cpu; /* should always be 0 on m68k */
3331
unsigned long tp_value; /* thread pointer */
@@ -37,7 +35,6 @@ struct thread_info {
3735
#define INIT_THREAD_INFO(tsk) \
3836
{ \
3937
.task = &tsk, \
40-
.addr_limit = KERNEL_DS, \
4138
.preempt_count = INIT_PREEMPT_COUNT, \
4239
}
4340

arch/m68k/include/asm/tlbflush.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ static inline void flush_tlb_kernel_page(void *addr)
1313
if (CPU_IS_COLDFIRE) {
1414
mmu_write(MMUOR, MMUOR_CNL);
1515
} else if (CPU_IS_040_OR_060) {
16-
mm_segment_t old_fs = get_fs();
17-
set_fs(KERNEL_DS);
16+
set_fc(SUPER_DATA);
1817
__asm__ __volatile__(".chip 68040\n\t"
1918
"pflush (%0)\n\t"
2019
".chip 68k"
2120
: : "a" (addr));
22-
set_fs(old_fs);
21+
set_fc(USER_DATA);
2322
} else if (CPU_IS_020_OR_030)
2423
__asm__ __volatile__("pflush #4,#4,(%0)" : : "a" (addr));
2524
}
@@ -84,12 +83,8 @@ static inline void flush_tlb_mm(struct mm_struct *mm)
8483

8584
static inline void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
8685
{
87-
if (vma->vm_mm == current->active_mm) {
88-
mm_segment_t old_fs = force_uaccess_begin();
89-
86+
if (vma->vm_mm == current->active_mm)
9087
__flush_tlb_one(addr);
91-
force_uaccess_end(old_fs);
92-
}
9388
}
9489

9590
static inline void flush_tlb_range(struct vm_area_struct *vma,

arch/m68k/include/asm/uaccess.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
#include <linux/compiler.h>
1111
#include <linux/types.h>
12-
#include <asm/segment.h>
1312
#include <asm/extable.h>
1413

1514
/* We let the MMU do all checking */
@@ -451,9 +450,6 @@ do { \
451450
goto err_label; \
452451
} while (0)
453452

454-
#define user_addr_max() \
455-
(uaccess_kernel() ? ~0UL : TASK_SIZE)
456-
457453
extern long strncpy_from_user(char *dst, const char __user *src, long count);
458454
extern __must_check long strnlen_user(const char __user *str, long n);
459455

arch/m68k/kernel/asm-offsets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int main(void)
3131
DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
3232
DEFINE(THREAD_USP, offsetof(struct thread_struct, usp));
3333
DEFINE(THREAD_SR, offsetof(struct thread_struct, sr));
34-
DEFINE(THREAD_FS, offsetof(struct thread_struct, fs));
34+
DEFINE(THREAD_FC, offsetof(struct thread_struct, fc));
3535
DEFINE(THREAD_CRP, offsetof(struct thread_struct, crp));
3636
DEFINE(THREAD_ESP0, offsetof(struct thread_struct, esp0));
3737
DEFINE(THREAD_FPREG, offsetof(struct thread_struct, fp));

arch/m68k/kernel/entry.S

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <linux/linkage.h>
3737
#include <asm/errno.h>
3838
#include <asm/setup.h>
39-
#include <asm/segment.h>
4039
#include <asm/traps.h>
4140
#include <asm/unistd.h>
4241
#include <asm/asm-offsets.h>
@@ -337,7 +336,7 @@ resume:
337336

338337
/* save fs (sfc,%dfc) (may be pointing to kernel memory) */
339338
movec %sfc,%d0
340-
movew %d0,%a0@(TASK_THREAD+THREAD_FS)
339+
movew %d0,%a0@(TASK_THREAD+THREAD_FC)
341340

342341
/* save usp */
343342
/* it is better to use a movel here instead of a movew 8*) */
@@ -423,7 +422,7 @@ resume:
423422
movel %a0,%usp
424423

425424
/* restore fs (sfc,%dfc) */
426-
movew %a1@(TASK_THREAD+THREAD_FS),%a0
425+
movew %a1@(TASK_THREAD+THREAD_FC),%a0
427426
movec %a0,%sfc
428427
movec %a0,%dfc
429428

0 commit comments

Comments
 (0)