Received: by 10.192.165.156 with SMTP id m28csp201495imm; Tue, 17 Apr 2018 08:44:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48JyC1O9IZ+hoZyqqWGTp7d7lSVo5JxmilNLsovUs0SH4G5AxPiAKsut/WYwzT6XrLWC2QR X-Received: by 10.99.165.79 with SMTP id r15mr2281553pgu.236.1523979890954; Tue, 17 Apr 2018 08:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523979890; cv=none; d=google.com; s=arc-20160816; b=af+3vUQocmvgFc8+ZcgOf2Kho9YTG4dzp6wYd5cLVGAZpK8ilK2BUnXm3axTlwruPM 67CxBIF4S7+LOso0ck4rHU1hw/BW5IJNv+rYDWZRcmT+r6mIxG/o6ziLwDfDz16tLl1W ukDP6KaWD3lj9oJU1Rxm1ScFMzgDcBgNNwkH6necYhgysFFuWKHFyBy9iiQgq0hpBdOD hFN38aMVbtbgdihwAoXXjWrZbzgTyAhEGb7d36B9ZWzFLdSNpz1bKM/JO0938dwfT/oh dZsXdyKlxAtI+SUnyKmV4pgAEp/y5Bdz04A6/GKw6LtXjahReXomMNM+162UsMDaBARq p7zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=9hPquF0kCF/+G9C+joX4DrqhnLprmcXH1pp4z8ClW4Q=; b=PGKt9tFCXY3CEir8fhGpU3SfSsc/3f/g8/hbtQtg7jG/zBRDanwwSi6EB8QUb2r195 3efooFZRs3Q40m7T28CR16yu8lzaSELy63wERX+cx6qL5bewfbN02sFCgVtbPtZkWJtF An6vD7qmdXypG1pE8fj+sgZYU6Lv4qvz/X7ZaV2zx/4qdlhH+0Mjp/yfCdzgN3p7L9k3 o4ajQEnzlJqylLzE29FHq9lO+bOs0mbEuLCUEYL24onMSlBXNEXJnhQpAQnecpH23hKS b45mhtnd5N5zq5sTm5VT/nky4oJyTMaPgr0n/jZacEevjfHHCQVYjh6uVaQUgAHMP1Zj QI+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3si3586218pgc.425.2018.04.17.08.44.36; Tue, 17 Apr 2018 08:44:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753058AbeDQPnN (ORCPT + 99 others); Tue, 17 Apr 2018 11:43:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:44304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752747AbeDQPnE (ORCPT ); Tue, 17 Apr 2018 11:43:04 -0400 Received: from saruman (jahogan.plus.com [212.159.75.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5FAB9217D4; Tue, 17 Apr 2018 15:43:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FAB9217D4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jhogan@kernel.org Date: Tue, 17 Apr 2018 16:43:00 +0100 From: James Hogan To: Matt Redfearn Cc: Ralf Baechle , 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 Message-ID: <20180417154259.GA21386@saruman> References: <1523973590-23356-1-git-send-email-matt.redfearn@mips.com> <1523976741-29916-1-git-send-email-matt.redfearn@mips.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WIyZ46R2i8wDzkSu" Content-Disposition: inline In-Reply-To: <1523976741-29916-1-git-send-email-matt.redfearn@mips.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > 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. >=20 > This issue was found with the following test code: > int j, k; > for (j =3D 0; j < 512; j++) { > if ((k =3D clear_user(NULL, j)) !=3D j) { > pr_err("clear_user (NULL %d) returned %d\n", j, k); > } > } > Which now passes on Creator Ci40 (MIPS32) and Cavium Octeon II (MIPS64). >=20 > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Cc: stable@vger.kernel.org > Suggested-by: James Hogan > Signed-off-by: Matt Redfearn Applied, thanks James --WIyZ46R2i8wDzkSu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEd80NauSabkiESfLYbAtpk944dnoFAlrWFgMACgkQbAtpk944 dnrf1BAAmf3KlW6EcbOTuhPhsCrFWYl1zVFklbUG7arIV3Y6cMpd9WkYKZFB6fM4 mkwb9INdDK1wLiI0CAXfR/+1Sj5aPuCTMMbqmTKAcEfni6vvGG6PPybpZMiHZ7IL X8WJJ58rCP6Mn81FYtg/rQy0zgC6u3v5PgwNg/JTz9Uv7THxJffHETO5Sz7UH5Ie lndhniM9hNrqqZF1Xu+JWvZH2tyjvHR/fzjxIrAC9uF+hBMX0rkEoNg96e96huPj JYCDBnfODbN/8mweoAP25/8vOSLKsIifLR/gfQBLupcaXat/PXkG5X0If3/n7kM7 5MDjl8R0XVn8ko/pspWovGghwzDc0vnOqAAmQXT1jsf11ccVpLpar/qCJs7Fn+74 e4K84skeasyhKa9VbhPAgvsKXJkm/7LyQSJtTDRTvWXqduJWBmeuYoDLmt8/21rH H04cg0P6HojTnF1rwhiL/3V5Mv159cWE7tfLBv30J+ANdS+FbgcIUwP4OrqJwPwl A9O0stHBqoBsF5BozXO+QnkgpHyqqsFwc15qBKAe4jAtlfmD4meJ+v99334gwylq 86qH6G+IeFGhWgakd5haXeH5x3CtiIpm/Y0MpkGXgolQvs9sU08ZTGRgM19bEkEo 9xNjFGXSmDRrkWAg1Vw1KwMOB0RCorQIEBNI8z/OsQ0eOvfBFv8= =fP0w -----END PGP SIGNATURE----- --WIyZ46R2i8wDzkSu--