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 B833AC433F5 for ; Thu, 16 Dec 2021 09:39:59 +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=wxbFYM3FC8XSOs2WaAdpwrlLZCqQ6/9mmJaj7OWUclc=; b=wru2xH98LtLzym pxlVWiElk7A6p9XMo8rIrkAQAJJZmjL1v1JE3n9pZrgxJgr7o/r7+BZkuJyyydX/FIdVz7OwC866C 3xVGzhzDmlpCgoSBYEWLMAjpl0+S/0WTa3xh12K9b+yDsRb4wTPtEK2hPMnHespBhoAxR8QfEvdt4 dXGJJClWcFeMvn2jLAKI30NsE4wcp7L2k01QN/72HBHYyk02UP3CgLBmNaxJlTmAwpniZ3jKj+8YY PGAsHpenTM5TK6RAWjS1kZoaJQxLqUiUu2DgcwMAKX4M44QZiZihijLXm/bHGrqYJloUQ/0R5sUzF zPYdfzQsMXSAuADWhNxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxnDP-004Wp7-0q; Thu, 16 Dec 2021 09:38:20 +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 1mxn5T-004TUY-Ek for linux-arm-kernel@lists.infradead.org; Thu, 16 Dec 2021 09:30:09 +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 CA02EB82319; Thu, 16 Dec 2021 09:30:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8995CC36AE2; Thu, 16 Dec 2021 09:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639647004; bh=tdJYNdxLUPV6qVQKqfWPoYJsQEPQyaUiEoBuM4hT90Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=I4I4RJ8gi8AwkFAtHSnNSaQAXcRHOydV3eGf+M74gs3zZT6UTnaEr8m5JEzbplMGi aS4vaDq85rB01mAFNcEwe+jXSwGpwk1B7kfbYhSIwJdWVNKicrEgvn6TuuLbLbSoLP p2Meo+LvREzHyG0pz2tFgRIs84KtTO/WjJrlCx5nJtvDiInE+S7D24Egth0tqu+1B0 AwGJeSKqa9RTEwnsK2wB9g1Se2eDYNcFhcxxuEf/ANFnRtxOD7XpyShLfPRwOMQ4cE h/3CRSDhkZcGbcjVX1SUJYVGnzG21lzIziCNxcPsK/c7xM1SbyGQPPt4hhKYX9NRKv w99pHPt5UA9UA== Received: from cfbb000407.r.cam.camfibre.uk ([185.219.108.64] helo=why.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 1mxn5O-00CToW-Jr; Thu, 16 Dec 2021 09:30:02 +0000 Date: Thu, 16 Dec 2021 09:30:02 +0000 Message-ID: <87r1acx5gl.wl-maz@kernel.org> From: Marc Zyngier To: D Scott Phillips Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Darren Hart , patches@amperecomputing.com Subject: Re: [PATCH] arm64: errata: Fix exec handling in erratum 1418040 workaround In-Reply-To: <20211215230240.604489-1-scott@os.amperecomputing.com> References: <20211215230240.604489-1-scott@os.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: 185.219.108.64 X-SA-Exim-Rcpt-To: 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-20211216_013007_843468_58F553A1 X-CRM114-Status: GOOD ( 22.22 ) 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, 15 Dec 2021 23:02:40 +0000, D Scott Phillips wrote: > > The erratum 1418040 workaround changes vct access trapping when switching > between compat and non-compat threads. The workaround logic assumes that > the hardware vct trapping state matches the previous task's compat-ness. > However, when a non-compat task execs a compat binary or vice versa, the > cntkctl state and task compat-ness get out of sync. Keep the hardware > trapping state in sync with the task personality. > > Fixes: d49f7d7376d0 ("arm64: Move handling of erratum 1418040 into C code") > Signed-off-by: D Scott Phillips > Cc: # 5.4.x > --- > arch/arm64/include/asm/elf.h | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h > index 97932fbf973d..463ff8f00aa7 100644 > --- a/arch/arm64/include/asm/elf.h > +++ b/arch/arm64/include/asm/elf.h > @@ -160,8 +160,18 @@ typedef struct user_fpsimd_state elf_fpregset_t; > > #define SET_PERSONALITY(ex) \ > ({ \ > + if (IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040)) \ > + preempt_disable(); \ > clear_thread_flag(TIF_32BIT); \ > current->personality &= ~READ_IMPLIES_EXEC; \ > + if (this_cpu_has_cap(ARM64_WORKAROUND_1418040)) { \ > + u64 val; \ > + val = read_sysreg(cntkctl_el1); \ > + val |= ARCH_TIMER_USR_VCT_ACCESS_EN; \ > + write_sysreg(val, cntkctl_el1); \ > + } \ > + if (IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040)) \ > + preempt_enable(); \ > }) > > /* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ > @@ -223,7 +233,17 @@ int compat_elf_check_arch(const struct elf32_hdr *); > */ > #define COMPAT_SET_PERSONALITY(ex) \ > ({ \ > + if (IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040)) \ > + preempt_disable(); \ > set_thread_flag(TIF_32BIT); \ > + if (this_cpu_has_cap(ARM64_WORKAROUND_1418040)) { \ > + u64 val; \ > + val = read_sysreg(cntkctl_el1); \ > + val &= ~ARCH_TIMER_USR_VCT_ACCESS_EN; \ > + write_sysreg(val, cntkctl_el1); \ > + } \ > + if (IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040)) \ > + preempt_enable(); \ > }) > #ifdef CONFIG_COMPAT_VDSO > #define COMPAT_ARCH_DLINFO \ I'd have opted for the use of sysreg_clear_set() instead of the open-coded RMW, as it would elide the write-back in most cases. This looks otherwise OK to me. With that fixed: Reviewed-by: Marc Zyngier 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