Skip to content

Commit e2931f0

Browse files
pccgregkh
authored andcommitted
arm64: fix inline asm in load_unaligned_zeropad()
commit 185f2e5 upstream. The inline asm's addr operand is marked as input-only, however in the case where an exception is taken it may be modified by the BIC instruction on the exception path. Fix the problem by using a temporary register as the destination register for the BIC instruction. Signed-off-by: Peter Collingbourne <pcc@google.com> Cc: stable@vger.kernel.org Link: https://linux-review.googlesource.com/id/I84538c8a2307d567b4f45bb20b715451005f9617 Link: https://lore.kernel.org/r/20210401165110.3952103-1-pcc@google.com Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 957f83a commit e2931f0

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎arch/arm64/include/asm/word-at-a-time.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ static inline unsigned long find_zero(unsigned long mask)
5353
*/
5454
static inline unsigned long load_unaligned_zeropad(const void *addr)
5555
{
56-
unsigned long ret, offset;
56+
unsigned long ret, tmp;
5757

5858
/* Load word from unaligned pointer addr */
5959
asm(
6060
"1: ldr %0, %3\n"
6161
"2:\n"
6262
" .pushsection .fixup,\"ax\"\n"
6363
" .align 2\n"
64-
"3: and %1, %2, #0x7\n"
65-
" bic %2, %2, #0x7\n"
66-
" ldr %0, [%2]\n"
64+
"3: bic %1, %2, #0x7\n"
65+
" ldr %0, [%1]\n"
66+
" and %1, %2, #0x7\n"
6767
" lsl %1, %1, #0x3\n"
6868
#ifndef __AARCH64EB__
6969
" lsr %0, %0, %1\n"
@@ -73,7 +73,7 @@ static inline unsigned long load_unaligned_zeropad(const void *addr)
7373
" b 2b\n"
7474
" .popsection\n"
7575
_ASM_EXTABLE(1b, 3b)
76-
: "=&r" (ret), "=&r" (offset)
76+
: "=&r" (ret), "=&r" (tmp)
7777
: "r" (addr), "Q" (*(unsigned long *)addr));
7878

7979
return ret;

0 commit comments

Comments
 (0)