Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp531993ybz; Wed, 15 Apr 2020 13:27:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKbpfnGaqvWL24Ow/vY66wRwwPm51NnFUVhmDCINvH0Jz4AludoB3/AI7eCX5rjl9VaWFij X-Received: by 2002:aa7:c497:: with SMTP id m23mr3229541edq.155.1586982431255; Wed, 15 Apr 2020 13:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586982431; cv=none; d=google.com; s=arc-20160816; b=u5AGRzZa+Cvoq84GXifCycrnGrek3r4z/3Y27w533EtHEkIei9yTuHN/tcPBXhhM6k CBqBmOy9Jgk5nrKkUhl3ooeExOCHpKt3sZfF+K84plGUWLeoPhrqRjBxkPOjacFXQ9Ia 1Jv8ylQzHabWCaSXeJqsyTY/YJW9ydvmVBioUeT69dHRVh+zvL8Uct8aoJXX5m0mG/3t 6Tgl5KyPcdFROixKFR4nylyvWp1eb03ZFoFspaTOtOQWyMlIv1/Qrg4tqvH9VWfWF09p Y/4lYLRzSXWStf2AO92aqEgs/w99fnjLoMmsQVabbxWPu0WnqDZ5DhtHRzlW0JEjD6te rFVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=br9WOVY5u2ADvGjGMhdFs1wXIc1AMol/eI2z78EwOsM=; b=omsOCqnTS/UYE5Rc/W8EF5ea1SwMC8FL2cLjnphlUb7gVYMJfYIQC4svQDRbgTI+en O8HKr9Vq+qBSMzU5AiIdkRg9DeLZnhLTLOvU9S/SNIV4HHSUWSzO40LKy/M2OrCvwWsn Np5XQhvB13mM87Vf+Z4gSwdVxdhEtTpThq9QFm1nHOt4mELd3hDPBQCP2UbXbnmKzKco 0WreokG909HINTTWxFvyvjx9subxIoKdcb+bILPpT+nCDdiueM5XLvBCMSFbFUi7EGO8 ryfTe9LxU2rqvb5L0RJrtXih27D0R2qnPrH7yKIDxVTISDObU2KqyaQqya0RgT8yKbOv npGw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r8si11276563edl.85.2020.04.15.13.26.46; Wed, 15 Apr 2020 13:27:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438059AbgDNJ7L (ORCPT + 99 others); Tue, 14 Apr 2020 05:59:11 -0400 Received: from foss.arm.com ([217.140.110.172]:52210 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438040AbgDNJ7J (ORCPT ); Tue, 14 Apr 2020 05:59:09 -0400 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 605841FB; Tue, 14 Apr 2020 02:59:08 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3EB863F6C4; Tue, 14 Apr 2020 02:59:07 -0700 (PDT) Date: Tue, 14 Apr 2020 10:59:04 +0100 From: Mark Rutland To: Fangrui Song Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Catalin Marinas , Will Deacon , clang-built-linux@googlegroups.com Subject: Re: [PATCH] arm64: Delete the space separator in __emit_inst Message-ID: <20200414095904.GB1278@C02TD0UTHF1T.local> References: <20200413033811.75074-1-maskray@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200413033811.75074-1-maskray@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Fangrui, On Sun, Apr 12, 2020 at 08:38:11PM -0700, Fangrui Song 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. I'm a little confused by the above; sorry if the below sounds stupid or pedantic, but I just want to make sure I've understood the problem correctly. For the above, ALTERNATIVE() and SET_PSTATE_PAN() are both preprocessor macros, so I would expect those to be expanded before either the integrated assembler or an external assembler consumes any of the assembly (and both would see the same expanded text). Given that, I'm a bit confused as to why the integrated assembly would have an impact on preprocessing. Does compiling the pre-processed source using the integrated assembler result in the same behaviour? Can we see the expanded text to make that clear? ... at what stage exactly does this go wrong? Thanks, Mark. > > 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 > > Link: https://github.com/ClangBuiltLinux/linux/issues/939 > Cc: clang-built-linux@googlegroups.com > Signed-off-by: Fangrui Song > --- > 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" > #endif > -- > 2.26.0.110.g2183baf09c-goog >