Skip to content

[Deepin-Kernel-SIG] [linux 6.6.y] [Hygon] x86: Fix objtool noreturn warnings from Hygon copy_user routines - #2081

Open
Avenger-285714 wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
Avenger-285714:hygon-copyuser-6.6
Open

[Deepin-Kernel-SIG] [linux 6.6.y] [Hygon] x86: Fix objtool noreturn warnings from Hygon copy_user routines#2081
Avenger-285714 wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
Avenger-285714:hygon-copyuser-6.6

Conversation

@Avenger-285714

@Avenger-285714 Avenger-285714 commented Aug 12, 2026

Copy link
Copy Markdown
Member

Commit 9590a37 ("x86: Enhanced copy capabilities for Hygon processor") added copy_user_avx2.S and copy_user_sse2.S, placing the sub-256-byte copy block and the tail handler after SYM_FUNC_END() as separate SYM_CODE_START_LOCAL() (STT_NOTYPE) symbols. Every exit path of copy_user_avx2_pf64_nt_string() jumps into one of those out-of-function blocks, so the function body itself contains no return instruction at all.

objtool's __dead_end_function() only scans instructions within the function symbol's bounds for INSN_RETURN, and jump_is_sibling_call() explicitly refuses to treat jumps into STT_NOTYPE symbols as sibling calls. The function is therefore misclassified as noreturn, the code following each call site is treated as unreachable, and validate_unreachables() emits one warning per caller when building x86_64_defconfig with "make CC="ccache clang" LLVM=1":

vmlinux.o: warning: objtool: xfpregs_set+0x249: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: fpregs_set+0x2d1: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: copy_fpstate_to_sigframe+0x464: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: fpu__restore_sig+0x1e8: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: regset_tls_set+0x192: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: copy_from_user_nofault+0xbd: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: copy_to_user_nofault+0xb2: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: do_wp_page+0xd07: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: set_fd_set+0x88: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: copyout+0x84: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: copyin+0x84: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: _copy_from_user+0x86: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: _copy_to_user+0x89: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: i915_gem_execbuffer2_ioctl+0x634: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: parse_timeline_fences+0x3c7: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: eb_relocate_vma+0x1cb: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: shmem_pwrite+0x21c: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: i915_gem_shmem_pread+0x280: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: i915_gem_gtt_pread+0x246: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: i915_gem_shmem_pwrite+0x2e6: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: query_memregion_info+0x235: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: copy_mc_to_user+0x8d: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: insn_fetch_from_user_inatomic+0x9f: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
vmlinux.o: warning: objtool: copy_from_user_nmi+0xab: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation

Move the local blocks back between SYM_FUNC_START() and SYM_FUNC_END() and turn them into plain .L local labels, updating the jump references accordingly, in the same style as copy_user_64.S. All returns are then inside the function symbol and objtool can follow every path as normal intra-function control flow, so no annotation games are needed.

No instructions are changed: all _ASM_EXTABLE_UA entries, the STAC/CLAC pairing, and the vzeroupper/sfence ordering on the fault and tail paths are preserved, and no new symbols are introduced.

copy_user_sse2_opt_string() escapes the warning only because its normal path happens to keep one RET inside the symbol; its fault path shares the same out-of-symbol tail jump, so fix it the same way.

Fixes: 9590a37 ("x86: Enhanced copy capabilities for Hygon processor")
Assisted-by: Kimi Code:K3

Summary by Sourcery

Adjust Hygon x86 copy_user AVX2/SSE2 routines so intra-function tail and sub-256-byte copy handlers are implemented as local labels within the function symbols, resolving objtool noreturn misclassification warnings without changing runtime behavior.

Bug Fixes:

  • Fix objtool noreturn warnings for copy_user_avx2_pf64_nt_string() and copy_user_sse2_opt_string() by ensuring all return paths remain within their function symbols.

Enhancements:

  • Align copy_user_avx2 and copy_user_sse2 implementations with the copy_user_64 style by using local .L labels instead of separate STT_NOTYPE symbols for internal control-flow blocks.

