From: Catalin Marinas <catalin.marinas@arm.com>
To: Fangrui Song <maskray@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Ilie Halip <ilie.halip@gmail.com>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-kernel@vger.kernel.org, Jian Cai <jiancai@google.com>,
clang-built-linux@googlegroups.com, Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] arm64: Delete the space separator in __emit_inst
Date: Wed, 15 Apr 2020 13:07:52 +0100 [thread overview]
Message-ID: <20200415120752.GD6526@gaia> (raw)
In-Reply-To: <20200414163255.66437-1-maskray@google.com>
On Tue, Apr 14, 2020 at 09:32:55AM -0700, Fangrui Song wrote:
> In assembly, many instances of __emit_inst(x) expand to a directive. In
> a few places __emit_inst(x) is used as an assembler macro argument. For
> example, in arch/arm64/kvm/hyp/entry.S
>
> ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN)
>
> expands to the following by the C preprocessor:
>
> alternative_insn nop, .inst (0xd500401f | ((0) << 16 | (4) << 5) | ((!!1) << 8)), 4, 1
>
> Both comma and space are separators, with an exception that content
> inside a pair of parentheses/quotes is not split, so the clang
> integrated assembler splits the arguments to:
>
> nop, .inst, (0xd500401f | ((0) << 16 | (4) << 5) | ((!!1) << 8)), 4, 1
>
> GNU as preprocesses the input with do_scrub_chars(). Its arm64 backend
> (along with many other non-x86 backends) sees:
>
> alternative_insn nop,.inst(0xd500401f|((0)<<16|(4)<<5)|((!!1)<<8)),4,1
> # .inst(...) is parsed as one argument
>
> while its x86 backend sees:
>
> alternative_insn nop,.inst (0xd500401f|((0)<<16|(4)<<5)|((!!1)<<8)),4,1
> # The extra space before '(' makes the whole .inst (...) parsed as two arguments
>
> The non-x86 backend's behavior is considered unintentional
> (https://sourceware.org/bugzilla/show_bug.cgi?id=25750).
> So drop the space separator inside `.inst (...)` to make the clang
> integrated assembler work.
>
> Suggested-by: Ilie Halip <ilie.halip@gmail.com>
> Signed-off-by: Fangrui Song <maskray@google.com>
> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> Link: https://github.com/ClangBuiltLinux/linux/issues/939
Queued for 5.7. Thanks.
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: Fangrui Song <maskray@google.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Nick Desaulniers <ndesaulniers@google.com>,
clang-built-linux@googlegroups.com,
Ilie Halip <ilie.halip@gmail.com>, Jian Cai <jiancai@google.com>
Subject: Re: [PATCH v2] arm64: Delete the space separator in __emit_inst
Date: Wed, 15 Apr 2020 13:07:52 +0100 [thread overview]
Message-ID: <20200415120752.GD6526@gaia> (raw)
In-Reply-To: <20200414163255.66437-1-maskray@google.com>
On Tue, Apr 14, 2020 at 09:32:55AM -0700, Fangrui Song wrote:
> In assembly, many instances of __emit_inst(x) expand to a directive. In
> a few places __emit_inst(x) is used as an assembler macro argument. For
> example, in arch/arm64/kvm/hyp/entry.S
>
> ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN)
>
> expands to the following by the C preprocessor:
>
> alternative_insn nop, .inst (0xd500401f | ((0) << 16 | (4) << 5) | ((!!1) << 8)), 4, 1
>
> Both comma and space are separators, with an exception that content
> inside a pair of parentheses/quotes is not split, so the clang
> integrated assembler splits the arguments to:
>
> nop, .inst, (0xd500401f | ((0) << 16 | (4) << 5) | ((!!1) << 8)), 4, 1
>
> GNU as preprocesses the input with do_scrub_chars(). Its arm64 backend
> (along with many other non-x86 backends) sees:
>
> alternative_insn nop,.inst(0xd500401f|((0)<<16|(4)<<5)|((!!1)<<8)),4,1
> # .inst(...) is parsed as one argument
>
> while its x86 backend sees:
>
> alternative_insn nop,.inst (0xd500401f|((0)<<16|(4)<<5)|((!!1)<<8)),4,1
> # The extra space before '(' makes the whole .inst (...) parsed as two arguments
>
> The non-x86 backend's behavior is considered unintentional
> (https://sourceware.org/bugzilla/show_bug.cgi?id=25750).
> So drop the space separator inside `.inst (...)` to make the clang
> integrated assembler work.
>
> Suggested-by: Ilie Halip <ilie.halip@gmail.com>
> Signed-off-by: Fangrui Song <maskray@google.com>
> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
> Link: https://github.com/ClangBuiltLinux/linux/issues/939
Queued for 5.7. Thanks.
--
Catalin
next prev parent reply other threads:[~2020-04-15 12:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-14 16:32 [PATCH v2] arm64: Delete the space separator in __emit_inst Fangrui Song
2020-04-14 16:32 ` Fangrui Song
2020-04-15 12:07 ` Catalin Marinas [this message]
2020-04-15 12:07 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200415120752.GD6526@gaia \
--to=catalin.marinas@arm.com \
--cc=clang-built-linux@googlegroups.com \
--cc=ilie.halip@gmail.com \
--cc=jiancai@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maskray@google.com \
--cc=ndesaulniers@google.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.