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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 82944C433E0 for ; Tue, 12 Jan 2021 19:01:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C9DF323122 for ; Tue, 12 Jan 2021 19:01:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9DF323122 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1E0336B00A4; Tue, 12 Jan 2021 14:01:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18FEC6B00A6; Tue, 12 Jan 2021 14:01:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 056916B00A7; Tue, 12 Jan 2021 14:01:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id D4A1E6B00A4 for ; Tue, 12 Jan 2021 14:01:42 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3F093362E for ; Tue, 12 Jan 2021 19:01:40 +0000 (UTC) X-FDA: 77698041960.07.bath21_410f81927517 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 01BD61803FD61 for ; Tue, 12 Jan 2021 19:01:39 +0000 (UTC) X-HE-Tag: bath21_410f81927517 X-Filterd-Recvd-Size: 2746 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 19:01:38 +0000 (UTC) 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: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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