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 84549CD5BC8 for ; Tue, 26 May 2026 18:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=O5eXUrKnetgtJ3OgaH9ilju2x9X0gZP/DkKCYpLF5xo=; b=kBi0W/ZrchgFKNcy4x7C4SqwtC wCxAQ3XZ8lNWX9DmhPoS9ekikf1D6kG4id71GKZ7fEReCScCAQze2Y0EL7pF7HlTDLtT2b8r6QKGw uQqNEE03N2EyMvktd8Re5kQuYu0fNsIezFvgqV4wIMO0PHKuyQAk1w18AvJqMCIZbI2jnTw6bATbK mxbxUv/FCRqETarJpCKjb/xYp0mTiG67bJJqkR937xuP1NQNAJZrPKy6DZQghgCK5Fswh9vqGWBvy LQHmhJ0sQxKt5YLcBN5QWHJnhEs9Uoj9c5CFbsw3ek4HAGOFv6mIzhibLg7XD6VEen2SrFsZMeo2j YzpxN78w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRwX5-00000002r5m-1fxv; Tue, 26 May 2026 18:29:39 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wRwX2-00000002r5I-3qWr for linux-arm-kernel@lists.infradead.org; Tue, 26 May 2026 18:29:38 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4EE702936; Tue, 26 May 2026 11:29:30 -0700 (PDT) Received: from arm.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CB51C3F7B4; Tue, 26 May 2026 11:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779820175; bh=KpUppVZ8QZSoZsraIQoIJK5QdakJlsWa/Qre1zpsV2A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N4EdRD/0ShkZ57IyNX70SdcB/Q5k0LEXw52dLQVujI+Vwslvq6V1hDq1tpeG1/aaX BAZ3BhKUpKgUUaSLG9f2Swj9DLuk3/9X8+1V4sGBWT+MZ8xj7+w4G+uyn9TryisCLu ucEf7pUjmBDQD08PtnyFBfYqcdTlbaDowEHWfCLU= Date: Tue, 26 May 2026 19:29:24 +0100 From: Catalin Marinas To: Maciej Wieczor-Retman Cc: Will Deacon , Jonathan Corbet , Shuah Khan , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Andrew Morton , Jan Kiszka , Kieran Bingham , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Samuel Holland , Maciej Wieczor-Retman , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, workflows@vger.kernel.org, linux-mm@kvack.org, llvm@lists.linux.dev Subject: Re: [PATCH v12 01/15] kasan: sw_tags: Use arithmetic shift for shadow computation Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260526_112937_040070_AC2B2C4C X-CRM114-Status: GOOD ( 16.48 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 30, 2026 at 02:33:05PM +0000, Maciej Wieczor-Retman wrote: > diff --git a/Documentation/arch/arm64/kasan-offsets.sh b/Documentation/arch/arm64/kasan-offsets.sh > index 2dc5f9e18039..ce777c7c7804 100644 > --- a/Documentation/arch/arm64/kasan-offsets.sh > +++ b/Documentation/arch/arm64/kasan-offsets.sh > @@ -5,8 +5,12 @@ > > print_kasan_offset () { > printf "%02d\t" $1 > - printf "0x%08x00000000\n" $(( (0xffffffff & (-1 << ($1 - 1 - 32))) \ > - - (1 << (64 - 32 - $2)) )) > + if [[ $2 -ne 4 ]] then Nitpick: does this need a semicolon before 'then'? I can see Sashiko raised it here: https://sashiko.dev/#/patchset/cover.1774872838.git.m.wieczorretman@pm.me > + printf "0x%08x00000000\n" $(( (0xffffffff & (-1 << ($1 - 1 - 32))) \ > + - (1 << (64 - 32 - $2)) )) > + else > + printf "0x%08x00000000\n" $(( (0xffffffff & (-1 << ($1 - 1 - 32))) )) > + fi > } > > echo KASAN_SHADOW_SCALE_SHIFT = 3 [...] > diff --git a/scripts/gdb/linux/kasan.py b/scripts/gdb/linux/kasan.py > index 56730b3fde0b..4b86202b155f 100644 > --- a/scripts/gdb/linux/kasan.py > +++ b/scripts/gdb/linux/kasan.py > @@ -7,7 +7,8 @@ > # > > import gdb > -from linux import constants, mm > +from linux import constants, utils, mm > +from ctypes import c_int64 as s64 > > def help(): > t = """Usage: lx-kasan_mem_to_shadow [Hex memory addr] > @@ -39,6 +40,8 @@ class KasanMemToShadow(gdb.Command): > else: > help() > def kasan_mem_to_shadow(self, addr): > + if constants.CONFIG_KASAN_SW_TAGS and not utils.is_target_arch('x86'): Does this need to be constants.LX_CONFIG_KASAN_SW_TAGS? I don't claim I fully understand this script but the other constants.* use LX_*. > + addr = s64(addr) > return (addr >> self.p_ops.KASAN_SHADOW_SCALE_SHIFT) + self.p_ops.KASAN_SHADOW_OFFSET And, again, Sashiko mentions that the bitwise right shift here will fail after the cast to c_int64. I just tried this in python: >>> from ctypes import c_int64 as s64 >>> s64(0xffff000008eca008) >> 4 Traceback (most recent call last): File "", line 1, in s64(0xffff000008eca008) >> 4 ~~~~~~~~~~~~~~~~~~~~~~~~^^~~ TypeError: unsupported operand type(s) for >>: 'c_long' and 'int' I guess it's hidden by the wrong check on constants.CONFIG_KASAN_SW_TAGS. Otherwise I think the changes are fine. If you fix the above, feel free to add: Acked-by: Catalin Marinas