[Deepin-Kernel-SIG] [linux 6.6.y] [Hygon] x86: Fix objtool noreturn warnings from Hygon copy_user routines - #2081
Conversation
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>
Reviewer's GuideAdjust 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 flowflowchart 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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Moves Hygon copy-user tail handlers inside their function boundaries so objtool correctly recognizes return paths.
Changes:
- Converts internal handlers to
.Llocal 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.
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:
Enhancements: