linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Ilie Halip <ilie.halip@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Kees Cook <keescook@chromium.org>,
	Sami Tolvanen <samitolvanen@google.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	clang-built-linux <clang-built-linux@googlegroups.com>
Subject: Re: [PATCH] arm64: alternative: fix build with clang integrated assembler
Date: Thu, 19 Mar 2020 16:43:56 -0700	[thread overview]
Message-ID: <CAKwvOdneL8F_ZHBAzyb+VoJ+Z1FZp0VW8asGTu=g39TrouqAgA@mail.gmail.com> (raw)
In-Reply-To: <20200319214530.2046-1-ilie.halip@gmail.com>

On Thu, Mar 19, 2020 at 2:45 PM Ilie Halip <ilie.halip@gmail.com> wrote:
>
> Building an arm64 defconfig with clang's integrated assembler, this error
> occurs:
>     <instantiation>:2:2: error: unrecognized instruction mnemonic
>      _ASM_EXTABLE 9999b, 9f
>      ^
>     arch/arm64/mm/cache.S:50:1: note: while in macro instantiation
>     user_alt 9f, "dc cvau, x4", "dc civac, x4", 0
>     ^
>
> While GNU as seems fine with case-sensitive macro instantiations, clang
> doesn't, so use the actual macro name (_asm_extable) as in the rest of
> the file.
>
> Also checked that the generated assembly matches the GCC output.
>
> Fixes: 290622efc76e ("arm64: fix "dc cvau" cache operation on errata-affected core")
> Link: https://github.com/ClangBuiltLinux/linux/issues/924
> Signed-off-by: Ilie Halip <ilie.halip@gmail.com>
> ---
>  arch/arm64/include/asm/alternative.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
> index 324e7d5ab37e..5e5dc05d63a0 100644
> --- a/arch/arm64/include/asm/alternative.h
> +++ b/arch/arm64/include/asm/alternative.h
> @@ -221,7 +221,7 @@ alternative_endif
>
>  .macro user_alt, label, oldinstr, newinstr, cond
>  9999:  alternative_insn "\oldinstr", "\newinstr", \cond
> -       _ASM_EXTABLE 9999b, \label
> +       _asm_extable 9999b, \label
>  .endm

Testing a -next defconfig build, if I apply this, apply fixes for
https://github.com/ClangBuiltLinux/linux/issues/913, then disable
CONFIG_KVM, I can assemble (with Clang's integrated assembler) and
boot an aarch64 kernel.  I think that's a first for Clang.  Wow.

For CONFIG_KVM, I see:
arch/arm64/kvm/hyp/entry.S:112:87: error: too many positional arguments
 alternative_insn nop, .inst (0xd500401f | ((0) << 16 | (4) << 5) |
((!!1) << 8)), 4, 1

               ^
which also uses `alternative_insn`, but not `user_alt`, so another bug
for us to look into, filed:
https://github.com/ClangBuiltLinux/linux/issues/939

Looks like `_asm_extable` itself is a macro, defined in
arch/arm64/include/asm/assembler.h on line 125.  It's probably easy to
fix this in clang, but from a consistency with the rest of the file
(arch/arm64/include/asm/alternative.h) this patch should be accepted.

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>

Should be easy to fix in Clang, too. Filed:
https://bugs.llvm.org/show_bug.cgi?id=45257
Thanks for the patch!

-- 
Thanks,
~Nick Desaulniers

  reply	other threads:[~2020-03-19 23:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 21:45 [PATCH] arm64: alternative: fix build with clang integrated assembler Ilie Halip
2020-03-19 23:43 ` Nick Desaulniers [this message]
2020-03-20  8:11   ` Will Deacon

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='CAKwvOdneL8F_ZHBAzyb+VoJ+Z1FZp0VW8asGTu=g39TrouqAgA@mail.gmail.com' \
    --to=ndesaulniers@google.com \
    --cc=andre.przywara@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=ilie.halip@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samitolvanen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).