From: James Hogan <jhogan@kernel.org>
To: Matt Redfearn <matt.redfearn@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
linux-mips@linux-mips.org, stable@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] MIPS: memset.S: Fix return of __clear_user from Lpartial_fixup
Date: Tue, 17 Apr 2018 16:43:00 +0100 [thread overview]
Message-ID: <20180417154259.GA21386@saruman> (raw)
In-Reply-To: <1523976741-29916-1-git-send-email-matt.redfearn@mips.com>
[-- Attachment #1: Type: text/plain, Size: 1488 bytes --]
On Tue, Apr 17, 2018 at 03:52:21PM +0100, Matt Redfearn wrote:
> The __clear_user function is defined to return the number of bytes that
> could not be cleared. From the underlying memset / bzero implementation
> this means setting register a2 to that number on return. Currently if a
> page fault is triggered within the memset_partial block, the value
> loaded into a2 on return is meaningless.
>
> The label .Lpartial_fixup\@ is jumped to on page fault. In order to work
> out how many bytes failed to copy, the exception handler should find how
> many bytes left in the partial block (andi a2, STORMASK), add that to
> the partial block end address (a2), and subtract the faulting address to
> get the remainder. Currently it incorrectly subtracts the partial block
> start address (t1), which has additionally has been clobbered to
> generate a jump target in memset_partial. Fix this by adding the block
> end address instead.
>
> This issue was found with the following test code:
> int j, k;
> for (j = 0; j < 512; j++) {
> if ((k = clear_user(NULL, j)) != j) {
> pr_err("clear_user (NULL %d) returned %d\n", j, k);
> }
> }
> Which now passes on Creator Ci40 (MIPS32) and Cavium Octeon II (MIPS64).
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Suggested-by: James Hogan <jhogan@kernel.org>
> Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
Applied, thanks
James
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2018-04-17 15:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1522315704-31641-1-git-send-email-matt.redfearn@mips.com>
2018-03-29 9:28 ` [PATCH 1/2] MIPS: memset.S: EVA & fault support for small_memset Matt Redfearn
2018-04-16 20:22 ` James Hogan
2018-04-17 13:20 ` Matt Redfearn
2018-05-14 22:56 ` Maciej W. Rozycki
2018-03-29 9:28 ` [PATCH 2/2] MIPS: memset.S: Fix return of __clear_user from Lpartial_fixup Matt Redfearn
2018-04-16 22:13 ` James Hogan
2018-04-17 13:21 ` Matt Redfearn
2018-04-17 13:59 ` [PATCH v2] " Matt Redfearn
2018-04-17 14:52 ` [PATCH v3] " Matt Redfearn
2018-04-17 15:43 ` James Hogan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180417154259.GA21386@saruman \
--to=jhogan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=matt.redfearn@mips.com \
--cc=ralf@linux-mips.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).