Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3300254pxb; Tue, 12 Jan 2021 11:03:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3SHZ9yYeTVa40IcscX0P+IS65fifpoGmgOW4VzRCdcNoGVn1TpQ+l/vefDAzj/8W6anRE X-Received: by 2002:a17:906:dfd3:: with SMTP id jt19mr205244ejc.64.1610478223462; Tue, 12 Jan 2021 11:03:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610478223; cv=none; d=google.com; s=arc-20160816; b=FZhMdl7cVBn3aeOQjW26DEbjCjJZyYpozuxu/Ww89C1O+r8x1lFZg57R+8geMebisL KgGLE49QDMKkD9dlpvnLCGYpVqE5u8zePALiq74a1pqyl7tLcuRSOpi0W4azgeCP7YBY AdEPYEMtCWif19MgkW1XCQzaeBjPPWl5tjej0mcsLVMlYEzwSwoGcGeTdx04waV0MIio tZTIN6DgV76H4vdHmVB4iuOkWHdyeSd+cVsXUrgvoZ4bpL817sYUVtuzZaD86yI6QDn9 g3JHdSLmoyLpJq4QZgP6rcsSVc6mOi3nrzsjQ6uHkmVqSZjk457+pFk+hjkMLngm2nOf 4UsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=SP+NUTFvp17i9S5C1CDMr1WvuTdzVkFZgv+dfka9Sqk=; b=V3P7jAToQHlbwb3tXNR9doTEAiKATFy0Xxwll6uNUtEd12fnJg4WzkxpTm0hgpi24O inBgEd8XUDa7UqCcqxH8+6tON8lDCKYRocdMlBsE7Ex0dvqIVpyOYj2Y5mfR5iZcGark nIXEO4OjSqaYwVs7d8cef6Ri3+i3H6a9jZsmsxc4pluX66vllbswczo42crRJPdhZ9Ci ZF/cIUiJJRuHcqH6mijCb7kj8nlSr1eT2E27MI1Je4AaCM9sxzEh3OwGx2ru3f7PdapE L7K4y4KFz3uljA1sd0tF3lyHWtij8IonNdMoeOGW0kgknoEiSp2Y0Bur44bXsS98MNpT w7JA== 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 fy14si1417920ejb.227.2021.01.12.11.03.19; Tue, 12 Jan 2021 11:03:43 -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 S2390934AbhALTCS (ORCPT + 99 others); Tue, 12 Jan 2021 14:02:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:41014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbhALTCR (ORCPT ); Tue, 12 Jan 2021 14:02:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B3467230F9; Tue, 12 Jan 2021 19:01:34 +0000 (UTC) Date: Tue, 12 Jan 2021 19:01:32 +0000 From: Catalin Marinas To: Andrey Konovalov Cc: Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver , Andrew Morton , Will Deacon , Andrey Ryabinin , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 05/11] kasan, arm64: allow using KUnit tests with HW_TAGS mode Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 05, 2021 at 07:27:49PM +0100, Andrey Konovalov wrote: > diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c > index 3c40da479899..57d3f165d907 100644 > --- a/arch/arm64/mm/fault.c > +++ b/arch/arm64/mm/fault.c > @@ -302,12 +302,20 @@ static void die_kernel_fault(const char *msg, unsigned long addr, > static void report_tag_fault(unsigned long addr, unsigned int esr, > struct pt_regs *regs) > { > - bool is_write = ((esr & ESR_ELx_WNR) >> ESR_ELx_WNR_SHIFT) != 0; > + static bool reported; > + bool is_write; > + > + if (READ_ONCE(reported)) > + return; > + > + if (mte_report_once()) > + WRITE_ONCE(reported, true); I guess the assumption here is that you don't get any report before the tests start and temporarily set report_once to false. It's probably fine, if we get a tag check failure we'd notice in the logs anyway. > /* > * SAS bits aren't set for all faults reported in EL1, so we can't > * find out access size. > */ > + is_write = ((esr & ESR_ELx_WNR) >> ESR_ELx_WNR_SHIFT) != 0; I now noticed, you could write this in a shorter way: is_write = !!(esr & ESR_ELx_WNR); > kasan_report(addr, 0, is_write, regs->pc); > } The patch looks fine to me. Reviewed-by: Catalin Marinas