Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5CD3C43461 for ; Mon, 14 Sep 2020 15:23:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 687A621973 for ; Mon, 14 Sep 2020 15:23:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="iICAT9Ua" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 687A621973 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Qq8sD4yZJVqjEtXaZ/FSpS/nlXrzbg9YkdKL96qIvZQ=; b=iICAT9UaSqRR37VOH+jl/+74k9 /qAtlNCQPefgT8uPmVTs6D1bvZSlSqgWmRYKhzVlbXf6uS6qvnI4F1ka7TcfjaWLYP5dHTCLvQwHh Me4RGksi7JxtAn7kDDwHHtI4Hcwaw2UNkWpjKhUMa8ddiRiQSsJsatcvfypdmDTotSR9zcbSYYrQW 1QscjYXTUjOhVctB9zR9lPjek2VQlwvm6SsT6ziVTyHDlpdwYBXk0AnfNsbsSEz+Ex1+jnpKp+oYS oODNU+l6rTe+7NaMiINuXBAGOZASzgmRd3hl4K5bsgrNIxScR4YqIX26CA1veSybo2VzSeqqYr1Kj fdukKhMA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHqIJ-0005bH-C6; Mon, 14 Sep 2020 15:21:27 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHqFK-0004LY-E8 for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 15:18:49 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C4CC712FC; Mon, 14 Sep 2020 08:18:21 -0700 (PDT) Received: from seattle-bionic.arm.com.Home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E9AAD3F718; Mon, 14 Sep 2020 08:18:20 -0700 (PDT) From: Oliver Swede To: catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v5 13/14] arm64: usercopy: Add conclusive fixup routine Date: Mon, 14 Sep 2020 15:17:59 +0000 Message-Id: <20200914151800.2270-14-oli.swede@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914151800.2270-1-oli.swede@arm.com> References: <20200914151800.2270-1-oli.swede@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_111822_576666_08770AF8 X-CRM114-Status: GOOD ( 14.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This adds a second-stage routine to the usercopy functions that contains the final calculation for the return value, which represents the number of bytes not copied and is returned to the faulting syscall. This is only reached in the code path where a fault occurs during the second in-order copy; otherwise, the intermediate fixup will fall back to returning zero if it reaches the end of the buffer. As the intermediate fixup has already placed either srcend or dstend in x5 depending on the instruction that faulted, the sub operation is the same and the final fixup can be re-used for both cases. Signed-off-by: Oliver Swede --- arch/arm64/lib/copy_user_fixup.S | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm64/lib/copy_user_fixup.S b/arch/arm64/lib/copy_user_fixup.S index 6a7b2406d948..4858edd55994 100644 --- a/arch/arm64/lib/copy_user_fixup.S +++ b/arch/arm64/lib/copy_user_fixup.S @@ -62,8 +62,17 @@ L(all_copied): mov x0, #0 // reached the end of buffer ret -9998: -// TODO: add accurate fixup L(none_copied): mov x0, x2 // count (x2) ret + +/* + * Faults during a scan of the user buffer while running an + * in-order copy. + * + * Calculate the number of bytes not copied, using the fault + * address as a precise indicator. + */ +9998: + sub x0, x5, addr // x0: srcend-faddr or dstend-faddr + ret -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel