[PATCH v2 4/4] xtensa: initialize result in __get_user_asm for unaligned access

From: Max Filippov
Date: Fri Oct 11 2019 - 20:37:41 EST


__get_user_asm macro leaves result register uninitialized when alignment
check fails. Add 'insn' parameter to __check_align_{1,2,4} and pass an
instruction that initializes result register from __get_user_asm.

Signed-off-by: Max Filippov <jcmvbkbc@xxxxxxxxx>
---
arch/xtensa/include/asm/uaccess.h | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index 43e923678dfb..d8cff972f3cf 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -129,17 +129,19 @@ do { \
* sync.
*/

-#define __check_align_1 ""
+#define __check_align_1(insn) ""

-#define __check_align_2 \
+#define __check_align_2(insn) \
" _bbci.l %[addr], 0, 1f \n" \
" movi %[err], %[efault] \n" \
+ " "insn" \n" \
" _j 2f \n"

-#define __check_align_4 \
+#define __check_align_4(insn) \
" _bbsi.l %[addr], 0, 0f \n" \
" _bbci.l %[addr], 1, 1f \n" \
"0: movi %[err], %[efault] \n" \
+ " "insn" \n" \
" _j 2f \n"


@@ -153,7 +155,7 @@ do { \
*/
#define __put_user_asm(x_, addr_, err_, align, insn, cb)\
__asm__ __volatile__( \
- __check_align_##align \
+ __check_align_##align("") \
"1: "insn" %[x], %[addr], 0 \n" \
"2: \n" \
" .section .fixup,\"ax\" \n" \
@@ -221,7 +223,7 @@ do { \
do { \
u32 __x; \
__asm__ __volatile__( \
- __check_align_##align \
+ __check_align_##align("movi %[x], 0") \
"1: "insn" %[x], %[addr], 0 \n" \
"2: \n" \
" .section .fixup,\"ax\" \n" \
--
2.20.1