Skip to content

[WIP] Clang and KABI fixes - #2068

Draft
Avenger-285714 wants to merge 23 commits into
deepin-community:linux-6.6.yfrom
Avenger-285714:clang-and-kabi-fix
Draft

[WIP] Clang and KABI fixes#2068
Avenger-285714 wants to merge 23 commits into
deepin-community:linux-6.6.yfrom
Avenger-285714:clang-and-kabi-fix

Conversation

@Avenger-285714

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

Copy link
Copy Markdown
Member
  1. Fix build errors with llvm-23
  2. Fix incompletely KABI solution and incorrect KABI fix.

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:

  • Fix incorrect allocation sizes and null-initialized pointer usage in HDA CS35L41 GPIO handling and Huawei hinic3 PF info allocation.
  • Correct cgroup writeback switch work handling by moving fields into a separately allocated Deepin extension and ensuring proper allocation and cleanup paths.
  • Fix use of the writeback switch work field in cgwb_release and inode writeback switching to avoid accessing freed or uninitialized memory.
  • Limit DST_Y prefetch register values in multiple AMD DML display versions to hardware register range to avoid invalid programming.
  • Update kcompat generator script to recognise Deepin-specific dev_uevent const annotations.

Enhancements:

  • Simplify AMD display DML prefetch schedule and watermark calculation APIs by relying on per-plane vba state instead of long parameter lists, improving maintainability and alignment with upstream code.
  • Introduce Deepin kABI documentation and tooling stubs to manage and verify kernel binary interface stability.
  • Deprecate unused task_struct extension hooks in favour of Deepin kABI auxiliary structures while preserving ABI layout.

Build:

  • Adjust AMD DML Makefile frame warning flags to respect CONFIG_FRAME_WARN and toolchain capabilities when building with newer LLVM/Clang versions.

Documentation:

  • Add Deepin-specific kABI documentation (including Chinese translation) explaining the reserved structures and auxiliary mechanisms for maintaining ABI stability.

Stefan Binding and others added 5 commits August 5, 2026 22:49
[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>
@sourcery-ai

sourcery-ai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors 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

Change Details Files
Refactor DML prefetch and watermark helpers to use vba_vars_st state instead of huge parameter lists and add DST_Y_PREFETCH clamping.
  • Shrink CalculatePrefetchSchedule and CalculateWatermarksAndDRAMSpeedChangeSupport signatures by removing many scalar/array parameters now read from mode_lib->vba
  • Rework CalculatePrefetchSchedule internals to fetch VM, metadata and delay parameters from vba_vars_st arrays indexed by k and to write back results into vba_vars_st instead of out-parameters
  • Add clamping of dst_y_prefetch_equ to 63.75 in dcn30, dcn31 and dcn314 implementations to match hardware register limits
  • Adjust all callers of CalculatePrefetchSchedule and CalculateWatermarksAndDRAMSpeedChangeSupport to pass reduced argument sets and to rely on vba_vars_st fields
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c
drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c
Fix DEEPIN KABI violations in cgroup writeback by moving switch_work and switch_wbs_ctxs into a separate extension object and wiring it up.
  • Introduce struct bdi_writeback_deepin holding a back pointer, switch_work and switch_wbs_ctxs, referenced via a new deepin pointer field in struct bdi_writeback
  • Allocate and initialize bdi_writeback_deepin in cgwb_create and cgwb_bdi_init; free it in cgwb_free_rcu, cgwb_create error paths, and release_bdi
  • Update cgwb_release_workfn, inode_switch_wbs_work_fn and wb_queue_isw to use wb->deepin->switch_work and wb->deepin->switch_wbs_ctxs instead of in-struct members
  • Reserve former DEEPIN_KABI slots 2–6 in struct bdi_writeback and document the KABI workaround in comments
mm/backing-dev.c
include/linux/backing-dev-defs.h
fs/fs-writeback.c
Clarify and deprecate the unused task_struct_extend extension hook and point developers to the AUX mechanism.
  • Add a detailed comment above struct task_struct_extend describing it as deprecated and explaining the preferred DEEPIN_KABI_AUX mechanism
  • Keep the empty struct definition to preserve task_struct layout under CONFIG_DEEPIN_KABI_RESERVE
include/linux/sched.h
Adjust DML Makefile frame warning handling to honor CONFIG_FRAME_WARN limits more safely under Clang/llvm.
  • Replace hard-coded frame_warn_flag assignments with frame_warn_limit and guard setting -Wframe-larger-than so it is only applied when CONFIG_FRAME_WARN is below the chosen limit
  • Format Makefile logic with nested ifeq/endif using frame_warn_limit and test-lt
drivers/gpu/drm/amd/display/dc/dml/Makefile
Fix small Clang/llvm-related correctness issues and warnings in various subsystems.
  • Initialize ACPI GPIO mapping pointers in cs35l41_add_gpios to NULL to avoid potential uninitialized-use diagnostics
  • Fix hinic3_get_pf_info allocation to use sizeof(**pf_infos) instead of sizeof(*pf_infos), matching the pointed-to type
  • Extend kcompat-generator.sh pattern for dev_uevent to match DEEPIN_KABI_CONST in addition to existing markers
sound/pci/hda/cs35l41_hda_property.c
drivers/net/ethernet/huawei/hinic3/hw/hinic3_lld.c
drivers/net/ethernet/xel/xlnid/sdk/kcompat-generator.sh
Add Deepin-specific kABI documentation and tooling skeletons.
  • Introduce Documentation/deepin and zh_CN/deepin trees with index and kabi.rst placeholders
  • Add deepin/kabi helper scripts and symtypes files such as check-kabi, diff-kabi, make-kabi, show-kabi, symtype-generate, symtypes, update-kabi
  • Hook the new documentation into the main and zh_CN documentation indices and Kconfig/MAINTAINERS as appropriate
Documentation/deepin/index.rst
Documentation/deepin/kabi.rst
Documentation/translations/zh_CN/deepin/index.rst
Documentation/translations/zh_CN/deepin/kabi.rst
Documentation/index.rst
Documentation/translations/zh_CN/index.rst
MAINTAINERS
init/Kconfig
deepin/kabi/check-kabi
deepin/kabi/diff-kabi
deepin/kabi/make-kabi
deepin/kabi/show-kabi
deepin/kabi/symtype-generate
deepin/kabi/symtypes
deepin/kabi/update-kabi

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

@Avenger-285714
Avenger-285714 marked this pull request as draft August 5, 2026 17:12
@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

@Avenger-285714

Copy link
Copy Markdown
Member Author

风险:AI 完成的提交暂时还未仔细检查,当前仅是 vibe 了一套验证补丁。

@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 left some high level feedback:

  • 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.
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.

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.

🟡 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_deepin extension.
  • 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 named symbol. 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 the symbol parameter, 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.

Comment thread deepin/kabi/update-kabi
fi
} > $stable_entry

echo2 "Added symbol \`$sym' for architecture \`$arch' ($checksum)."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

胡说八道

Comment on lines +414 to +417
if ! [ -e "$CROSS_COMPILE$CPP" ]; then
echo "ERROR: $arch $CPP not found ($CROSS_COMPILE$CPP)"
exit 1
fi

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

true

Comment thread deepin/kabi/symtypes
Comment on lines +90 to +93
def st_open(path):
if not path:
raise ValueError("Blank blank.")
if not os.path.exists(path):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

没必要修改

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>
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>
rostedt and others added 7 commits August 6, 2026 21:37
[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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants