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 05A29C433F5 for ; Wed, 22 Dec 2021 12:46:04 +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:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oFFIZtPOtTIQ8+h+Swxh07slgiZlnGlmA+msms6usgs=; b=PwOLIuG7wzFCAl ZTjR6Na/c5KeFJzqfnjGP89KRzgYn7bu+/ZNgO4ct/79l+B1nlncX+ZWlIMV4j+tJR5O1G0TQEFgM aVmBskBVvx+ziTA3cfKD3eSTzG9Yt5J9rdJq0QQTxOpUeMh0m6kSv8UM9zPQmsLNi5ImWj6RgpXrL xiK96tpO+C6jle4QFZULkseWY1rc95w67Lb6kEa1Cztn9dymX27LzhTHSzKzFMNRBhfCAVe0p7tKl tYil7BqTCg8oeTWWAEzEt5pbbnwdHUzOTe/bWPZFQTXNy9c+SqGK73OnyxByeP/48DW2aVCL7t2kd q4ywS7YGbCsiyp4vKKAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n00yz-00AJIR-CJ; Wed, 22 Dec 2021 12:44:37 +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 1n00yv-00AJHg-8r for linux-arm-kernel@lists.infradead.org; Wed, 22 Dec 2021 12:44:34 +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 743C9B81C4D; Wed, 22 Dec 2021 12:44:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35536C36AE8; Wed, 22 Dec 2021 12:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640177070; bh=uGynwpQJhMdywubL03t3CJ9zr6XtseBj4p1bqAWMMNQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GGrczD9JKibHJdBk58hLOPTAXW35xO5zVlcnhVKhDNVtlobtOYCL8PP9/oxXZKSc5 ABAwgomtddFEpj+Iz9VQnldyce94wlJm34P+OkZi/FeevH2sQlcGOoCMwBv6POGoV+ 0pHdTaF/sNr0/mGC4zAQUkTAgVPm8sUMhlneBV5TxbzVIVgBJX/61ZJc6foNn95sqa R2YCZit4fpKv9NV+ZPpfqkJetvlOYUCmtwSxS99y4bCr57GdAwFVVuFcwJ6rdeGyNN z0G0EjVWhLN8hx5ST+LC73RvV0GHFkTicaaq53jNtOKrcWLJ7yBXUttMT8d0g0fJJh G01/NeoeLa4sQ== Received: from 91-161-240-24.subs.proxad.net ([91.161.240.24] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n00yp-00Dkak-OH; Wed, 22 Dec 2021 12:44:27 +0000 Date: Wed, 22 Dec 2021 12:44:20 +0000 Message-ID: <875yrg24ij.wl-maz@kernel.org> From: Marc Zyngier To: Catalin Marinas Cc: D Scott Phillips , linux-arm-kernel@lists.infradead.org, Will Deacon , Darren Hart , patches@amperecomputing.com Subject: Re: [PATCH v5] arm64: errata: Fix exec handling in erratum 1418040 workaround In-Reply-To: References: <20211220234114.3926-1-scott@os.amperecomputing.com> <86zgotg1nj.fsf@scott-ph-mail.amperecomputing.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 91.161.240.24 X-SA-Exim-Rcpt-To: catalin.marinas@arm.com, scott@os.amperecomputing.com, linux-arm-kernel@lists.infradead.org, will@kernel.org, darren@os.amperecomputing.com, patches@amperecomputing.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211222_044433_630119_FD37F31C X-CRM114-Status: GOOD ( 33.59 ) 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 Wed, 22 Dec 2021 11:03:13 +0000, Catalin Marinas wrote: > > 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. I'm not overly surprised. Writing to this register is likely to require some level of synchronisation pretty deep inside the core as event stream changes would take effect immediately. > > 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. No, I think this is pretty much it. Feel free to apply it with my Reviewed-by: Marc Zyngier Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel