Skip to content

[Deepin-Kernel-SIG] [linux 6.6.y] arm64/haoc: use raw PTE helpers for IEE mappings#2000

Merged
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-07-20-update-5
Jul 21, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.6.y] arm64/haoc: use raw PTE helpers for IEE mappings#2000
opsiff merged 1 commit into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-07-20-update-5

Conversation

@opsiff

@opsiff opsiff commented Jul 21, 2026

Copy link
Copy Markdown
Member

deepin inclusion
category: bugfix

Commit 69cbff5 ("arm64/mm: wire up PTE_CONT for user mappings") made the public arm64 PTE helpers contpte-aware. In particular, set_pte() strips PTE_CONT before storing a PTE and ptep_get() may aggregate the access/dirty state of an entire contiguous range.

That is right for core-mm user mappings, but HAOC/IEE edits kernel and IEE page tables directly and deliberately installs or removes PTE_CONT on those mappings. Routing those updates through the public helpers silently drops the contiguous bit and can warn when rewriting existing contiguous mappings.

Use the raw arm64 helpers, __set_pte() and __ptep_get(), for HAOC/IEE PTE updates and reads, matching the private-helper usage in the arm64 kernel and hugetlb paths. Keep the existing explicit WRITE_ONCE() and barrier sequences unchanged.

Assisted-by: codex:gpt-5.5:xhigh
Fixes: 69cbff5 ("arm64/mm: wire up PTE_CONT for user mappings")

Summary by Sourcery

Bug Fixes:

  • Prevent loss of PTE_CONT and related warnings in HAOC/IEE mappings by replacing contpte-aware public PTE helpers with raw PTE accessors for IEE page table reads and writes.

@sourcery-ai

sourcery-ai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR updates the HAOC/IEE arm64 page table manipulation code to use the raw PTE helpers (__set_pte and __ptep_get) instead of the public contpte-aware helpers, so that kernel/IEE mappings can safely preserve and manipulate PTE_CONT and other attributes without unintended aggregation or stripping by the user-mapping helpers.

Flow diagram for iee_set_logical_mem PTE update using raw helpers

flowchart TD
  A[iee_set_logical_mem] --> B[ptep = pte_offset_kernel]
  B --> C[pte = __ptep_get ptep]
  C --> D{prot ?}
  D -->|true| E[set PTE_RDONLY,
clear PTE_DBM in pte]
  D -->|false| F[clear PTE_RDONLY in pte]
  E --> G[__set_pte ptep pte]
  F --> G[__set_pte ptep pte]
  G --> H[next ptep / addr]
  H -->|loop over order| C
Loading

File-Level Changes

Change Details Files
Switch HAOC/IEE PTE writes from contpte-aware set_pte() to raw __set_pte() to preserve PTE_CONT semantics and match low-level kernel usage.
  • Replace set_pte() with __set_pte() for all PTE updates in HAOC IEE functions that manipulate kernel or IEE page tables.
  • Ensure contiguous mappings clearing logic now reads PTEs via raw helpers before masking out PTE_CONT and writing back with __set_pte().
  • Update IEE token mapping functions to install or update PTEs using __set_pte() instead of the public helper.
arch/arm64/kernel/haoc/iee/iee-func.c
arch/arm64/kernel/haoc/iee/iee-token.c
arch/arm64/kernel/haoc/iee/iee-mmu.c
Switch HAOC/IEE PTE reads from READ_ONCE()/ptep_get() to raw __ptep_get() so that PTE_CONT and access/dirty state are not aggregated or altered.
  • Replace READ_ONCE(*ptep) and ptep_get() call sites with __ptep_get() to read the exact hardware PTE value for HAOC/IEE mappings.
  • Use the raw value from __ptep_get() when checking/clearing PTE_CONT in contiguous mapping handling paths.
  • Feed __ptep_get() results into permission-update and pgattr_change_is_safe checks to ensure correctness against the real PTE values.
arch/arm64/kernel/haoc/iee/iee-func.c
arch/arm64/kernel/haoc/iee/iee-token.c
arch/arm64/kernel/haoc/iee/iee-mmu.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

@deepin-ci-robot
deepin-ci-robot requested review from BLumia and myml July 21, 2026 02:43
deepin inclusion
category: bugfix

Commit 69cbff5 ("arm64/mm: wire up PTE_CONT for user mappings")
made the public arm64 PTE helpers contpte-aware. In particular,
set_pte() strips PTE_CONT before storing a PTE and ptep_get() may
aggregate the access/dirty state of an entire contiguous range.

That is right for core-mm user mappings, but HAOC/IEE edits kernel and
IEE page tables directly and deliberately installs or removes PTE_CONT
on those mappings. Routing those updates through the public helpers
silently drops the contiguous bit and can warn when rewriting existing
contiguous mappings.

Use the raw arm64 helpers, __set_pte() and __ptep_get(), for HAOC/IEE
PTE updates and reads, matching the private-helper usage in the arm64
kernel and hugetlb paths. Keep the existing explicit WRITE_ONCE() and
barrier sequences unchanged.

Assisted-by: Codex:gpt-5.5:xhigh
Fixes: 69cbff5 ("arm64/mm: wire up PTE_CONT for user mappings")
Signed-off-by: Wentao Guan <[email protected]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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


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

@opsiff
opsiff requested a review from Avenger-285714 July 21, 2026 02:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes HAOC/IEE’s direct page-table edits on arm64 to avoid contpte-aware public helpers that strip PTE_CONT and may warn when rewriting contiguous mappings. It updates HAOC/IEE to use the raw PTE accessors so contiguous-bit semantics are preserved when manipulating kernel/IEE page tables directly.

Changes:

  • Replace set_pte() with __set_pte() in HAOC/IEE PTE update paths to avoid stripping PTE_CONT.
  • Replace ptep_get() / open-coded READ_ONCE(*ptep) reads with __ptep_get() for raw, non-aggregating PTE reads in IEE page-table logic.
  • Keep the existing explicit WRITE_ONCE() and barrier/TLB sequences intact while changing only the PTE accessor layer.

Reviewed changes

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

File Description
arch/arm64/kernel/haoc/iee/iee-token.c Switch token mapping PTE reads/writes to raw helpers to preserve PTE_CONT.
arch/arm64/kernel/haoc/iee/iee-mmu.c Use raw PTE helpers during fixmap PTE initialization and safety checks.
arch/arm64/kernel/haoc/iee/iee-func.c Use raw helpers across logical-mem protection, IEE address validity toggles, and contiguous-bit clearing paths.

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

@amjac27 amjac27 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. 此外,在后续 CONFIG_PTP 的设计里,我们会显示将 set_pte 设置为 __set_pte 的别名;将 __ptep_get 设置为 READ_ONCE 的别名。

@Avenger-285714

Copy link
Copy Markdown
Member

/approve

看了一下这个修改,在ARM64_CONTPTE未使能时这里的修改也是安全的。

@deepin-ci-robot

Copy link
Copy Markdown

[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

@opsiff
opsiff merged commit 60ff595 into deepin-community:linux-6.6.y Jul 21, 2026
14 of 16 checks passed
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