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=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 CCCE0C433ED for ; Thu, 29 Apr 2021 17:39:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 4087F61400 for ; Thu, 29 Apr 2021 17:39:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4087F61400 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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=desiato.20200630; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LcPvhZCZctvQb8Q8VXt8So0ZoYvgcT0wq2TaLS/WwSE=; b=XwvyueH3NcV4MbJu/8hUT9Vqj 2Y1hg6AOW/grYWmuZujg8iT63JjhhQATgcNk1ONJ3ZFQKZY5MT9BRoQEG15JYqyf6IcsWhmOWGRX4 wQvJsWrb6Sj4rSsvGc7aqz20uYbkpCcVtG4NvFvdQeZFzblG+6LnjjzifHjSqPUBp4S7pJG8XvM4x 7fExzB4UGOl1NSvr0wVMk9sLetEkV+o2DMqs1yL/rCbJKJmqAbS+Jtv5pYqpK66Er5iNNbIvROGkD P/ScVsKceRquJ480a4yD+Yqic1wNP7STs89iOdQMqQI2PiUw4749TxcM9lHOzh5iZwoE1JzAq2fSi kAnoRrD4Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lcAbq-0067zo-Oc; Thu, 29 Apr 2021 17:37:54 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lcAbo-0067zj-Ru for linux-arm-kernel@desiato.infradead.org; Thu, 29 Apr 2021 17:37:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=G7c6opEVNW2Rh0QBpdBC/Ina5SLtVEYeV/ydtSgA7c0=; b=GHGcisx8yFr/8264AdE0b3lyqm xunjvSNzW2KYtrMSL6IveywBPA4FxYtmwRDsgtFQzxMUA6NwQAxG2dV5dJZpvrU+rxM5Z21qk6PNf FbtyT/0RleJRyCfpk6QATCpgEFqa4hm3pGs+SLOYp1eCkeQOOEiJNgLC1As1Qdv53+novsASmYwd9 J2cEotv2k8TOGZVXg9GjfcYERKpgQpv0Njy+4KrMQMBoaFDRIniuzzO+8wtREiynNspAvjnBLtmu+ asTrMbtFC8lh7mCOcV1wnQwAzy9i6Q27EniEL/X4/5+mquJVLEfu8t6oUfcEAXkeRJ2lMUciDTgjO 7wotcpfg==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lcAbl-000p8X-Ti for linux-arm-kernel@lists.infradead.org; Thu, 29 Apr 2021 17:37:51 +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 181881FB; Thu, 29 Apr 2021 10:37:42 -0700 (PDT) Received: from [10.57.61.145] (unknown [10.57.61.145]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B102E3F70D; Thu, 29 Apr 2021 10:37:39 -0700 (PDT) Subject: Re: [PATCH] [v2] coresight: etm4x: avoid build failure with unrolled loops To: Arnd Bergmann , Mathieu Poirier , Alexander Shishkin , Nathan Chancellor , Nick Desaulniers Cc: Arnd Bergmann , Mike Leach , Leo Yan , Greg Kroah-Hartman , Sai Prakash Ranjan , Qi Liu , Tingwei Zhang , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com References: <20210429145752.3218324-1-arnd@kernel.org> From: Suzuki K Poulose Message-ID: Date: Thu, 29 Apr 2021 18:37:38 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210429145752.3218324-1-arnd@kernel.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210429_103750_082652_C45B42DD X-CRM114-Status: GOOD ( 14.74 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Arnd On 29/04/2021 15:57, Arnd Bergmann wrote: > From: Arnd Bergmann > > clang-12 fails to build the etm4x driver with -fsanitize=array-bounds, > where it decides to unroll certain loops in a way that result in a > C variable getting put into an inline assembly > > :1:7: error: expected constant expression in '.inst' directive > .inst (0xd5200000|((((2) << 19) | ((1) << 16) | (((((((((((0x160 + (i * 4))))) >> 2))) >> 7) & 0x7)) << 12) | ((((((((((0x160 + (i * 4))))) >> 2))) & 0xf)) << 8) | (((((((((((0x160 + (i * 4))))) >> 2))) >> 4) & 0x7)) << 5)))|(.L__reg_num_x8)) > ^ > drivers/hwtracing/coresight/coresight-etm4x-core.c:702:4: note: while in macro instantiation > etm4x_relaxed_read32(csa, TRCCNTVRn(i)); > ^ > drivers/hwtracing/coresight/coresight-etm4x.h:403:4: note: expanded from macro 'etm4x_relaxed_read32' > read_etm4x_sysreg_offset((offset), false))) > ^ > drivers/hwtracing/coresight/coresight-etm4x.h:383:12: note: expanded from macro 'read_etm4x_sysreg_offset' > __val = read_etm4x_sysreg_const_offset((offset)); \ > ^ > drivers/hwtracing/coresight/coresight-etm4x.h:149:2: note: expanded from macro 'read_etm4x_sysreg_const_offset' > READ_ETM4x_REG(ETM4x_OFFSET_TO_REG(offset)) > ^ > drivers/hwtracing/coresight/coresight-etm4x.h:144:2: note: expanded from macro 'READ_ETM4x_REG' > read_sysreg_s(ETM4x_REG_NUM_TO_SYSREG((reg))) > ^ > arch/arm64/include/asm/sysreg.h:1108:15: note: expanded from macro 'read_sysreg_s' > asm volatile(__mrs_s("%0", r) : "=r" (__val)); \ > ^ > arch/arm64/include/asm/sysreg.h:1074:2: note: expanded from macro '__mrs_s' > " mrs_s " v ", " __stringify(r) "\n" \ > ^ > > This only happened in a few loops in which the array bounds sanitizer > added a special case for an array overflow that clang determined to be > possible, but any compiler is free to unroll any of the loops in the > same way that breaks the sysreg macros. > > Introduce helper functions that perform a sysreg access with a > non-constant register number and use them in each call that passes > a loop counter. You don't need to add this special helper. We have the exact infrastructure already. So these could simply be replaced with: csdev_access_xxx(csa, ...) see : include/linux/coresight.h Cheers Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel