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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 CD35DC433DF for ; Fri, 31 Jul 2020 10:43:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 9A48F20838 for ; Fri, 31 Jul 2020 10:43:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dqPzi4vj"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="cRURwEuN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A48F20838 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject: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=YNEOp3PAZvM729PMTkBxqWw7NV1t0To+jeSQyLB4+aQ=; b=dqPzi4vjZkw7bFEdlIWZoOnaO ILp/G0tcF1sDcpFRdOje3rALseSiZ0q3/tzag8U0tfwop2/Ylfxca62jyrCJBZHv7ELgbxipN4CTT TypOyXL/ylOFLsSPqkR1zVfJQQdar/S1nBqG07eXbric3YGWHzA6/zmbgjP9BfBmB6m/YC5ghCpMo 9ft5PuZojXJ0oH8QZO0lCtiaiiII/y9U7/OJBNYLwi+rgtlhlX0RxDmB9dhDR4ntKKh0YnmqgZIvp TN4stFlyJ/osIV7zqdJ5Ka5X4jVTLyylx220GMRrRtKcNu4ZkY2me/RGzriQGn6rzX//QM2E/yuiu utpZZva3A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1STj-0001Sy-2C; Fri, 31 Jul 2020 10:41:31 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1STh-0001SD-1x for linux-arm-kernel@lists.infradead.org; Fri, 31 Jul 2020 10:41:30 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F0A7120838; Fri, 31 Jul 2020 10:41:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596192086; bh=2f9kYJoOul92c3b3g7wax6pPTRVxQi/rfoyHd6gFfas=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cRURwEuNpQkPQ++2g0gU5CPxUanSn/49MhJlGmLxxkgKoYOYERXx+WUFSmLsROlaz MjaKZwKuHNifaDwtGIVpbe+wAFuPojOBg7fII5vOeprBuigFt1FhIaPyKAnS+dh58K A1kakb8VMKtqt79Ji4Gttav/AtVsKug2y+1nz3ro= Date: Fri, 31 Jul 2020 11:41:21 +0100 From: Will Deacon To: Marc Zyngier Subject: Re: [PATCH v2 1/2] arm64: Move handling of erratum 1418040 into C code Message-ID: <20200731104121.GA26500@willie-the-truck> References: <20200731083358.50058-1-maz@kernel.org> <20200731083358.50058-2-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200731083358.50058-2-maz@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200731_064129_267250_4969B670 X-CRM114-Status: GOOD ( 22.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sai Prakash Ranjan , Suzuki K Poulose , Catalin Marinas , Stephen Boyd , dianders@google.com, kernel-team@android.com, linux-arm-kernel@lists.infradead.org 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 Fri, Jul 31, 2020 at 09:33:57AM +0100, Marc Zyngier wrote: > Instead of dealing with erratum 1418040 on each entry and exit, > let's move the handling to __switch_to() instead, which has > several advantages: > > - It can be applied when it matters (switching between 32 and 64 > bit tasks). > - It is written in C (yay!) > - It can rely on static keys rather than alternatives > > Tested-by: Sai Prakash Ranjan > Signed-off-by: Marc Zyngier > --- > arch/arm64/kernel/entry.S | 21 --------------------- > arch/arm64/kernel/process.c | 35 +++++++++++++++++++++++++++++++++++ > 2 files changed, 35 insertions(+), 21 deletions(-) [...] > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 6089638c7d43..8bbf066224ab 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -515,6 +515,40 @@ static void entry_task_switch(struct task_struct *next) > __this_cpu_write(__entry_task, next); > } > > +/* > + * ARM erratum 1418040 handling, affecting the 32bit view of CNTVCT. > + * Assuming the virtual counter is enabled at the beginning of times: > + * > + * - disable access when switching from a 64bit task to a 32bit task > + * - enable access when switching from a 32bit task to a 64bit task > + */ > +static __always_inline Do we need the __always_inline? None of the other calls from __switch_to() have it. > +void erratum_1418040_thread_switch(struct task_struct *prev, > + struct task_struct *next) > +{ > + bool prev32, next32; > + u64 val; > + > + if (!(IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040) && > + cpus_have_const_cap(ARM64_WORKAROUND_1418040))) > + return; > + > + prev32 = is_compat_thread(task_thread_info(prev)); > + next32 = is_compat_thread(task_thread_info(next)); > + > + if (prev32 == next32) > + return; > + > + val = read_sysreg(cntkctl_el1); > + > + if (prev32 & !next32) I know they're bools but this is perverse! Why can't it just be: if (next32) val &= ~ARCH_TIMER_USR_VCT_ACCESS_EN; else val |= ARCH_TIMER_USR_VCT_ACCESS_EN; ? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel