Skip to content

[24.10] mt7620: workaround jal imm26 and redundant PAGE_ALIGN - #22216

Merged
openwrt-bot merged 1 commit into
openwrt:openwrt-24.10from
namiltd:mt7620
Mar 1, 2026
Merged

openwrt-bot merged 1 commit into
openwrt:openwrt-24.10from
namiltd:mt7620

Conversation

@namiltd

@namiltd namiltd commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even "half-written" instructions when the compiler emits a direct 'jal imm26' call.
This is triggered in:

  • the small random helpers inside get_random_u32_below(), and
  • the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via a volatile function pointer (load into register + jalr) when building for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:

  • skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages() because the micro-randomization (< PAGE_SIZE) implemented by many ports (including MT7620) is negated immediately by PAGE_ALIGN(). Skipping the redundant PAGE_ALIGN() reduces exposure to the problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Link: #20553
(cherry picked from commit 22ccb44)

@github-actions github-actions Bot added target/ramips pull request/issue for ramips target release/24.10 pull request/issue targeted (also) for OpenWrt 24.10 release labels Feb 28, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt#20553
(cherry picked from commit 22ccb44)
Link: openwrt#22216
Signed-off-by: Robert Marko <[email protected]>
@openwrt-bot
openwrt-bot merged commit f700509 into openwrt:openwrt-24.10 Mar 1, 2026
1 check passed
@robimarko

Copy link
Copy Markdown
Contributor

Thanks! Rebased on top of openwrt-24.10 and merged!

@namiltd
namiltd deleted the mt7620 branch March 1, 2026 10:29
liudf0716 pushed a commit to liudf0716/chawrt that referenced this pull request Mar 19, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt/openwrt#20553
(cherry picked from commit 22ccb44)
Link: openwrt/openwrt#22216
Signed-off-by: Robert Marko <[email protected]>
(cherry picked from commit f700509)
codelinaro-mirror-sync Bot pushed a commit to CodeLinaro-mirror/le_owrt_prplwrt that referenced this pull request Oct 18, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt/openwrt#20553
(cherry picked from commit 22ccb445e611018ede702e6c0798640353632cce)
Link: openwrt/openwrt#22216
Signed-off-by: Robert Marko <[email protected]>
(cherry picked from commit f700509)
codelinaro-mirror-sync Bot pushed a commit to CodeLinaro-mirror/le_owrt_prplwrt that referenced this pull request Oct 18, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt/openwrt#20553
(cherry picked from commit 22ccb445e611018ede702e6c0798640353632cce)
Link: openwrt/openwrt#22216
Signed-off-by: Robert Marko <[email protected]>
(cherry picked from commit f700509)
sKyissKy pushed a commit to sKyissKy/immortalwrt-mt798x-6.6 that referenced this pull request Nov 19, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt/openwrt#20553
(cherry picked from commit 22ccb44)
Link: openwrt/openwrt#22216
Signed-off-by: Robert Marko <[email protected]>

(cherry picked from commit f700509)
sKyissKy pushed a commit to sKyissKy/immortalwrt-mt798x-6.6 that referenced this pull request Nov 25, 2026
On MT7620-class platforms (CONFIG_NET_RALINK_MT7620) we observe sporadic
wrong-jump-targets, kernel oopses, hanging, corrupted backtraces or even
"half-written" instructions when the compiler emits a direct 'jal imm26'
call.
This is triggered in:
  - the small random helpers inside get_random_u32_below(), and
  - the blkcg_maybe_throttle_current() call in resume_user_mode_work().

This patch forces those two call sites to use an indirect call via
a volatile function pointer (load into register + jalr) when building
for MT7620, avoiding embedding a 26-bit immediate jump target.

Additionally, on MT7620 builds the exec path in fs/exec.c is modified:
  - skip arch_align_stack() + PAGE_ALIGN() in setup_arg_pages()
    because the micro-randomization (< PAGE_SIZE) implemented by many
    ports (including MT7620) is negated immediately by PAGE_ALIGN().
    Skipping the redundant PAGE_ALIGN() reduces exposure to the
    problematic code pattern.

These changes are targeted workarounds for MT7620; behavioral logic is unchanged.

Signed-off-by: Mieczyslaw Nalewaj <[email protected]>
Link: openwrt/openwrt#20553
(cherry picked from commit 22ccb44)
Link: openwrt/openwrt#22216
Signed-off-by: Robert Marko <[email protected]>
(cherry picked from commit f700509)
Reference: https://github.com/immortalwrt/immortalwrt (openwrt-24.10, commit f700509)
Signed-off-by: sKyissKy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/24.10 pull request/issue targeted (also) for OpenWrt 24.10 release target/ramips pull request/issue for ramips target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants