From: Paul Walmsley <pjw@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Paul Walmsley <pjw@kernel.org>, Alexandre Ghiti <alex@ghiti.fr>,
Palmer Dabbelt <palmer@dabbelt.com>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Craig Topper <craig.topper@sifive.com>,
linux-riscv@lists.infradead.org, llvm@lists.linux.dev,
patches@lists.linux.dev
Subject: Re: [PATCH RFC v2] riscv: Use 64-bit variable for output in __get_user_asm
Date: Wed, 14 Jan 2026 18:02:46 -0700 (MST) [thread overview]
Message-ID: <7bc39d4d-6e2d-f0af-9787-5fd2c92bfd4e@kernel.org> (raw)
In-Reply-To: <20260113-riscv-wa-llvm-asm-goto-outputs-assertion-failure-v2-1-e04aba2e1f9f@kernel.org>
Hi Nathan,
On Tue, 13 Jan 2026, Nathan Chancellor wrote:
> After commit f6bff7827a48 ("riscv: uaccess: use 'asm_goto_output' for
> get_user()"), which was the first commit that started using asm goto
> with outputs on RISC-V, builds of clang built with assertions enabled
> start crashing in certain files that use get_user() with:
>
> clang: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:12743: Register FollowCopyChain(MachineRegisterInfo &, Register): Assertion `MI->getOpcode() == TargetOpcode::COPY && "start of copy chain MUST be COPY"' failed.
>
> Internally, LLVM generates an addiw instruction when the output of the
> inline asm (which may be any scalar type) needs to be sign extended for
> ABI reasons, such as a later function call, so that basic block does not
> have to do it.
>
> Use a temporary 64-bit variable as the output of the inline assembly in
> __get_user_asm() and explicitly cast it to truncate it if necessary,
> avoiding the addiw that triggers the assertion.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/2092
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> Changes in v2:
> - Rebase on 6.19-rc5
> - Send to updated addresses
> - Link to v1: https://lore.kernel.org/r/20250811-riscv-wa-llvm-asm-goto-outputs-assertion-failure-v1-1-7bb8c9cbb92b@kernel.org
> ---
> I did this unconditionally but I did not do much investigation into how
> the code generation changes, as I never have good luck with figuring out
> what is real vs. noise. If this is a worry, I can just duplicate this
> under a CONFIG_CC_IS_CLANG block. Alternatively, we could mark
> CONFIG_CC_HAS_ASM_GOTO_OUTPUT as broken with clang when targeting
> RISC-V.
I'm assuming this would be a temporary patch, and that we might be able to
remove it at some point (years, I guess?)
Might be worth adding a comment in the code to explain why a temporary
variable is needed.
thanks for the patch,
- Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-01-15 1:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 0:09 [PATCH RFC v2] riscv: Use 64-bit variable for output in __get_user_asm Nathan Chancellor
2026-01-15 1:02 ` Paul Walmsley [this message]
2026-01-16 5:10 ` Nathan Chancellor
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=7bc39d4d-6e2d-f0af-9787-5fd2c92bfd4e@kernel.org \
--to=pjw@kernel.org \
--cc=alex@ghiti.fr \
--cc=craig.topper@sifive.com \
--cc=justinstitt@google.com \
--cc=linux-riscv@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=palmer@dabbelt.com \
--cc=patches@lists.linux.dev \
/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