metag/usercopy: Fix src fixup in from user rapf loops
authorJames Hogan <james.hogan@imgtec.com>
Mon, 3 Apr 2017 16:41:40 +0000 (17:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Jun 2017 22:47:07 +0000 (00:47 +0200)
commit816a1aec47661696de464dea9b7afaa8814a38d8
treebc989511441c5bacde3128e7ab40b8d479f82d9a
parentcabb4ce1458c43c74f250c6f95dd8fce0a3c21f9
metag/usercopy: Fix src fixup in from user rapf loops

commit 2c0b1df88b987a12d95ea1d6beaf01894f3cc725 upstream.

The fixup code to rewind the source pointer in
__asm_copy_from_user_{32,64}bit_rapf_loop() always rewound the source by
a single unit (4 or 8 bytes), however this is insufficient if the fault
didn't occur on the first load in the loop, as the source pointer will
have been incremented but nothing will have been stored until all 4
register [pairs] are loaded.

Read the LSM_STEP field of TXSTATUS (which is already loaded into a
register), a bit like the copy_to_user versions, to determine how many
iterations of MGET[DL] have taken place, all of which need rewinding.

Fixes: 373cd784d0fc ("metag: Memory handling")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-metag@vger.kernel.org
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Willy Tarreau <w@1wt.eu>
arch/metag/lib/usercopy.c