From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 96E1AC433B4 for ; Wed, 12 May 2021 13:52:34 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 EFBF5613B4 for ; Wed, 12 May 2021 13:52:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFBF5613B4 Authentication-Results: mail.kernel.org; dmarc=fail (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=desiato.20200630; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wK/zqvG7dcs3KZXn7NzkkDROU7TvSjxnMiu4fskuIH4=; b=J6fhGxwVZBqK4r84oqPUkM1Kb QBANt7NXmexPQPFaFGuNxhauc8D/qtrgpUmWBHzWLU6TKVaH1DPKIqBh2+RZAkCaVdhc5Q4+jX00T 97pcc4/ULsDucwGxM6tZmdRXX7oQ3gxOacwNRWUde8gousaa4b/RPHvBEYk0kjgwKBeprtycOTznt 17WE/NHnVZHKLl0pC19BTZWL03Axo5ObNRhjKvOsSM81miavXQaCZ2quHM3sr2hZRKfR6nbo/MOyq 3bjqcO8Xu+dM/g+kneT+g3eZ9WHVKPwvXwGaEt3hMilBlzsO+20MkS/gJLDH2C7/PwvNYEXd3MoBN wFCDhSfHg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgpGY-002xTS-So; Wed, 12 May 2021 13:51:11 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgpGW-002xT5-Ju for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 13:51:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=/aNOf9RQOGwVSjK1JdPdq6ut1/aDQ2dxlWeb7OoRXxI=; b=gp8WHTdrsiaD8D9Zc0aLfOXMtb lVvYU7ZdTfo0X5nDqnn7DrsX7/EUfvDxaxXn2k0fzea9Qx77i1rfVp7w+AGtx7IHPLgZcckDXVzYu Ym7pPxcTFxM10O9sHgW0lokKBBB1Z0X5zf+RATjtynHmKGTvndqkWzyxVl8XRf9F1M7glRGul9Y6q T6IFNcv6gkEDVkNQ4G7+9ccxnfAggomA4yMB6+kOUoUq4ykvK4xmg3A9IPFuPYmh+s9imYTwH4htC ORwEW2jTuGHlhACxk7+/AE2tUr9WLZmzIQop7WGpu3cDV6fcqNUrwfIS90U7Z5+CCZipMH07771d6 ExJNfx7g==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgpGT-00AQKw-Iw for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 13:51:07 +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 F0F8231B; Wed, 12 May 2021 06:51:02 -0700 (PDT) Received: from [192.168.1.123] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 077023F718; Wed, 12 May 2021 06:51:01 -0700 (PDT) Subject: Re: [PATCH 8/8] arm64: Rewrite __arch_clear_user() To: Mark Rutland Cc: will@kernel.org, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, yangyingliang@huawei.com References: <76a1700b0316b50fb5881da603f2daf3c81468f4.1620738177.git.robin.murphy@arm.com> <20210512104833.GD88854@C02TD0UTHF1T.local> <20210512130418.GF88854@C02TD0UTHF1T.local> From: Robin Murphy Message-ID: Date: Wed, 12 May 2021 14:51:01 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210512130418.GF88854@C02TD0UTHF1T.local> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_065105_751272_6670959A X-CRM114-Status: GOOD ( 23.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021-05-12 14:06, Mark Rutland wrote: > On Wed, May 12, 2021 at 12:31:39PM +0100, Robin Murphy wrote: >> On 2021-05-12 11:48, Mark Rutland wrote: >>> On Tue, May 11, 2021 at 05:12:38PM +0100, Robin Murphy wrote: >>>> Rewrite __arch_clear_user() with regular >>>> USER() annotations so that it's clearer what's going on, and take the >>>> opportunity to minimise the branchiness in the most common paths, which >>>> also allows the exception fixup to return a more accurate result. >>> >>> IIUC this isn't always accurate for the {4,2,1}-byte cases; example >>> below. I'm not sure whether that's intentional since the commit message >>> says "more accurate" rather than "accurate". >> >> Indeed, the "more" was definitely significant :) > > :) > >>> If we think that under-estimating is fine, I reckon it'd be worth a >>> comment to make that clear. >> >> Indeed for smaller amounts there's no change in fixup behaviour at all, but >> I have to assume that underestimating by up to 100% is probably OK since >> we've been underestimating by fully 100% for nearly 10 years now. I don't >> believe it's worth having any more complexity than necessary for the fault >> case - grepping for clear_user() usage suggests that nobody really cares >> about the return value beyond whether it's zero or not, so the minor >> "improvement" here is more of a nice-to-have TBH. >> >> The existing comment doesn't actually explain anything either, which is why >> I didn't replace it, but I'm happy to add something if you like. > > I don't have strong feelings either way, but I think that we should at > least document this, since that'll at least save us rehashing the same > point in future. :) > > That said, IIUC to make this always accurate we only need two ADDs (diff > below). Since those will only be executed at most once each, I suspect > they won't have a measureable impact in practice. > > So maybe it's worth adding them to avoid any risk that someone needs > this to be accurate in future? Hmm, now that you've caused me to ponder it some more, it can in fact be achieved with just two extra ADDs _out of line_, and still neatly enough that I'm now definitely going to do that. Thanks for the push! Robin. > > Mark. > > ---->8---- > diff --git a/arch/arm64/lib/clear_user.S b/arch/arm64/lib/clear_user.S > index 1005345b4066..7ef553ec2677 100644 > --- a/arch/arm64/lib/clear_user.S > +++ b/arch/arm64/lib/clear_user.S > @@ -32,12 +32,14 @@ USER(9f, sttr xzr, [x2, #-8]) > > 2: tbz x1, #2, 3f > USER(9f, sttr wzr, [x0]) > + add x0, x0, #4 > USER(9f, sttr wzr, [x2, #-4]) > mov x0, #0 > ret > > 3: tbz x1, #1, 4f > USER(9f, sttrh wzr, [x0]) > + add x0, x0, #2 > 4: tbz x1, #0, 5f > USER(9f, sttrb wzr, [x2, #-1]) > 5: mov x0, #0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel