Skip to content

Commit 23ef827

Browse files
committed
Merge tag 'for-5.15/parisc-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux
Pull parisc fixes from Helge Deller: - Build warning fixes in Makefile and Dino PCI driver - Fix when sched_clock is marked unstable - Drop strnlen_user() in favour of generic version - Prevent kernel to write outside userspace signal stack - Remove CONFIG_SET_FS including KERNEL_DS and USER_DS from parisc and switch to __get/put_kernel_nofault() * tag 'for-5.15/parisc-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux: parisc: Implement __get/put_kernel_nofault() parisc: Mark sched_clock unstable only if clocks are not syncronized parisc: Move pci_dev_is_behind_card_dino to where it is used parisc: Reduce sigreturn trampoline to 3 instructions parisc: Check user signal stack trampoline is inside TASK_SIZE parisc: Drop useless debug info and comments from signal.c parisc: Drop strnlen_user() in favour of generic version parisc: Add missing FORCE prerequisite in Makefile
2 parents 589e5ca + 6710287 commit 23ef827

File tree

14 files changed

+102
-179
lines changed

14 files changed

+102
-179
lines changed

arch/parisc/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ config PARISC
1010
select ARCH_HAS_ELF_RANDOMIZE
1111
select ARCH_HAS_STRICT_KERNEL_RWX
1212
select ARCH_HAS_UBSAN_SANITIZE_ALL
13-
select ARCH_HAS_STRNLEN_USER
1413
select ARCH_NO_SG_CHAIN
1514
select ARCH_SUPPORTS_HUGETLBFS if PA20
1615
select ARCH_SUPPORTS_MEMORY_FAILURE
@@ -65,7 +64,6 @@ config PARISC
6564
select HAVE_KPROBES_ON_FTRACE
6665
select HAVE_DYNAMIC_FTRACE_WITH_REGS
6766
select HAVE_SOFTIRQ_ON_OWN_STACK if IRQSTACKS
68-
select SET_FS
6967
select TRACE_IRQFLAGS_SUPPORT
7068

7169
help

arch/parisc/boot/compressed/Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ endif
2626
OBJECTS += $(obj)/head.o $(obj)/real2.o $(obj)/firmware.o $(obj)/misc.o $(obj)/piggy.o
2727

2828
LDFLAGS_vmlinux := -X -e startup --as-needed -T
29-
$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(LIBGCC)
29+
$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS) $(LIBGCC) FORCE
3030
$(call if_changed,ld)
3131

3232
sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\|parisc_kernel_start\)$$/\#define SZ\2 0x\1/p'
3333

3434
quiet_cmd_sizes = GEN $@
3535
cmd_sizes = $(NM) $< | sed -n $(sed-sizes) > $@
3636

37-
$(obj)/sizes.h: vmlinux
37+
$(obj)/sizes.h: vmlinux FORCE
3838
$(call if_changed,sizes)
3939

4040
AFLAGS_head.o += -I$(objtree)/$(obj) -DBOOTLOADER
@@ -70,19 +70,19 @@ suffix-$(CONFIG_KERNEL_LZMA) := lzma
7070
suffix-$(CONFIG_KERNEL_LZO) := lzo
7171
suffix-$(CONFIG_KERNEL_XZ) := xz
7272

73-
$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y)
73+
$(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE
7474
$(call if_changed,gzip)
75-
$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y)
75+
$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE
7676
$(call if_changed,bzip2)
77-
$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y)
77+
$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
7878
$(call if_changed,lz4)
79-
$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
79+
$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE
8080
$(call if_changed,lzma)
81-
$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y)
81+
$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
8282
$(call if_changed,lzo)
83-
$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y)
83+
$(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE
8484
$(call if_changed,xzkern)
8585

8686
LDFLAGS_piggy.o := -r --format binary --oformat $(LD_BFD) -T
87-
$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y)
87+
$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
8888
$(call if_changed,ld)

arch/parisc/include/asm/processor.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
101101

102102
#define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
103103

104-
typedef struct {
105-
int seg;
106-
} mm_segment_t;
107-
108104
#define ARCH_MIN_TASKALIGN 8
109105

110106
struct thread_struct {

arch/parisc/include/asm/rt_sigframe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef _ASM_PARISC_RT_SIGFRAME_H
33
#define _ASM_PARISC_RT_SIGFRAME_H
44

5-
#define SIGRETURN_TRAMP 4
5+
#define SIGRETURN_TRAMP 3
66
#define SIGRESTARTBLOCK_TRAMP 5
77
#define TRAMP_SIZE (SIGRETURN_TRAMP + SIGRESTARTBLOCK_TRAMP)
88

arch/parisc/include/asm/thread_info.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
struct thread_info {
1212
struct task_struct *task; /* main task structure */
1313
unsigned long flags; /* thread_info flags (see TIF_*) */
14-
mm_segment_t addr_limit; /* user-level address space limit */
1514
__u32 cpu; /* current CPU */
1615
int preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */
1716
};
@@ -21,7 +20,6 @@ struct thread_info {
2120
.task = &tsk, \
2221
.flags = 0, \
2322
.cpu = 0, \
24-
.addr_limit = KERNEL_DS, \
2523
.preempt_count = INIT_PREEMPT_COUNT, \
2624
}
2725

arch/parisc/include/asm/uaccess.h

Lines changed: 62 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
#include <linux/bug.h>
1212
#include <linux/string.h>
1313

14-
#define KERNEL_DS ((mm_segment_t){0})
15-
#define USER_DS ((mm_segment_t){1})
16-
17-
#define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
18-
19-
#define get_fs() (current_thread_info()->addr_limit)
20-
#define set_fs(x) (current_thread_info()->addr_limit = (x))
21-
2214
/*
2315
* Note that since kernel addresses are in a separate address space on
2416
* parisc, we don't need to do anything for access_ok().
@@ -33,11 +25,11 @@
3325
#define get_user __get_user
3426

3527
#if !defined(CONFIG_64BIT)
36-
#define LDD_USER(val, ptr) __get_user_asm64(val, ptr)
37-
#define STD_USER(x, ptr) __put_user_asm64(x, ptr)
28+
#define LDD_USER(sr, val, ptr) __get_user_asm64(sr, val, ptr)
29+
#define STD_USER(sr, x, ptr) __put_user_asm64(sr, x, ptr)
3830
#else
39-
#define LDD_USER(val, ptr) __get_user_asm(val, "ldd", ptr)
40-
#define STD_USER(x, ptr) __put_user_asm("std", x, ptr)
31+
#define LDD_USER(sr, val, ptr) __get_user_asm(sr, val, "ldd", ptr)
32+
#define STD_USER(sr, x, ptr) __put_user_asm(sr, "std", x, ptr)
4133
#endif
4234

4335
/*
@@ -67,28 +59,15 @@ struct exception_table_entry {
6759
#define ASM_EXCEPTIONTABLE_ENTRY_EFAULT( fault_addr, except_addr )\
6860
ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr + 1)
6961

70-
/*
71-
* load_sr2() preloads the space register %%sr2 - based on the value of
72-
* get_fs() - with either a value of 0 to access kernel space (KERNEL_DS which
73-
* is 0), or with the current value of %%sr3 to access user space (USER_DS)
74-
* memory. The following __get_user_asm() and __put_user_asm() functions have
75-
* %%sr2 hard-coded to access the requested memory.
76-
*/
77-
#define load_sr2() \
78-
__asm__(" or,= %0,%%r0,%%r0\n\t" \
79-
" mfsp %%sr3,%0\n\t" \
80-
" mtsp %0,%%sr2\n\t" \
81-
: : "r"(get_fs()) : )
82-
83-
#define __get_user_internal(val, ptr) \
62+
#define __get_user_internal(sr, val, ptr) \
8463
({ \
8564
register long __gu_err __asm__ ("r8") = 0; \
8665
\
8766
switch (sizeof(*(ptr))) { \
88-
case 1: __get_user_asm(val, "ldb", ptr); break; \
89-
case 2: __get_user_asm(val, "ldh", ptr); break; \
90-
case 4: __get_user_asm(val, "ldw", ptr); break; \
91-
case 8: LDD_USER(val, ptr); break; \
67+
case 1: __get_user_asm(sr, val, "ldb", ptr); break; \
68+
case 2: __get_user_asm(sr, val, "ldh", ptr); break; \
69+
case 4: __get_user_asm(sr, val, "ldw", ptr); break; \
70+
case 8: LDD_USER(sr, val, ptr); break; \
9271
default: BUILD_BUG(); \
9372
} \
9473
\
@@ -97,15 +76,14 @@ struct exception_table_entry {
9776

9877
#define __get_user(val, ptr) \
9978
({ \
100-
load_sr2(); \
101-
__get_user_internal(val, ptr); \
79+
__get_user_internal("%%sr3,", val, ptr); \
10280
})
10381

104-
#define __get_user_asm(val, ldx, ptr) \
82+
#define __get_user_asm(sr, val, ldx, ptr) \
10583
{ \
10684
register long __gu_val; \
10785
\
108-
__asm__("1: " ldx " 0(%%sr2,%2),%0\n" \
86+
__asm__("1: " ldx " 0(" sr "%2),%0\n" \
10987
"9:\n" \
11088
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
11189
: "=r"(__gu_val), "=r"(__gu_err) \
@@ -114,18 +92,31 @@ struct exception_table_entry {
11492
(val) = (__force __typeof__(*(ptr))) __gu_val; \
11593
}
11694

95+
#define HAVE_GET_KERNEL_NOFAULT
96+
#define __get_kernel_nofault(dst, src, type, err_label) \
97+
{ \
98+
type __z; \
99+
long __err; \
100+
__err = __get_user_internal("%%sr0,", __z, (type *)(src)); \
101+
if (unlikely(__err)) \
102+
goto err_label; \
103+
else \
104+
*(type *)(dst) = __z; \
105+
}
106+
107+
117108
#if !defined(CONFIG_64BIT)
118109

119-
#define __get_user_asm64(val, ptr) \
110+
#define __get_user_asm64(sr, val, ptr) \
120111
{ \
121112
union { \
122113
unsigned long long l; \
123114
__typeof__(*(ptr)) t; \
124115
} __gu_tmp; \
125116
\
126117
__asm__(" copy %%r0,%R0\n" \
127-
"1: ldw 0(%%sr2,%2),%0\n" \
128-
"2: ldw 4(%%sr2,%2),%R0\n" \
118+
"1: ldw 0(" sr "%2),%0\n" \
119+
"2: ldw 4(" sr "%2),%R0\n" \
129120
"9:\n" \
130121
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
131122
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \
@@ -138,16 +129,16 @@ struct exception_table_entry {
138129
#endif /* !defined(CONFIG_64BIT) */
139130

140131

141-
#define __put_user_internal(x, ptr) \
132+
#define __put_user_internal(sr, x, ptr) \
142133
({ \
143134
register long __pu_err __asm__ ("r8") = 0; \
144135
__typeof__(*(ptr)) __x = (__typeof__(*(ptr)))(x); \
145136
\
146137
switch (sizeof(*(ptr))) { \
147-
case 1: __put_user_asm("stb", __x, ptr); break; \
148-
case 2: __put_user_asm("sth", __x, ptr); break; \
149-
case 4: __put_user_asm("stw", __x, ptr); break; \
150-
case 8: STD_USER(__x, ptr); break; \
138+
case 1: __put_user_asm(sr, "stb", __x, ptr); break; \
139+
case 2: __put_user_asm(sr, "sth", __x, ptr); break; \
140+
case 4: __put_user_asm(sr, "stw", __x, ptr); break; \
141+
case 8: STD_USER(sr, __x, ptr); break; \
151142
default: BUILD_BUG(); \
152143
} \
153144
\
@@ -156,10 +147,20 @@ struct exception_table_entry {
156147

157148
#define __put_user(x, ptr) \
158149
({ \
159-
load_sr2(); \
160-
__put_user_internal(x, ptr); \
150+
__put_user_internal("%%sr3,", x, ptr); \
161151
})
162152

153+
#define __put_kernel_nofault(dst, src, type, err_label) \
154+
{ \
155+
type __z = *(type *)(src); \
156+
long __err; \
157+
__err = __put_user_internal("%%sr0,", __z, (type *)(dst)); \
158+
if (unlikely(__err)) \
159+
goto err_label; \
160+
}
161+
162+
163+
163164

164165
/*
165166
* The "__put_user/kernel_asm()" macros tell gcc they read from memory
@@ -170,26 +171,26 @@ struct exception_table_entry {
170171
* r8 is already listed as err.
171172
*/
172173

173-
#define __put_user_asm(stx, x, ptr) \
174-
__asm__ __volatile__ ( \
175-
"1: " stx " %2,0(%%sr2,%1)\n" \
176-
"9:\n" \
177-
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
178-
: "=r"(__pu_err) \
174+
#define __put_user_asm(sr, stx, x, ptr) \
175+
__asm__ __volatile__ ( \
176+
"1: " stx " %2,0(" sr "%1)\n" \
177+
"9:\n" \
178+
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
179+
: "=r"(__pu_err) \
179180
: "r"(ptr), "r"(x), "0"(__pu_err))
180181

181182

182183
#if !defined(CONFIG_64BIT)
183184

184-
#define __put_user_asm64(__val, ptr) do { \
185-
__asm__ __volatile__ ( \
186-
"1: stw %2,0(%%sr2,%1)\n" \
187-
"2: stw %R2,4(%%sr2,%1)\n" \
188-
"9:\n" \
189-
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
190-
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \
191-
: "=r"(__pu_err) \
192-
: "r"(ptr), "r"(__val), "0"(__pu_err)); \
185+
#define __put_user_asm64(sr, __val, ptr) do { \
186+
__asm__ __volatile__ ( \
187+
"1: stw %2,0(" sr "%1)\n" \
188+
"2: stw %R2,4(" sr "%1)\n" \
189+
"9:\n" \
190+
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
191+
ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \
192+
: "=r"(__pu_err) \
193+
: "r"(ptr), "r"(__val), "0"(__pu_err)); \
193194
} while (0)
194195

195196
#endif /* !defined(CONFIG_64BIT) */
@@ -200,14 +201,12 @@ struct exception_table_entry {
200201
*/
201202

202203
extern long strncpy_from_user(char *, const char __user *, long);
203-
extern unsigned lclear_user(void __user *, unsigned long);
204-
extern long lstrnlen_user(const char __user *, long);
204+
extern __must_check unsigned lclear_user(void __user *, unsigned long);
205+
extern __must_check long strnlen_user(const char __user *src, long n);
205206
/*
206207
* Complex access routines -- macros
207208
*/
208-
#define user_addr_max() (~0UL)
209209

210-
#define strnlen_user lstrnlen_user
211210
#define clear_user lclear_user
212211
#define __clear_user lclear_user
213212

arch/parisc/kernel/asm-offsets.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ int main(void)
230230
DEFINE(TI_TASK, offsetof(struct thread_info, task));
231231
DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
232232
DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
233-
DEFINE(TI_SEGMENT, offsetof(struct thread_info, addr_limit));
234233
DEFINE(TI_PRE_COUNT, offsetof(struct thread_info, preempt_count));
235234
DEFINE(THREAD_SZ, sizeof(struct thread_info));
236235
/* THREAD_SZ_ALGN includes space for a stack frame. */

arch/parisc/kernel/parisc_ksyms.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ EXPORT_SYMBOL(__xchg64);
3232

3333
#include <linux/uaccess.h>
3434
EXPORT_SYMBOL(lclear_user);
35-
EXPORT_SYMBOL(lstrnlen_user);
3635

3736
#ifndef CONFIG_64BIT
3837
/* Needed so insmod can set dp value */

arch/parisc/kernel/setup.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ void __init setup_arch(char **cmdline_p)
150150
#ifdef CONFIG_PA11
151151
dma_ops_init();
152152
#endif
153-
154-
clear_sched_clock_stable();
155153
}
156154

157155
/*

0 commit comments

Comments
 (0)