Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp744276pxb; Thu, 25 Feb 2021 14:06:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhqSkCJafWy1JUWfwy2KXgZqprsoKhrll6HdaCKv5pENmBVkkLVQOeATt0xVOXDRnzxrbi X-Received: by 2002:a05:6402:1d9b:: with SMTP id dk27mr72750edb.209.1614290786639; Thu, 25 Feb 2021 14:06:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614290786; cv=none; d=google.com; s=arc-20160816; b=l6D5WAf5Rgb5tGshw5pX3cBsqw+Va60Iw0NswHWLqveNNU01QkyarpUKf/FjH2/Zs/ k3kcvOtpBOOVJ+0PmI9z8awoo73MeaaRmJR5nJgml92gNFxkLo9sZdlkcCnoegD01LA/ 0m1jRU0vRRUcxj2v1r/DTD8xPhGrGFOq9kAKLeATazsLHpjgAItgFpf+JBPPIrSQPpFx Ve8NopmAE5Zd8F216NQklFn7XwVGNWlnPvRXbcf8hJZHoidmEypJnav0VvLnojHOxWom 0IZeAmdUkh0w7/KA/6gxHqQev+qGu+MzvQsmHdWVgt6Yqo2v16KFEnCXccds2I2lEVm1 rIlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=EKCjfjlTCd3wpaMe+Kw4fyWwwnsfTACf9u0jXIB+SJE=; b=jnocAvSKUJ0N+29/kroLz33OHjoar3M8euXwq7bCPy+9qWiqQnzncZ/jet8XjFLToO EGo8GnjEIwkGVQ9mJkQhYqpDTQmJyt1aStvAE/AYf46yR83YR4p/D0w7FlCtcqCliLAa t38lHdZxDu9D51Dz/fgL8fbMRXCu+vDq6nL6/xgr4dzSFauAm0E7iyP7im17Cn+rDb5a AwSQxrOcRn8Rvb5uneAFkGCmPyiYgBMNL3DtL5LStvNNLmRW9seggzdD/Cvyvx/Ne2PC HbJQGrsXbHZhPXO+wxeJkKP3GDKdKOlPLbiGijzngXtF+SuWFOFOwncBm+9eZ5qsq4WG 4NeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=to2a1hhe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id he39si4349553ejc.512.2021.02.25.14.06.03; Thu, 25 Feb 2021 14:06:26 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=to2a1hhe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233974AbhBYWFT (ORCPT + 99 others); Thu, 25 Feb 2021 17:05:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:35988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233902AbhBYWFR (ORCPT ); Thu, 25 Feb 2021 17:05:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8537464F35 for ; Thu, 25 Feb 2021 22:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614290676; bh=l2PljfWdgORWpMkKP++LYTc6Q0RJUHrCOYwpRFKOcrI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=to2a1hheMyIIHIFIn+rlIDREMGnx9S2IupNO9QLyHOp6+GqNgudgeduuzAi69+AjR UeGl3PgtXS6aF5sU84VVIcIEK37A8ESHGx4fo7jikNhs14xwQP16PMnFWt485UyRsK Y9klWxVH2kgryRMTXwbDVqadCvRjq1EFGMwGU3JmRiEr0mHgW/Y52/JKfyF1A9ALk1 0dJgNWG5AinD/d6jpaIcJaQTr/dNiGtsDuZj7AxeHOmmqlR3RMs5KGUq8OOPDm9pht QEFlCQTkOaiSWpQMqZkocMehtDIy3wsVxjploP42rybIu1hVFEnNDudGsGmayZdv+i HFgsNlEZyyF9A== Received: by mail-oo1-f42.google.com with SMTP id x19so1742579ooj.10 for ; Thu, 25 Feb 2021 14:04:36 -0800 (PST) X-Gm-Message-State: AOAM5338m6Qs/CgYxk6vS8ziPF3WEPGTy9Ug4JYbRscGUnJs3xYMx50X RJqYL1YMKExTNbbUysmigw3g4IgSMC+jJeWz9xw= X-Received: by 2002:a4a:870c:: with SMTP id z12mr48017ooh.15.1614290675584; Thu, 25 Feb 2021 14:04:35 -0800 (PST) MIME-Version: 1.0 References: <20210225094324.3542511-1-arnd@kernel.org> <20210225164522.GA3554437@xps15> In-Reply-To: From: Arnd Bergmann Date: Thu, 25 Feb 2021 23:04:19 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] coresight: etm4x: work around clang-12+ build failure To: Nick Desaulniers Cc: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Nathan Chancellor , Arnd Bergmann , Mike Leach , Leo Yan , Greg Kroah-Hartman , Sai Prakash Ranjan , coresight@lists.linaro.org, Linux ARM , LKML , clang-built-linux , Bill Wendling Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2021 at 10:23 PM 'Nick Desaulniers' via Clang Built Linux wrote: > > On Thu, Feb 25, 2021 at 8:45 AM Mathieu Poirier > wrote: > > > > Good morning, > > > > On Thu, Feb 25, 2021 at 10:42:58AM +0100, Arnd Bergmann wrote: > > > From: Arnd Bergmann > > > > > > clang-12 fails to build the etm4x driver with -fsanitize=array-bounds: > > Is a sanitizer enabled, that would trap on OOB? > > > > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1310 As described over there, this happens only with the array-bounds sanitizer. Actually, looking at it again now, in the reduced test case, the inline assembly is not even parsable, it only works because it never gets emitted without -fsanitize=array-bounds, and the alternative code path is used in #define read_etm4x_sysreg_offset(offset, _64bit) \ ({ \ u64 __val; \ \ if (__builtin_constant_p((offset))) \ __val = read_etm4x_sysreg_const_offset((offset)); \ else \ __val = etm4x_sysreg_read((offset), true, (_64bit)); \ __val; \ }) read_etm4x_sysreg_const_offset() eventually turns into something like asm("msr_s " __stringify(offset)); so the offset has to be something that can be parsed by the assembler. __builtin_constant_p() checks that it is a constant value at compile-time, and in this case it can be because there is a small upper bound and clang just unrolls the loop. I don't think there is an alternative to __builtin_constant_p() that can be used to decide if the argument is something that can be used as a constant expression in an inline assembly. Arnd