Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp603929rwj; Thu, 22 Dec 2022 12:00:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXv03GqWz6cwXzw3KS9O3dDD7KULu7E3+nB5UXVj8gEuiYSyV4sYA/ltZ+f378DXhJBpXFWg X-Received: by 2002:a05:6a20:a8a2:b0:b2:310a:9fd2 with SMTP id ca34-20020a056a20a8a200b000b2310a9fd2mr13738303pzb.43.1671739214461; Thu, 22 Dec 2022 12:00:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671739214; cv=none; d=google.com; s=arc-20160816; b=auBLdp2luO+mUpqW0jnPK04cXyfCttbFIY5X4derMiHdeOPS+SZAM9of3+gsClbG74 WmZmCgDGVedSEqHjfLz9NbFc3YKmico9pfb19aRTrOC7EHiRMGr7Ua8caYgmmpwCpN2E 5Hr5gjaWQp3/a1F1T06+9flyIoAp/pONt6FQ7qnvtWx4vrPY4Gg0hGza1IKCK9AHC5Yt YTqLroqH9bTw1DHpdNu9VbYl1EaZuubrdxRpk0PqH72y0g2foMyWQYoilTZHcffejw2+ 2PGsRZ99fAbnFMSEuVDQfUr+lZkXvOAEtlt+sIJDw5GPfIjF4cPC5J5vE4SyrPM1jmC8 d+Wg== 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=/BQ9n0kH0mbMHZf64/LlHldiSHJ2YosTB1WTP5AW4Lc=; b=gwAJLSoQHx/oK+qIOMBx4N4IaSifF7TxTqrg+4BsrNq8Qi3vBTQSbS/2AkMMsNbzFn 9L7QvqzPxJ9ZXRaf/lkVwVlmEVA6kaIko3MHXjPCzXGbl5uDNFkQD4f2KZcRcqvQ50Xc 8JqlAjWMUwCDA/8lLAh2LADoHul99d/+DgmEuj/mbqI6RnpPEAGctlMYIJiXmXfxnVXQ Qu2C6XctnHHKfIVkAe08NlFDzQgd+L9ZecSHgXqtPmrDTVC6wa2usZGs/bxTqBM1w8x6 N159Gp4vIMVgH1beIRvaLLVEZvhonEPCUZUm6Da6KPtloIc6ZSK2Ut5I8/yuTAlGUBdr vIEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hbQD11e1; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w19-20020a056a0014d300b0057fd2fa85fcsi1608869pfu.81.2022.12.22.11.59.54; Thu, 22 Dec 2022 12:00:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hbQD11e1; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230479AbiLVTwm (ORCPT + 99 others); Thu, 22 Dec 2022 14:52:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbiLVTwl (ORCPT ); Thu, 22 Dec 2022 14:52:41 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 549A117401 for ; Thu, 22 Dec 2022 11:52:39 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id v3so1996449pgh.4 for ; Thu, 22 Dec 2022 11:52:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/BQ9n0kH0mbMHZf64/LlHldiSHJ2YosTB1WTP5AW4Lc=; b=hbQD11e1hF4r0xWaBVvu/F1S8mQcnYHXN3WCkQUqrRecdfPVpmqEmcIdXeZ1Vcumv0 RgtJc4xnzZMdqdrDMqr2zjK1byRueshhIcwQKxLogZg/ENPE+ZR5xFk7OiSBRIm9CCs0 oPvYBSG1ecgPXamSUqbXaCTdoGEp9HtePiNoONh7geNYvnSMwh3qyKKJcC5J2KhSXnQY krDpQEE2oeOd9kWdupcomaSxhFuxgqz+ORabvcf/xgX1HXCfECQuQyywqL61+qpdT+r8 pVRaclu4S//C4T64ixOvQ+63jc650o5gu6llKkzRkg1f3ZwQswrCwvME6hBeCqxxw/Up YGGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/BQ9n0kH0mbMHZf64/LlHldiSHJ2YosTB1WTP5AW4Lc=; b=E1ZKzU+Ra5CDjhmpEn9xLDa+5ARBEjC+p+zyRnynSkppgBI0t1rOyo3C2yiB5Ewa6H f5pM7veZA2tslhrTzYeIurptaIj3BwpX7+53lOpKD3C4wQYIeRjE42KVesOv0nSgwI0/ uaGe5IQCHptRXSOElp51mGZo54YUwOAleb+rC2kTwO+cnODV7KaV++G3AmT/CtSCvtJC DmFz14Mk28QCDPBg+x446A6gViCjEFRS5x1SlEJaCxjsoAZrywXSzdwpLmp1tmmHcCEG psOFKLQcjbeecBgJUNbbEh35mLePMDdj7viZDOeWtbZrREsz7JU/V1sq+ot8KGFnADke aa2A== X-Gm-Message-State: AFqh2krJxywTBunPqiI2i1AfTV80alc6hKfEd6llH8klQ7WUS1q68YLV IawO4oIQTiYYUVaLTTegb6IcIyXnvYX+rnLF06ybRA== X-Received: by 2002:a63:c50:0:b0:494:7a78:4bb0 with SMTP id 16-20020a630c50000000b004947a784bb0mr278550pgm.427.1671738758528; Thu, 22 Dec 2022 11:52:38 -0800 (PST) MIME-Version: 1.0 References: <20221222193039.2267074-1-nathan@kernel.org> In-Reply-To: <20221222193039.2267074-1-nathan@kernel.org> From: Nick Desaulniers Date: Thu, 22 Dec 2022 11:52:27 -0800 Message-ID: Subject: Re: [PATCH] ARM: Reduce __thumb2__ definition to crypto files that require it To: Nathan Chancellor Cc: Russell King , Arnd Bergmann , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, "kernelci.org bot" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Dec 22, 2022 at 11:30 AM Nathan Chancellor wrote: > > Commit 1d2e9b67b001 ("ARM: 9265/1: pass -march= only to compiler") added > a __thumb2__ define to ASFLAGS to avoid build errors in the crypto code, > which relies on __thumb2__ for preprocessing. Commit 59e2cf8d21e0 ("ARM: > 9275/1: Drop '-mthumb' from AFLAGS_ISA") followed up on this by removing > -mthumb from AFLAGS so that __thumb2__ would not be defined when the > default target was ARMv7 or newer. > > Unfortunately, the second commit's fix assumes that the toolchain > defaults to -mno-thumb / -marm, which is not the case for Debian's > arm-linux-gnueabihf target, which defaults to -mthumb: > > $ echo | arm-linux-gnueabihf-gcc -dM -E - | grep __thumb > #define __thumb2__ 1 > #define __thumb__ 1 Interesting, that was hard to foresee in review of 1d2e9b67b001 and 59e2cf8d21e0. FWIW, their non-hf target does not. $ echo | arm-linux-gnueabi-gcc -dM -E - | grep __thumb $ > > This target is used by several CI systems, which will still see > redefined macro warnings, despite '-mthumb' not being present in the > flags: > > : warning: "__thumb2__" redefined > : note: this is the location of the previous definition > > Remove the global AFLAGS __thumb2__ define and move it to the crypto > folder where it is required by the imported OpenSSL algorithms; the rest > of the kernel should use the internal CONFIG_THUMB2_KERNEL symbol to > know whether or not Thumb2 is being used or not. Be sure that __thumb2__ > is undefined first so that there are no macro redefinition warnings. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1772 > Reported-by: "kernelci.org bot" > Suggested-by: Ard Biesheuvel > Signed-off-by: Nathan Chancellor Thanks Nathan and Ard. I ran the following tests: 1. build w/ llvm stock config CONFIG_THUMB2_KERNEL=y kernel. 2. build w/ llvm+debian's OOT patch https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/-/raw/622dbcbd40b316ed3905a2d25d9623544a06e6b1/debian/patches/930008-arm.diff CONFIG_THUMB2_KERNEL=y kernel. 3. check that -U removes from being set by preprocessor for both debian's arm-linux-gnueabihf-gcc and clang -mthumb $ echo | arm-linux-gnueabihf-gcc -dM -E - | grep __thumb #define __thumb2__ 1 #define __thumb__ 1 $ echo | arm-linux-gnueabihf-gcc -dM -E - -U__thumb2__ | grep __thumb #define __thumb__ 1 $ echo | clang --target=arm-linux-gnueabihf -mthumb -dM -E - -mcpu=cortex-a7 | grep __thumb #define __thumb2__ 1 #define __thumb__ 1 $ echo | clang --target=arm-linux-gnueabihf -mthumb -dM -E - -mcpu=cortex-a7 -U__thumb2__ | grep __thumb #define __thumb__ 1 Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers > --- > arch/arm/Makefile | 2 +- > arch/arm/crypto/Makefile | 7 ++++++- > 2 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/Makefile b/arch/arm/Makefile > index 4067f5169144..955b0362cdfb 100644 > --- a/arch/arm/Makefile > +++ b/arch/arm/Makefile > @@ -132,7 +132,7 @@ AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) > > ifeq ($(CONFIG_THUMB2_KERNEL),y) > CFLAGS_ISA :=-Wa,-mimplicit-it=always $(AFLAGS_NOWARN) > -AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb -D__thumb2__=2 > +AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb > CFLAGS_ISA +=-mthumb > else > CFLAGS_ISA :=$(call cc-option,-marm,) $(AFLAGS_NOWARN) > diff --git a/arch/arm/crypto/Makefile b/arch/arm/crypto/Makefile > index 971e74546fb1..13e62c7c25dc 100644 > --- a/arch/arm/crypto/Makefile > +++ b/arch/arm/crypto/Makefile > @@ -53,7 +53,12 @@ $(obj)/%-core.S: $(src)/%-armv4.pl > > clean-files += poly1305-core.S sha256-core.S sha512-core.S > > +aflags-thumb2-$(CONFIG_THUMB2_KERNEL) := -U__thumb2__ -D__thumb2__=1 > + > +AFLAGS_sha256-core.o += $(aflags-thumb2-y) > +AFLAGS_sha512-core.o += $(aflags-thumb2-y) > + > # massage the perlasm code a bit so we only get the NEON routine if we need it > poly1305-aflags-$(CONFIG_CPU_V7) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=5 > poly1305-aflags-$(CONFIG_KERNEL_MODE_NEON) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=7 > -AFLAGS_poly1305-core.o += $(poly1305-aflags-y) > +AFLAGS_poly1305-core.o += $(poly1305-aflags-y) $(aflags-thumb2-y) > > base-commit: 71a7507afbc3f27c346898f13ab9bfd918613c34 > -- > 2.39.0 > -- Thanks, ~Nick Desaulniers