Commit 9590a37 ("x86: Enhanced copy capabilities for Hygon
processor") added copy_user_avx2.S and copy_user_sse2.S, placing the
sub-256-byte copy block and the tail handler after SYM_FUNC_END() as
separate SYM_CODE_START_LOCAL() (STT_NOTYPE) symbols.  Every exit path
of copy_user_avx2_pf64_nt_string() jumps into one of those
out-of-function blocks, so the function body itself contains no return
instruction at all.

objtool's __dead_end_function() only scans instructions within the
function symbol's bounds for INSN_RETURN, and jump_is_sibling_call()
explicitly refuses to treat jumps into STT_NOTYPE symbols as sibling
calls. The function is therefore misclassified as noreturn, the code
following each call site is treated as unreachable, and
validate_unreachables() emits one warning per caller when building
x86_64_defconfig with "make CC=\"ccache clang\" LLVM=1":

  vmlinux.o: warning: objtool: xfpregs_set+0x249: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: fpregs_set+0x2d1: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: copy_fpstate_to_sigframe+0x464: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: fpu__restore_sig+0x1e8: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: regset_tls_set+0x192: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: copy_from_user_nofault+0xbd: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: copy_to_user_nofault+0xb2: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: do_wp_page+0xd07: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: set_fd_set+0x88: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: copyout+0x84: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: copyin+0x84: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: _copy_from_user+0x86: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: _copy_to_user+0x89: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: i915_gem_execbuffer2_ioctl+0x634: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: parse_timeline_fences+0x3c7: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: eb_relocate_vma+0x1cb: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: shmem_pwrite+0x21c: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: i915_gem_shmem_pread+0x280: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: i915_gem_gtt_pread+0x246: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: i915_gem_shmem_pwrite+0x2e6: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: query_memregion_info+0x235: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: copy_mc_to_user+0x8d: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: insn_fetch_from_user_inatomic+0x9f: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation
  vmlinux.o: warning: objtool: copy_from_user_nmi+0xab: copy_user_avx2_pf64_nt_string() is missing a __noreturn annotation

Move the local blocks back between SYM_FUNC_START() and SYM_FUNC_END()
and turn them into plain .L local labels, updating the jump references
accordingly, in the same style as copy_user_64.S. All returns are then
inside the function symbol and objtool can follow every path as normal
intra-function control flow, so no annotation games are needed.

No instructions are changed: all _ASM_EXTABLE_UA entries, the STAC/CLAC
pairing, and the vzeroupper/sfence ordering on the fault and tail paths
are preserved, and no new symbols are introduced.

copy_user_sse2_opt_string() escapes the warning only because its normal
path happens to keep one RET inside the symbol; its fault path shares
the same out-of-symbol tail jump, so fix it the same way.

Fixes: 9590a37 ("x86: Enhanced copy capabilities for Hygon processor")
Assisted-by: Kimi Code:K3
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
@Avenger-285714
Avenger-285714 requested review from opsiff and a balanced review from Copilot August 12, 2026 09:10
@sourcery-ai

sourcery-ai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adjust Hygon x86 copy_user assembly routines so their internal tail and small-length handlers are normal in-function local labels instead of separate STT_NOTYPE symbols, allowing objtool to see all return paths and eliminating false noreturn warnings, without changing actual instruction behavior.

Flow diagram for updated copy_user_avx2_pf64_nt_string control flow

flowchart TD
  copy_user_avx2_pf64_nt_string["copy_user_avx2_pf64_nt_string"] --> check_len["cmpq $256,%rdx"]
  check_len -->|"jb .Lless_than_256_bytes_cpy"| Lless_than_256_bytes_cpy[".Lless_than_256_bytes_cpy"]
  check_len -->|"len >= 256"| large_block_paths["large_block_nt_*_cpy"]
  large_block_paths -->|"sfence; vzeroupper; jmp .Lless_than_256_bytes_cpy"| Lless_than_256_bytes_cpy
  large_block_paths -->|"fault path jmp .Lavx2_copy_user_handle_tail"| Lavx2_copy_user_handle_tail[".Lavx2_copy_user_handle_tail"]
  Lless_than_256_bytes_cpy -->|"rep movsb; RET"| RET_in_func["RET inside copy_user_avx2_pf64_nt_string"]
  Lavx2_copy_user_handle_tail -->|"tail handling; RET"| RET_in_func
Loading

File-Level Changes

Change Details Files
Convert out-of-function tail and sub-256-byte handlers in Hygon copy_user routines into in-function local labels so objtool correctly tracks return paths.
  • Replace SYM_CODE_START_LOCAL/SYM_CODE_END blocks for tail and small-length handlers with plain .L local labels inside the enclosing SYM_FUNC_START/SYM_FUNC_END range.
  • Update all jumps that previously targeted symbol-like local code blocks (Lavx2_copy_user_handle_tail, Lless_than_256_bytes_cpy, Lsse2_copy_user_handle_tail) to jump to the corresponding .L labels.
  • Reorder SYM_FUNC_END/EXPORT_SYMBOL for copy_user_* functions so that tail handlers are covered by the function symbol boundaries while preserving extable entries and control-flow ordering.
arch/x86/lib/copy_user_avx2.S
arch/x86/lib/copy_user_sse2.S

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from avenger-285714. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves Hygon copy-user tail handlers inside their function boundaries so objtool correctly recognizes return paths.

Changes:

  • Converts internal handlers to .L local labels.
  • Extends AVX2/SSE2 function symbols to include all return paths.
  • Preserves existing copy, fault-handling, and FPU helper behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
arch/x86/lib/copy_user_sse2.S Moves the SSE2 tail handler inside the function symbol.
arch/x86/lib/copy_user_avx2.S Moves AVX2 short-copy and tail handlers inside the function symbol.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants