Skip to content

Commit 3448890

Browse files
author
Al Viro
committed
powerpc: get rid of zeroing, switch to RAW_COPY_USER
Signed-off-by: Al Viro <[email protected]>
1 parent f2ed8be commit 3448890

File tree

6 files changed

+14
-138
lines changed

6 files changed

+14
-138
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ config PPC
8787
select ARCH_HAS_DMA_SET_COHERENT_MASK
8888
select ARCH_HAS_ELF_RANDOMIZE
8989
select ARCH_HAS_GCOV_PROFILE_ALL
90+
select ARCH_HAS_RAW_COPY_USER
9091
select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE
9192
select ARCH_HAS_SG_CHAIN
9293
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST

arch/powerpc/include/asm/uaccess.h

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -269,42 +269,19 @@ extern unsigned long __copy_tofrom_user(void __user *to,
269269

270270
#ifndef __powerpc64__
271271

272-
static inline unsigned long copy_from_user(void *to,
273-
const void __user *from, unsigned long n)
274-
{
275-
if (likely(access_ok(VERIFY_READ, from, n))) {
276-
check_object_size(to, n, false);
277-
return __copy_tofrom_user((__force void __user *)to, from, n);
278-
}
279-
memset(to, 0, n);
280-
return n;
281-
}
282-
283-
static inline unsigned long copy_to_user(void __user *to,
284-
const void *from, unsigned long n)
285-
{
286-
if (access_ok(VERIFY_WRITE, to, n)) {
287-
check_object_size(from, n, true);
288-
return __copy_tofrom_user(to, (__force void __user *)from, n);
289-
}
290-
return n;
291-
}
272+
#define INLINE_COPY_FROM_USER
273+
#define INLINE_COPY_TO_USER
292274

293275
#else /* __powerpc64__ */
294276

295-
#define __copy_in_user(to, from, size) \
296-
__copy_tofrom_user((to), (from), (size))
297-
298-
extern unsigned long copy_from_user(void *to, const void __user *from,
299-
unsigned long n);
300-
extern unsigned long copy_to_user(void __user *to, const void *from,
301-
unsigned long n);
302-
extern unsigned long copy_in_user(void __user *to, const void __user *from,
303-
unsigned long n);
304-
277+
static inline unsigned long
278+
raw_copy_in_user(void __user *to, const void __user *from, unsigned long n)
279+
{
280+
return __copy_tofrom_user(to, from, n);
281+
}
305282
#endif /* __powerpc64__ */
306283

307-
static inline unsigned long __copy_from_user_inatomic(void *to,
284+
static inline unsigned long raw_copy_from_user(void *to,
308285
const void __user *from, unsigned long n)
309286
{
310287
if (__builtin_constant_p(n) && (n <= 8)) {
@@ -328,12 +305,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
328305
return 0;
329306
}
330307

331-
check_object_size(to, n, false);
332-
333308
return __copy_tofrom_user((__force void __user *)to, from, n);
334309
}
335310

336-
static inline unsigned long __copy_to_user_inatomic(void __user *to,
311+
static inline unsigned long raw_copy_to_user(void __user *to,
337312
const void *from, unsigned long n)
338313
{
339314
if (__builtin_constant_p(n) && (n <= 8)) {
@@ -357,25 +332,9 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
357332
return 0;
358333
}
359334

360-
check_object_size(from, n, true);
361-
362335
return __copy_tofrom_user(to, (__force const void __user *)from, n);
363336
}
364337

365-
static inline unsigned long __copy_from_user(void *to,
366-
const void __user *from, unsigned long size)
367-
{
368-
might_fault();
369-
return __copy_from_user_inatomic(to, from, size);
370-
}
371-
372-
static inline unsigned long __copy_to_user(void __user *to,
373-
const void *from, unsigned long size)
374-
{
375-
might_fault();
376-
return __copy_to_user_inatomic(to, from, size);
377-
}
378-
379338
extern unsigned long __clear_user(void __user *addr, unsigned long size);
380339

381340
static inline unsigned long clear_user(void __user *addr, unsigned long size)

arch/powerpc/lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ obj-y += string.o alloc.o crtsavres.o code-patching.o \
1414

1515
obj-$(CONFIG_PPC32) += div64.o copy_32.o
1616

17-
obj64-y += copypage_64.o copyuser_64.o usercopy_64.o mem_64.o hweight_64.o \
17+
obj64-y += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \
1818
copyuser_power7.o string_64.o copypage_power7.o memcpy_power7.o \
1919
memcpy_64.o memcmp_64.o
2020

arch/powerpc/lib/copy_32.S

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -477,18 +477,6 @@ _GLOBAL(__copy_tofrom_user)
477477
bdnz 130b
478478
/* then clear out the destination: r3 bytes starting at 4(r6) */
479479
132: mfctr r3
480-
srwi. r0,r3,2
481-
li r9,0
482-
mtctr r0
483-
beq 113f
484-
112: stwu r9,4(r6)
485-
bdnz 112b
486-
113: andi. r0,r3,3
487-
mtctr r0
488-
beq 120f
489-
114: stb r9,4(r6)
490-
addi r6,r6,1
491-
bdnz 114b
492480
120: blr
493481

494482
EX_TABLE(30b,108b)
@@ -497,7 +485,5 @@ _GLOBAL(__copy_tofrom_user)
497485
EX_TABLE(41b,111b)
498486
EX_TABLE(130b,132b)
499487
EX_TABLE(131b,120b)
500-
EX_TABLE(112b,120b)
501-
EX_TABLE(114b,120b)
502488

503489
EXPORT_SYMBOL(__copy_tofrom_user)

arch/powerpc/lib/copyuser_64.S

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -319,32 +319,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD)
319319
blr
320320

321321
/*
322-
* here we have trapped again, need to clear ctr bytes starting at r3
322+
* here we have trapped again, amount remaining is in ctr.
323323
*/
324-
143: mfctr r5
325-
li r0,0
326-
mr r4,r3
327-
mr r3,r5 /* return the number of bytes not copied */
328-
1: andi. r9,r4,7
329-
beq 3f
330-
90: stb r0,0(r4)
331-
addic. r5,r5,-1
332-
addi r4,r4,1
333-
bne 1b
334-
blr
335-
3: cmpldi cr1,r5,8
336-
srdi r9,r5,3
337-
andi. r5,r5,7
338-
blt cr1,93f
339-
mtctr r9
340-
91: std r0,0(r4)
341-
addi r4,r4,8
342-
bdnz 91b
343-
93: beqlr
344-
mtctr r5
345-
92: stb r0,0(r4)
346-
addi r4,r4,1
347-
bdnz 92b
324+
143: mfctr r3
348325
blr
349326

350327
/*
@@ -389,10 +366,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD)
389366
ld r5,-8(r1)
390367
add r6,r6,r5
391368
subf r3,r3,r6 /* #bytes not copied */
392-
190:
393-
191:
394-
192:
395-
blr /* #bytes not copied in r3 */
369+
blr
396370

397371
EX_TABLE(20b,120b)
398372
EX_TABLE(220b,320b)
@@ -451,9 +425,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_UNALIGNED_LD_STD)
451425
EX_TABLE(88b,188b)
452426
EX_TABLE(43b,143b)
453427
EX_TABLE(89b,189b)
454-
EX_TABLE(90b,190b)
455-
EX_TABLE(91b,191b)
456-
EX_TABLE(92b,192b)
457428

458429
/*
459430
* Routine to copy a whole page of data, optimized for POWER4.

arch/powerpc/lib/usercopy_64.c

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

0 commit comments

Comments
 (0)