Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2243267pxk; Mon, 14 Sep 2020 08:15:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjqNj0TO+3ZfW+ppfM5bt2hgL7CowF+wawl1B219JaniDy43AgeVJK4zG8rTTo2YdgR5Wr X-Received: by 2002:a17:906:354c:: with SMTP id s12mr15646722eja.370.1600096523646; Mon, 14 Sep 2020 08:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600096523; cv=none; d=google.com; s=arc-20160816; b=FtYTNLOR9SiBN5VnYRRrP8mYaF+WdLAc989MjfLYhMJU84ViFu4VNaf28c8fYnG0GK MAsf8eQ+p/QbWCJE3h5tjmY7V/AtauKl4fJ0BZ+1GvHf1fNzezhDpq02a+QGM0IRV+jm QyDW2RkBoFJhgcEmzVexCTz5oB8qxPTk4wly931AnAktrGuTRE7oA22N5T5gfRRnffIY 4x8gz5yB80TQEeEBiyij3UoL1SLavBNkl+UkFTlnMhjI+4EdU2Lm3ZUU8M/w5IOgNKDh o70zfMRGh+mTRDWkU4Sn/IkZGfIryW2/W/iwZXoBuCjmjqdbDK6rsnL1BGeKP+WOhTu4 zQlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=HCgzjRf9cqtGdGs8VEgcuVymmQ5R3nb1IuCcD6wN/0A=; b=AGq17ZOVf24znKzUqmJlQBfbYbdtSjCtGh9RxW20P2KthNzAe5XEAbGGSJLPBZnGn5 nNK7PDD3kFDwO33KHGacnWUyHHxNHy4MJP5iPF0+8wK+bFg6V0mmYKh0UOTXGvr4urBi MKbhF9MJbkgF457uiWWqfY+KDeFUNNqgbAQLXHXfg5WqEBvqxBFcUVlCCtc79OrWXlQX xE7Sj6QQG4oVBC0e5YeavjI8XDcEaalqButDVntym4oXLJ2YpDsNyXbb3GcpwJqSzOCd F4Ay1iN4JlmcpVS49KkrnJ/k4tx9Uk0JA9bLPgIqHVl+ETysXTv7T7nRzZsDrRCTuOiZ prDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o17si7604691ejg.470.2020.09.14.08.15.00; Mon, 14 Sep 2020 08:15:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726385AbgINPNz (ORCPT + 99 others); Mon, 14 Sep 2020 11:13:55 -0400 Received: from foss.arm.com ([217.140.110.172]:39646 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726340AbgINPKw (ORCPT ); Mon, 14 Sep 2020 11:10:52 -0400 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 74FE41597; Mon, 14 Sep 2020 08:10:50 -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 7BA8F3F718; Mon, 14 Sep 2020 08:10:49 -0700 (PDT) From: Oliver Swede To: catalin.marinas@arm.com, will@kernel.org Cc: robin.murphy@arm.com, linux-arm-kernel@lists.indradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 13/14] arm64: usercopy: Add conclusive fixup routine Date: Mon, 14 Sep 2020 15:09:57 +0000 Message-Id: <20200914150958.2200-14-oli.swede@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914150958.2200-1-oli.swede@arm.com> References: <20200914150958.2200-1-oli.swede@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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