Skip to content

[Deepin-Kernel-SIG] [linux 6.18.y] [Deepin] [AOSC] arm64: disable mpam in tsv110#1521

Open
opsiff wants to merge 2 commits intodeepin-community:linux-6.18.yfrom
opsiff:linux-6.18.y-2026-03-02-mpam-disable
Open

[Deepin-Kernel-SIG] [linux 6.18.y] [Deepin] [AOSC] arm64: disable mpam in tsv110#1521
opsiff wants to merge 2 commits intodeepin-community:linux-6.18.yfrom
opsiff:linux-6.18.y-2026-03-02-mpam-disable

Conversation

@opsiff
Copy link
Member

@opsiff opsiff commented Mar 2, 2026

If you really need it , use aosc.try_mpam=1.
If you really noneed it, use arm64.nompam=1.

Log:

[ 0.000000] CPU features: SYS_ID_AA64PFR0_EL1[43:40]: forced to 0
[ 0.000000] CPU features: SYS_ID_AA64PFR1_EL1[19:16]: already set to 0
[ 0.000000] CPU features: detected: GICv3 CPU interface
[ 0.000000] CPU features: detected: Virtualization Host Extensions
[ 0.000000] CPU features: detected: Spectre-v4
[ 0.000000] CPU features: detected: Spectre-BHB
[ 0.000000] alternatives: applying boot alternatives
[ 0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-6.18.13-arm64-desktop-rolling root=UUID=c2f3cdb4-f919-43ba-bd32-172c2744dfb2 ro splash quiet console=tty plymouth.ignore-serial-consoles DEEPIN_GFXMODE= luks.crypttab=n
[ 0.000000] Unknown kernel command line parameters "splash DEEPIN_GFXMODE=", will be passed to user space.
[ 0.000000] printk: log_buf_len individual max cpu contribution: 32768 bytes
[ 0.000000] printk: log_buf_len total cpu_extra contributions: 753664 bytes
[ 0.000000] printk: log_buf_len min size: 131072 bytes
[ 0.000000] printk: log buffer data + meta data: 1048576 + 3670016 = 4718592 bytes
[ 0.000000] printk: early log buf free: 125224(95%)
[ 0.000000] Dentry cache hash table entries: 4194304 (order: 13, 33554432 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 2097152 (order: 12, 16777216 bytes, linear)
[ 0.000000] software IO TLB: area num 32.
[ 0.000000] software IO TLB: mapped [mem 0x000000007b000000-0x000000007f000000] (64MB)
[ 0.000000] Fallback order for Node 0: 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 8387568
[ 0.000000] Policy zone: Normal
[ 0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off

We have to work OotB on W510, and ARM64 does not support extending the
built-in command line with the one from the bootloader.  So only try
MPAM if the user explicitly gives "aosc.try_mpam=1" via the cmdline.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>

Signed-off-by: Kexy Biscuit <kexybiscuit@aosc.io>
(cherry picked from commit 8fc0099ea8f6edfb929c09bbcd38e57485a2ddf6)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 2, 2026

Reviewer's Guide

Introduces an AOSC-specific feature override mechanism to selectively disable MPAM by default on HiSilicon TSV110-based arm64 systems with broken firmware, unless explicitly re-enabled via a new aosc.try_mpam=1 kernel parameter, by wiring this override into the existing feature override/command-line parsing path.

Sequence diagram for AOSC MPAM override handling on TSV110 at ARM64 boot

sequenceDiagram
    actor Admin
    participant Kernel
    participant parse_cmdline
    participant AOSCFeatureOverride
    participant CPUFeatures

    Admin->>Kernel: Boot system with kernel cmdline
    Kernel->>parse_cmdline: parse_cmdline(fdt, chosen)
    parse_cmdline->>parse_cmdline: __parse_cmdline(normal_cmdline, true)

    loop For each entry in mpam_disable_list
        parse_cmdline->>CPUFeatures: read_cpuid_id() and match MIDR_HISI_TSV110
        alt CPU model matches TSV110
            parse_cmdline->>AOSCFeatureOverride: arm64_apply_feature_override(0, 0, 4, aosc_feature_override)
            alt aosc.try_mpam overridden by user (return nonzero)
                AOSCFeatureOverride-->>parse_cmdline: MPAM allowed, no override
                parse_cmdline-->>Kernel: continue boot without arm64.nompam
            else aosc.try_mpam not set (return 0)
                AOSCFeatureOverride-->>parse_cmdline: no user override
                parse_cmdline->>parse_cmdline: __parse_cmdline(arm64.nompam, true)
                parse_cmdline->>CPUFeatures: Disable MPAM via arm64.nompam
                parse_cmdline-->>Kernel: continue boot with MPAM disabled
            end
        else CPU model does not match TSV110
            parse_cmdline-->>Kernel: no MPAM override applied
        end
    end

    Kernel-->>Admin: System booted with MPAM enabled or disabled per override
Loading

Class diagram for AOSC feature override integration for MPAM

classDiagram
    class arm64_ftr_override {
        +u64 val
        +u64 mask
        +bool overridden
    }

    class ftr_field_desc {
        +string name
        +int shift
        +void* constraint
    }

    class ftr_set_desc {
        +string name
        +arm64_ftr_override* override
        +ftr_field_desc fields[]
    }

    class aosc_feature_override {
        <<struct instance>>
        +u64 val
        +u64 mask
        +bool overridden
    }

    class aosc_features {
        <<const struct instance>>
        +name = aosc
        +fields: try_mpam
    }

    class sw_features {
        <<const struct instance>>
        +name = sw
        +fields: existing_software_features
    }

    class regs_array {
        <<array of ftr_set_desc*>>
        +mmfr0
        +mmfr1
        +isar0_to_2
        +smfr0
        +sw_features
        +aosc_features
    }

    ftr_set_desc --> arm64_ftr_override : override
    ftr_set_desc --> ftr_field_desc : fields

    aosc_feature_override --> arm64_ftr_override : embeds
    aosc_features --> ftr_set_desc : conforms_to
    sw_features --> ftr_set_desc : conforms_to

    regs_array --> ftr_set_desc : contains_pointers
    regs_array --> aosc_features : includes
    regs_array --> sw_features : includes
Loading

File-Level Changes

Change Details Files
Add AOSC-specific feature override descriptor to control MPAM behavior via kernel command line.
  • Define a new aosc_feature_override structure to integrate with the existing arm64 feature override framework.
  • Introduce an aosc_features ftr_set descriptor with a try_mpam field that can be toggled via the aosc.try_mpam kernel parameter.
  • Register the new aosc_features descriptor in the global regs list so it is parsed and applied during early feature override initialization.
arch/arm64/kernel/pi/idreg-override.c
Disable MPAM automatically on HiSilicon TSV110 CPUs unless explicitly overridden, by injecting arm64.nompam at boot.
  • Extend parse_cmdline to contain a list of MIDR ranges (mpam_disable_list) currently targeting MIDR_HISI_TSV110.
  • Iterate over mpam_disable_list at boot, detect if the current CPU matches, and conditionally apply the AOSC feature override for MPAM.
  • If no explicit aosc.try_mpam override is detected (feature override apply fails/returns false), inject arm64.nompam into command-line parsing to force MPAM off on affected systems.
arch/arm64/kernel/pi/idreg-override.c

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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The mpam_disable_list array is declared as a local static const with __initconst inside parse_cmdline; consider moving it to file scope (like the other midr_range tables) to avoid unusual attribute use on a local variable and to match existing kernel style.
  • The call to arm64_apply_feature_override(0, 0, 4, &aosc_feature_override) uses magic numbers for the register and field; replacing these with named constants or at least a brief comment indicating which ID register/field is being overridden would make the intent clearer and reduce the chance of misuse.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `mpam_disable_list` array is declared as a local `static const` with `__initconst` inside `parse_cmdline`; consider moving it to file scope (like the other `midr_range` tables) to avoid unusual attribute use on a local variable and to match existing kernel style.
- The call to `arm64_apply_feature_override(0, 0, 4, &aosc_feature_override)` uses magic numbers for the register and field; replacing these with named constants or at least a brief comment indicating which ID register/field is being overridden would make the intent clearer and reduce the chance of misuse.

## Individual Comments

### Comment 1
<location path="arch/arm64/kernel/pi/idreg-override.c" line_range="416-423" />
<code_context>
+	};
+
+	for (const struct midr_range *r = mpam_disable_list; r->model; r++) {
+		if (midr_is_cpu_model_range(read_cpuid_id(), r->model,
+					    r->rv_min, r->rv_max)) {
+			if (!arm64_apply_feature_override(0, 0, 4, &aosc_feature_override)) {
+				__parse_cmdline("arm64.nompam", true);
+			}
+		}
</code_context>
<issue_to_address>
**suggestion:** Clarify control flow when a CPU model matches to avoid repeated override attempts.

Given that the feature override (or fallback to `arm64.nompam`) is a one-time decision per CPU, consider breaking after the first match. This prevents any chance of reapplying the override if ranges ever overlap or the helper behavior changes, and makes the single-application intent clearer:

```c
if (midr_is_cpu_model_range(...)) {
	if (!arm64_apply_feature_override(...))
		__parse_cmdline("arm64.nompam", true);
	break;
}
```

```suggestion
	for (const struct midr_range *r = mpam_disable_list; r->model; r++) {
		if (midr_is_cpu_model_range(read_cpuid_id(), r->model,
					    r->rv_min, r->rv_max)) {
			if (!arm64_apply_feature_override(0, 0, 4, &aosc_feature_override))
				__parse_cmdline("arm64.nompam", true);
			break;
		}
	}
```
</issue_to_address>

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.

deepin inclusion
category: feature

Only disable mpam for mpam_disable_list, such as TSV110.

Tested in DMI: HUAWEI HUAWEIPGU-WBY0/HUAWEIPGU-WBY0-PCB, BIOS 1.08 12/23/2019.

Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@opsiff opsiff force-pushed the linux-6.18.y-2026-03-02-mpam-disable branch from 081f65a to 6bc74a2 Compare March 2, 2026 10:15
@Avenger-285714 Avenger-285714 changed the title [Deepin-Kernel-SIG] [linux 6.6.y] [Deepin] [AOSC] arm64: disable mpam in tsv110 [Deepin-Kernel-SIG] [linux 6.18.y] [Deepin] [AOSC] arm64: disable mpam in tsv110 Mar 2, 2026
@Avenger-285714
Copy link
Member

/approve

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Avenger-285714

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

The pull request process is described 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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an early-boot quirk for HiSilicon TSV110 (e.g., W510) to disable MPAM by default unless explicitly opted-in via a new aosc.try_mpam=1 boot parameter, implemented in the arm64 early feature override framework.

Changes:

  • Introduces a new pseudo feature set (aosc) to parse aosc.try_mpam from the kernel command line.
  • Detects TSV110 by MIDR during early boot and auto-applies arm64.nompam unless aosc.try_mpam is set.
  • Registers the new feature set in the early override registry list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +218 to +223
static struct arm64_ftr_override __read_mostly aosc_feature_override;

static const struct ftr_set_desc aosc_features __prel64_initconst = {
.name = "aosc",
.override = &aosc_feature_override,
.fields = {
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

aosc_feature_override appears to be used only during early command-line parsing (to decide whether to auto-apply arm64.nompam on TSV110). Since it is not referenced after init_feature_override() completes, consider marking it __initdata (and dropping __read_mostly) so it can be freed with other init-only data instead of permanently occupying .data..read_mostly.

Copilot uses AI. Check for mistakes.
Comment on lines +407 to +409
* Sorry but we have to work OotB on some platforms with broken
* firmware, notably W510. Use "aosc.try_mpam=1" if you really need
* MPAM on AOSC.
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

This change introduces a new boot parameter (aosc.try_mpam=1) that affects CPU feature enablement on TSV110, but it isn't documented in Documentation/admin-guide/kernel-parameters.txt (there are entries for arm64.nompam, etc.). Please add documentation for aosc.try_mpam so users can discover and understand the override and its default behavior.

Suggested change
* Sorry but we have to work OotB on some platforms with broken
* firmware, notably W510. Use "aosc.try_mpam=1" if you really need
* MPAM on AOSC.
* Some platforms (notably TSV110 / W510) ship with firmware that
* advertises MPAM but is not reliable enough for use out of the box.
*
* By default, for all CPUs in mpam_disable_list we forcibly disable
* MPAM early by injecting "arm64.nompam" into the effective
* command line (see the loop below).
*
* The "aosc.try_mpam=1" boot parameter provides an opt-in override
* for systems where the firmware is known to be good: when this
* parameter is present, arm64_apply_feature_override() will succeed
* and we will NOT add "arm64.nompam", so MPAM remains enabled.

Copilot uses AI. Check for mistakes.
Comment on lines +407 to +409
* Sorry but we have to work OotB on some platforms with broken
* firmware, notably W510. Use "aosc.try_mpam=1" if you really need
* MPAM on AOSC.
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

The comment uses the abbreviation "OotB", which may be unclear to readers outside this context. Consider spelling this out (e.g., "out of the box") and tightening the wording to be more descriptive of the technical reason (firmware reports MPAM incorrectly on TSV110/W510) rather than apologetic.

Suggested change
* Sorry but we have to work OotB on some platforms with broken
* firmware, notably W510. Use "aosc.try_mpam=1" if you really need
* MPAM on AOSC.
* Disable MPAM by default on platforms with firmware that reports
* MPAM incorrectly, notably TSV110/W510. Use "aosc.try_mpam=1" if
* you really need MPAM on AOSC.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants