Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4395095ybb; Tue, 14 Apr 2020 06:31:43 -0700 (PDT) X-Google-Smtp-Source: APiQypLjse+XoQq6frx93ELcLV+rujbB34FFVFtkNN8Vr7fssPkgyZqFMdfkPKBkM5s3+j6ZI9L8 X-Received: by 2002:a17:906:1199:: with SMTP id n25mr158852eja.30.1586871103171; Tue, 14 Apr 2020 06:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586871103; cv=none; d=google.com; s=arc-20160816; b=ylcBirlHmTtGDgclz00DsZ553zoH9y6Rcc+z+DmY3Y7dF5QXCJktskumbAtEpaiGh1 S1FDa1zyiy7EipU7boqT8zO0dc81PRRjFj/ZYyPeYPQFPCjbCR1vxafmGnOXqx0OW7i+ S2m48SYIIyoeWKDsJEAtqDUzsce1wQfCvtkQCJT44gIU+PlDYnHMLdJgmyi+DvNmQdYV 6ZxCWU38p/ljxzEzIUjKdGyyIGOv0/CSsgxKePbWTlFZx0RBr+WhHrp8c/7O6KLvOo6U XAdBRLtjUaiOvxR7UbERHPjUIgJsOPnEeAjiNG8zq9XuxmIT2HPuq1txT3GpLOAASRVm Bhng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XGx7qFwHLiVd4V1d68uSwgIpjNRKonWDkoXdUUpJdmU=; b=PpKEzC9EOhTDY7hlq9Mo+E12GrSO21z8osfFgTnHAQYPqqOR1jez0EShHzbY7jHeJU BxE7z5mAY7JdIC0GJHnIgQWcR/vwL2Ibe0wQts3oB+473S0dBoM8x/MzPsQWBhWkUbH3 WlfvbNXzeCQNYL9xNaJlM1pT2KlvNvPWB7wEga/YQmtUqsPYqSTdSeFepPnSIu0vckHL aIiT/5rzL8dEYVHxN15SrVXRjgqRCxYFLkemPhPYd+PKmizth1M3QfOM2zX3WwECqNHG zZa4Eb2zMrU9mrbKPlbqRh23Bh9/jmDDcjInJ+kaMFe4KvLpU1CLOzzTyuaWGxHo1sA0 Dxdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=MsUxuzO8; spf=pass (google.com: best guess record for 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si8222978ejj.173.2020.04.14.06.31.19; Tue, 14 Apr 2020 06:31:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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=@google.com header.s=20161025 header.b=MsUxuzO8; spf=pass (google.com: best guess record for 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387638AbgDMSHw (ORCPT + 99 others); Mon, 13 Apr 2020 14:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2387625AbgDMSHt (ORCPT ); Mon, 13 Apr 2020 14:07:49 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87CD9C0A3BDC for ; Mon, 13 Apr 2020 11:07:49 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id v23so4868861pfm.1 for ; Mon, 13 Apr 2020 11:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XGx7qFwHLiVd4V1d68uSwgIpjNRKonWDkoXdUUpJdmU=; b=MsUxuzO8lWza4IDAgKmbcE58BeSxidJVPD8d41B6WQkHuYQiWuox58R4hrZyfYImH+ aG62uSXK90iOIw6wd/xPilPwCkapK+hPKP4pFn2CfMlIMYGiCND/S1J0Yz5/uj9vWZQb +ANK8Thwg3DqA4R5z5sF3HQGcwVTb0rUo/pFXkUlb0Tqp2xl8GlvruWuLqK6sveKzvOW cYbOgQhjtNcauJqQtCifBfn8eB+bn0G0UVG00DSR6GDHK9UMn+wHcd3K0TYWEfysj7lE QmdDQ02RPvWbZA6bOpV62Sd/ZLNdk4hQ8NCmKN5QRVwhadATPJocCJgmmEtl2lfWLwZr m6Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XGx7qFwHLiVd4V1d68uSwgIpjNRKonWDkoXdUUpJdmU=; b=S5uW6IBVagFbSnOCco76/1fmg+Z3hxVhzHoLRZWdE0y5805D7NlHoS4ccB9bWBIbhF tnPgcV/yILh7Wd5hqaC9bWN+5XJDIN55Il0akT+yAZLzsyBVhXE7vwtJGNI5/OwlCiqy D5iOKOONxh0i0nNeSxPQPaoZW1KU5lZ2E2kw0fcbvcujKP+L3PTLZiI2UadXx+6iuttX 1SON3QPuyyfOonNVEiVHb3eQs/LEhAYvQFxriz+TtAGqn3M22ffUeglkT4frnCw7QMgA 9bCWdhTfRBtoddcrmlQBFUvHC54VSfcs6C+WmuYC8ut8INxVQoYunQl/oF/K36y9qt2V 9C4A== X-Gm-Message-State: AGi0PuY9E5o0npM4G8U2LvsOh29rWM3XqAsACWEI9yFHC/sxGs7TrNlu pXOHHi+Z7HJ8EC/jPbWc+bs+ZSPVt18J1d2Wu4Rv9w== X-Received: by 2002:a63:6604:: with SMTP id a4mr17243102pgc.381.1586801268806; Mon, 13 Apr 2020 11:07:48 -0700 (PDT) MIME-Version: 1.0 References: <20200413033811.75074-1-maskray@google.com> In-Reply-To: <20200413033811.75074-1-maskray@google.com> From: Nick Desaulniers Date: Mon, 13 Apr 2020 11:07:37 -0700 Message-ID: Subject: Re: [PATCH] arm64: Delete the space separator in __emit_inst To: Fangrui Song Cc: Linux ARM , LKML , Catalin Marinas , Will Deacon , Mark Rutland , clang-built-linux , Ilie Halip , Jian Cai Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 12, 2020 at 8:38 PM 'Fangrui Song' via Clang Built Linux wrote: > > Many instances of __emit_inst(x) expand to a directive. In a few places > it is used as a macro argument, e.g. > > arch/arm64/include/asm/sysreg.h > #define __emit_inst(x) .inst (x) > > arch/arm64/include/asm/sysreg.h > #define SET_PSTATE_PAN(x) __emit_inst(0xd500401f | PSTATE_PAN | ((!!x) << PSTATE_Imm_shift)) > > arch/arm64/kvm/hyp/entry.S > ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN) > > Clang integrated assembler parses `.inst (x)` as two arguments passing > to a macro. We delete the space separator so that `.inst(x)` will be > parsed as one argument. > > Note, GNU as parsing `.inst (x)` as one argument is unintentional (for > example the x86 backend will parse the construct as two arguments). > See https://sourceware.org/bugzilla/show_bug.cgi?id=25750#c10 Thanks for the patch and for leading the discussion with the binutils developers on this curious parsing case. > > Link: https://github.com/ClangBuiltLinux/linux/issues/939 > Cc: clang-built-linux@googlegroups.com > Signed-off-by: Fangrui Song Shouldn't this have: Suggested-by: Ilie Halip Since Ilie sugguested this in https://github.com/ClangBuiltLinux/linux/issues/939#issuecomment-601776123? > --- > arch/arm64/include/asm/sysreg.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h > index ebc622432831..af21e2ec5e3e 100644 > --- a/arch/arm64/include/asm/sysreg.h > +++ b/arch/arm64/include/asm/sysreg.h > @@ -49,7 +49,9 @@ > #ifndef CONFIG_BROKEN_GAS_INST > > #ifdef __ASSEMBLY__ > -#define __emit_inst(x) .inst (x) > +// The space separator is omitted so that __emit_inst(x) can be parsed as > +// either a directive or a macro argument. > +#define __emit_inst(x) .inst(x) > #else > #define __emit_inst(x) ".inst " __stringify((x)) "\n\t" What happens if someone starts using `__emit_inst` from inline assembly, and passes that subexpression to a macro? There are no users today in arch/arm64/, but I think it's better to change both. With this applied on -next, and testing via: $ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make LLVM=1 LLVM_IAS=1 -j71 defconfig $ qemu-system-aarch64 -kernel arch/arm64/boot/Image.gz -machine virt -cpu cortex-a57 -nographic --append "console=ttyAMA0" -m 2048 -initrd I was able to build and boot, modulo: https://github.com/ClangBuiltLinux/linux/issues/988 (new) https://github.com/ClangBuiltLinux/linux/issues/716 https://github.com/ClangBuiltLinux/linux/issues/510 (more specific to LLD than AS) so we're pretty close to being able to assemble an arm64 defconfig with Clang. -- Thanks, ~Nick Desaulniers