Skip to content

Commit c7474da

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/uaccess: Use asm goto for __mvc_kernel_nofault()
Use asm goto for __mvc_kernel_nofault() if available. This generates slightly better code, since the error checking happens implicitly with the goto (aka exception) and the good path comes without any checks and branches. Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 5b629e6 commit c7474da

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

arch/s390/include/asm/uaccess.h

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -343,37 +343,33 @@ static inline void *s390_kernel_write(void *dst, const void *src, size_t size)
343343

344344
void __noreturn __mvc_kernel_nofault_bad(void);
345345

346-
#ifdef CONFIG_CC_HAS_ASM_AOR_FORMAT_FLAGS
346+
#if defined(CONFIG_CC_HAS_ASM_GOTO_OUTPUT) && defined(CONFIG_CC_HAS_ASM_AOR_FORMAT_FLAGS)
347347

348348
#define __mvc_kernel_nofault(dst, src, type, err_label) \
349349
do { \
350-
int __rc; \
351-
\
352350
switch (sizeof(type)) { \
353351
case 1: \
354352
case 2: \
355353
case 4: \
356354
case 8: \
357-
asm_inline volatile( \
355+
asm goto( \
358356
"0: mvc %O[_dst](%[_len],%R[_dst]),%[_src]\n" \
359-
"1: lhi %[_rc],0\n" \
360-
"2:\n" \
361-
EX_TABLE_UA_FAULT(0b, 2b, %[_rc]) \
362-
EX_TABLE_UA_FAULT(1b, 2b, %[_rc]) \
363-
: [_rc] "=d" (__rc), \
364-
[_dst] "=Q" (*(type *)dst) \
357+
"1: nopr %%r7\n" \
358+
EX_TABLE(0b, %l[err_label]) \
359+
EX_TABLE(1b, %l[err_label]) \
360+
: [_dst] "=Q" (*(type *)dst) \
365361
: [_src] "Q" (*(type *)(src)), \
366-
[_len] "I" (sizeof(type))); \
367-
if (__rc) \
368-
goto err_label; \
362+
[_len] "I" (sizeof(type)) \
363+
: \
364+
: err_label); \
369365
break; \
370366
default: \
371367
__mvc_kernel_nofault_bad(); \
372368
break; \
373369
} \
374370
} while (0)
375371

376-
#else /* CONFIG_CC_HAS_ASM_AOR_FORMAT_FLAGS */
372+
#else /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT) && CONFIG_CC_HAS_ASM_AOR_FORMAT_FLAGS */
377373

378374
#define __mvc_kernel_nofault(dst, src, type, err_label) \
379375
do { \
@@ -405,7 +401,7 @@ do { \
405401
} \
406402
} while (0)
407403

408-
#endif /* CONFIG_CC_HAS_ASM_AOR_FORMAT_FLAGS */
404+
#endif /* CONFIG_CC_HAS_ASM_GOTO_OUTPUT && CONFIG_CC_HAS_ASM_AOR_FORMAT_FLAGS */
409405

410406
#define __get_kernel_nofault __mvc_kernel_nofault
411407
#define __put_kernel_nofault __mvc_kernel_nofault

0 commit comments

Comments
 (0)