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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C91A7C433EF for ; Wed, 22 Dec 2021 11:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=adtvzakCD9wG7EEYoryWCuQleCQjJ8pBuschBlgm4Fw=; b=eK1azvRPjYmBs4 skBdJYdbG+lt3nozInaZ8e2DPxgyK4pE0tp2IDXp8aVhjZjXPDpcxoNtuPfdd8GObdDshVdUeHyQj sBY2I1hLMZehRj/n61MYeVD2uQTO+W5ubqsAw7CevBEp8rqJvo0Ia99t79e3sYWHgGQwgb3Slglq9 8zvXOgQ5Xan5cstyzd/xtM57RBsxog7UF2EN+4UAvok9SOE8ag3MNnCgyMU51vlfocscPfsOO2w22 oVbOzRkD0lBM1ixDpIKTJThNrS+ncxJExUU8Np4t3xwjq/lED/Xpt1s5GPOBYFlK86PkvDkYoyuY4 K8Q29135U5vbjfTEhfUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzzP1-00A3ks-Rn; Wed, 22 Dec 2021 11:03:23 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzzOy-00A3jz-ON for linux-arm-kernel@lists.infradead.org; Wed, 22 Dec 2021 11:03:22 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 71A70B817D0; Wed, 22 Dec 2021 11:03:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0860FC36AE8; Wed, 22 Dec 2021 11:03:16 +0000 (UTC) Date: Wed, 22 Dec 2021 11:03:13 +0000 From: Catalin Marinas To: D Scott Phillips Cc: linux-arm-kernel@lists.infradead.org, Marc Zyngier , Will Deacon , Darren Hart , patches@amperecomputing.com Subject: Re: [PATCH v5] arm64: errata: Fix exec handling in erratum 1418040 workaround Message-ID: References: <20211220234114.3926-1-scott@os.amperecomputing.com> <86zgotg1nj.fsf@scott-ph-mail.amperecomputing.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <86zgotg1nj.fsf@scott-ph-mail.amperecomputing.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211222_030320_983400_58285EC5 X-CRM114-Status: GOOD ( 25.34 ) 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-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 On Tue, Dec 21, 2021 at 12:10:08PM -0800, D Scott Phillips wrote: > Catalin Marinas writes: > > On Mon, Dec 20, 2021 at 03:41:14PM -0800, D Scott Phillips wrote: > >> The erratum 1418040 workaround enables CNTVCT_EL1 access trapping in EL0 > >> when executing compat threads. The workaround is applied when switching > >> between tasks, but the need for the workaround could also change at an > >> exec(), when a non-compat task execs a compat binary or vice versa. Apply > >> the workaround in arch_setup_new_exec(). > >> > >> This leaves a small window of time between SET_PERSONALITY and > >> arch_setup_new_exec where preemption could occur and confuse the old > >> workaround logic that compares TIF_32BIT between prev and next. Instead, we > >> can just read cntkctl to make sure it's in the state that the next task > >> needs. I measured cntkctl read time to be about the same as a mov from a > >> general-purpose register on N1. Update the workaround logic to examine the > >> current value of cntkctl instead of the previous task's compat state. > > > > The patch looks fine to me but I was wondering what the cost of writing > > CNTKCTL_EL1 is, compared to a read. If it turns out to be negligible, we > > can simplify this patch further ;). > > I measured it at something like 20-30x the time of a read, though that > was in a tight loop of writing, so maybe the cost could be hidden some > by out-of-order execution. Are you thinking of moving the erratum > workaround back to the exit to user path? No, just wondering whether we can avoid the read/check/write with preemption disabled. Thread switches happen less often than the return to user. I'll probably take your current patch as a fix of Marc's commit. Waiting a bit to see if Marc has any further comments. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel