Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp671439pxb; Tue, 9 Feb 2021 09:31:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmoDquPol6dmIswWtDX9REu5SRDSmAk37+OLBCunxai22zqLhegdyoAAelV5rbcA3MmMRO X-Received: by 2002:a17:907:724a:: with SMTP id ds10mr22647832ejc.28.1612891887549; Tue, 09 Feb 2021 09:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612891887; cv=none; d=google.com; s=arc-20160816; b=xT50zmuUroufKaUX7M+q8/ABrDI1lU10lX49VaaiOtEDEJToaNt8gO15l3x509zCei xpTQumb/hocE3K9DHRsKtc7AVLnbjIK9ZJdPcdANNICgmtw8A2kT6pUSivjiwVxYdcO4 vh1GcxIrG8AAnCJDIPTzenDzuf3QQm/nofui1No8GIgxy3PFHipkFGTG3Y/lFXJsAcLv TZp6f1Dbm4qx2QEAhsV7m2gb5ENQ72pbFm2T58SWJhlOO9NKETVH56m9N7Rcg1YRmz6H AJCriOUef2TV+7sSXD8U+kBAtA+yBlLy3bdQQVezjrohIINkbEBnidOd76CjtPBKmpN2 jNoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=y3Jn7vUyJMqJR+8ePjV2FthkaY1io0EJOa7ZnDuK/TE=; b=w23yPU5undPbtq0gwCcNY2sEu/jNoxHCvwSzZbfJYhM6LLKD2HEPhtRoAFxzlFc6uk 49JGWyquD7jSf6TDU6fBRzIun/OqP8K7LbE6mVmWffFTvWmGNmXN/ZIzA8Cvhmaf8qX4 1gRGGj4dC5H8/33256ZQx+NeL9jl+R3OPQrS7LNHsucxU7CXK3m2YNB2V+wpFnVofvdY QHU7Y4oFVG2GvxEdDfcgvepe9Sw6kBOOo7waUA/SJGYfubQsr/35mqUoQrEaBRcCxw2c /MG4m05sjdz0f7/hhi+y4KaP5rTHpIPbHVr2gEhsgFXn6j5LYJ1vJ/eJ6aFR7jnFJ5lD utzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si14887055edi.590.2021.02.09.09.31.01; Tue, 09 Feb 2021 09:31:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233046AbhBIR3e (ORCPT + 99 others); Tue, 9 Feb 2021 12:29:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:57048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233142AbhBIR3H (ORCPT ); Tue, 9 Feb 2021 12:29:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C72D964E9C; Tue, 9 Feb 2021 17:28:24 +0000 (UTC) Date: Tue, 9 Feb 2021 17:28:22 +0000 From: Catalin Marinas To: Lorenzo Pieralisi Cc: Vincenzo Frascino , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Andrew Morton , Will Deacon , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Andrey Konovalov Subject: Re: [PATCH v12 6/7] arm64: mte: Save/Restore TFSR_EL1 during suspend Message-ID: <20210209172821.GI1435@arm.com> References: <20210208165617.9977-1-vincenzo.frascino@arm.com> <20210208165617.9977-7-vincenzo.frascino@arm.com> <20210209115533.GE1435@arm.com> <20210209143328.GA27791@e121166-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210209143328.GA27791@e121166-lin.cambridge.arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 09, 2021 at 02:33:28PM +0000, Lorenzo Pieralisi wrote: > On Tue, Feb 09, 2021 at 11:55:33AM +0000, Catalin Marinas wrote: > > On Mon, Feb 08, 2021 at 04:56:16PM +0000, Vincenzo Frascino wrote: > > > When MTE async mode is enabled TFSR_EL1 contains the accumulative > > > asynchronous tag check faults for EL1 and EL0. > > > > > > During the suspend/resume operations the firmware might perform some > > > operations that could change the state of the register resulting in > > > a spurious tag check fault report. > > > > > > Save/restore the state of the TFSR_EL1 register during the > > > suspend/resume operations to prevent this to happen. > > > > Do we need a similar fix for TFSRE0_EL1? We get away with this if > > suspend is only entered on the idle (kernel) thread but I recall we > > could also enter suspend on behalf of a user process (I may be wrong > > though). > > Yes, when we suspend the machine to RAM, we execute suspend on behalf > on a userspace process (but that's only running on 1 cpu, the others > are hotplugged out). > > IIUC (and that's an if) TFSRE0_EL1 is checked on kernel entry so I don't > think there is a need to save/restore it (just reset it on suspend > exit). You are right, we don't check TFSRE0_EL1 on return to user, only clear it, so no need to do anything on suspend/resume. > TFSR_EL1, I don't see a point in saving/restoring it (it is a bit > per-CPU AFAICS) either, IMO we should "check" it on suspend (if it is > possible in that context) and reset it on resume. I think this should work. > I don't think though you can "check" with IRQs disabled so I suspect > that TFSR_EL1 has to be saved/restored (which means that there is a > black out period where we run kernel code without being able to detect > faults but there is no solution to that other than delaying saving the > value to just before calling into PSCI). Likewise on resume from low > power. It depends on whether kasan_report can be called with IRQs disabled. I don't see why not, so if this works I'd rather just call mte_check_async (or whatever it's called) on the suspend path and zero the register on resume (mte_suspend_exit). We avoid any saving of the state. -- Catalin