[WIP] Clang and KABI fixes - #2068
Conversation
[Upstream commit ed7326a] Initialise the variables to NULL so that they cannot be uninitialised when devm_kfree is called. Found by static analysis. Fixes: 8c4c216 ("ALSA: hda: cs35l41: Add config table to support many laptops without _DSD") Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Link: https://lore.kernel.org/r/20231219162232.790358-2-sbinding@opensource.cirrus.com Signed-off-by: Takashi Iwai <tiwai@suse.de> (cherry picked from commit ed7326a) [WangYuli: This fixes clang-23 build errors.] Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 820ccf8] Currently, there are several files in drm/amd/display that aim to have a higher -Wframe-larger-than value to avoid instances of that warning with a lower value from the user's configuration. However, with the way that it is currently implemented, it does not respect the user's request via CONFIG_FRAME_WARN for a higher stack frame limit, which can cause pain when new instances of the warning appear and break the build due to CONFIG_WERROR. Adjust the logic to switch from a hard coded -Wframe-larger-than value to only using the value as a minimum clamp and deferring to the requested value from CONFIG_FRAME_WARN if it is higher. Suggested-by: Harry Wentland <harry.wentland@amd.com> Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Closes: https://lore.kernel.org/2025013003-audience-opposing-7f95@gregkh/ Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> [backport note: dropped the dml2/Makefile hunk; drivers/gpu/drm/amd/display/dc/dml2/ does not exist in 6.6 (dml2 was introduced in 6.7)] (cherry picked from commit 820ccf8) Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 33bc899] [Why] The minimum value of the dst_y_prefetch_equ was not correct in prefetch calculation whice causes OPTC underflow. [How] Add the min operation of dst_y_prefetch_equ in prefetch calculation for legacy DML. Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com> Signed-off-by: TungYu Lu <tungyu.lu@amd.com> Signed-off-by: Zaeem Mohamed <zaeem.mohamed@amd.com> Tested-by: Mark Broadworth <mark.broadworth@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 33bc899) Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
…tchSchedule() [Upstream commit f54a91f] After an innocuous optimization change in clang-22, dml30_ModeSupportAndSystemConfigurationFull() is over the 2048 byte stack limit for display_mode_vba_30.c. drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn30/display_mode_vba_30.c:3529:6: warning: stack frame size (2096) exceeds limit (2048) in 'dml30_ModeSupportAndSystemConfigurationFull' [-Wframe-larger-than] 3529 | void dml30_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_lib) | ^ With clang-21, this function was already close to the limit: drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn30/display_mode_vba_30.c:3529:6: warning: stack frame size (1912) exceeds limit (1586) in 'dml30_ModeSupportAndSystemConfigurationFull' [-Wframe-larger-than] 3529 | void dml30_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_lib) | ^ CalculatePrefetchSchedule() has a large number of parameters, which must be passed on the stack. Most of the parameters between the two callsites are the same, so they can be accessed through the existing mode_lib pointer, instead of being passed as explicit arguments. Doing this reduces the stack size of dml30_ModeSupportAndSystemConfigurationFull() from 2096 bytes to 1912 bytes with clang-22. Closes: ClangBuiltLinux/linux#2117 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit b20b3fc) (cherry picked from commit f54a91f) Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
…marksAndDRAMSpeedChangeSupport() [Upstream commit 6ce6fbf] CalculateWatermarksAndDRAMSpeedChangeSupport() has a large number of parameters, which must be passed on the stack. Most of the parameters between the two callsites are the same, so they can be accessed through the existing mode_lib pointer, instead of being passed as explicit arguments. Doing this reduces the stack size of dml30_ModeSupportAndSystemConfigurationFull() from 1912 bytes to 1840 bytes building for x86_64 with clang-22, helping stay under the 2048 byte limit for display_mode_vba_30.c. Additionally, now that there is a pointer to mode_lib->vba available, use 'v' consistently throughout the entire function. Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 563dfbe) (cherry picked from commit 6ce6fbf) Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Reviewer's GuideRefactors AMD DML prefetch/watermark calculations to pull many parameters from vba_vars_st, tightens DST_Y_PREFETCH bounds, and adjusts frame warning flags, while fixing Deepin KABI issues around bdi_writeback/task_struct extensions and various Clang/llvm warnings and bugs across subsystems. 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 |
|
风险:AI 完成的提交暂时还未仔细检查,当前仅是 vibe 了一套验证补丁。 |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In the DML vba refactor,
CalculatePrefetchSchedule()andCalculateWatermarksAndDRAMSpeedChangeSupport()now implicitly rely onmode_lib->vbafor many fields while still taking a large number of parameters; consider either dropping the now-redundant parameters or documenting clearly which arguments are ignored to avoid confusion and future misuse. - The new
bdi_writeback_deepinallocation/free logic is spread acrosscgwb_create(),cgwb_bdi_init(),cgwb_free_rcu(), andrelease_bdi(); it may be worth adding small helpers to centralizedeepininit/teardown so all paths (including future ones) consistently allocate, initialize, and free the extension without leaks or double frees.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the DML vba refactor, `CalculatePrefetchSchedule()` and `CalculateWatermarksAndDRAMSpeedChangeSupport()` now implicitly rely on `mode_lib->vba` for many fields while still taking a large number of parameters; consider either dropping the now-redundant parameters or documenting clearly which arguments are ignored to avoid confusion and future misuse.
- The new `bdi_writeback_deepin` allocation/free logic is spread across `cgwb_create()`, `cgwb_bdi_init()`, `cgwb_free_rcu()`, and `release_bdi()`; it may be worth adding small helpers to centralize `deepin` init/teardown so all paths (including future ones) consistently allocate, initialize, and free the extension without leaks or double frees.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
🟡 Changes recommended
The newly added Deepin kABI tooling scripts contain confirmed undefined-variable/placeholder-message issues that can break or degrade tool usability.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR aims to address LLVM/Clang 23 build issues while improving Deepin’s kABI stability mechanisms and fixing several correctness problems across subsystems (writeback/cgroup, AMD display DML, and a couple of driver allocations).
Changes:
- Introduce/extend Deepin kABI infrastructure: docs (EN + zh_CN), MAINTAINERS entries, new tooling scripts, and a new Kconfig for compile-time size/alignment checks.
- Fix cgroup writeback kABI layout constraints by moving inode-switching work/queues into a separately allocated
bdi_writeback_deepinextension. - Adjust AMD display DML behavior (prefetch register limiting and internal VBA-state refactors) and fix a few driver allocation/initialization issues.
File summaries
| File | Description |
|---|---|
| sound/pci/hda/cs35l41_hda_property.c | Initialize GPIO mapping pointers to avoid uninitialized-use warnings. |
| mm/backing-dev.c | Allocate/free wb->deepin extension and route inode-switch work via the extension to preserve kABI layout. |
| MAINTAINERS | Add Deepin kABI helper ownership patterns and documentation paths. |
| init/Kconfig | Add DEEPIN_KABI_SIZE_ALIGN_CHECKS option for compile-time kABI macro assertions. |
| include/linux/sched.h | Document deprecation of task_struct_extend and direct new users to AUX mechanism. |
| include/linux/backing-dev-defs.h | Introduce struct bdi_writeback_deepin and move cgroup writeback switch fields behind a pointer for kABI. |
| fs/fs-writeback.c | Update inode writeback switching to use wb->deepin->{switch_work,switch_wbs_ctxs}. |
| drivers/net/ethernet/xel/xlnid/sdk/kcompat-generator.sh | Teach kcompat generator to detect DEEPIN_KABI_CONST in dev_uevent signatures. |
| drivers/net/ethernet/huawei/hinic3/hw/hinic3_lld.c | Fix allocation size for pf_infos to match the pointed-to type. |
| drivers/gpu/drm/amd/display/dc/dml/Makefile | Make frame warning flag selection respect CONFIG_FRAME_WARN vs an internal limit. |
| drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c | Clamp DST_Y prefetch values to register range. |
| drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c | Clamp DST_Y prefetch values to register range. |
| drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c | Refactor large DML functions to rely on internal vba state and clamp DST_Y prefetch values. |
| Documentation/index.rst | Add Deepin documentation index to the top-level docs tree. |
| Documentation/deepin/index.rst | New Deepin downstream documentation index. |
| Documentation/deepin/kabi.rst | New English Deepin kABI maintainer guide describing macros, workflow, and pitfalls. |
| Documentation/translations/zh_CN/index.rst | Add Deepin documentation index to zh_CN docs tree. |
| Documentation/translations/zh_CN/deepin/index.rst | New zh_CN Deepin downstream documentation index. |
| Documentation/translations/zh_CN/deepin/kabi.rst | New zh_CN translation of Deepin kABI maintainer guide. |
| deepin/kabi/check-kabi | Add Deepin copy of CentOS/RHEL-like kABI checking tool. |
| deepin/kabi/diff-kabi | Add Deepin tool to diff symtypes vs reference. |
| deepin/kabi/make-kabi | Add Deepin tool to generate Module.kabi baselines from Module.symvers. |
| deepin/kabi/show-kabi | Add Deepin tool to display stablelist/baseline info. |
| deepin/kabi/symtype-generate | Add Deepin symtype/symversion generation driver script (adapted for Deepin defconfigs). |
| deepin/kabi/symtypes | Add Deepin symtypes utility (Python) for dependency inspection/diffing. |
| deepin/kabi/update-kabi | Add Deepin tool to update stablelist checksums/symtypes. |
Review details
Suppressed comments (2)
deepin/kabi/update-kabi:81
- This status message references
$sym, but the function parameter is namedsymbol. As written, the message prints an empty symbol name.
if [ "$prev_csum" = "$checksum" ]; then
echo2 "Symbol checksum of \`$sym' for architecture \`$arch' unchanged."
return
deepin/kabi/update-kabi:91
- This update message uses
$sym(undefined here) instead of thesymbolparameter, so the message won't identify which symbol was updated.
echo2 "Updated symbol \`$sym' for architecture \`$arch'" \
"($prev_csum -> $checksum)."
- Files reviewed: 26/26 changed files
- Comments generated: 3
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| fi | ||
| } > $stable_entry | ||
|
|
||
| echo2 "Added symbol \`$sym' for architecture \`$arch' ($checksum)." |
| if ! [ -e "$CROSS_COMPILE$CPP" ]; then | ||
| echo "ERROR: $arch $CPP not found ($CROSS_COMPILE$CPP)" | ||
| exit 1 | ||
| fi |
| def st_open(path): | ||
| if not path: | ||
| raise ValueError("Blank blank.") | ||
| if not os.path.exists(path): |
Building with clang-23 (-Werror) fails with:
drivers/net/ethernet/huawei/hinic3/hw/hinic3_lld.c:2151:14: error:
allocation of insufficient size '8' for type 'struct
hinic3_hw_pf_infos' with size '1156' [-Werror,-Walloc-size]
*pf_infos = kzalloc(sizeof(*pf_infos), GFP_KERNEL);
pf_infos is a 'struct hinic3_hw_pf_infos **', so sizeof(*pf_infos)
evaluates to the size of a pointer (8 bytes) instead of the size of
the pointed-to structure (1156 bytes). Use sizeof(**pf_infos), matching
the double-pointer allocation pattern already used in hinic3_nic_cfg.c.
This is not just a build-time diagnostic: hinic3_get_hw_pf_infos()
subsequently fills the buffer with a full struct hinic3_hw_pf_infos,
so every call to hinic3_get_pf_info() overflows the 8-byte allocation
by over a kilobyte at runtime.
Fixes: c866011 ("net/hinic3:Add Huawei Intelligent Network Card Driver:hinic3")
Assisted-by: Kimi Code:K3
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
include/linux/deepin_kabi.h references CONFIG_DEEPIN_KABI_SIZE_ALIGN_CHECKS via IS_BUILTIN() to gate the compile-time size/alignment assertions in DEEPIN_KABI_REPLACE, DEEPIN_KABI_EXTEND_WITH_SIZE and DEEPIN_KABI_EXCLUDE_WITH_SIZE, but the symbol was never defined in any Kconfig file. IS_BUILTIN() of an undefined symbol evaluates to 0, so the assertions are permanently compiled out with no way to turn them on. Mirror the RHEL setup (RH_KABI_SIZE_ALIGN_CHECKS in Kconfig.redhat of CentOS Stream, kernel-6.12.0-255.el10) and define the option next to CONFIG_DEEPIN_KABI_RESERVE. Unlike RHEL, do not default to y: the checks stay off unless enabled explicitly. The option depends on DEEPIN_KABI_RESERVE so both stay off by default. None of the macros guarded by this option is in use yet, so enabling it changes nothing today; it only arms the checks for future users. Fixes: 5083950 ("kABI: Introduce generic kABI macros to use for kABI workarounds") Fixes: efd0fdb ("kabi: Introduce CONFIG_KABI_RESERVE") Assisted-by: Kimi Code:K3 Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
The kcompat generator probes the kernel tree for a const-qualified dev_uevent() method, accepting either a plain const or RHEL's RH_KABI_CONST annotation. On deepin kernels the equivalent annotation is DEEPIN_KABI_CONST, which the probe does not recognize. Extend the match expression with DEEPIN_KABI_CONST so the generator keeps producing correct results when it is re-run against a deepin kernel tree. Keep the RH_KABI_CONST branch: this SDK is cross-distro compatibility code and may still be built on RHEL kernels. The pre-generated kcompat_generated_defs.h does not need to be regenerated: upstream 6.6 dev_uevent() is already const-qualified, so the plain const branch already matches. Fixes: a1accf3 ("net: ethernet: xel: add XEL network driver support") Assisted-by: Kimi Code:K3 Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
struct task_struct_extend was reserved as an extension hang point for task_struct so that merging upstream changes adding task_struct fields would not disturb the task_struct layout. It has never been wired up: there is no allocation, initialization or dereference site anywhere in the tree. The kABI auxiliary structure mechanism (struct task_struct_deepin plus DEEPIN_KABI_AUX_PTR/SET_SIZE/AUX) serves the same purpose and is the better design: it is size-versioned, so code can detect at runtime whether a given field exists, and it follows the semantics documented in include/linux/deepin_kabi.h. Keep the structure and the pointer in place - removing them would change the task_struct layout - but mark the mechanism deprecated and point new work at the AUX mechanism instead. Fixes: 34aa3d7 ("deepin: KABI: KABI reservation for sched structures") Assisted-by: Kimi Code:K3 Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
c69abf2 to
31ba85d
Compare
Import the kABI tooling from CentOS Stream 10
(kernel-6.12.0-255.el10), redhat/kabi/, into scripts/deepin/kabi/:
check-kabi compare Module.symvers against a reference
Module.kabi, exit 1 on CRC mismatch
show-kabi dump Module.kabi_<arch> or kabi stablelists from
the per-symbol kabi-module database
make-kabi generate a reference Module.kabi from
Module.symvers
update-kabi update the per-symbol checksum/symtypes database
diff-kabi diff symtypes against the reference database
symtypes symtypes parsing/diffing helpers
symtype-generate orchestrator that (re)generates checksums
All tools are python3/bash with no third-party dependencies. Keep the
comparison logic identical to upstream; local adaptations are marked
with "deepin:" and are limited to:
* show-kabi: emit [deepin66_<arch>_stablelist] headers instead of
[rhel9_<arch>_stablelist]
* update-kabi, diff-kabi, symtype-generate: default the
data/tools root directory to scripts/deepin/ instead of redhat/
* symtype-generate: add loongarch64 and riscv64 to the arch map,
exclude the deepin/ directory in source searches, and replace the
redhat/configs lookup with a mapping onto the in-tree deepin
defconfigs
Each file carries a header noting its origin and sync point.
Assisted-by: Kimi Code:K3
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Add Documentation/deepin/kabi.rst, the maintainer's guide for the
deepin kABI infrastructure, together with an idiomatic Chinese
translation under Documentation/translations/zh_CN/deepin/ following
the zh_CN translation conventions.
The guide covers:
* the relationship with CentOS Stream rh_kabi, the current sync
point (kernel-6.12.0-255.el10) and how to re-verify the header
with a normalized diff
* the configuration warning: CONFIG_DEEPIN_KABI_RESERVE defaults to
off, so builds that need kABI stability must enable it explicitly,
and toggling it is a one-time baseline reset
* macro usage rules (RESERVE/USE conventions, EXTEND limits,
BROKEN/EXCLUDE justification requirements)
* the placement sensitivity of DEEPIN_KABI_FORCE_CHANGE: in a
trailing declarator position stock genksyms silently discards the
attribute and the CRC does not change, with verified numbers and a
re-verification procedure
* how to activate the AUX mechanism before first use, and its
preference over the deprecated struct task_struct_extend
* the manual symbol baseline workflow with make-kabi/check-kabi
* an errata section noting the CONFIG_KABI_RESERVE vs
CONFIG_DEEPIN_KABI_RESERVE commit message mismatch
Hook the new deepin index into both the English and zh_CN document
trees.
Assisted-by: Kimi Code:K3
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
The DEEPIN KABI-HELPERS entry only covered include/linux/deepin_kabi.h. Add the newly imported tooling (scripts/deepin/kabi/), the new documentation (Documentation/deepin/ and its zh_CN translation), and a content regex for DEEPIN_KABI_ so that patches touching any of the files using the kABI macros are routed to the kABI maintainers. Assisted-by: Kimi Code:K3 Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Adjust the freshly introduced option to match how it is meant to be
used:
* default DEEPIN_KABI_RESERVE: the checks stay off while kABI
reservations are off (the upstream default), but enabling
DEEPIN_KABI_RESERVE turns them on automatically, since that is the
configuration where kABI guarantees actually apply.
* Force-disable the option when a debugging option that changes
struct sizes is selected (LOCKDEP, PROVE_LOCKING, DEBUG_SPINLOCK,
DEBUG_MUTEXES, DEBUG_RWSEMS, DEBUG_OBJECTS). The dependency lives
on this option, not on the debugging options, so the debugging
options remain freely selectable; selecting one simply makes the
kABI checks drop out. Such builds deliberately allow struct size
drift and the assertions would only produce false positives.
Also rewrite the help text: the original wording was copied from the
RHEL Kconfig.redhat entry and refers to RHEL-style debug kernel builds,
a concept that does not exist in the deepin distribution. The new text
states plainly what is checked, why the debugging options conflict, and
that they stay selectable.
Fixes: a16d9a70a2a1f ("kabi: Introduce CONFIG_DEEPIN_KABI_SIZE_ALIGN_CHECKS")
Assisted-by: Kimi Code:K3
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
The kABI fix in bbe9174 ("writeback: kabi fix in struct bdi_writeback") moved the fields added by upstream commit ed5400f ("writeback: Avoid contention on wb->list_lock when switching inodes") into the reserved space at the end of struct bdi_writeback, consuming 5 reserved slots (40 bytes) for struct work_struct. That sizing only holds when CONFIG_DEEPIN_KABI_RESERVE=n. With the reservations enabled - the configuration kABI guarantees apply to - struct work_struct carries kABI padding of its own and is 48 bytes large, so the two new fields need 56 bytes while only 48 were reserved. The replacement union then silently grows bdi_writeback by 8 bytes, which propagates into every struct embedding it (backing_dev_info and beyond), as caught by the DEEPIN_KABI_SIZE_ALIGN_CHECKS static assertion. Redo the fix: move switch_work and switch_wbs_ctxs into a new, separately allocated extension structure, struct bdi_writeback_deepin, and reference it from bdi_writeback through a pointer consumed from a single reserved slot. The remaining slots stay reserved. With CONFIG_DEEPIN_KABI_RESERVE=y, the layout is restored to the frozen pre-change baseline. When reservations are disabled, the extension pointer remains a real field and struct bdi_writeback is still 8 bytes larger than that baseline; this configuration does not provide the distribution kABI guarantee. The extension is kernel-internal and carries a back-pointer so that inode_switch_wbs_work_fn() can recover the base wb from the work item. Allocation sites are cgwb_create() (memcg writebacks) and cgwb_bdi_init() (the root wb embedded in backing_dev_info); the extension is freed in cgwb_free_rcu() and release_bdi() respectively, with the error paths of cgwb_create() covered as well. Fixes: bbe9174 ("writeback: kabi fix in struct bdi_writeback") Assisted-by: Kimi Code:K3 Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Signed-off-by: WangYuli <wangyuli@deepin.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
symtype-generate runs under `set -euo pipefail`, so expanding the
unbound $arch variable in the cross-compiler not-found message aborts
the script with "arch: unbound variable" before the intended
diagnostic can be printed.
Use $CARCH instead; it is set from -a or $(uname -m) and is already
used to build CROSS_COMPILE, so the message now reads, e.g.:
ERROR: aarch64 gcc not found (/usr/bin/aarch64-linux-gnu-gcc)
The bug was inherited from the upstream CentOS Stream 10
redhat/kabi/symtype-generate; this is a local deepin adaptation.
Fixes: 13936a8 ("kabi: Import kABI checking tools from CentOS Stream 10")
Reported-by: GitHub Copilot:Code Review model
Link: deepin-community#2068
Assisted-by: GitHub Copilot:deepseek-v4-flash
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit b055f4c] In order to share the elf parsing that is in sorttable.c so that other programs could use the same code, move it into elf-parse.c and elf-parse.h. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Nicolas Schier <nicolas.schier@linux.dev> Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Link: https://lore.kernel.org/20251022004452.752298788@kernel.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> [WangYuli: Fix conflicts in scripts/Makefile because of ab0f4ce.] (cherry picked from commit b055f4c) Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 92ef432] KCONFIG_WARN_UNKNOWN_SYMBOLS=1 and KCONFIG_WERROR=1 are descriptive and suitable in scripting, but typing them from the command line can be tedious. Associate them with KBUILD_EXTRA_WARN (and the W= shorthand). Support a new letter 'c' to enable extra checks in Kconfig. You can still manage compiler warnings (W=1) and Kconfig warnings (W=c) independently. Reuse the letter 'e' to turn Kconfig warnings into errors. As usual, you can combine multiple letters in KCONFIG_EXTRA_WARN. $ KCONFIG_WARN_UNKNOWN_SYMBOLS=1 KCONFIG_WERROR=1 make defconfig can be shortened to: $ KBUILD_EXTRA_WARN=ce make defconfig or, even shorter: $ make W=ce defconfig Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> (cherry picked from commit 92ef432) Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Clang warns that 'res' may be used uninitialized in
phytium_qspi_probe():
drivers/spi/spi-phytium-qspi.c:717:11: error: variable 'res' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
717 | else if (has_acpi_companion(dev)) {
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/spi/spi-phytium-qspi.c:723:45: note: uninitialized use occurs here
723 | qspi->io_base = devm_ioremap_resource(dev, res);
| ^~~
drivers/spi/spi-phytium-qspi.c:717:7: note: remove the 'if' if its condition is always true
717 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/spi/spi-phytium-qspi.c:688:22: note: initialize the variable 'res' to silence this warning
688 | struct resource *res;
| ^
| = NULL
1 error generated.
'res' is only assigned inside the 'if (dev->of_node)' /
'else if (has_acpi_companion(dev))' branches. When a device has
neither a DT node nor an ACPI companion, neither branch is taken and
'res' is passed uninitialized to devm_ioremap_resource(). GCC does
not report this, but with CONFIG_WERROR=y a clang build fails.
Initialize 'res' to NULL so that devm_ioremap_resource() handles the
missing-resource case gracefully (it returns -EINVAL for a NULL
resource) instead of consuming an uninitialized pointer.
Fixes: 8b02928 ("arm64: phytium: UEFI mode acpi table support for qspi/spi driver")
Assisted-by: GitHub Copilot:deepseek-v4-flash
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Fix a clang build error (fatal because CONFIG_WERROR=y) when compiling
for arm64:
drivers/mtd/maps/phytium_lbc.c:439:13: error: variable 'res' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
439 | } else if (has_acpi_companion(dev)) {
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/mtd/maps/phytium_lbc.c:460:31: note: uninitialized use occurs here
460 | lbc->mm_size = resource_size(res);
| ^~~
drivers/mtd/maps/phytium_lbc.c:439:9: note: remove the 'if' if its
condition is always true
439 | } else if (has_acpi_companion(dev)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/mtd/maps/phytium_lbc.c:406:22: note: initialize the variable
'res' to silence this warning
406 | struct resource *res;
| ^
| = NULL
1 error generated.
In phytium_lbc_probe(), 'res' is only assigned inside the
"if (dev->of_node)" and "else if (has_acpi_companion(dev))" branches, but
it is dereferenced unconditionally afterwards by:
lbc->mm_size = resource_size(res);
When the probed platform device has neither a device tree node nor an
ACPI companion, 'res' is never assigned, so resource_size() dereferences
an uninitialized pointer. This is undefined behavior at runtime and is
also reported by clang's -Wsometimes-uninitialized, which is promoted to
a hard error by CONFIG_WERROR=y.
Reject devices with neither a device tree node nor an ACPI companion by
returning -ENODEV before 'res' is used. This guarantees 'res' is always
initialized when resource_size() is reached. No manual cleanup is needed
on this path because 'lbc' is allocated with devm_kzalloc() and is freed
automatically by devres when the probe fails.
Fixes: 64b35ad ("lbc: phytium: Add uefi support for localbus controller driver")
Assisted-by: GitHub Copilot:deepseek-v4-flash
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
modpost reports a section mismatch: WARNING: modpost: vmlinux: section mismatch in reference: __create_pgd_mapping_for_iee+0x54 (section: .text.unlikely.) -> __create_pgd_mapping_for_iee_locked (section: .init.text) __create_pgd_mapping_for_iee() lacks a __init annotation, so the compiler places it in a non-init section (.text.unlikely) while it calls __create_pgd_mapping_for_iee_locked(), which lives in .init.text. After init memory is freed, that reference would dangle, hence the mismatch warning. The only caller is __map_memblock_for_iee(), itself __init, reached exclusively from iee_init_mappings() during paging_init(). The call can never happen at runtime, so the wrapper belongs in .init.text too. Annotate it __init instead of __ref: the reference is genuinely init-only, and this also lets the wrapper's code be freed by free_initmem(), slightly reducing the runtime memory footprint. Fixes: 76baf5e ("HAOC: Add support for AArch64 Isolated Execution Environment(IEE).") Assisted-by: Kimi Code:K3 Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
The declaration of iee_init_mappings() in asm/haoc/iee.h lacks the __init annotation present on its definition in iee-mmu.c and on the duplicate declaration in asm/haoc/iee-mmu.h. Keep the annotations consistent so the init-only nature of the function is visible at every declaration site. No functional change. Fixes: 76baf5e ("HAOC: Add support for AArch64 Isolated Execution Environment(IEE).") Assisted-by: Kimi Code:K3 Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
sky1_timer_probe() is registered as the platform driver's .probe callback and therefore lives in .text. It calls sky1_clocksource_init() and sky1_clockevent_init(), which are marked __init and land in .init.text, triggering modpost section mismatch warnings: WARNING: modpost: drivers/clocksource/timer-sky1-gpt: section mismatch in reference: sky1_timer_probe+0x194 (section: .text) -> sky1_clocksource_init (section: .init.text) WARNING: modpost: drivers/clocksource/timer-sky1-gpt: section mismatch in reference: sky1_timer_probe+0x1a0 (section: .text) -> sky1_clockevent_init (section: .init.text) .probe can run after init memory has been freed: the driver is tristate, so probe executes at module load time, and even built-in it may run late via deferred probe or unbind/rebind. Referencing freed .init.text from such a path is a potential use-after-free. Drop the __init annotation from both helpers. Neither of them calls any other __init function, so this fully resolves the mismatch. An init-only registration model (e.g. builtin_platform_driver_probe()) is not applicable here since the driver is tristate and also supports ACPI-based platforms. Fixes: 6a1b5aa ("clocksource: timer-sky1-gpt: add sky1 gpt timer support") Assisted-by: Kimi Code:K3 Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
31ba85d to
8295379
Compare
KABI 修复补丁已验证。现在继续修复 LLVM 构建问题。 |
Summary by Sourcery
Refactor AMD DML display prefetch and watermark calculations to use internal vba state, adjust frame warning flags for newer Clang, and fix Deepin kABI-related structures and writeback handling to maintain binary compatibility while addressing allocator and workqueue issues.
Bug Fixes:
Enhancements:
Build:
Documentation: